Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip processor concatenation if the display color space is also data. #1896

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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