Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SKIA_EXT_ANALYSIS_CANVAS_H_ | |
| 6 #define SKIA_EXT_ANALYSIS_CANVAS_H_ | |
| 7 | |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | |
| 9 #include "third_party/skia/include/core/SkDevice.h" | |
| 10 | |
| 11 namespace skia { | |
| 12 | |
| 13 class AnalysisDevice; | |
| 14 | |
| 15 // Does not render anything, but gathers statistics about a region | |
| 16 // (specified as a clip rectangle) of an SkPicture as the picture is | |
| 17 // played back through it. | |
| 18 // To use: create a SkBitmap with kNo_Config, create an AnalysisDevice | |
| 19 // using that bitmap, and create an AnalysisCanvas using the device. | |
| 20 // Play a picture into the canvas, and then check isCheap(). | |
| 21 class SK_API AnalysisCanvas : public SkCanvas { | |
| 22 public: | |
| 23 AnalysisCanvas(AnalysisDevice*); | |
| 24 virtual ~AnalysisCanvas(); | |
| 25 | |
| 26 // Creates a canvas and its supporting data structures. | |
| 27 //static AnalysisCanvas* Create(int width, int height); | |
|
Sami
2013/02/06 17:41:47
Left over from refactoring?
Tom Hudson
2013/02/06 17:53:36
Done.
| |
| 28 | |
| 29 // Returns true if the estimated cost of drawing is below an | |
| 30 // arbitrary threshold. | |
| 31 bool isCheap() const; | |
| 32 | |
| 33 // Returns the estimated cost of drawing, in arbitrary units. | |
| 34 int getEstimatedCost() const; | |
| 35 | |
| 36 virtual bool clipRect(const SkRect& rect, | |
| 37 SkRegion::Op op = SkRegion::kIntersect_Op, | |
| 38 bool doAntiAlias = false) OVERRIDE; | |
| 39 virtual bool clipPath(const SkPath& path, | |
| 40 SkRegion::Op op = SkRegion::kIntersect_Op, | |
| 41 bool doAntiAlias = false) OVERRIDE; | |
| 42 virtual bool clipRRect(const SkRRect& rrect, | |
| 43 SkRegion::Op op = SkRegion::kIntersect_Op, | |
| 44 bool doAntiAlias = false) OVERRIDE; | |
| 45 | |
| 46 virtual int saveLayer(const SkRect* bounds, const SkPaint*, | |
| 47 SkCanvas::SaveFlags flags) OVERRIDE; | |
| 48 private: | |
| 49 typedef SkCanvas INHERITED; | |
| 50 }; | |
| 51 | |
| 52 class SK_API AnalysisDevice : public SkDevice { | |
| 53 public: | |
| 54 AnalysisDevice(const SkBitmap& bm); | |
| 55 virtual ~AnalysisDevice(); | |
| 56 | |
| 57 int getEstimatedCost() const; | |
| 58 | |
| 59 protected: | |
| 60 virtual void clear(SkColor color) OVERRIDE; | |
| 61 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE; | |
| 62 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | |
| 63 size_t count, const SkPoint[], | |
| 64 const SkPaint& paint) OVERRIDE; | |
| 65 virtual void drawRect(const SkDraw&, const SkRect& r, | |
| 66 const SkPaint& paint) OVERRIDE; | |
| 67 virtual void drawOval(const SkDraw&, const SkRect& oval, | |
| 68 const SkPaint& paint) OVERRIDE; | |
| 69 virtual void drawPath(const SkDraw&, const SkPath& path, | |
| 70 const SkPaint& paint, | |
| 71 const SkMatrix* prePathMatrix = NULL, | |
| 72 bool pathIsMutable = false) OVERRIDE; | |
| 73 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | |
| 74 const SkIRect* srcRectOrNull, | |
| 75 const SkMatrix& matrix, const SkPaint& paint) | |
| 76 OVERRIDE; | |
| 77 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, | |
| 78 int x, int y, const SkPaint& paint) OVERRIDE; | |
| 79 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, | |
| 80 const SkRect* srcOrNull, const SkRect& dst, | |
| 81 const SkPaint& paint) OVERRIDE; | |
| 82 virtual void drawText(const SkDraw&, const void* text, size_t len, | |
| 83 SkScalar x, SkScalar y, const SkPaint& paint) | |
| 84 OVERRIDE; | |
| 85 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, | |
| 86 const SkScalar pos[], SkScalar constY, | |
| 87 int scalarsPerPos, const SkPaint& paint) OVERRIDE; | |
| 88 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | |
| 89 const SkPath& path, const SkMatrix* matrix, | |
| 90 const SkPaint& paint) OVERRIDE; | |
| 91 #ifdef SK_BUILD_FOR_ANDROID | |
| 92 virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, | |
| 93 size_t len, | |
| 94 const SkPoint pos[], const SkPaint& paint, | |
| 95 const SkPath& path, const SkMatrix* matrix) | |
| 96 OVERRIDE; | |
| 97 #endif | |
| 98 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, | |
| 99 int vertexCount, | |
| 100 const SkPoint verts[], const SkPoint texs[], | |
| 101 const SkColor colors[], SkXfermode* xmode, | |
| 102 const uint16_t indices[], int indexCount, | |
| 103 const SkPaint& paint) OVERRIDE; | |
| 104 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, | |
| 105 const SkPaint&) OVERRIDE; | |
| 106 | |
| 107 int estimatedCost_; | |
| 108 | |
| 109 private: | |
| 110 typedef SkDevice INHERITED; | |
| 111 }; | |
| 112 | |
| 113 } // namespace skia | |
| 114 | |
| 115 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | |
| 116 | |
| OLD | NEW |