Stop using legacy GrContext member function aliases.
[chromium-blink-merge.git] / skia / ext / analysis_canvas.h
blobd3d3b80dc8d8581002d2cbd443ac6507f0a86763
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.
5 #ifndef SKIA_EXT_ANALYSIS_CANVAS_H_
6 #define SKIA_EXT_ANALYSIS_CANVAS_H_
8 #include "base/compiler_specific.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPicture.h"
12 namespace skia {
14 // Does not render anything, but gathers statistics about a region
15 // (specified as a clip rectangle) of an SkPicture as the picture is
16 // played back through it.
17 // To use: play a picture into the canvas, and then check result.
18 class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback {
19 public:
20 AnalysisCanvas(int width, int height);
21 virtual ~AnalysisCanvas();
23 // Returns true when a SkColor can be used to represent result.
24 bool GetColorIfSolid(SkColor* color) const;
26 void SetForceNotSolid(bool flag);
27 void SetForceNotTransparent(bool flag);
29 // SkDrawPictureCallback override.
30 virtual bool abortDrawing() override;
32 // SkCanvas overrides.
33 virtual void clear(SkColor) override;
34 virtual void drawPaint(const SkPaint& paint) override;
35 virtual void drawPoints(PointMode,
36 size_t count,
37 const SkPoint pts[],
38 const SkPaint&) override;
39 virtual void drawOval(const SkRect&, const SkPaint&) override;
40 virtual void drawRect(const SkRect&, const SkPaint&) override;
41 virtual void drawRRect(const SkRRect&, const SkPaint&) override;
42 virtual void drawPath(const SkPath& path, const SkPaint&) override;
43 virtual void drawBitmap(const SkBitmap&,
44 SkScalar left,
45 SkScalar top,
46 const SkPaint* paint = NULL) override;
47 virtual void drawBitmapRectToRect(const SkBitmap&,
48 const SkRect* src,
49 const SkRect& dst,
50 const SkPaint* paint,
51 DrawBitmapRectFlags flags) override;
52 virtual void drawBitmapMatrix(const SkBitmap&,
53 const SkMatrix&,
54 const SkPaint* paint = NULL) override;
55 virtual void drawBitmapNine(const SkBitmap& bitmap,
56 const SkIRect& center,
57 const SkRect& dst,
58 const SkPaint* paint = NULL) override;
59 virtual void drawSprite(const SkBitmap&, int left, int top,
60 const SkPaint* paint = NULL) override;
61 virtual void drawVertices(VertexMode,
62 int vertexCount,
63 const SkPoint vertices[],
64 const SkPoint texs[],
65 const SkColor colors[],
66 SkXfermode*,
67 const uint16_t indices[],
68 int indexCount,
69 const SkPaint&) override;
71 protected:
72 virtual void willSave() override;
73 virtual SaveLayerStrategy willSaveLayer(const SkRect*,
74 const SkPaint*,
75 SaveFlags) override;
76 virtual void willRestore() override;
78 virtual void onClipRect(const SkRect& rect,
79 SkRegion::Op op,
80 ClipEdgeStyle edge_style) override;
81 virtual void onClipRRect(const SkRRect& rrect,
82 SkRegion::Op op,
83 ClipEdgeStyle edge_style) override;
84 virtual void onClipPath(const SkPath& path,
85 SkRegion::Op op,
86 ClipEdgeStyle edge_style) override;
87 virtual void onClipRegion(const SkRegion& deviceRgn,
88 SkRegion::Op op) override;
90 virtual void onDrawText(const void* text,
91 size_t byteLength,
92 SkScalar x,
93 SkScalar y,
94 const SkPaint&) override;
95 virtual void onDrawPosText(const void* text,
96 size_t byteLength,
97 const SkPoint pos[],
98 const SkPaint&) override;
99 virtual void onDrawPosTextH(const void* text,
100 size_t byteLength,
101 const SkScalar xpos[],
102 SkScalar constY,
103 const SkPaint&) override;
104 virtual void onDrawTextOnPath(const void* text,
105 size_t byteLength,
106 const SkPath& path,
107 const SkMatrix* matrix,
108 const SkPaint&) override;
109 virtual void onDrawTextBlob(const SkTextBlob* blob,
110 SkScalar x,
111 SkScalar y,
112 const SkPaint& paint) override;
113 virtual void onDrawDRRect(const SkRRect& outer,
114 const SkRRect& inner,
115 const SkPaint&) override;
117 void OnComplexClip();
119 private:
120 typedef SkCanvas INHERITED;
122 int saved_stack_size_;
123 int force_not_solid_stack_level_;
124 int force_not_transparent_stack_level_;
126 bool is_forced_not_solid_;
127 bool is_forced_not_transparent_;
128 bool is_solid_color_;
129 SkColor color_;
130 bool is_transparent_;
131 int draw_op_count_;
134 } // namespace skia
136 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_