Skip to content

Commit

Permalink
Skip processor concatenation if the display color space is also data. (
Browse files Browse the repository at this point in the history
…#1896)

* Skip processor concatenation if the display view transform is also data.

Signed-off-by: Eric Renaud-Houde <[email protected]>

* Moved missing display color space exception before processor creation.

Signed-off-by: Eric Renaud-Houde <[email protected]>

---------

Signed-off-by: Eric Renaud-Houde <[email protected]>
Co-authored-by: Doug Walker <[email protected]>
  • Loading branch information
num3ric and doug-walker authored Nov 14, 2023
1 parent 1d3b695 commit 52b4965
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/OpenColorIO/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4719,20 +4719,29 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr
"the source color space.");
}

const char* csName = dstConfig->getDisplayViewColorSpaceName(dstDisplay, dstView);
const char* displayColorSpaceName = View::UseDisplayName(csName) ? dstDisplay : csName;
ConstColorSpaceRcPtr displayColorSpace = dstConfig->getColorSpace(displayColorSpaceName);
if (!displayColorSpace)
{
throw Exception("Can't create the processor for the destination config: "
"display color space not found.");
}

auto p2 = dstConfig->getProcessor(dstContext, dstInterchangeName, dstDisplay, dstView, direction);
if (!p2)
{
throw Exception("Can't create the processor for the destination config "
"and the destination color space.");
"and the destination display view transform.");
}

ProcessorRcPtr processor = Processor::Create();
processor->getImpl()->setProcessorCacheFlags(srcConfig->getImpl()->m_cacheFlags);

// If the source color spaces is a data space, its corresponding processor
// If either of the color spaces are data spaces, its corresponding processor
// will be empty, but need to make sure the entire result is also empty to
// better match the semantics of how data spaces are handled.
if (!srcColorSpace->isData())
if (!srcColorSpace->isData() && !displayColorSpace->isData())
{
if (direction == TRANSFORM_DIR_INVERSE)
{
Expand Down
8 changes: 8 additions & 0 deletions tests/cpu/Config_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5924,6 +5924,7 @@ ocio_profile_version: 2
displayname:
- !<View> {name: view1, colorspace: displaytest1}
- !<View> {name: view2, view_transform: vt1, display_colorspace: display2}
- !<View> {name: view3, colorspace: data_space}
view_transforms:
- !<ViewTransform>
Expand Down Expand Up @@ -6166,6 +6167,13 @@ ocio_profile_version: 2
auto ff4 = OCIO_DYNAMIC_POINTER_CAST<OCIO::FixedFunctionTransform>(t4);
OCIO_CHECK_ASSERT(ff4);

// If one of the spaces is a data space, the whole result must be a no-op.
OCIO_CHECK_NO_THROW(p = OCIO::Config::GetProcessorFromConfigs(
config2, "test2", config1, "displayname", "view3", OCIO::TRANSFORM_DIR_FORWARD));
OCIO_REQUIRE_ASSERT(p);
group = p->createGroupTransform();
OCIO_REQUIRE_EQUAL(group->getNumTransforms(), 0);

constexpr const char * SIMPLE_CONFIG3{ R"(
ocio_profile_version: 2
Expand Down

0 comments on commit 52b4965

Please sign in to comment.