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/SkBitmapDevice.h" | 9 #include "third_party/skia/include/core/SkBitmapDevice.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "third_party/skia/include/core/SkPicture.h" | 11 #include "third_party/skia/include/core/SkPicture.h" |
12 #include "ui/gfx/rect.h" | |
12 | 13 |
13 namespace skia { | 14 namespace skia { |
14 | 15 |
15 class AnalysisDevice; | 16 class AnalysisDevice; |
16 | 17 |
17 // Does not render anything, but gathers statistics about a region | 18 // Gathers statistics about a region of an SkPicture as the picture is played |
enne (OOO)
2013/11/07 00:58:18
cc is the only user of AnalysisCanvas, so I change
| |
18 // (specified as a clip rectangle) of an SkPicture as the picture is | 19 // back and rastered through it. |
19 // played back through it. | 20 class SK_API AnalysisCanvas : public SkCanvas { |
20 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice | |
21 // using that bitmap, and create an AnalysisCanvas using the device. | |
22 // Play a picture into the canvas, and then check result. | |
23 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { | |
24 public: | 21 public: |
25 AnalysisCanvas(AnalysisDevice*); | 22 AnalysisCanvas(AnalysisDevice* device); |
reveman
2013/11/07 15:36:31
explicit?
enne (OOO)
2013/11/07 22:13:50
Done.
| |
26 virtual ~AnalysisCanvas(); | 23 virtual ~AnalysisCanvas(); |
27 | 24 |
28 // Returns true when a SkColor can be used to represent result. | 25 // Returns true when a SkColor can be used to represent result. |
29 bool GetColorIfSolid(SkColor* color) const; | 26 bool GetColorIfSolid(SkColor* color) const; |
30 bool HasText() const; | 27 bool HasText() const; |
31 | 28 |
32 // SkDrawPictureCallback override. | |
33 virtual bool abortDrawing() OVERRIDE; | |
34 | |
35 // SkCanvas overrides. | 29 // SkCanvas overrides. |
36 virtual bool clipRect(const SkRect& rect, | 30 virtual bool clipRect(const SkRect& rect, |
37 SkRegion::Op op = SkRegion::kIntersect_Op, | 31 SkRegion::Op op = SkRegion::kIntersect_Op, |
38 bool do_anti_alias = false) OVERRIDE; | 32 bool do_anti_alias = false) OVERRIDE; |
39 virtual bool clipPath(const SkPath& path, | 33 virtual bool clipPath(const SkPath& path, |
40 SkRegion::Op op = SkRegion::kIntersect_Op, | 34 SkRegion::Op op = SkRegion::kIntersect_Op, |
41 bool do_anti_alias = false) OVERRIDE; | 35 bool do_anti_alias = false) OVERRIDE; |
42 virtual bool clipRRect(const SkRRect& rrect, | 36 virtual bool clipRRect(const SkRRect& rrect, |
43 SkRegion::Op op = SkRegion::kIntersect_Op, | 37 SkRegion::Op op = SkRegion::kIntersect_Op, |
44 bool do_anti_alias = false) OVERRIDE; | 38 bool do_anti_alias = false) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... | |
56 int saved_stack_size_; | 50 int saved_stack_size_; |
57 int force_not_solid_stack_level_; | 51 int force_not_solid_stack_level_; |
58 int force_not_transparent_stack_level_; | 52 int force_not_transparent_stack_level_; |
59 }; | 53 }; |
60 | 54 |
61 // TODO(robertphillips): Once Skia's SkBaseDevice API is refactored to | 55 // TODO(robertphillips): Once Skia's SkBaseDevice API is refactored to |
62 // remove the bitmap-specific entry points, it might make sense for this | 56 // remove the bitmap-specific entry points, it might make sense for this |
63 // to be derived from SkBaseDevice (rather than SkBitmapDevice) | 57 // to be derived from SkBaseDevice (rather than SkBitmapDevice) |
64 class SK_API AnalysisDevice : public SkBitmapDevice { | 58 class SK_API AnalysisDevice : public SkBitmapDevice { |
65 public: | 59 public: |
66 AnalysisDevice(const SkBitmap& bitmap); | 60 // |analysis_rect| is in SkCanvas space. |
enne (OOO)
2013/11/07 00:58:18
Previously the analyze step would size the SkBitma
Stephen White
2013/11/07 18:14:22
From the Skia side, SkCanvas space is not really d
enne (OOO)
2013/11/07 22:13:50
Ok, so this should say device space to be what I i
| |
61 AnalysisDevice(const SkBitmap& bitmap, gfx::Rect analysis_rect); | |
67 virtual ~AnalysisDevice(); | 62 virtual ~AnalysisDevice(); |
68 | 63 |
69 bool GetColorIfSolid(SkColor* color) const; | 64 bool GetColorIfSolid(SkColor* color) const; |
70 bool HasText() const; | 65 bool HasText() const; |
71 | 66 |
72 void SetForceNotSolid(bool flag); | 67 void SetForceNotSolid(bool flag); |
73 void SetForceNotTransparent(bool flag); | 68 void SetForceNotTransparent(bool flag); |
74 | 69 |
70 gfx::Rect AnalysisRect() const { return analysis_rect_; } | |
71 | |
75 protected: | 72 protected: |
76 // SkBaseDevice overrides. | 73 // SkBaseDevice overrides. |
77 virtual void clear(SkColor color) OVERRIDE; | 74 virtual void clear(SkColor color) OVERRIDE; |
78 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; | 75 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; |
79 virtual void drawPoints(const SkDraw& draw, | 76 virtual void drawPoints(const SkDraw& draw, |
80 SkCanvas::PointMode mode, | 77 SkCanvas::PointMode mode, |
81 size_t count, | 78 size_t count, |
82 const SkPoint points[], | 79 const SkPoint points[], |
83 const SkPaint& paint) OVERRIDE; | 80 const SkPaint& paint) OVERRIDE; |
84 virtual void drawRect(const SkDraw& draw, | 81 virtual void drawRect(const SkDraw& draw, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 const SkPaint& paint) OVERRIDE; | 144 const SkPaint& paint) OVERRIDE; |
148 virtual void drawDevice(const SkDraw& draw, | 145 virtual void drawDevice(const SkDraw& draw, |
149 SkBaseDevice* device, | 146 SkBaseDevice* device, |
150 int x, | 147 int x, |
151 int y, | 148 int y, |
152 const SkPaint& paint) OVERRIDE; | 149 const SkPaint& paint) OVERRIDE; |
153 | 150 |
154 private: | 151 private: |
155 typedef SkBitmapDevice INHERITED; | 152 typedef SkBitmapDevice INHERITED; |
156 | 153 |
154 void AnalyzeDrawRect(const SkDraw& draw, | |
155 const SkRect& rect, | |
156 const SkPaint& paint); | |
157 | |
158 gfx::Rect analysis_rect_; | |
157 bool is_forced_not_solid_; | 159 bool is_forced_not_solid_; |
158 bool is_forced_not_transparent_; | 160 bool is_forced_not_transparent_; |
159 bool is_solid_color_; | 161 bool is_solid_color_; |
160 SkColor color_; | 162 SkColor color_; |
161 bool is_transparent_; | 163 bool is_transparent_; |
162 bool has_text_; | 164 bool has_text_; |
163 }; | 165 }; |
164 | 166 |
165 } // namespace skia | 167 } // namespace skia |
166 | 168 |
167 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | 169 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ |
168 | 170 |
OLD | NEW |