Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef GrTBackendEffectFactory_DEFINED |
michael@0 | 9 | #define GrTBackendEffectFactory_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "GrBackendEffectFactory.h" |
michael@0 | 12 | #include "GrDrawEffect.h" |
michael@0 | 13 | #include "gl/GrGLProgramEffects.h" |
michael@0 | 14 | |
michael@0 | 15 | /** |
michael@0 | 16 | * Implements GrBackendEffectFactory for a GrEffect subclass as a singleton. |
michael@0 | 17 | */ |
michael@0 | 18 | template <typename EffectClass> |
michael@0 | 19 | class GrTBackendEffectFactory : public GrBackendEffectFactory { |
michael@0 | 20 | |
michael@0 | 21 | public: |
michael@0 | 22 | typedef typename EffectClass::GLEffect GLEffect; |
michael@0 | 23 | |
michael@0 | 24 | /** Returns a human-readable name that is accessible via GrEffect or |
michael@0 | 25 | GrGLEffect and is consistent between the two of them. |
michael@0 | 26 | */ |
michael@0 | 27 | virtual const char* name() const SK_OVERRIDE { return EffectClass::Name(); } |
michael@0 | 28 | |
michael@0 | 29 | /** Returns a value that identifies the GLSL shader code generated by |
michael@0 | 30 | a GrEffect. This enables caching of generated shaders. Part of the |
michael@0 | 31 | id identifies the GrEffect subclass. The remainder is based |
michael@0 | 32 | on the aspects of the GrEffect object's configuration that affect |
michael@0 | 33 | GLSL code generation. */ |
michael@0 | 34 | virtual EffectKey glEffectKey(const GrDrawEffect& drawEffect, |
michael@0 | 35 | const GrGLCaps& caps) const SK_OVERRIDE { |
michael@0 | 36 | SkASSERT(kIllegalEffectClassID != fEffectClassID); |
michael@0 | 37 | EffectKey effectKey = GLEffect::GenKey(drawEffect, caps); |
michael@0 | 38 | EffectKey textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps); |
michael@0 | 39 | EffectKey transformKey = GrGLProgramEffects::GenTransformKey(drawEffect); |
michael@0 | 40 | EffectKey attribKey = GrGLProgramEffects::GenAttribKey(drawEffect); |
michael@0 | 41 | #ifdef SK_DEBUG |
michael@0 | 42 | static const EffectKey kIllegalEffectKeyMask = (uint16_t) (~((1U << kEffectKeyBits) - 1)); |
michael@0 | 43 | SkASSERT(!(kIllegalEffectKeyMask & effectKey)); |
michael@0 | 44 | |
michael@0 | 45 | static const EffectKey kIllegalTextureKeyMask = (uint16_t) (~((1U << kTextureKeyBits) - 1)); |
michael@0 | 46 | SkASSERT(!(kIllegalTextureKeyMask & textureKey)); |
michael@0 | 47 | |
michael@0 | 48 | static const EffectKey kIllegalTransformKeyMask = (uint16_t) (~((1U << kTransformKeyBits) - 1)); |
michael@0 | 49 | SkASSERT(!(kIllegalTransformKeyMask & transformKey)); |
michael@0 | 50 | |
michael@0 | 51 | static const EffectKey kIllegalAttribKeyMask = (uint16_t) (~((1U << kAttribKeyBits) - 1)); |
michael@0 | 52 | SkASSERT(!(kIllegalAttribKeyMask & textureKey)); |
michael@0 | 53 | |
michael@0 | 54 | static const EffectKey kIllegalClassIDMask = (uint16_t) (~((1U << kClassIDBits) - 1)); |
michael@0 | 55 | SkASSERT(!(kIllegalClassIDMask & fEffectClassID)); |
michael@0 | 56 | #endif |
michael@0 | 57 | return (fEffectClassID << (kEffectKeyBits+kTextureKeyBits+kTransformKeyBits+kAttribKeyBits)) | |
michael@0 | 58 | (attribKey << (kEffectKeyBits+kTextureKeyBits+kTransformKeyBits)) | |
michael@0 | 59 | (transformKey << (kEffectKeyBits+kTextureKeyBits)) | |
michael@0 | 60 | (textureKey << kEffectKeyBits) | |
michael@0 | 61 | (effectKey); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | /** Returns a new instance of the appropriate *GL* implementation class |
michael@0 | 65 | for the given GrEffect; caller is responsible for deleting |
michael@0 | 66 | the object. */ |
michael@0 | 67 | virtual GrGLEffect* createGLInstance(const GrDrawEffect& drawEffect) const SK_OVERRIDE { |
michael@0 | 68 | return SkNEW_ARGS(GLEffect, (*this, drawEffect)); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | /** This class is a singleton. This function returns the single instance. |
michael@0 | 72 | */ |
michael@0 | 73 | static const GrBackendEffectFactory& getInstance() { |
michael@0 | 74 | static SkAlignedSTStorage<1, GrTBackendEffectFactory> gInstanceMem; |
michael@0 | 75 | static const GrTBackendEffectFactory* gInstance; |
michael@0 | 76 | if (!gInstance) { |
michael@0 | 77 | gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), |
michael@0 | 78 | GrTBackendEffectFactory); |
michael@0 | 79 | } |
michael@0 | 80 | return *gInstance; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | protected: |
michael@0 | 84 | GrTBackendEffectFactory() { |
michael@0 | 85 | fEffectClassID = GenID(); |
michael@0 | 86 | } |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | #endif |