| 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/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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 // TODO(robertphillips): Once Skia's SkBaseDevice API is refactored to |
| 62 // remove the bitmap-specific entry points, it might make sense for this |
| 63 // to be derived from SkBaseDevice (rather than SkBitmapDevice) |
| 64 class SK_API AnalysisDevice : public SkBitmapDevice { |
| 62 public: | 65 public: |
| 63 AnalysisDevice(const SkBitmap& bitmap); | 66 AnalysisDevice(const SkBitmap& bitmap); |
| 64 virtual ~AnalysisDevice(); | 67 virtual ~AnalysisDevice(); |
| 65 | 68 |
| 66 bool GetColorIfSolid(SkColor* color) const; | 69 bool GetColorIfSolid(SkColor* color) const; |
| 67 bool HasText() const; | 70 bool HasText() const; |
| 68 | 71 |
| 69 void SetForceNotSolid(bool flag); | 72 void SetForceNotSolid(bool flag); |
| 70 void SetForceNotTransparent(bool flag); | 73 void SetForceNotTransparent(bool flag); |
| 71 | 74 |
| 72 protected: | 75 protected: |
| 73 // SkDevice overrides. | 76 // SkBaseDevice overrides. |
| 74 virtual void clear(SkColor color) OVERRIDE; | 77 virtual void clear(SkColor color) OVERRIDE; |
| 75 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; | 78 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; |
| 76 virtual void drawPoints(const SkDraw& draw, | 79 virtual void drawPoints(const SkDraw& draw, |
| 77 SkCanvas::PointMode mode, | 80 SkCanvas::PointMode mode, |
| 78 size_t count, | 81 size_t count, |
| 79 const SkPoint points[], | 82 const SkPoint points[], |
| 80 const SkPaint& paint) OVERRIDE; | 83 const SkPaint& paint) OVERRIDE; |
| 81 virtual void drawRect(const SkDraw& draw, | 84 virtual void drawRect(const SkDraw& draw, |
| 82 const SkRect& rect, | 85 const SkRect& rect, |
| 83 const SkPaint& paint) OVERRIDE; | 86 const SkPaint& paint) OVERRIDE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 SkCanvas::VertexMode vertex_mode, | 139 SkCanvas::VertexMode vertex_mode, |
| 137 int vertex_count, | 140 int vertex_count, |
| 138 const SkPoint verts[], | 141 const SkPoint verts[], |
| 139 const SkPoint texs[], | 142 const SkPoint texs[], |
| 140 const SkColor colors[], | 143 const SkColor colors[], |
| 141 SkXfermode* xmode, | 144 SkXfermode* xmode, |
| 142 const uint16_t indices[], | 145 const uint16_t indices[], |
| 143 int index_count, | 146 int index_count, |
| 144 const SkPaint& paint) OVERRIDE; | 147 const SkPaint& paint) OVERRIDE; |
| 145 virtual void drawDevice(const SkDraw& draw, | 148 virtual void drawDevice(const SkDraw& draw, |
| 146 SkDevice* device, | 149 SkBaseDevice* device, |
| 147 int x, | 150 int x, |
| 148 int y, | 151 int y, |
| 149 const SkPaint& paint) OVERRIDE; | 152 const SkPaint& paint) OVERRIDE; |
| 150 | 153 |
| 151 private: | 154 private: |
| 152 typedef SkDevice INHERITED; | 155 typedef SkBitmapDevice INHERITED; |
| 153 | 156 |
| 154 bool is_forced_not_solid_; | 157 bool is_forced_not_solid_; |
| 155 bool is_forced_not_transparent_; | 158 bool is_forced_not_transparent_; |
| 156 bool is_solid_color_; | 159 bool is_solid_color_; |
| 157 SkColor color_; | 160 SkColor color_; |
| 158 bool is_transparent_; | 161 bool is_transparent_; |
| 159 bool has_text_; | 162 bool has_text_; |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 } // namespace skia | 165 } // namespace skia |
| 163 | 166 |
| 164 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | 167 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ |
| 165 | 168 |
| OLD | NEW |