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 | #include "GrEffect.h" |
michael@0 | 9 | #include "GrBackendEffectFactory.h" |
michael@0 | 10 | #include "GrContext.h" |
michael@0 | 11 | #include "GrCoordTransform.h" |
michael@0 | 12 | #include "GrMemoryPool.h" |
michael@0 | 13 | #include "SkTLS.h" |
michael@0 | 14 | |
michael@0 | 15 | #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
michael@0 | 16 | SkTArray<GrEffectTestFactory*, true>* GrEffectTestFactory::GetFactories() { |
michael@0 | 17 | static SkTArray<GrEffectTestFactory*, true> gFactories; |
michael@0 | 18 | return &gFactories; |
michael@0 | 19 | } |
michael@0 | 20 | #endif |
michael@0 | 21 | |
michael@0 | 22 | namespace GrEffectUnitTest { |
michael@0 | 23 | const SkMatrix& TestMatrix(SkRandom* random) { |
michael@0 | 24 | static SkMatrix gMatrices[5]; |
michael@0 | 25 | static bool gOnce; |
michael@0 | 26 | if (!gOnce) { |
michael@0 | 27 | gMatrices[0].reset(); |
michael@0 | 28 | gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); |
michael@0 | 29 | gMatrices[2].setRotate(SkIntToScalar(17)); |
michael@0 | 30 | gMatrices[3].setRotate(SkIntToScalar(185)); |
michael@0 | 31 | gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); |
michael@0 | 32 | gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); |
michael@0 | 33 | gMatrices[4].setRotate(SkIntToScalar(215)); |
michael@0 | 34 | gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); |
michael@0 | 35 | gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); |
michael@0 | 36 | gOnce = true; |
michael@0 | 37 | } |
michael@0 | 38 | return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | class GrEffect_Globals { |
michael@0 | 43 | public: |
michael@0 | 44 | static GrMemoryPool* GetTLS() { |
michael@0 | 45 | return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | private: |
michael@0 | 49 | static void* CreateTLS() { |
michael@0 | 50 | return SkNEW_ARGS(GrMemoryPool, (4096, 4096)); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | static void DeleteTLS(void* pool) { |
michael@0 | 54 | SkDELETE(reinterpret_cast<GrMemoryPool*>(pool)); |
michael@0 | 55 | } |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | int32_t GrBackendEffectFactory::fCurrEffectClassID = GrBackendEffectFactory::kIllegalEffectClassID; |
michael@0 | 59 | |
michael@0 | 60 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 61 | |
michael@0 | 62 | GrEffectRef::~GrEffectRef() { |
michael@0 | 63 | SkASSERT(this->unique()); |
michael@0 | 64 | fEffect->EffectRefDestroyed(); |
michael@0 | 65 | fEffect->unref(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | void* GrEffectRef::operator new(size_t size) { |
michael@0 | 69 | return GrEffect_Globals::GetTLS()->allocate(size); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | void GrEffectRef::operator delete(void* target) { |
michael@0 | 73 | GrEffect_Globals::GetTLS()->release(target); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 77 | |
michael@0 | 78 | GrEffect::~GrEffect() { |
michael@0 | 79 | SkASSERT(NULL == fEffectRef); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | const char* GrEffect::name() const { |
michael@0 | 83 | return this->getFactory().name(); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | void GrEffect::addCoordTransform(const GrCoordTransform* transform) { |
michael@0 | 87 | fCoordTransforms.push_back(transform); |
michael@0 | 88 | SkDEBUGCODE(transform->setInEffect();) |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | void GrEffect::addTextureAccess(const GrTextureAccess* access) { |
michael@0 | 92 | fTextureAccesses.push_back(access); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | void* GrEffect::operator new(size_t size) { |
michael@0 | 96 | return GrEffect_Globals::GetTLS()->allocate(size); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | void GrEffect::operator delete(void* target) { |
michael@0 | 100 | GrEffect_Globals::GetTLS()->release(target); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | #ifdef SK_DEBUG |
michael@0 | 104 | void GrEffect::assertEquality(const GrEffect& other) const { |
michael@0 | 105 | SkASSERT(this->numTransforms() == other.numTransforms()); |
michael@0 | 106 | for (int i = 0; i < this->numTransforms(); ++i) { |
michael@0 | 107 | SkASSERT(this->coordTransform(i) == other.coordTransform(i)); |
michael@0 | 108 | } |
michael@0 | 109 | SkASSERT(this->numTextures() == other.numTextures()); |
michael@0 | 110 | for (int i = 0; i < this->numTextures(); ++i) { |
michael@0 | 111 | SkASSERT(this->textureAccess(i) == other.textureAccess(i)); |
michael@0 | 112 | } |
michael@0 | 113 | } |
michael@0 | 114 | #endif |