Instrumented libraries: fix libpci3 build on Trusty.
[chromium-blink-merge.git] / skia / ext / analysis_canvas.h
blobabedcaf0e5240d42bca95999eaed15a047185bd9
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 ~AnalysisCanvas() override;
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 bool abortDrawing() override;
32 // SkCanvas overrides.
33 void clear(SkColor) override;
34 void drawPaint(const SkPaint& paint) override;
35 void drawPoints(PointMode,
36 size_t count,
37 const SkPoint pts[],
38 const SkPaint&) override;
39 void drawOval(const SkRect&, const SkPaint&) override;
40 void drawRect(const SkRect&, const SkPaint&) override;
41 void drawRRect(const SkRRect&, const SkPaint&) override;
42 void drawPath(const SkPath& path, const SkPaint&) override;
43 void drawBitmap(const SkBitmap&,
44 SkScalar left,
45 SkScalar top,
46 const SkPaint* paint = NULL) override;
47 void drawBitmapRectToRect(const SkBitmap&,
48 const SkRect* src,
49 const SkRect& dst,
50 const SkPaint* paint,
51 DrawBitmapRectFlags flags) override;
52 void drawBitmapMatrix(const SkBitmap&,
53 const SkMatrix&,
54 const SkPaint* paint = NULL) override;
55 void drawBitmapNine(const SkBitmap& bitmap,
56 const SkIRect& center,
57 const SkRect& dst,
58 const SkPaint* paint = NULL) override;
59 void drawSprite(const SkBitmap&,
60 int left,
61 int top,
62 const SkPaint* paint = NULL) override;
63 void drawVertices(VertexMode,
64 int vertexCount,
65 const SkPoint vertices[],
66 const SkPoint texs[],
67 const SkColor colors[],
68 SkXfermode*,
69 const uint16_t indices[],
70 int indexCount,
71 const SkPaint&) override;
73 protected:
74 void willSave() override;
75 SaveLayerStrategy willSaveLayer(const SkRect*,
76 const SkPaint*,
77 SaveFlags) override;
78 void willRestore() override;
80 void onClipRect(const SkRect& rect,
81 SkRegion::Op op,
82 ClipEdgeStyle edge_style) override;
83 void onClipRRect(const SkRRect& rrect,
84 SkRegion::Op op,
85 ClipEdgeStyle edge_style) override;
86 void onClipPath(const SkPath& path,
87 SkRegion::Op op,
88 ClipEdgeStyle edge_style) override;
89 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) override;
91 void onDrawText(const void* text,
92 size_t byteLength,
93 SkScalar x,
94 SkScalar y,
95 const SkPaint&) override;
96 void onDrawPosText(const void* text,
97 size_t byteLength,
98 const SkPoint pos[],
99 const SkPaint&) override;
100 void onDrawPosTextH(const void* text,
101 size_t byteLength,
102 const SkScalar xpos[],
103 SkScalar constY,
104 const SkPaint&) override;
105 void onDrawTextOnPath(const void* text,
106 size_t byteLength,
107 const SkPath& path,
108 const SkMatrix* matrix,
109 const SkPaint&) override;
110 void onDrawTextBlob(const SkTextBlob* blob,
111 SkScalar x,
112 SkScalar y,
113 const SkPaint& paint) override;
114 void onDrawDRRect(const SkRRect& outer,
115 const SkRRect& inner,
116 const SkPaint&) override;
118 void OnComplexClip();
120 private:
121 typedef SkCanvas INHERITED;
123 int saved_stack_size_;
124 int force_not_solid_stack_level_;
125 int force_not_transparent_stack_level_;
127 bool is_forced_not_solid_;
128 bool is_forced_not_transparent_;
129 bool is_solid_color_;
130 SkColor color_;
131 bool is_transparent_;
132 int draw_op_count_;
135 } // namespace skia
137 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_