Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: skia/ext/analysis_canvas.h

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor cleanup Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkDevice.h"
11 #include "third_party/skia/include/core/SkPicture.h" 11 #include "third_party/skia/include/core/SkPicture.h"
12 12
13 namespace skia { 13 namespace skia {
14 14
15 class AnalysisDevice; 15 class AnalysisDevice;
16 16
17 // Does not render anything, but gathers statistics about a region 17 // Does not render anything, but gathers statistics about a region
18 // (specified as a clip rectangle) of an SkPicture as the picture is 18 // (specified as a clip rectangle) of an SkPicture as the picture is
19 // played back through it. 19 // played back through it.
20 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice 20 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice
vandebo (ex-Chrome) 2013/08/22 20:41:58 This suggests that Bitmap is a artifact of no base
robertphillips 2013/08/23 14:01:03 I think the comment is currently correct in that S
21 // using that bitmap, and create an AnalysisCanvas using the device. 21 // using that bitmap, and create an AnalysisCanvas using the device.
22 // Play a picture into the canvas, and then check result. 22 // Play a picture into the canvas, and then check result.
23 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { 23 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback {
24 public: 24 public:
25 AnalysisCanvas(AnalysisDevice*); 25 AnalysisCanvas(AnalysisDevice*);
26 virtual ~AnalysisCanvas(); 26 virtual ~AnalysisCanvas();
27 27
28 // Returns true when a SkColor can be used to represent result. 28 // Returns true when a SkColor can be used to represent result.
29 bool GetColorIfSolid(SkColor* color) const; 29 bool GetColorIfSolid(SkColor* color) const;
30 bool HasText() const; 30 bool HasText() const;
(...skipping 20 matching lines...) Expand all
51 virtual void restore() OVERRIDE; 51 virtual void restore() OVERRIDE;
52 52
53 private: 53 private:
54 typedef SkCanvas INHERITED; 54 typedef SkCanvas INHERITED;
55 55
56 int saved_stack_size_; 56 int saved_stack_size_;
57 int force_not_solid_stack_level_; 57 int force_not_solid_stack_level_;
58 int force_not_transparent_stack_level_; 58 int force_not_transparent_stack_level_;
59 }; 59 };
60 60
61 class SK_API AnalysisDevice : public SkDevice { 61 class SK_API AnalysisDevice : public SkBitmapDevice {
vandebo (ex-Chrome) 2013/08/22 20:41:58 Why inherit from BitmapDevice for this one?
robertphillips 2013/08/23 14:01:03 The Skia patch that is about to land doesn't actua
vandebo (ex-Chrome) 2013/08/23 17:10:04 TODO here?
robertphillips 2013/08/26 13:11:48 Done.
62 public: 62 public:
63 AnalysisDevice(const SkBitmap& bitmap); 63 AnalysisDevice(const SkBitmap& bitmap);
64 virtual ~AnalysisDevice(); 64 virtual ~AnalysisDevice();
65 65
66 bool GetColorIfSolid(SkColor* color) const; 66 bool GetColorIfSolid(SkColor* color) const;
67 bool HasText() const; 67 bool HasText() const;
68 68
69 void SetForceNotSolid(bool flag); 69 void SetForceNotSolid(bool flag);
70 void SetForceNotTransparent(bool flag); 70 void SetForceNotTransparent(bool flag);
71 71
72 protected: 72 protected:
73 // SkDevice overrides. 73 // SkBaseDevice overrides.
74 virtual void clear(SkColor color) OVERRIDE; 74 virtual void clear(SkColor color) OVERRIDE;
75 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; 75 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE;
76 virtual void drawPoints(const SkDraw& draw, 76 virtual void drawPoints(const SkDraw& draw,
77 SkCanvas::PointMode mode, 77 SkCanvas::PointMode mode,
78 size_t count, 78 size_t count,
79 const SkPoint points[], 79 const SkPoint points[],
80 const SkPaint& paint) OVERRIDE; 80 const SkPaint& paint) OVERRIDE;
81 virtual void drawRect(const SkDraw& draw, 81 virtual void drawRect(const SkDraw& draw,
82 const SkRect& rect, 82 const SkRect& rect,
83 const SkPaint& paint) OVERRIDE; 83 const SkPaint& paint) OVERRIDE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 SkCanvas::VertexMode vertex_mode, 136 SkCanvas::VertexMode vertex_mode,
137 int vertex_count, 137 int vertex_count,
138 const SkPoint verts[], 138 const SkPoint verts[],
139 const SkPoint texs[], 139 const SkPoint texs[],
140 const SkColor colors[], 140 const SkColor colors[],
141 SkXfermode* xmode, 141 SkXfermode* xmode,
142 const uint16_t indices[], 142 const uint16_t indices[],
143 int index_count, 143 int index_count,
144 const SkPaint& paint) OVERRIDE; 144 const SkPaint& paint) OVERRIDE;
145 virtual void drawDevice(const SkDraw& draw, 145 virtual void drawDevice(const SkDraw& draw,
146 SkDevice* device, 146 SkBaseDevice* device,
147 int x, 147 int x,
148 int y, 148 int y,
149 const SkPaint& paint) OVERRIDE; 149 const SkPaint& paint) OVERRIDE;
150 150
151 private: 151 private:
152 typedef SkDevice INHERITED; 152 typedef SkBitmapDevice INHERITED;
153 153
154 bool is_forced_not_solid_; 154 bool is_forced_not_solid_;
155 bool is_forced_not_transparent_; 155 bool is_forced_not_transparent_;
156 bool is_solid_color_; 156 bool is_solid_color_;
157 SkColor color_; 157 SkColor color_;
158 bool is_transparent_; 158 bool is_transparent_;
159 bool has_text_; 159 bool has_text_;
160 }; 160 };
161 161
162 } // namespace skia 162 } // namespace skia
163 163
164 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ 164 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_
165 165
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698