gfx/skia/trunk/include/utils/SkDumpCanvas.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.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2011 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 #ifndef SkDumpCanvas_DEFINED
michael@0 9 #define SkDumpCanvas_DEFINED
michael@0 10
michael@0 11 #include "SkCanvas.h"
michael@0 12
michael@0 13 #ifdef SK_DEVELOPER
michael@0 14
michael@0 15 /** This class overrides all the draw methods on SkCanvas, and formats them
michael@0 16 as text, and then sends that to a Dumper helper object.
michael@0 17
michael@0 18 Typical use might be to dump a display list to a log file to see what is
michael@0 19 being drawn.
michael@0 20 */
michael@0 21 class SkDumpCanvas : public SkCanvas {
michael@0 22 public:
michael@0 23 class Dumper;
michael@0 24
michael@0 25 explicit SkDumpCanvas(Dumper* = 0);
michael@0 26 virtual ~SkDumpCanvas();
michael@0 27
michael@0 28 enum Verb {
michael@0 29 kNULL_Verb,
michael@0 30
michael@0 31 kSave_Verb,
michael@0 32 kRestore_Verb,
michael@0 33
michael@0 34 kMatrix_Verb,
michael@0 35
michael@0 36 kClip_Verb,
michael@0 37
michael@0 38 kDrawPaint_Verb,
michael@0 39 kDrawPoints_Verb,
michael@0 40 kDrawOval_Verb,
michael@0 41 kDrawRect_Verb,
michael@0 42 kDrawRRect_Verb,
michael@0 43 kDrawDRRect_Verb,
michael@0 44 kDrawPath_Verb,
michael@0 45 kDrawBitmap_Verb,
michael@0 46 kDrawText_Verb,
michael@0 47 kDrawPicture_Verb,
michael@0 48 kDrawVertices_Verb,
michael@0 49 kDrawData_Verb,
michael@0 50
michael@0 51 kBeginCommentGroup_Verb,
michael@0 52 kAddComment_Verb,
michael@0 53 kEndCommentGroup_Verb,
michael@0 54
michael@0 55 kCull_Verb
michael@0 56 };
michael@0 57
michael@0 58 /** Subclasses of this are installed on the DumpCanvas, and then called for
michael@0 59 each drawing command.
michael@0 60 */
michael@0 61 class Dumper : public SkRefCnt {
michael@0 62 public:
michael@0 63 SK_DECLARE_INST_COUNT(Dumper)
michael@0 64
michael@0 65 virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
michael@0 66 const SkPaint*) = 0;
michael@0 67
michael@0 68 private:
michael@0 69 typedef SkRefCnt INHERITED;
michael@0 70 };
michael@0 71
michael@0 72 Dumper* getDumper() const { return fDumper; }
michael@0 73 void setDumper(Dumper*);
michael@0 74
michael@0 75 int getNestLevel() const { return fNestLevel; }
michael@0 76
michael@0 77 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
michael@0 78 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
michael@0 79 const SkPaint& paint) SK_OVERRIDE;
michael@0 80 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
michael@0 81 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
michael@0 82 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
michael@0 83 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
michael@0 84 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
michael@0 85 const SkPaint* paint) SK_OVERRIDE;
michael@0 86 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
michael@0 87 const SkRect& dst, const SkPaint* paint,
michael@0 88 DrawBitmapRectFlags flags) SK_OVERRIDE;
michael@0 89 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
michael@0 90 const SkPaint* paint) SK_OVERRIDE;
michael@0 91 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
michael@0 92 const SkPaint* paint) SK_OVERRIDE;
michael@0 93 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
michael@0 94 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
michael@0 95 virtual void drawPosText(const void* text, size_t byteLength,
michael@0 96 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
michael@0 97 virtual void drawPosTextH(const void* text, size_t byteLength,
michael@0 98 const SkScalar xpos[], SkScalar constY,
michael@0 99 const SkPaint& paint) SK_OVERRIDE;
michael@0 100 virtual void drawTextOnPath(const void* text, size_t byteLength,
michael@0 101 const SkPath& path, const SkMatrix* matrix,
michael@0 102 const SkPaint& paint) SK_OVERRIDE;
michael@0 103 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
michael@0 104 virtual void drawVertices(VertexMode vmode, int vertexCount,
michael@0 105 const SkPoint vertices[], const SkPoint texs[],
michael@0 106 const SkColor colors[], SkXfermode* xmode,
michael@0 107 const uint16_t indices[], int indexCount,
michael@0 108 const SkPaint& paint) SK_OVERRIDE;
michael@0 109 virtual void drawData(const void*, size_t) SK_OVERRIDE;
michael@0 110 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
michael@0 111 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
michael@0 112 virtual void endCommentGroup() SK_OVERRIDE;
michael@0 113
michael@0 114 protected:
michael@0 115 virtual void willSave(SaveFlags) SK_OVERRIDE;
michael@0 116 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
michael@0 117 virtual void willRestore() SK_OVERRIDE;
michael@0 118
michael@0 119 virtual void didTranslate(SkScalar, SkScalar) SK_OVERRIDE;
michael@0 120 virtual void didScale(SkScalar, SkScalar) SK_OVERRIDE;
michael@0 121 virtual void didRotate(SkScalar) SK_OVERRIDE;
michael@0 122 virtual void didSkew(SkScalar, SkScalar) SK_OVERRIDE;
michael@0 123 virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
michael@0 124 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
michael@0 125
michael@0 126 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
michael@0 127 virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
michael@0 128 virtual void onPopCull() SK_OVERRIDE;
michael@0 129
michael@0 130 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
michael@0 131 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
michael@0 132 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
michael@0 133 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
michael@0 134
michael@0 135 static const char* EdgeStyleToAAString(ClipEdgeStyle edgeStyle);
michael@0 136
michael@0 137 private:
michael@0 138 Dumper* fDumper;
michael@0 139 int fNestLevel; // for nesting recursive elements like pictures
michael@0 140
michael@0 141 void dump(Verb, const SkPaint*, const char format[], ...);
michael@0 142
michael@0 143 typedef SkCanvas INHERITED;
michael@0 144 };
michael@0 145
michael@0 146 /** Formats the draw commands, and send them to a function-pointer provided
michael@0 147 by the caller.
michael@0 148 */
michael@0 149 class SkFormatDumper : public SkDumpCanvas::Dumper {
michael@0 150 public:
michael@0 151 SkFormatDumper(void (*)(const char text[], void* refcon), void* refcon);
michael@0 152
michael@0 153 // override from baseclass that does the formatting, and in turn calls
michael@0 154 // the function pointer that was passed to the constructor
michael@0 155 virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
michael@0 156 const SkPaint*) SK_OVERRIDE;
michael@0 157
michael@0 158 private:
michael@0 159 void (*fProc)(const char*, void*);
michael@0 160 void* fRefcon;
michael@0 161
michael@0 162 typedef SkDumpCanvas::Dumper INHERITED;
michael@0 163 };
michael@0 164
michael@0 165 /** Subclass of Dumper that dumps the drawing command to SkDebugf
michael@0 166 */
michael@0 167 class SkDebugfDumper : public SkFormatDumper {
michael@0 168 public:
michael@0 169 SkDebugfDumper();
michael@0 170
michael@0 171 private:
michael@0 172 typedef SkFormatDumper INHERITED;
michael@0 173 };
michael@0 174
michael@0 175 #endif
michael@0 176
michael@0 177 #endif

mercurial