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 | /* |
michael@0 | 3 | * Copyright 2013 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | #include "GrPaint.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "GrBlend.h" |
michael@0 | 12 | #include "effects/GrSimpleTextureEffect.h" |
michael@0 | 13 | |
michael@0 | 14 | void GrPaint::addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
michael@0 | 15 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix); |
michael@0 | 16 | this->addColorEffect(effect)->unref(); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | void GrPaint::addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
michael@0 | 20 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix); |
michael@0 | 21 | this->addCoverageEffect(effect)->unref(); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | void GrPaint::addColorTextureEffect(GrTexture* texture, |
michael@0 | 25 | const SkMatrix& matrix, |
michael@0 | 26 | const GrTextureParams& params) { |
michael@0 | 27 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
michael@0 | 28 | this->addColorEffect(effect)->unref(); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | void GrPaint::addCoverageTextureEffect(GrTexture* texture, |
michael@0 | 32 | const SkMatrix& matrix, |
michael@0 | 33 | const GrTextureParams& params) { |
michael@0 | 34 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
michael@0 | 35 | this->addCoverageEffect(effect)->unref(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | bool GrPaint::isOpaque() const { |
michael@0 | 39 | return this->getOpaqueAndKnownColor(NULL, NULL); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { |
michael@0 | 43 | GrColor tempColor; |
michael@0 | 44 | uint32_t colorComps; |
michael@0 | 45 | if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { |
michael@0 | 46 | if (kRGBA_GrColorComponentFlags == colorComps) { |
michael@0 | 47 | *color = tempColor; |
michael@0 | 48 | return true; |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | return false; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, |
michael@0 | 55 | uint32_t* solidColorKnownComponents) const { |
michael@0 | 56 | |
michael@0 | 57 | // TODO: Share this implementation with GrDrawState |
michael@0 | 58 | |
michael@0 | 59 | GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage); |
michael@0 | 60 | uint32_t coverageComps = kRGBA_GrColorComponentFlags; |
michael@0 | 61 | int count = fCoverageStages.count(); |
michael@0 | 62 | for (int i = 0; i < count; ++i) { |
michael@0 | 63 | (*fCoverageStages[i].getEffect())->getConstantColorComponents(&coverage, &coverageComps); |
michael@0 | 64 | } |
michael@0 | 65 | if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage) { |
michael@0 | 66 | return false; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | GrColor color = fColor; |
michael@0 | 70 | uint32_t colorComps = kRGBA_GrColorComponentFlags; |
michael@0 | 71 | count = fColorStages.count(); |
michael@0 | 72 | for (int i = 0; i < count; ++i) { |
michael@0 | 73 | (*fColorStages[i].getEffect())->getConstantColorComponents(&color, &colorComps); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); |
michael@0 | 77 | |
michael@0 | 78 | GrBlendCoeff srcCoeff = fSrcBlendCoeff; |
michael@0 | 79 | GrBlendCoeff dstCoeff = fDstBlendCoeff; |
michael@0 | 80 | GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0); |
michael@0 | 81 | |
michael@0 | 82 | bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoeff); |
michael@0 | 83 | if (NULL != solidColor) { |
michael@0 | 84 | if (opaque) { |
michael@0 | 85 | switch (srcCoeff) { |
michael@0 | 86 | case kZero_GrBlendCoeff: |
michael@0 | 87 | *solidColor = 0; |
michael@0 | 88 | *solidColorKnownComponents = kRGBA_GrColorComponentFlags; |
michael@0 | 89 | break; |
michael@0 | 90 | |
michael@0 | 91 | case kOne_GrBlendCoeff: |
michael@0 | 92 | *solidColor = color; |
michael@0 | 93 | *solidColorKnownComponents = colorComps; |
michael@0 | 94 | break; |
michael@0 | 95 | |
michael@0 | 96 | // The src coeff should never refer to the src and if it refers to dst then opaque |
michael@0 | 97 | // should have been false. |
michael@0 | 98 | case kSC_GrBlendCoeff: |
michael@0 | 99 | case kISC_GrBlendCoeff: |
michael@0 | 100 | case kDC_GrBlendCoeff: |
michael@0 | 101 | case kIDC_GrBlendCoeff: |
michael@0 | 102 | case kSA_GrBlendCoeff: |
michael@0 | 103 | case kISA_GrBlendCoeff: |
michael@0 | 104 | case kDA_GrBlendCoeff: |
michael@0 | 105 | case kIDA_GrBlendCoeff: |
michael@0 | 106 | default: |
michael@0 | 107 | GrCrash("srcCoeff should not refer to src or dst."); |
michael@0 | 108 | break; |
michael@0 | 109 | |
michael@0 | 110 | // TODO: update this once GrPaint actually has a const color. |
michael@0 | 111 | case kConstC_GrBlendCoeff: |
michael@0 | 112 | case kIConstC_GrBlendCoeff: |
michael@0 | 113 | case kConstA_GrBlendCoeff: |
michael@0 | 114 | case kIConstA_GrBlendCoeff: |
michael@0 | 115 | *solidColorKnownComponents = 0; |
michael@0 | 116 | break; |
michael@0 | 117 | } |
michael@0 | 118 | } else { |
michael@0 | 119 | solidColorKnownComponents = 0; |
michael@0 | 120 | } |
michael@0 | 121 | } |
michael@0 | 122 | return opaque; |
michael@0 | 123 | } |