Skip to content

Commit

Permalink
fixup! OpenColorIO : Defer expansion of context variables in OCIO vars
Browse files Browse the repository at this point in the history
Because we are now using `Context::substitute()` on the values in the Context, we must use `/` rather than `\` for Windows paths, as `\` is an escape character. Is this too much of a change to make within Gaffer 1.4, even though `/` has always been our standard? I'm not sure, but I think one thing to factor into consideration is that it's probably fairly unlikely that anyone is setting the context in the way the unit tests do - and that all setting of the context via OpenColorIOConfigPlugs will need to have been using `/` already.
  • Loading branch information
johnhaddon committed Jun 13, 2024
1 parent 9446f1d commit 5e5429c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/GafferImageTest/ColorSpaceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def testConfigFromGafferContext( self ) :

with Gaffer.Context() as c :

GafferImage.OpenColorIOAlgo.setConfig( c, str( self.openColorIOPath() / "context.ocio" ) )
GafferImage.OpenColorIOAlgo.setConfig( c, ( self.openColorIOPath() / "context.ocio" ).as_posix() )
GafferImage.OpenColorIOAlgo.addVariable( c, "LUT", "srgb.spi1d" )
GafferImage.OpenColorIOAlgo.addVariable( c, "CDL", "cineon.spi1d" )

Expand Down
2 changes: 1 addition & 1 deletion python/GafferImageTest/DisplayTransformTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def testDisplayAndViewDefaultToConfig( self ) :
explicitDisplayTransform["view"].setValue( config.getDefaultView( config.getDefaultDisplay() ) )

with Gaffer.Context() as context :
GafferImage.OpenColorIOAlgo.setConfig( context, str( configPath ) )
GafferImage.OpenColorIOAlgo.setConfig( context, configPath.as_posix() )
self.assertImagesEqual( defaultDisplayTransform["out"], explicitDisplayTransform["out"] )

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/GafferImageTest/ImageReaderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def f( fileName, fileFormat, dataType, metadata, config ) :
( "exr", "openexr", "half", "" ),
( "dpx", "dpx", "uint12", "" ),
( "TIFF", "tiff", "float", "" ),
( "tif", "tiff", "uint32", str( self.openColorIOPath() / "context.ocio" ) ),
( "tif", "tiff", "uint32", ( self.openColorIOPath() / "context.ocio" ).as_posix() ),
] :

w["fileName"].setValue( self.temporaryDirectory() / "{0}.{1}".format( dataType, ext ) )
Expand Down
2 changes: 1 addition & 1 deletion python/GafferImageTest/ImageWriterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ def f( fileName, fileFormat, dataType, metadata, config ) :
( "exr", "openexr", "half", "" ),
( "dpx", "dpx", "uint12", "" ),
( "TIFF", "tiff", "float", "" ),
( "tif", "tiff", "uint32", str( self.openColorIOPath() / "context.ocio" ) ),
( "tif", "tiff", "uint32", ( self.openColorIOPath() / "context.ocio" ).as_posix() ),
] :

w["fileName"].setValue( self.temporaryDirectory() / "{0}.{1}".format( dataType, ext ) )
Expand Down
4 changes: 2 additions & 2 deletions python/GafferImageTest/OpenColorIOAlgoTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def testCurrentConfig( self ) :

with Gaffer.Context() as c :

GafferImage.OpenColorIOAlgo.setConfig( c, str( self.openColorIOPath() / "context.ocio" ) )
GafferImage.OpenColorIOAlgo.setConfig( c, ( self.openColorIOPath() / "context.ocio" ).as_posix() )
customConfig = GafferImage.OpenColorIOAlgo.currentConfig()
self.assertIsInstance( customConfig, PyOpenColorIO.Config )
self.assertEqual( customConfig.getCacheID(), PyOpenColorIO.Config.CreateFromFile( c["ocio:config"] ).getCacheID() )
Expand All @@ -89,7 +89,7 @@ def testCurrentConfigAndContext( self ) :

with Gaffer.Context() as c :

GafferImage.OpenColorIOAlgo.setConfig( c, str( self.openColorIOPath() / "context.ocio" ) )
GafferImage.OpenColorIOAlgo.setConfig( c, ( self.openColorIOPath() / "context.ocio" ).as_posix() )
GafferImage.OpenColorIOAlgo.addVariable( c, "LUT", "srgb.spi1d" )

customConfig, customContext = GafferImage.OpenColorIOAlgo.currentConfigAndContext()
Expand Down

0 comments on commit 5e5429c

Please sign in to comment.