| 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 "base/compiler_specific.h" | |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | |
| 10 #include "third_party/skia/include/core/SkPicture.h" | |
| 11 | |
| 12 namespace skia { | |
| 13 | |
| 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, | |
| 19 public SkPicture::AbortCallback { | |
| 20 public: | |
| 21 AnalysisCanvas(int width, int height); | |
| 22 ~AnalysisCanvas() override; | |
| 23 | |
| 24 // Returns true when a SkColor can be used to represent result. | |
| 25 bool GetColorIfSolid(SkColor* color) const; | |
| 26 | |
| 27 void SetForceNotSolid(bool flag); | |
| 28 void SetForceNotTransparent(bool flag); | |
| 29 | |
| 30 // SkPicture::AbortCallback override. | |
| 31 bool abort() override; | |
| 32 | |
| 33 // SkCanvas overrides. | |
| 34 void onDrawPaint(const SkPaint& paint) override; | |
| 35 void onDrawPoints(PointMode, | |
| 36 size_t count, | |
| 37 const SkPoint pts[], | |
| 38 const SkPaint&) override; | |
| 39 void onDrawOval(const SkRect&, const SkPaint&) override; | |
| 40 void onDrawRect(const SkRect&, const SkPaint&) override; | |
| 41 void onDrawRRect(const SkRRect&, const SkPaint&) override; | |
| 42 void onDrawPath(const SkPath& path, const SkPaint&) override; | |
| 43 void onDrawBitmap(const SkBitmap&, | |
| 44 SkScalar left, | |
| 45 SkScalar top, | |
| 46 const SkPaint* paint = NULL) override; | |
| 47 void onDrawBitmapRect(const SkBitmap&, | |
| 48 const SkRect* src, | |
| 49 const SkRect& dst, | |
| 50 const SkPaint* paint, | |
| 51 SrcRectConstraint flags) override; | |
| 52 void onDrawBitmapNine(const SkBitmap& bitmap, | |
| 53 const SkIRect& center, | |
| 54 const SkRect& dst, | |
| 55 const SkPaint* paint = NULL) override; | |
| 56 void onDrawSprite(const SkBitmap&, | |
| 57 int left, | |
| 58 int top, | |
| 59 const SkPaint* paint = NULL) override; | |
| 60 void onDrawVertices(VertexMode, | |
| 61 int vertexCount, | |
| 62 const SkPoint vertices[], | |
| 63 const SkPoint texs[], | |
| 64 const SkColor colors[], | |
| 65 SkXfermode*, | |
| 66 const uint16_t indices[], | |
| 67 int indexCount, | |
| 68 const SkPaint&) override; | |
| 69 | |
| 70 protected: | |
| 71 void willSave() override; | |
| 72 SaveLayerStrategy willSaveLayer(const SkRect*, | |
| 73 const SkPaint*, | |
| 74 SaveFlags) override; | |
| 75 void willRestore() override; | |
| 76 | |
| 77 void onClipRect(const SkRect& rect, | |
| 78 SkRegion::Op op, | |
| 79 ClipEdgeStyle edge_style) override; | |
| 80 void onClipRRect(const SkRRect& rrect, | |
| 81 SkRegion::Op op, | |
| 82 ClipEdgeStyle edge_style) override; | |
| 83 void onClipPath(const SkPath& path, | |
| 84 SkRegion::Op op, | |
| 85 ClipEdgeStyle edge_style) override; | |
| 86 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) override; | |
| 87 | |
| 88 void onDrawText(const void* text, | |
| 89 size_t byteLength, | |
| 90 SkScalar x, | |
| 91 SkScalar y, | |
| 92 const SkPaint&) override; | |
| 93 void onDrawPosText(const void* text, | |
| 94 size_t byteLength, | |
| 95 const SkPoint pos[], | |
| 96 const SkPaint&) override; | |
| 97 void onDrawPosTextH(const void* text, | |
| 98 size_t byteLength, | |
| 99 const SkScalar xpos[], | |
| 100 SkScalar constY, | |
| 101 const SkPaint&) override; | |
| 102 void onDrawTextOnPath(const void* text, | |
| 103 size_t byteLength, | |
| 104 const SkPath& path, | |
| 105 const SkMatrix* matrix, | |
| 106 const SkPaint&) override; | |
| 107 void onDrawTextBlob(const SkTextBlob* blob, | |
| 108 SkScalar x, | |
| 109 SkScalar y, | |
| 110 const SkPaint& paint) override; | |
| 111 void onDrawDRRect(const SkRRect& outer, | |
| 112 const SkRRect& inner, | |
| 113 const SkPaint&) override; | |
| 114 | |
| 115 void OnComplexClip(); | |
| 116 | |
| 117 private: | |
| 118 typedef SkCanvas INHERITED; | |
| 119 | |
| 120 int saved_stack_size_; | |
| 121 int force_not_solid_stack_level_; | |
| 122 int force_not_transparent_stack_level_; | |
| 123 | |
| 124 bool is_forced_not_solid_; | |
| 125 bool is_forced_not_transparent_; | |
| 126 bool is_solid_color_; | |
| 127 SkColor color_; | |
| 128 bool is_transparent_; | |
| 129 int draw_op_count_; | |
| 130 }; | |
| 131 | |
| 132 } // namespace skia | |
| 133 | |
| 134 #endif // SKIA_EXT_ANALYSIS_CANVAS_H_ | |
| 135 | |
| OLD | NEW |