Remove explicit Skia save flags.
[chromium-blink-merge.git] / skia / ext / analysis_canvas.h
blob922a3ee5c60077706799f3735dbebb554799b07f
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;
25 bool HasText() const;
27 void SetForceNotSolid(bool flag);
28 void SetForceNotTransparent(bool flag);
30 // SkDrawPictureCallback override.
31 virtual bool abortDrawing() OVERRIDE;
33 // SkCanvas overrides.
34 virtual void clear(SkColor) OVERRIDE;
35 virtual void drawPaint(const SkPaint& paint) OVERRIDE;
36 virtual void drawPoints(PointMode,
37 size_t count,
38 const SkPoint pts[],
39 const SkPaint&) OVERRIDE;
40 virtual void drawOval(const SkRect&, const SkPaint&) OVERRIDE;
41 virtual void drawRect(const SkRect&, const SkPaint&) OVERRIDE;
42 virtual void drawRRect(const SkRRect&, const SkPaint&) OVERRIDE;
43 virtual void drawPath(const SkPath& path, const SkPaint&) OVERRIDE;
44 virtual void drawBitmap(const SkBitmap&,
45 SkScalar left,
46 SkScalar top,
47 const SkPaint* paint = NULL) OVERRIDE;
48 virtual void drawBitmapRectToRect(const SkBitmap&,
49 const SkRect* src,
50 const SkRect& dst,
51 const SkPaint* paint,
52 DrawBitmapRectFlags flags) OVERRIDE;
53 virtual void drawBitmapMatrix(const SkBitmap&,
54 const SkMatrix&,
55 const SkPaint* paint = NULL) OVERRIDE;
56 virtual void drawBitmapNine(const SkBitmap& bitmap,
57 const SkIRect& center,
58 const SkRect& dst,
59 const SkPaint* paint = NULL) OVERRIDE;
60 virtual void drawSprite(const SkBitmap&, int left, int top,
61 const SkPaint* paint = NULL) OVERRIDE;
62 virtual void drawText(const void* text,
63 size_t byteLength,
64 SkScalar x,
65 SkScalar y,
66 const SkPaint&) OVERRIDE;
67 virtual void drawPosText(const void* text,
68 size_t byteLength,
69 const SkPoint pos[],
70 const SkPaint&) OVERRIDE;
71 virtual void drawPosTextH(const void* text,
72 size_t byteLength,
73 const SkScalar xpos[],
74 SkScalar constY,
75 const SkPaint&) OVERRIDE;
76 virtual void drawTextOnPath(const void* text,
77 size_t byteLength,
78 const SkPath& path,
79 const SkMatrix* matrix,
80 const SkPaint&) OVERRIDE;
81 virtual void drawVertices(VertexMode,
82 int vertexCount,
83 const SkPoint vertices[],
84 const SkPoint texs[],
85 const SkColor colors[],
86 SkXfermode*,
87 const uint16_t indices[],
88 int indexCount,
89 const SkPaint&) OVERRIDE;
91 protected:
92 virtual void willSave(SaveFlags) OVERRIDE;
93 virtual SaveLayerStrategy willSaveLayer(const SkRect*,
94 const SkPaint*,
95 SaveFlags) OVERRIDE;
96 virtual void willRestore() OVERRIDE;
98 virtual void onClipRect(const SkRect& rect,
99 SkRegion::Op op,
100 ClipEdgeStyle edge_style) OVERRIDE;
101 virtual void onClipRRect(const SkRRect& rrect,
102 SkRegion::Op op,
103 ClipEdgeStyle edge_style) OVERRIDE;
104 virtual void onClipPath(const SkPath& path,
105 SkRegion::Op op,
106 ClipEdgeStyle edge_style) OVERRIDE;
108 private:
109 typedef SkCanvas INHERITED;
111 int saved_stack_size_;
112 int force_not_solid_stack_level_;
113 int force_not_transparent_stack_level_;
115 bool is_forced_not_solid_;
116 bool is_forced_not_transparent_;
117 bool is_solid_color_;
118 SkColor color_;
119 bool is_transparent_;
120 bool has_text_;
123 } // namespace skia
125 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_