3 * Copyright 2016 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #ifndef SkDeferredCanvas_DEFINED
10 #define SkDeferredCanvas_DEFINED
12 #include "../private/SkTDArray.h"
15 class SK_API SkDeferredCanvas : public SkCanvas {
17 SkDeferredCanvas(SkCanvas* = nullptr);
18 ~SkDeferredCanvas() override;
20 void reset(SkCanvas*);
22 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
23 SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
27 sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
28 SkISize getBaseLayerSize() const override;
29 bool getClipBounds(SkRect* bounds) const override;
30 bool getClipDeviceBounds(SkIRect* bounds) const override;
31 bool isClipEmpty() const override;
32 bool isClipRect() const override;
33 bool onPeekPixels(SkPixmap*) override;
34 bool onAccessTopLayerPixels(SkPixmap*) override;
35 SkImageInfo onImageInfo() const override;
36 bool onGetProps(SkSurfaceProps*) const override;
37 void onFlush() override;
39 void willSave() override;
40 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
41 void willRestore() override;
43 void didConcat(const SkMatrix&) override;
44 void didSetMatrix(const SkMatrix&) override;
46 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
47 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
48 const SkPaint&) override;
49 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
50 const SkPaint&) override;
51 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
52 SkScalar constY, const SkPaint&) override;
53 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
54 const SkMatrix* matrix, const SkPaint&) override;
55 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[],
56 const SkRect* cullRect, const SkPaint&) override;
57 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
58 const SkPaint& paint) override;
59 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
60 const SkPoint texCoords[4], SkXfermode* xmode,
61 const SkPaint& paint) override;
63 void onDrawPaint(const SkPaint&) override;
64 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
65 void onDrawRect(const SkRect&, const SkPaint&) override;
66 void onDrawRegion(const SkRegion& region, const SkPaint& paint) override;
67 void onDrawOval(const SkRect&, const SkPaint&) override;
68 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
69 void onDrawRRect(const SkRRect&, const SkPaint&) override;
70 void onDrawPath(const SkPath&, const SkPaint&) override;
72 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
73 void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
74 const SkPaint*) override;
75 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
76 const SkPaint*) override;
77 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
78 SrcRectConstraint) override;
80 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
81 void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
82 const SkPaint*) override;
83 void onDrawImageNine(const SkImage* image, const SkIRect& center,
84 const SkRect& dst, const SkPaint*) override;
85 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
86 const SkPaint*, SrcRectConstraint) override;
88 void onDrawVertices(VertexMode vmode, int vertexCount,
89 const SkPoint vertices[], const SkPoint texs[],
90 const SkColor colors[], SkXfermode* xmode,
91 const uint16_t indices[], int indexCount,
92 const SkPaint&) override;
93 void onDrawAtlas(const SkImage* image, const SkRSXform xform[],
94 const SkRect rects[], const SkColor colors[],
95 int count, SkXfermode::Mode mode,
96 const SkRect* cull, const SkPaint* paint) override;
98 void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
99 void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
100 void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
101 void onClipRegion(const SkRegion&, ClipOp) override;
103 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
104 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
105 void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
110 SkCanvas* fCanvas{nullptr};
125 SkVector fTrans; // post translate
129 bool isConcat(SkMatrix*) const;
130 void getConcat(SkMatrix* mat) const {
131 SkDEBUGCODE(bool isconcat = ) this->isConcat(mat);
134 void setConcat(const SkMatrix&);
136 SkTDArray<Rec> fRecs;
139 void push_cliprect(const SkRect&);
140 bool push_concat(const SkMatrix&);
142 void emit(const Rec& rec);
145 void flush_before_saves();
146 void flush_le(int index);
147 void flush_translate(SkScalar* x, SkScalar* y, const SkPaint&);
148 void flush_translate(SkScalar* x, SkScalar* y, const SkRect& bounds, const SkPaint* = nullptr);
149 void flush_check(SkRect* bounds, const SkPaint*, unsigned flags = 0);
151 void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* boundsOrNull);
153 typedef SkCanvas INHERITED;