Chromium Code Reviews| 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 "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 | |
| 48 virtual void restore() OVERRIDE; | |
| 49 | |
| 45 private: | 50 private: |
| 46 typedef SkCanvas INHERITED; | 51 typedef SkCanvas INHERITED; |
| 52 | |
| 53 int saveDepth_; | |
|
Tom Hudson
2013/02/25 17:16:04
Not clear from the name what this does.
| |
| 47 }; | 54 }; |
| 48 | 55 |
| 49 class SK_API AnalysisDevice : public SkDevice { | 56 class SK_API AnalysisDevice : public SkDevice { |
| 50 public: | 57 public: |
| 51 AnalysisDevice(const SkBitmap& bm); | 58 AnalysisDevice(const SkBitmap& bm); |
| 52 virtual ~AnalysisDevice(); | 59 virtual ~AnalysisDevice(); |
| 53 | 60 |
| 54 int getEstimatedCost() const; | 61 int getEstimatedCost() const; |
| 62 bool getColorIfSolid(SkColor* color) const; | |
| 63 bool isTransparent() const; | |
| 64 | |
| 65 void setForceNotSolid(bool flag); | |
| 55 | 66 |
| 56 protected: | 67 protected: |
| 57 virtual void clear(SkColor color) OVERRIDE; | 68 virtual void clear(SkColor color) OVERRIDE; |
| 58 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE; | 69 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE; |
| 59 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | 70 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, |
| 60 size_t count, const SkPoint[], | 71 size_t count, const SkPoint[], |
| 61 const SkPaint& paint) OVERRIDE; | 72 const SkPaint& paint) OVERRIDE; |
| 62 virtual void drawRect(const SkDraw&, const SkRect& r, | 73 virtual void drawRect(const SkDraw&, const SkRect& r, |
| 63 const SkPaint& paint) OVERRIDE; | 74 const SkPaint& paint) OVERRIDE; |
| 64 virtual void drawOval(const SkDraw&, const SkRect& oval, | 75 virtual void drawOval(const SkDraw&, const SkRect& oval, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 const SkColor colors[], SkXfermode* xmode, | 109 const SkColor colors[], SkXfermode* xmode, |
| 99 const uint16_t indices[], int indexCount, | 110 const uint16_t indices[], int indexCount, |
| 100 const SkPaint& paint) OVERRIDE; | 111 const SkPaint& paint) OVERRIDE; |
| 101 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, | 112 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, |
| 102 const SkPaint&) OVERRIDE; | 113 const SkPaint&) OVERRIDE; |
| 103 | 114 |
| 104 int estimatedCost_; | 115 int estimatedCost_; |
| 105 | 116 |
| 106 private: | 117 private: |
| 107 typedef SkDevice INHERITED; | 118 typedef SkDevice INHERITED; |
| 119 | |
| 120 bool isForcedNotSolid_; | |
| 121 bool isSolidColor_; | |
| 122 SkColor color_; | |
| 108 }; | 123 }; |
| 109 | 124 |
| 110 } // namespace skia | 125 } // namespace skia |
| 111 | 126 |
| 112 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | 127 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ |
| 113 | 128 |
| OLD | NEW |