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 2012 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 | |
michael@0 | 10 | #ifndef SKDEBUGCANVAS_H_ |
michael@0 | 11 | #define SKDEBUGCANVAS_H_ |
michael@0 | 12 | |
michael@0 | 13 | #include "SkCanvas.h" |
michael@0 | 14 | #include "SkDrawCommand.h" |
michael@0 | 15 | #include "SkPicture.h" |
michael@0 | 16 | #include "SkTArray.h" |
michael@0 | 17 | #include "SkString.h" |
michael@0 | 18 | |
michael@0 | 19 | class SkTexOverrideFilter; |
michael@0 | 20 | |
michael@0 | 21 | class SK_API SkDebugCanvas : public SkCanvas { |
michael@0 | 22 | public: |
michael@0 | 23 | SkDebugCanvas(int width, int height); |
michael@0 | 24 | virtual ~SkDebugCanvas(); |
michael@0 | 25 | |
michael@0 | 26 | void toggleFilter(bool toggle) { fFilter = toggle; } |
michael@0 | 27 | |
michael@0 | 28 | void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; } |
michael@0 | 29 | |
michael@0 | 30 | /** |
michael@0 | 31 | * Enable or disable overdraw visualization |
michael@0 | 32 | */ |
michael@0 | 33 | void setOverdrawViz(bool overdrawViz) { fOverdrawViz = overdrawViz; } |
michael@0 | 34 | |
michael@0 | 35 | /** |
michael@0 | 36 | * Enable or disable texure filtering override |
michael@0 | 37 | */ |
michael@0 | 38 | void overrideTexFiltering(bool overrideTexFiltering, SkPaint::FilterLevel level); |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | Executes all draw calls to the canvas. |
michael@0 | 42 | @param canvas The canvas being drawn to |
michael@0 | 43 | */ |
michael@0 | 44 | void draw(SkCanvas* canvas); |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | Executes the draw calls up to the specified index. |
michael@0 | 48 | @param canvas The canvas being drawn to |
michael@0 | 49 | @param index The index of the final command being executed |
michael@0 | 50 | */ |
michael@0 | 51 | void drawTo(SkCanvas* canvas, int index); |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | Returns the most recently calculated transformation matrix |
michael@0 | 55 | */ |
michael@0 | 56 | const SkMatrix& getCurrentMatrix() { |
michael@0 | 57 | return fMatrix; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | Returns the most recently calculated clip |
michael@0 | 62 | */ |
michael@0 | 63 | const SkIRect& getCurrentClip() { |
michael@0 | 64 | return fClip; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | Returns the index of the last draw command to write to the pixel at (x,y) |
michael@0 | 69 | */ |
michael@0 | 70 | int getCommandAtPoint(int x, int y, int index); |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | Removes the command at the specified index |
michael@0 | 74 | @param index The index of the command to delete |
michael@0 | 75 | */ |
michael@0 | 76 | void deleteDrawCommandAt(int index); |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | Returns the draw command at the given index. |
michael@0 | 80 | @param index The index of the command |
michael@0 | 81 | */ |
michael@0 | 82 | SkDrawCommand* getDrawCommandAt(int index); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | Sets the draw command for a given index. |
michael@0 | 86 | @param index The index to overwrite |
michael@0 | 87 | @param command The new command |
michael@0 | 88 | */ |
michael@0 | 89 | void setDrawCommandAt(int index, SkDrawCommand* command); |
michael@0 | 90 | |
michael@0 | 91 | /** |
michael@0 | 92 | Returns information about the command at the given index. |
michael@0 | 93 | @param index The index of the command |
michael@0 | 94 | */ |
michael@0 | 95 | SkTDArray<SkString*>* getCommandInfo(int index); |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | Returns the visibility of the command at the given index. |
michael@0 | 99 | @param index The index of the command |
michael@0 | 100 | */ |
michael@0 | 101 | bool getDrawCommandVisibilityAt(int index); |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | Returns the vector of draw commands |
michael@0 | 105 | */ |
michael@0 | 106 | SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead") |
michael@0 | 107 | const SkTDArray<SkDrawCommand*>& getDrawCommands() const; |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | Returns the vector of draw commands. Do not use this entry |
michael@0 | 111 | point - it is going away! |
michael@0 | 112 | */ |
michael@0 | 113 | SkTDArray<SkDrawCommand*>& getDrawCommands(); |
michael@0 | 114 | |
michael@0 | 115 | /** |
michael@0 | 116 | * Returns the string vector of draw commands |
michael@0 | 117 | */ |
michael@0 | 118 | SkTArray<SkString>* getDrawCommandsAsStrings() const; |
michael@0 | 119 | |
michael@0 | 120 | /** |
michael@0 | 121 | Returns length of draw command vector. |
michael@0 | 122 | */ |
michael@0 | 123 | int getSize() const { |
michael@0 | 124 | return fCommandVector.count(); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | /** |
michael@0 | 128 | Toggles the visibility / execution of the draw command at index i with |
michael@0 | 129 | the value of toggle. |
michael@0 | 130 | */ |
michael@0 | 131 | void toggleCommand(int index, bool toggle); |
michael@0 | 132 | |
michael@0 | 133 | void setBounds(int width, int height) { |
michael@0 | 134 | fWidth = width; |
michael@0 | 135 | fHeight = height; |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | void setUserMatrix(SkMatrix matrix) { |
michael@0 | 139 | fUserMatrix = matrix; |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 143 | // Inherited from SkCanvas |
michael@0 | 144 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 145 | |
michael@0 | 146 | virtual void clear(SkColor) SK_OVERRIDE; |
michael@0 | 147 | |
michael@0 | 148 | virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, |
michael@0 | 149 | const SkPaint*) SK_OVERRIDE; |
michael@0 | 150 | |
michael@0 | 151 | virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src, |
michael@0 | 152 | const SkRect& dst, const SkPaint* paint, |
michael@0 | 153 | DrawBitmapRectFlags flags) SK_OVERRIDE; |
michael@0 | 154 | |
michael@0 | 155 | virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&, |
michael@0 | 156 | const SkPaint*) SK_OVERRIDE; |
michael@0 | 157 | |
michael@0 | 158 | virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
michael@0 | 159 | const SkRect& dst, const SkPaint*) SK_OVERRIDE; |
michael@0 | 160 | |
michael@0 | 161 | virtual void drawData(const void*, size_t) SK_OVERRIDE; |
michael@0 | 162 | |
michael@0 | 163 | virtual void beginCommentGroup(const char* description) SK_OVERRIDE; |
michael@0 | 164 | |
michael@0 | 165 | virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; |
michael@0 | 166 | |
michael@0 | 167 | virtual void endCommentGroup() SK_OVERRIDE; |
michael@0 | 168 | |
michael@0 | 169 | virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE; |
michael@0 | 170 | |
michael@0 | 171 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
michael@0 | 172 | |
michael@0 | 173 | virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; |
michael@0 | 174 | |
michael@0 | 175 | virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; |
michael@0 | 176 | |
michael@0 | 177 | virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], |
michael@0 | 178 | const SkPaint&) SK_OVERRIDE; |
michael@0 | 179 | |
michael@0 | 180 | virtual void drawPosText(const void* text, size_t byteLength, |
michael@0 | 181 | const SkPoint pos[], const SkPaint&) SK_OVERRIDE; |
michael@0 | 182 | |
michael@0 | 183 | virtual void drawPosTextH(const void* text, size_t byteLength, |
michael@0 | 184 | const SkScalar xpos[], SkScalar constY, |
michael@0 | 185 | const SkPaint&) SK_OVERRIDE; |
michael@0 | 186 | |
michael@0 | 187 | virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; |
michael@0 | 188 | |
michael@0 | 189 | virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE; |
michael@0 | 190 | |
michael@0 | 191 | virtual void drawSprite(const SkBitmap&, int left, int top, |
michael@0 | 192 | const SkPaint*) SK_OVERRIDE; |
michael@0 | 193 | |
michael@0 | 194 | virtual void drawText(const void* text, size_t byteLength, SkScalar x, |
michael@0 | 195 | SkScalar y, const SkPaint&) SK_OVERRIDE; |
michael@0 | 196 | |
michael@0 | 197 | virtual void drawTextOnPath(const void* text, size_t byteLength, |
michael@0 | 198 | const SkPath& path, const SkMatrix* matrix, |
michael@0 | 199 | const SkPaint&) SK_OVERRIDE; |
michael@0 | 200 | |
michael@0 | 201 | virtual void drawVertices(VertexMode, int vertexCount, |
michael@0 | 202 | const SkPoint vertices[], const SkPoint texs[], |
michael@0 | 203 | const SkColor colors[], SkXfermode*, |
michael@0 | 204 | const uint16_t indices[], int indexCount, |
michael@0 | 205 | const SkPaint&) SK_OVERRIDE; |
michael@0 | 206 | |
michael@0 | 207 | static const int kVizImageHeight = 256; |
michael@0 | 208 | static const int kVizImageWidth = 256; |
michael@0 | 209 | |
michael@0 | 210 | virtual bool isClipEmpty() const SK_OVERRIDE { return false; } |
michael@0 | 211 | virtual bool isClipRect() const SK_OVERRIDE { return true; } |
michael@0 | 212 | #ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE |
michael@0 | 213 | virtual ClipType getClipType() const SK_OVERRIDE { |
michael@0 | 214 | return kRect_ClipType; |
michael@0 | 215 | } |
michael@0 | 216 | #endif |
michael@0 | 217 | virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE { |
michael@0 | 218 | if (NULL != bounds) { |
michael@0 | 219 | bounds->setXYWH(0, 0, |
michael@0 | 220 | SkIntToScalar(this->imageInfo().fWidth), |
michael@0 | 221 | SkIntToScalar(this->imageInfo().fHeight)); |
michael@0 | 222 | } |
michael@0 | 223 | return true; |
michael@0 | 224 | } |
michael@0 | 225 | virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE { |
michael@0 | 226 | if (NULL != bounds) { |
michael@0 | 227 | bounds->setLargest(); |
michael@0 | 228 | } |
michael@0 | 229 | return true; |
michael@0 | 230 | } |
michael@0 | 231 | |
michael@0 | 232 | protected: |
michael@0 | 233 | virtual void willSave(SaveFlags) SK_OVERRIDE; |
michael@0 | 234 | virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; |
michael@0 | 235 | virtual void willRestore() SK_OVERRIDE; |
michael@0 | 236 | |
michael@0 | 237 | virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE; |
michael@0 | 238 | virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE; |
michael@0 | 239 | virtual void didRotate(SkScalar) SK_OVERRIDE; |
michael@0 | 240 | virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE; |
michael@0 | 241 | virtual void didConcat(const SkMatrix&) SK_OVERRIDE; |
michael@0 | 242 | virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
michael@0 | 243 | |
michael@0 | 244 | virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; |
michael@0 | 245 | virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE; |
michael@0 | 246 | virtual void onPopCull() SK_OVERRIDE; |
michael@0 | 247 | |
michael@0 | 248 | virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
michael@0 | 249 | virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
michael@0 | 250 | virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; |
michael@0 | 251 | virtual void onClipRegion(const SkRegion& region, SkRegion::Op) SK_OVERRIDE; |
michael@0 | 252 | |
michael@0 | 253 | void markActiveCommands(int index); |
michael@0 | 254 | |
michael@0 | 255 | private: |
michael@0 | 256 | SkTDArray<SkDrawCommand*> fCommandVector; |
michael@0 | 257 | int fWidth; |
michael@0 | 258 | int fHeight; |
michael@0 | 259 | bool fFilter; |
michael@0 | 260 | bool fMegaVizMode; |
michael@0 | 261 | int fIndex; |
michael@0 | 262 | SkMatrix fUserMatrix; |
michael@0 | 263 | SkMatrix fMatrix; |
michael@0 | 264 | SkIRect fClip; |
michael@0 | 265 | |
michael@0 | 266 | bool fOverdrawViz; |
michael@0 | 267 | SkDrawFilter* fOverdrawFilter; |
michael@0 | 268 | |
michael@0 | 269 | bool fOverrideTexFiltering; |
michael@0 | 270 | SkTexOverrideFilter* fTexOverrideFilter; |
michael@0 | 271 | |
michael@0 | 272 | /** |
michael@0 | 273 | Number of unmatched save() calls at any point during a draw. |
michael@0 | 274 | If there are any saveLayer() calls outstanding, we need to resolve |
michael@0 | 275 | all of them, which in practice means resolving all save() calls, |
michael@0 | 276 | to avoid corruption of our canvas. |
michael@0 | 277 | */ |
michael@0 | 278 | int fOutstandingSaveCount; |
michael@0 | 279 | |
michael@0 | 280 | /** |
michael@0 | 281 | The active saveLayer commands at a given point in the renderering. |
michael@0 | 282 | Only used when "mega" visualization is enabled. |
michael@0 | 283 | */ |
michael@0 | 284 | SkTDArray<SkDrawCommand*> fActiveLayers; |
michael@0 | 285 | |
michael@0 | 286 | /** |
michael@0 | 287 | The active cull commands at a given point in the rendering. |
michael@0 | 288 | Only used when "mega" visualization is enabled. |
michael@0 | 289 | */ |
michael@0 | 290 | SkTDArray<SkDrawCommand*> fActiveCulls; |
michael@0 | 291 | |
michael@0 | 292 | /** |
michael@0 | 293 | Adds the command to the classes vector of commands. |
michael@0 | 294 | @param command The draw command for execution |
michael@0 | 295 | */ |
michael@0 | 296 | void addDrawCommand(SkDrawCommand* command); |
michael@0 | 297 | |
michael@0 | 298 | /** |
michael@0 | 299 | Applies any panning and zooming the user has specified before |
michael@0 | 300 | drawing anything else into the canvas. |
michael@0 | 301 | */ |
michael@0 | 302 | void applyUserTransform(SkCanvas* canvas); |
michael@0 | 303 | |
michael@0 | 304 | typedef SkCanvas INHERITED; |
michael@0 | 305 | }; |
michael@0 | 306 | |
michael@0 | 307 | #endif |