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 2013 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 GrCoordTransform_DEFINED |
michael@0 | 9 | #define GrCoordTransform_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "GrEffect.h" |
michael@0 | 12 | #include "SkMatrix.h" |
michael@0 | 13 | #include "GrTexture.h" |
michael@0 | 14 | #include "GrTypes.h" |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * Coordinates available to GrEffect subclasses for requesting transformations. Transformed |
michael@0 | 18 | * coordinates are made available in the the portion of fragment shader emitted by the effect. |
michael@0 | 19 | */ |
michael@0 | 20 | enum GrCoordSet { |
michael@0 | 21 | /** |
michael@0 | 22 | * The user-space coordinates that map to the fragment being rendered. These coords account for |
michael@0 | 23 | * any change of coordinate system done on the CPU by GrContext before rendering, and also are |
michael@0 | 24 | * correct for draws that take explicit local coords rather than inferring them from the |
michael@0 | 25 | * primitive's positions (e.g. drawVertices). These are usually the coords a GrEffect wants. |
michael@0 | 26 | */ |
michael@0 | 27 | kLocal_GrCoordSet, |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * The actual vertex position. Note that GrContext may not draw using the original view matrix |
michael@0 | 31 | * specified by the caller, as it may have transformed vertices into another space. These are |
michael@0 | 32 | * usually not the coordinates a GrEffect wants. |
michael@0 | 33 | */ |
michael@0 | 34 | kPosition_GrCoordSet |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * A class representing a linear transformation from one of the built-in coordinate sets (local or |
michael@0 | 39 | * position). GrEffects just define these transformations, and the framework does the rest of the |
michael@0 | 40 | * work to make the transformed coordinates available in their fragment shader. |
michael@0 | 41 | */ |
michael@0 | 42 | class GrCoordTransform : public SkNoncopyable { |
michael@0 | 43 | public: |
michael@0 | 44 | GrCoordTransform() { SkDEBUGCODE(fInEffect = false); } |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Create a transformation that maps [0, 1] to a texture's boundaries. |
michael@0 | 48 | */ |
michael@0 | 49 | GrCoordTransform(GrCoordSet sourceCoords, const GrTexture* texture) { |
michael@0 | 50 | SkDEBUGCODE(fInEffect = false); |
michael@0 | 51 | this->reset(sourceCoords, texture); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Create a transformation from a matrix. The optional texture parameter is used to infer if the |
michael@0 | 56 | * framework should internally do a y reversal to account for it being upside down by Skia's |
michael@0 | 57 | * coord convention. |
michael@0 | 58 | */ |
michael@0 | 59 | GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture = NULL) { |
michael@0 | 60 | SkDEBUGCODE(fInEffect = false); |
michael@0 | 61 | this->reset(sourceCoords, m, texture); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | void reset(GrCoordSet sourceCoords, const GrTexture* texture) { |
michael@0 | 65 | SkASSERT(!fInEffect); |
michael@0 | 66 | SkASSERT(NULL != texture); |
michael@0 | 67 | this->reset(sourceCoords, GrEffect::MakeDivByTextureWHMatrix(texture), texture); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture = NULL) { |
michael@0 | 71 | SkASSERT(!fInEffect); |
michael@0 | 72 | fSourceCoords = sourceCoords; |
michael@0 | 73 | fMatrix = m; |
michael@0 | 74 | fReverseY = NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->origin(); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | GrCoordTransform& operator= (const GrCoordTransform& other) { |
michael@0 | 78 | SkASSERT(!fInEffect); |
michael@0 | 79 | fSourceCoords = other.fSourceCoords; |
michael@0 | 80 | fMatrix = other.fMatrix; |
michael@0 | 81 | fReverseY = other.fReverseY; |
michael@0 | 82 | return *this; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Access the matrix for editing. Note, this must be done before adding the transform to an |
michael@0 | 87 | * effect, since effects are immutable. |
michael@0 | 88 | */ |
michael@0 | 89 | SkMatrix* accessMatrix() { |
michael@0 | 90 | SkASSERT(!fInEffect); |
michael@0 | 91 | return &fMatrix; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | bool operator== (const GrCoordTransform& other) const { |
michael@0 | 95 | return fSourceCoords == other.fSourceCoords && |
michael@0 | 96 | fMatrix.cheapEqualTo(other.fMatrix) && |
michael@0 | 97 | fReverseY == other.fReverseY; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | GrCoordSet sourceCoords() const { return fSourceCoords; } |
michael@0 | 101 | const SkMatrix& getMatrix() const { return fMatrix; } |
michael@0 | 102 | bool reverseY() const { return fReverseY; } |
michael@0 | 103 | |
michael@0 | 104 | private: |
michael@0 | 105 | GrCoordSet fSourceCoords; |
michael@0 | 106 | SkMatrix fMatrix; |
michael@0 | 107 | bool fReverseY; |
michael@0 | 108 | |
michael@0 | 109 | typedef SkNoncopyable INHERITED; |
michael@0 | 110 | |
michael@0 | 111 | #ifdef SK_DEBUG |
michael@0 | 112 | public: |
michael@0 | 113 | void setInEffect() const { fInEffect = true; } |
michael@0 | 114 | private: |
michael@0 | 115 | mutable bool fInEffect; |
michael@0 | 116 | #endif |
michael@0 | 117 | }; |
michael@0 | 118 | |
michael@0 | 119 | #endif |