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 2006 The Android Open Source Project |
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 | // Inspired by Rob Johnson's most excellent QuickDraw GX sample code |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkCamera_DEFINED |
michael@0 | 11 | #define SkCamera_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkMatrix.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkCanvas; |
michael@0 | 16 | |
michael@0 | 17 | struct SkUnit3D { |
michael@0 | 18 | SkScalar fX, fY, fZ; |
michael@0 | 19 | |
michael@0 | 20 | void set(SkScalar x, SkScalar y, SkScalar z) { |
michael@0 | 21 | fX = x; fY = y; fZ = z; |
michael@0 | 22 | } |
michael@0 | 23 | static SkScalar Dot(const SkUnit3D&, const SkUnit3D&); |
michael@0 | 24 | static void Cross(const SkUnit3D&, const SkUnit3D&, SkUnit3D* cross); |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | struct SkPoint3D { |
michael@0 | 28 | SkScalar fX, fY, fZ; |
michael@0 | 29 | |
michael@0 | 30 | void set(SkScalar x, SkScalar y, SkScalar z) { |
michael@0 | 31 | fX = x; fY = y; fZ = z; |
michael@0 | 32 | } |
michael@0 | 33 | SkScalar normalize(SkUnit3D*) const; |
michael@0 | 34 | }; |
michael@0 | 35 | typedef SkPoint3D SkVector3D; |
michael@0 | 36 | |
michael@0 | 37 | struct SkMatrix3D { |
michael@0 | 38 | SkScalar fMat[3][4]; |
michael@0 | 39 | |
michael@0 | 40 | void reset(); |
michael@0 | 41 | |
michael@0 | 42 | void setRow(int row, SkScalar a, SkScalar b, SkScalar c, SkScalar d = 0) { |
michael@0 | 43 | SkASSERT((unsigned)row < 3); |
michael@0 | 44 | fMat[row][0] = a; |
michael@0 | 45 | fMat[row][1] = b; |
michael@0 | 46 | fMat[row][2] = c; |
michael@0 | 47 | fMat[row][3] = d; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | void setRotateX(SkScalar deg); |
michael@0 | 51 | void setRotateY(SkScalar deg); |
michael@0 | 52 | void setRotateZ(SkScalar deg); |
michael@0 | 53 | void setTranslate(SkScalar x, SkScalar y, SkScalar z); |
michael@0 | 54 | |
michael@0 | 55 | void preRotateX(SkScalar deg); |
michael@0 | 56 | void preRotateY(SkScalar deg); |
michael@0 | 57 | void preRotateZ(SkScalar deg); |
michael@0 | 58 | void preTranslate(SkScalar x, SkScalar y, SkScalar z); |
michael@0 | 59 | |
michael@0 | 60 | void setConcat(const SkMatrix3D& a, const SkMatrix3D& b); |
michael@0 | 61 | void mapPoint(const SkPoint3D& src, SkPoint3D* dst) const; |
michael@0 | 62 | void mapVector(const SkVector3D& src, SkVector3D* dst) const; |
michael@0 | 63 | |
michael@0 | 64 | void mapPoint(SkPoint3D* v) const { |
michael@0 | 65 | this->mapPoint(*v, v); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | void mapVector(SkVector3D* v) const { |
michael@0 | 69 | this->mapVector(*v, v); |
michael@0 | 70 | } |
michael@0 | 71 | }; |
michael@0 | 72 | |
michael@0 | 73 | class SkPatch3D { |
michael@0 | 74 | public: |
michael@0 | 75 | SkPatch3D(); |
michael@0 | 76 | |
michael@0 | 77 | void reset(); |
michael@0 | 78 | void transform(const SkMatrix3D&, SkPatch3D* dst = NULL) const; |
michael@0 | 79 | |
michael@0 | 80 | // dot a unit vector with the patch's normal |
michael@0 | 81 | SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const; |
michael@0 | 82 | SkScalar dotWith(const SkVector3D& v) const { |
michael@0 | 83 | return this->dotWith(v.fX, v.fY, v.fZ); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | // deprecated, but still here for animator (for now) |
michael@0 | 87 | void rotate(SkScalar x, SkScalar y, SkScalar z) {} |
michael@0 | 88 | void rotateDegrees(SkScalar x, SkScalar y, SkScalar z) {} |
michael@0 | 89 | |
michael@0 | 90 | private: |
michael@0 | 91 | public: // make public for SkDraw3D for now |
michael@0 | 92 | SkVector3D fU, fV; |
michael@0 | 93 | SkPoint3D fOrigin; |
michael@0 | 94 | |
michael@0 | 95 | friend class SkCamera3D; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | class SkCamera3D { |
michael@0 | 99 | public: |
michael@0 | 100 | SkCamera3D(); |
michael@0 | 101 | |
michael@0 | 102 | void reset(); |
michael@0 | 103 | void update(); |
michael@0 | 104 | void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const; |
michael@0 | 105 | |
michael@0 | 106 | SkPoint3D fLocation; |
michael@0 | 107 | SkPoint3D fAxis; |
michael@0 | 108 | SkPoint3D fZenith; |
michael@0 | 109 | SkPoint3D fObserver; |
michael@0 | 110 | |
michael@0 | 111 | private: |
michael@0 | 112 | mutable SkMatrix fOrientation; |
michael@0 | 113 | mutable bool fNeedToUpdate; |
michael@0 | 114 | |
michael@0 | 115 | void doUpdate() const; |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | class Sk3DView : SkNoncopyable { |
michael@0 | 119 | public: |
michael@0 | 120 | Sk3DView(); |
michael@0 | 121 | ~Sk3DView(); |
michael@0 | 122 | |
michael@0 | 123 | void save(); |
michael@0 | 124 | void restore(); |
michael@0 | 125 | |
michael@0 | 126 | void translate(SkScalar x, SkScalar y, SkScalar z); |
michael@0 | 127 | void rotateX(SkScalar deg); |
michael@0 | 128 | void rotateY(SkScalar deg); |
michael@0 | 129 | void rotateZ(SkScalar deg); |
michael@0 | 130 | |
michael@0 | 131 | #ifdef SK_BUILD_FOR_ANDROID |
michael@0 | 132 | void setCameraLocation(SkScalar x, SkScalar y, SkScalar z); |
michael@0 | 133 | SkScalar getCameraLocationX(); |
michael@0 | 134 | SkScalar getCameraLocationY(); |
michael@0 | 135 | SkScalar getCameraLocationZ(); |
michael@0 | 136 | #endif |
michael@0 | 137 | |
michael@0 | 138 | void getMatrix(SkMatrix*) const; |
michael@0 | 139 | void applyToCanvas(SkCanvas*) const; |
michael@0 | 140 | |
michael@0 | 141 | SkScalar dotWithNormal(SkScalar dx, SkScalar dy, SkScalar dz) const; |
michael@0 | 142 | |
michael@0 | 143 | private: |
michael@0 | 144 | struct Rec { |
michael@0 | 145 | Rec* fNext; |
michael@0 | 146 | SkMatrix3D fMatrix; |
michael@0 | 147 | }; |
michael@0 | 148 | Rec* fRec; |
michael@0 | 149 | Rec fInitialRec; |
michael@0 | 150 | SkCamera3D fCamera; |
michael@0 | 151 | }; |
michael@0 | 152 | |
michael@0 | 153 | #endif |