static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) { uint32_t key = 0; int numTextures = proc.numTextures(); for (int t = 0; t < numTextures; ++t) { const GrTextureAccess& access = proc.textureAccess(t); uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config()); if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) { key |= 1 << t; } } return key; }
uint32_t GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) { uint32_t key = 0; int numTextures = drawEffect.effect()->numTextures(); for (int t = 0; t < numTextures; ++t) { const GrTextureAccess& access = drawEffect.effect()->textureAccess(t); uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config()); if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) { key |= 1 << t; } } return key; }
static uint32_t gen_texture_key(const GrProcessor& proc, const GrGLCaps& caps) { uint32_t key = 0; int numTextures = proc.numTextures(); int shift = 0; for (int t = 0; t < numTextures; ++t) { const GrTextureAccess& access = proc.textureAccess(t); if (swizzle_requires_alpha_remapping(*caps.glslCaps(), access.getTexture()->config())) { key |= 1 << shift; } if (GR_GL_TEXTURE_EXTERNAL == static_cast<GrGLTexture*>(access.getTexture())->target()) { key |= 2 << shift; } shift += 2; } return key; }
GrBackendEffectFactory::EffectKey GrGLShaderBuilder::KeyForTextureAccess( const GrTextureAccess& access, const GrGLCaps& caps) { GrBackendEffectFactory::EffectKey key = 0; // Assume that swizzle support implies that we never have to modify a shader to adjust // for texture format/swizzle settings. if (!caps.textureSwizzleSupport() && swizzle_requires_alpha_remapping(caps, access)) { key = 1; } #if GR_DEBUG // Assert that key is set iff the swizzle will be modified. SkString origString(access.getSwizzle()); origString.prepend("."); SkString modifiedString; append_swizzle(&modifiedString, access, caps); if (!modifiedString.size()) { modifiedString = ".rgba"; } GrAssert(SkToBool(key) == (modifiedString != origString)); #endif return key; }