/** * A function which emits a meta key into the key builder. This is required because shader code may * be dependent on properties of the effect that the effect itself doesn't use * in its key (e.g. the pixel format of textures used). So we create a meta-key for * every effect using this function. It is also responsible for inserting the effect's class ID * which must be different for every GrProcessor subclass. It can fail if an effect uses too many * textures, transforms, etc, for the space allotted in the meta-key. NOTE, both FPs and GPs share * this function because it is hairy, though FPs do not have attribs, and GPs do not have transforms */ static bool get_meta_key(const GrProcessor& proc, const GrGLCaps& caps, uint32_t transformKey, uint32_t attribKey, GrProcessorKeyBuilder* b, uint16_t* processorKeySize) { const GrBackendProcessorFactory& factory = proc.getFactory(); factory.getGLProcessorKey(proc, caps, b); size_t size = b->size(); if (size > SK_MaxU16) { *processorKeySize = 0; // suppresses a warning. return false; } *processorKeySize = SkToU16(size); uint32_t textureKey = gen_texture_key(proc, caps); uint32_t classID = proc.getFactory().classID(); // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they // don't fit. static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) { return false; } uint32_t* key = b->add32n(2); key[0] = (textureKey << 16 | transformKey); key[1] = (classID << 16); return true; }