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

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

Issue 12213018: Implementation for cc::Picture::IsCheapInRect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to skyostil's comments Created 7 years, 10 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
« no previous file with comments | « cc/picture.cc ('k') | skia/ext/analysis_canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Returns true if the estimated cost of drawing is below an
27 // arbitrary threshold.
28 bool isCheap() const;
29
30 // Returns the estimated cost of drawing, in arbitrary units.
31 int getEstimatedCost() const;
32
33 virtual bool clipRect(const SkRect& rect,
34 SkRegion::Op op = SkRegion::kIntersect_Op,
35 bool doAntiAlias = false) OVERRIDE;
36 virtual bool clipPath(const SkPath& path,
37 SkRegion::Op op = SkRegion::kIntersect_Op,
38 bool doAntiAlias = false) OVERRIDE;
39 virtual bool clipRRect(const SkRRect& rrect,
40 SkRegion::Op op = SkRegion::kIntersect_Op,
41 bool doAntiAlias = false) OVERRIDE;
42
43 virtual int saveLayer(const SkRect* bounds, const SkPaint*,
44 SkCanvas::SaveFlags flags) OVERRIDE;
45 private:
46 typedef SkCanvas INHERITED;
47 };
48
49 class SK_API AnalysisDevice : public SkDevice {
50 public:
51 AnalysisDevice(const SkBitmap& bm);
52 virtual ~AnalysisDevice();
53
54 int getEstimatedCost() const;
55
56 protected:
57 virtual void clear(SkColor color) OVERRIDE;
58 virtual void drawPaint(const SkDraw&, const SkPaint& paint) OVERRIDE;
59 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode,
60 size_t count, const SkPoint[],
61 const SkPaint& paint) OVERRIDE;
62 virtual void drawRect(const SkDraw&, const SkRect& r,
63 const SkPaint& paint) OVERRIDE;
64 virtual void drawOval(const SkDraw&, const SkRect& oval,
65 const SkPaint& paint) OVERRIDE;
66 virtual void drawPath(const SkDraw&, const SkPath& path,
67 const SkPaint& paint,
68 const SkMatrix* prePathMatrix = NULL,
69 bool pathIsMutable = false) OVERRIDE;
70 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
71 const SkIRect* srcRectOrNull,
72 const SkMatrix& matrix, const SkPaint& paint)
73 OVERRIDE;
74 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
75 int x, int y, const SkPaint& paint) OVERRIDE;
76 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
77 const SkRect* srcOrNull, const SkRect& dst,
78 const SkPaint& paint) OVERRIDE;
79 virtual void drawText(const SkDraw&, const void* text, size_t len,
80 SkScalar x, SkScalar y, const SkPaint& paint)
81 OVERRIDE;
82 virtual void drawPosText(const SkDraw& draw, const void* text, size_t len,
83 const SkScalar pos[], SkScalar constY,
84 int scalarsPerPos, const SkPaint& paint) OVERRIDE;
85 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
86 const SkPath& path, const SkMatrix* matrix,
87 const SkPaint& paint) OVERRIDE;
88 #ifdef SK_BUILD_FOR_ANDROID
89 virtual void drawPosTextOnPath(const SkDraw& draw, const void* text,
90 size_t len,
91 const SkPoint pos[], const SkPaint& paint,
92 const SkPath& path, const SkMatrix* matrix)
93 OVERRIDE;
94 #endif
95 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode,
96 int vertexCount,
97 const SkPoint verts[], const SkPoint texs[],
98 const SkColor colors[], SkXfermode* xmode,
99 const uint16_t indices[], int indexCount,
100 const SkPaint& paint) OVERRIDE;
101 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
102 const SkPaint&) OVERRIDE;
103
104 int estimatedCost_;
105
106 private:
107 typedef SkDevice INHERITED;
108 };
109
110 } // namespace skia
111
112 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_
113
OLDNEW
« no previous file with comments | « cc/picture.cc ('k') | skia/ext/analysis_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698