def test_interface(self): desc = OCIO.GpuShaderDesc() desc.setLanguage(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3) self.assertEqual(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3, desc.getLanguage()) desc.setFunctionName("foo123") self.assertEqual("foo123", desc.getFunctionName()) desc.setLut3DEdgeLen(32) self.assertEqual(32, desc.getLut3DEdgeLen()) self.assertEqual("glsl_1.3 foo123 32", desc.getCacheID())
def test_interface(self): desc = OCIO.GpuShaderDesc() desc.setLanguage(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3) self.assertEqual(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3, desc.getLanguage()) desc.setFunctionName("foo123") self.assertEqual("foo123", desc.getFunctionName()) desc.finalize() self.assertEqual("glsl_1.3 foo123 ocio outColor $664fefaf8040c8fae4a3b56f2239872d", desc.getCacheID())
def test_interface(self): desc = OCIO.GpuShaderDesc() desc.setLanguage(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3) self.assertEqual(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3, desc.getLanguage()) desc.setFunctionName("foo123") self.assertEqual("foo123", desc.getFunctionName()) desc.finalize() self.assertEqual( "glsl_1.3 foo123 ocio outColor $4dd1c89df8002b409e089089ce8f24e7", desc.getCacheID())
def test_interface(self): desc = OCIO.GpuShaderDesc() desc.setLanguage(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3) self.assertEqual(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3, desc.getLanguage()) desc.setFunctionName("foo123") self.assertEqual("foo123", desc.getFunctionName()) desc.finalize() self.assertEqual( "glsl_1.3 foo123 ocio outColor $159b6ac2bdbbe3b57824faea46bd829b", desc.getCacheID())
def test_interface(self): _cfg = OCIO.Config().CreateFromStream(self.SIMPLE_PROFILE) _cfge = _cfg.createEditableCopy() _cfge.clearEnvironmentVars() self.assertEqual(0, _cfge.getNumEnvironmentVars()) _cfge.addEnvironmentVar("FOO", "test1") _cfge.addEnvironmentVar("FOO2", "test2${FOO}") self.assertEqual(2, _cfge.getNumEnvironmentVars()) self.assertEqual("FOO", _cfge.getEnvironmentVarNameByIndex(0)) self.assertEqual("FOO2", _cfge.getEnvironmentVarNameByIndex(1)) self.assertEqual("test1", _cfge.getEnvironmentVarDefault("FOO")) self.assertEqual("test2${FOO}", _cfge.getEnvironmentVarDefault("FOO2")) self.assertEqual("test2test1", _cfge.getCurrentContext().resolveStringVar("${FOO2}")) self.assertEqual({ 'FOO': 'test1', 'FOO2': 'test2${FOO}' }, _cfge.getEnvironmentVarDefaults()) _cfge.clearEnvironmentVars() self.assertEqual(0, _cfge.getNumEnvironmentVars()) self.assertEqual("luts", _cfge.getSearchPath()) _cfge.setSearchPath("otherdir") self.assertEqual("otherdir", _cfge.getSearchPath()) _cfge.sanityCheck() _cfge.setDescription("testdesc") self.assertEqual("testdesc", _cfge.getDescription()) self.assertEqual(self.SIMPLE_PROFILE, _cfg.serialize()) #self.assertEqual("$07d1fb1509eeae1837825fd4242f8a69:$885ad1683add38a11f7bbe34e8bf9ac0", # _cfg.getCacheID()) con = _cfg.getCurrentContext() self.assertNotEqual(0, con.getNumStringVars()) #self.assertEqual("", _cfg.getCacheID(con)) #self.assertEqual("", _cfge.getWorkingDir()) _cfge.setWorkingDir("/foobar") self.assertEqual("/foobar", _cfge.getWorkingDir()) self.assertEqual(3, _cfge.getNumColorSpaces()) self.assertEqual("lnh", _cfge.getColorSpaceNameByIndex(1)) lnh = _cfge.getColorSpace("lnh") self.assertEqual("ln", lnh.getFamily()) self.assertEqual(0, _cfge.getIndexForColorSpace("foobar")) cs = OCIO.ColorSpace() cs.setName("blah") _cfge.addColorSpace(cs) self.assertEqual(3, _cfge.getIndexForColorSpace("blah")) #_cfge.clearColorSpaces() #_cfge.parseColorSpaceFromString("foo") self.assertEqual(False, _cfg.isStrictParsingEnabled()) _cfge.setStrictParsingEnabled(True) self.assertEqual(True, _cfge.isStrictParsingEnabled()) self.assertEqual(2, _cfge.getNumRoles()) self.assertEqual(False, _cfg.hasRole("foo")) _cfge.setRole("foo", "vd8") self.assertEqual(3, _cfge.getNumRoles()) self.assertEqual(True, _cfge.hasRole("foo")) self.assertEqual("foo", _cfge.getRoleName(1)) self.assertEqual("sRGB", _cfge.getDefaultDisplay()) self.assertEqual(1, _cfge.getNumDisplays()) self.assertEqual("sRGB", _cfge.getDisplay(0)) self.assertEqual("Film1D", _cfge.getDefaultView("sRGB")) self.assertEqual(2, _cfge.getNumViews("sRGB")) self.assertEqual("Raw", _cfge.getView("sRGB", 1)) self.assertEqual("vd8", _cfge.getDisplayColorSpaceName("sRGB", "Film1D")) self.assertEqual("", _cfg.getDisplayLooks("sRGB", "Film1D")) _cfge.addDisplay("foo", "bar", "foo", "wee") _cfge.clearDisplays() _cfge.setActiveDisplays("sRGB") self.assertEqual("sRGB", _cfge.getActiveDisplays()) _cfge.setActiveViews("Film1D") self.assertEqual("Film1D", _cfge.getActiveViews()) luma = _cfge.getDefaultLumaCoefs() self.assertAlmostEqual(0.2126, luma[0], delta=1e-8) _cfge.setDefaultLumaCoefs([0.1, 0.2, 0.3]) tnewluma = _cfge.getDefaultLumaCoefs() self.assertAlmostEqual(0.1, tnewluma[0], delta=1e-8) self.assertEqual(0, _cfge.getNumLooks()) lk = OCIO.Look() lk.setName("coollook") lk.setProcessSpace("somespace") et = OCIO.ExponentTransform() et.setValue([0.1, 0.2, 0.3, 0.4]) lk.setTransform(et) iet = OCIO.ExponentTransform() iet.setValue([-0.1, -0.2, -0.3, -0.4]) lk.setInverseTransform(iet) _cfge.addLook(lk) self.assertEqual(1, _cfge.getNumLooks()) self.assertEqual("coollook", _cfge.getLookNameByIndex(0)) glk = _cfge.getLook("coollook") self.assertEqual("somespace", glk.getProcessSpace()) _cfge.clearLooks() self.assertEqual(0, _cfge.getNumLooks()) #getProcessor(context, srcColorSpace, dstColorSpace) #getProcessor(context, srcName,dstName); #getProcessor(transform); #getProcessor(transform, direction); #getProcessor(context, transform, direction); _proc = _cfg.getProcessor("lnh", "vd8") self.assertEqual(False, _proc.isNoOp()) self.assertEqual(True, _proc.hasChannelCrosstalk()) #float packedpix[] = new float[]{0.48f, 0.18f, 0.9f, 1.0f, # 0.48f, 0.18f, 0.18f, 1.0f, # 0.48f, 0.18f, 0.18f, 1.0f, # 0.48f, 0.18f, 0.18f, 1.0f }; #FloatBuffer buf = ByteBuffer.allocateDirect(2 * 2 * 4 * Float.SIZE / 8).asFloatBuffer(); #buf.put(packedpix); #PackedImageDesc foo = new PackedImageDesc(buf, 2, 2, 4); #_proc.apply(foo); #FloatBuffer wee = foo.getData(); #self.assertEqual(-2.4307251581696764E-35f, wee.get(2), 1e-8); # TODO: these should work in-place rgbfoo = _proc.applyRGB([0.48, 0.18, 0.18]) self.assertAlmostEqual(1.9351075, rgbfoo[0], delta=1e-7) # TODO: these should work in-place rgbafoo = _proc.applyRGBA([0.48, 0.18, 0.18, 1.0]) self.assertAlmostEqual(1.0, rgbafoo[3], delta=1e-8) #self.assertEqual("$a92ef63abd9edf61ad5a7855da064648", _proc.getCpuCacheID()) desc = OCIO.GpuShaderDesc() desc.setLanguage(OCIO.Constants.GPU_LANGUAGE_GLSL_1_3) desc.setFunctionName("pytestocio") desc.setLut3DEdgeLen(32) glsl = _proc.getGpuShaderText(desc) self.assertEqual(self.GLSLResult, glsl) # old DEPRECIATED GpuShaderDesc dict support desc2 = { "language": OCIO.Constants.GPU_LANGUAGE_GLSL_1_3, "functionName": "pytestocio", "lut3DEdgeLen": 32 } glsl = _proc.getGpuShaderText(desc2) self.assertEqual(self.GLSLResult, glsl) #self.assertEqual("$1dead2bf42974cd1769164e45a0c9e40", _proc.getGpuShaderTextCacheID(desc)) #self.assertEqual("$1dead2bf42974cd1769164e45a0c9e40", _proc.getGpuShaderTextCacheID(desc2)) len = desc.getLut3DEdgeLen() size = 3 * len * len * len self.assertEqual(0.0, _proc.getGpuLut3D(desc2)[size - 1]) self.assertEqual("<NULL>", _proc.getGpuLut3DCacheID(desc)) self.assertEqual("<NULL>", _proc.getGpuLut3DCacheID(desc2)) del _cfge del _cfg