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

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

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed unittest Created 7 years, 9 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 | Annotate | Revision Log
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 "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkDevice.h" 9 #include "third_party/skia/include/core/SkDevice.h"
10 10
11 namespace skia { 11 namespace skia {
12 12
13 class AnalysisDevice; 13 class AnalysisDevice;
14 14
15 // Does not render anything, but gathers statistics about a region 15 // Does not render anything, but gathers statistics about a region
16 // (specified as a clip rectangle) of an SkPicture as the picture is 16 // (specified as a clip rectangle) of an SkPicture as the picture is
17 // played back through it. 17 // played back through it.
18 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice 18 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice
19 // using that bitmap, and create an AnalysisCanvas using the device. 19 // using that bitmap, and create an AnalysisCanvas using the device.
20 // Play a picture into the canvas, and then check isCheap(). 20 // Play a picture into the canvas, and then check isCheap().
21 class SK_API AnalysisCanvas : public SkCanvas { 21 class SK_API AnalysisCanvas : public SkCanvas {
22 public: 22 public:
23 AnalysisCanvas(AnalysisDevice*); 23 AnalysisCanvas(AnalysisDevice*);
24 virtual ~AnalysisCanvas(); 24 virtual ~AnalysisCanvas();
25 25
26 // Returns true if the estimated cost of drawing is below an 26 // Returns true if the estimated cost of drawing is below an
27 // arbitrary threshold. 27 // arbitrary threshold.
28 bool isCheap() const; 28 bool isCheap() const;
29 bool getColorIfSolid(SkColor* color) const;
30 bool isTransparent() const;
29 31
30 // Returns the estimated cost of drawing, in arbitrary units. 32 // Returns the estimated cost of drawing, in arbitrary units.
31 int getEstimatedCost() const; 33 int getEstimatedCost() const;
32 34
33 virtual bool clipRect(const SkRect& rect, 35 virtual bool clipRect(const SkRect& rect,
34 SkRegion::Op op = SkRegion::kIntersect_Op, 36 SkRegion::Op op = SkRegion::kIntersect_Op,
35 bool doAntiAlias = false) OVERRIDE; 37 bool doAntiAlias = false) OVERRIDE;
36 virtual bool clipPath(const SkPath& path, 38 virtual bool clipPath(const SkPath& path,
37 SkRegion::Op op = SkRegion::kIntersect_Op, 39 SkRegion::Op op = SkRegion::kIntersect_Op,
38 bool doAntiAlias = false) OVERRIDE; 40 bool doAntiAlias = false) OVERRIDE;
39 virtual bool clipRRect(const SkRRect& rrect, 41 virtual bool clipRRect(const SkRRect& rrect,
40 SkRegion::Op op = SkRegion::kIntersect_Op, 42 SkRegion::Op op = SkRegion::kIntersect_Op,
41 bool doAntiAlias = false) OVERRIDE; 43 bool doAntiAlias = false) OVERRIDE;
42 44
43 virtual int saveLayer(const SkRect* bounds, const SkPaint*, 45 virtual int saveLayer(const SkRect* bounds, const SkPaint*,
44 SkCanvas::SaveFlags flags) OVERRIDE; 46 SkCanvas::SaveFlags flags) OVERRIDE;
47 virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) OVERRIDE;
48
49 virtual void restore() OVERRIDE;
50
45 private: 51 private:
46 typedef SkCanvas INHERITED; 52 typedef SkCanvas INHERITED;
53
54 int savedLayerStackSize_;
47 }; 55 };
48 56
49 class SK_API AnalysisDevice : public SkDevice { 57 class SK_API AnalysisDevice : public SkDevice {
50 public: 58 public:
51 AnalysisDevice(const SkBitmap& bm); 59 AnalysisDevice(const SkBitmap& bm);
52 virtual ~AnalysisDevice(); 60 virtual ~AnalysisDevice();
53 61
54 int getEstimatedCost() const; 62 int getEstimatedCost() const;
63 bool getColorIfSolid(SkColor* color) const;
64 bool isTransparent() const;
65
66 void setForceNotSolid(bool flag);
67 void setForceNotTransparent(bool flag);
55 68
56 protected: 69 protected:
57 virtual void clear(SkColor color) OVERRIDE; 70 virtual void clear(SkColor color) OVERRIDE;
58 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE; 71 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE;
59 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, 72 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode,
60 size_t count, const SkPoint[], 73 size_t count, const SkPoint[],
61 const SkPaint& paint) OVERRIDE; 74 const SkPaint& paint) OVERRIDE;
62 virtual void drawRect(const SkDraw&, const SkRect& r, 75 virtual void drawRect(const SkDraw&, const SkRect& r,
63 const SkPaint& paint) OVERRIDE; 76 const SkPaint& paint) OVERRIDE;
64 virtual void drawOval(const SkDraw&, const SkRect& oval, 77 virtual void drawOval(const SkDraw&, const SkRect& oval,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const SkColor colors[], SkXfermode* xmode, 111 const SkColor colors[], SkXfermode* xmode,
99 const uint16_t indices[], int indexCount, 112 const uint16_t indices[], int indexCount,
100 const SkPaint& paint) OVERRIDE; 113 const SkPaint& paint) OVERRIDE;
101 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, 114 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
102 const SkPaint&) OVERRIDE; 115 const SkPaint&) OVERRIDE;
103 116
104 int estimatedCost_; 117 int estimatedCost_;
105 118
106 private: 119 private:
107 typedef SkDevice INHERITED; 120 typedef SkDevice INHERITED;
121
122 bool isForcedNotSolid_;
123 bool isForcedNotTransparent_;
124 bool isSolidColor_;
125 SkColor color_;
126 bool isTransparent_;
108 }; 127 };
109 128
110 } // namespace skia 129 } // namespace skia
111 130
112 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ 131 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_
113 132
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698