OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SKIA_EXT_ANALYSIS_CANVAS_H_ | 5 #ifndef SKIA_EXT_ANALYSIS_CANVAS_H_ |
6 #define SKIA_EXT_ANALYSIS_CANVAS_H_ | 6 #define SKIA_EXT_ANALYSIS_CANVAS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkPicture.h" | 10 #include "third_party/skia/include/core/SkPicture.h" |
11 | 11 |
12 namespace skia { | 12 namespace skia { |
13 | 13 |
14 // Does not render anything, but gathers statistics about a region | 14 // Does not render anything, but gathers statistics about a region |
15 // (specified as a clip rectangle) of an SkPicture as the picture is | 15 // (specified as a clip rectangle) of an SkPicture as the picture is |
16 // played back through it. | 16 // played back through it. |
17 // To use: play a picture into the canvas, and then check result. | 17 // To use: play a picture into the canvas, and then check result. |
18 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { | 18 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { |
19 public: | 19 public: |
20 AnalysisCanvas(int width, int height); | 20 AnalysisCanvas(int width, int height); |
21 virtual ~AnalysisCanvas(); | 21 virtual ~AnalysisCanvas(); |
22 | 22 |
23 // Returns true when a SkColor can be used to represent result. | 23 // Returns true when a SkColor can be used to represent result. |
24 bool GetColorIfSolid(SkColor* color) const; | 24 bool GetColorIfSolid(SkColor* color) const; |
25 | 25 |
26 void SetForceNotSolid(bool flag); | 26 void SetForceNotSolid(bool flag); |
27 void SetForceNotTransparent(bool flag); | 27 void SetForceNotTransparent(bool flag); |
28 | 28 |
29 // SkDrawPictureCallback override. | 29 // SkDrawPictureCallback override. |
30 virtual bool abortDrawing() OVERRIDE; | 30 virtual bool abortDrawing() override; |
31 | 31 |
32 // SkCanvas overrides. | 32 // SkCanvas overrides. |
33 virtual void clear(SkColor) OVERRIDE; | 33 virtual void clear(SkColor) override; |
34 virtual void drawPaint(const SkPaint& paint) OVERRIDE; | 34 virtual void drawPaint(const SkPaint& paint) override; |
35 virtual void drawPoints(PointMode, | 35 virtual void drawPoints(PointMode, |
36 size_t count, | 36 size_t count, |
37 const SkPoint pts[], | 37 const SkPoint pts[], |
38 const SkPaint&) OVERRIDE; | 38 const SkPaint&) override; |
39 virtual void drawOval(const SkRect&, const SkPaint&) OVERRIDE; | 39 virtual void drawOval(const SkRect&, const SkPaint&) override; |
40 virtual void drawRect(const SkRect&, const SkPaint&) OVERRIDE; | 40 virtual void drawRect(const SkRect&, const SkPaint&) override; |
41 virtual void drawRRect(const SkRRect&, const SkPaint&) OVERRIDE; | 41 virtual void drawRRect(const SkRRect&, const SkPaint&) override; |
42 virtual void drawPath(const SkPath& path, const SkPaint&) OVERRIDE; | 42 virtual void drawPath(const SkPath& path, const SkPaint&) override; |
43 virtual void drawBitmap(const SkBitmap&, | 43 virtual void drawBitmap(const SkBitmap&, |
44 SkScalar left, | 44 SkScalar left, |
45 SkScalar top, | 45 SkScalar top, |
46 const SkPaint* paint = NULL) OVERRIDE; | 46 const SkPaint* paint = NULL) override; |
47 virtual void drawBitmapRectToRect(const SkBitmap&, | 47 virtual void drawBitmapRectToRect(const SkBitmap&, |
48 const SkRect* src, | 48 const SkRect* src, |
49 const SkRect& dst, | 49 const SkRect& dst, |
50 const SkPaint* paint, | 50 const SkPaint* paint, |
51 DrawBitmapRectFlags flags) OVERRIDE; | 51 DrawBitmapRectFlags flags) override; |
52 virtual void drawBitmapMatrix(const SkBitmap&, | 52 virtual void drawBitmapMatrix(const SkBitmap&, |
53 const SkMatrix&, | 53 const SkMatrix&, |
54 const SkPaint* paint = NULL) OVERRIDE; | 54 const SkPaint* paint = NULL) override; |
55 virtual void drawBitmapNine(const SkBitmap& bitmap, | 55 virtual void drawBitmapNine(const SkBitmap& bitmap, |
56 const SkIRect& center, | 56 const SkIRect& center, |
57 const SkRect& dst, | 57 const SkRect& dst, |
58 const SkPaint* paint = NULL) OVERRIDE; | 58 const SkPaint* paint = NULL) override; |
59 virtual void drawSprite(const SkBitmap&, int left, int top, | 59 virtual void drawSprite(const SkBitmap&, int left, int top, |
60 const SkPaint* paint = NULL) OVERRIDE; | 60 const SkPaint* paint = NULL) override; |
61 virtual void drawVertices(VertexMode, | 61 virtual void drawVertices(VertexMode, |
62 int vertexCount, | 62 int vertexCount, |
63 const SkPoint vertices[], | 63 const SkPoint vertices[], |
64 const SkPoint texs[], | 64 const SkPoint texs[], |
65 const SkColor colors[], | 65 const SkColor colors[], |
66 SkXfermode*, | 66 SkXfermode*, |
67 const uint16_t indices[], | 67 const uint16_t indices[], |
68 int indexCount, | 68 int indexCount, |
69 const SkPaint&) OVERRIDE; | 69 const SkPaint&) override; |
70 | 70 |
71 protected: | 71 protected: |
72 virtual void willSave() OVERRIDE; | 72 virtual void willSave() override; |
73 virtual SaveLayerStrategy willSaveLayer(const SkRect*, | 73 virtual SaveLayerStrategy willSaveLayer(const SkRect*, |
74 const SkPaint*, | 74 const SkPaint*, |
75 SaveFlags) OVERRIDE; | 75 SaveFlags) override; |
76 virtual void willRestore() OVERRIDE; | 76 virtual void willRestore() override; |
77 | 77 |
78 virtual void onClipRect(const SkRect& rect, | 78 virtual void onClipRect(const SkRect& rect, |
79 SkRegion::Op op, | 79 SkRegion::Op op, |
80 ClipEdgeStyle edge_style) OVERRIDE; | 80 ClipEdgeStyle edge_style) override; |
81 virtual void onClipRRect(const SkRRect& rrect, | 81 virtual void onClipRRect(const SkRRect& rrect, |
82 SkRegion::Op op, | 82 SkRegion::Op op, |
83 ClipEdgeStyle edge_style) OVERRIDE; | 83 ClipEdgeStyle edge_style) override; |
84 virtual void onClipPath(const SkPath& path, | 84 virtual void onClipPath(const SkPath& path, |
85 SkRegion::Op op, | 85 SkRegion::Op op, |
86 ClipEdgeStyle edge_style) OVERRIDE; | 86 ClipEdgeStyle edge_style) override; |
87 virtual void onClipRegion(const SkRegion& deviceRgn, | 87 virtual void onClipRegion(const SkRegion& deviceRgn, |
88 SkRegion::Op op) OVERRIDE; | 88 SkRegion::Op op) override; |
89 | 89 |
90 virtual void onDrawText(const void* text, | 90 virtual void onDrawText(const void* text, |
91 size_t byteLength, | 91 size_t byteLength, |
92 SkScalar x, | 92 SkScalar x, |
93 SkScalar y, | 93 SkScalar y, |
94 const SkPaint&) OVERRIDE; | 94 const SkPaint&) override; |
95 virtual void onDrawPosText(const void* text, | 95 virtual void onDrawPosText(const void* text, |
96 size_t byteLength, | 96 size_t byteLength, |
97 const SkPoint pos[], | 97 const SkPoint pos[], |
98 const SkPaint&) OVERRIDE; | 98 const SkPaint&) override; |
99 virtual void onDrawPosTextH(const void* text, | 99 virtual void onDrawPosTextH(const void* text, |
100 size_t byteLength, | 100 size_t byteLength, |
101 const SkScalar xpos[], | 101 const SkScalar xpos[], |
102 SkScalar constY, | 102 SkScalar constY, |
103 const SkPaint&) OVERRIDE; | 103 const SkPaint&) override; |
104 virtual void onDrawTextOnPath(const void* text, | 104 virtual void onDrawTextOnPath(const void* text, |
105 size_t byteLength, | 105 size_t byteLength, |
106 const SkPath& path, | 106 const SkPath& path, |
107 const SkMatrix* matrix, | 107 const SkMatrix* matrix, |
108 const SkPaint&) OVERRIDE; | 108 const SkPaint&) override; |
109 virtual void onDrawTextBlob(const SkTextBlob* blob, | 109 virtual void onDrawTextBlob(const SkTextBlob* blob, |
110 SkScalar x, | 110 SkScalar x, |
111 SkScalar y, | 111 SkScalar y, |
112 const SkPaint& paint) OVERRIDE; | 112 const SkPaint& paint) override; |
113 virtual void onDrawDRRect(const SkRRect& outer, | 113 virtual void onDrawDRRect(const SkRRect& outer, |
114 const SkRRect& inner, | 114 const SkRRect& inner, |
115 const SkPaint&) OVERRIDE; | 115 const SkPaint&) override; |
116 | 116 |
117 void OnComplexClip(); | 117 void OnComplexClip(); |
118 | 118 |
119 private: | 119 private: |
120 typedef SkCanvas INHERITED; | 120 typedef SkCanvas INHERITED; |
121 | 121 |
122 int saved_stack_size_; | 122 int saved_stack_size_; |
123 int force_not_solid_stack_level_; | 123 int force_not_solid_stack_level_; |
124 int force_not_transparent_stack_level_; | 124 int force_not_transparent_stack_level_; |
125 | 125 |
126 bool is_forced_not_solid_; | 126 bool is_forced_not_solid_; |
127 bool is_forced_not_transparent_; | 127 bool is_forced_not_transparent_; |
128 bool is_solid_color_; | 128 bool is_solid_color_; |
129 SkColor color_; | 129 SkColor color_; |
130 bool is_transparent_; | 130 bool is_transparent_; |
131 int draw_op_count_; | 131 int draw_op_count_; |
132 }; | 132 }; |
133 | 133 |
134 } // namespace skia | 134 } // namespace skia |
135 | 135 |
136 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | 136 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ |
137 | 137 |
OLD | NEW |