gfx/skia/trunk/src/utils/debugger/SkDebugCanvas.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial