1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkNoDrawCanvas_DEFINED
9#define SkNoDrawCanvas_DEFINED
10
11#include "include/core/SkCanvas.h"
12#include "include/core/SkCanvasVirtualEnforcer.h"
13
14struct SkIRect;
15
16// SkNoDrawCanvas is a helper for SkCanvas subclasses which do not need to
17// actually rasterize (e.g., analysis of the draw calls).
18//
19// It provides the following simplifications:
20//
21// * not backed by any device/pixels
22// * conservative clipping (clipping calls only use rectangles)
23//
24class SK_API SkNoDrawCanvas : public SkCanvasVirtualEnforcer<SkCanvas> {
25public:
26 SkNoDrawCanvas(int width, int height);
27 SkNoDrawCanvas(const SkIRect&);
28
29 explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
30
31 // Optimization to reset state to be the same as after construction.
32 void resetCanvas(int w, int h) { this->resetForNextPicture(SkIRect::MakeWH(w, h)); }
33 void resetCanvas(const SkIRect& rect) { this->resetForNextPicture(rect); }
34
35protected:
36 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
37 bool onDoSaveBehind(const SkRect*) override;
38
39 // No-op overrides for aborting rasterization earlier than SkNullBlitter.
40 void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
41 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
42 void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
43 void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
44 void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
45 const SkPaint&) override {}
46
47 void onDrawPaint(const SkPaint&) override {}
48 void onDrawBehind(const SkPaint&) override {}
49 void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
50 void onDrawRect(const SkRect&, const SkPaint&) override {}
51 void onDrawRegion(const SkRegion&, const SkPaint&) override {}
52 void onDrawOval(const SkRect&, const SkPaint&) override {}
53 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
54 void onDrawRRect(const SkRRect&, const SkPaint&) override {}
55 void onDrawPath(const SkPath&, const SkPaint&) override {}
56 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
57 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
58 SrcRectConstraint) override {}
59 void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
60 void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
61 const SkPaint*) override {}
62 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
63 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
64 int, SkBlendMode, const SkRect*, const SkPaint*) override {}
65 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
66 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
67
68 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
69 SkBlendMode) override {}
70 void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
71 const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
72
73private:
74 typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
75};
76
77#endif // SkNoDrawCanvas_DEFINED
78