OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2016 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkNWayCanvas_DEFINED | 9 #ifndef SkDeferredCanvas_DEFINED |
10 #define SkNWayCanvas_DEFINED | 10 #define SkDeferredCanvas_DEFINED |
11 | 11 |
12 #include "../private/SkTDArray.h" | 12 #include "../private/SkTDArray.h" |
13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
14 | 14 |
15 class SK_API SkNWayCanvas : public SkCanvas { | 15 class SK_API SkDeferredCanvas : public SkCanvas { |
16 public: | 16 public: |
17 SkNWayCanvas(int width, int height); | 17 SkDeferredCanvas(SkCanvas*); |
18 virtual ~SkNWayCanvas(); | 18 ~SkDeferredCanvas() override; |
19 | |
20 virtual void addCanvas(SkCanvas*); | |
21 virtual void removeCanvas(SkCanvas*); | |
22 virtual void removeAll(); | |
23 | |
24 /////////////////////////////////////////////////////////////////////////// | |
25 // These are forwarded to the N canvases we're referencing | |
26 | 19 |
27 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER | 20 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
28 SkDrawFilter* setDrawFilter(SkDrawFilter*) override; | 21 SkDrawFilter* setDrawFilter(SkDrawFilter*) override; |
29 #endif | 22 #endif |
30 | 23 |
31 protected: | 24 protected: |
32 SkTDArray<SkCanvas*> fList; | 25 sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) ove
rride; |
| 26 SkISize getBaseLayerSize() const override; |
| 27 bool getClipBounds(SkRect* bounds) const override; |
| 28 bool getClipDeviceBounds(SkIRect* bounds) const override; |
| 29 bool isClipEmpty() const override; |
| 30 bool isClipRect() const override; |
| 31 bool onPeekPixels(SkPixmap*) override; |
| 32 bool onAccessTopLayerPixels(SkPixmap*) override; |
| 33 SkImageInfo onImageInfo() const override; |
| 34 bool onGetProps(SkSurfaceProps*) const override; |
| 35 void onFlush() override; |
| 36 // SkCanvas* canvasForDrawIter() override; |
33 | 37 |
34 void willSave() override; | 38 void willSave() override; |
35 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; | 39 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
36 void willRestore() override; | 40 void willRestore() override; |
37 | 41 |
38 void didConcat(const SkMatrix&) override; | 42 void didConcat(const SkMatrix&) override; |
39 void didSetMatrix(const SkMatrix&) override; | 43 void didSetMatrix(const SkMatrix&) override; |
40 | 44 |
41 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; | 45 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
42 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS
calar y, | 46 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS
calar y, |
43 const SkPaint&) override; | 47 const SkPaint&) override; |
44 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin
t pos[], | 48 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin
t pos[], |
45 const SkPaint&) override; | 49 const SkPaint&) override; |
46 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], | 50 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], |
47 SkScalar constY, const SkPaint&) override; | 51 SkScalar constY, const SkPaint&) override; |
48 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP
ath& path, | 52 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP
ath& path, |
49 const SkMatrix* matrix, const SkPaint&) overri
de; | 53 const SkMatrix* matrix, const SkPaint&) overri
de; |
| 54 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[
], |
| 55 const SkRect* cullRect, const SkPaint&) override; |
50 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 56 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
51 const SkPaint& paint) override; | 57 const SkPaint& paint) override; |
52 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform
xform[], | |
53 const SkRect* cull, const SkPaint& paint) override; | |
54 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], | 58 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
55 const SkPoint texCoords[4], SkXfermode* xmode, | 59 const SkPoint texCoords[4], SkXfermode* xmode, |
56 const SkPaint& paint) override; | 60 const SkPaint& paint) override; |
57 | 61 |
58 void onDrawPaint(const SkPaint&) override; | 62 void onDrawPaint(const SkPaint&) override; |
59 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; | 63 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; |
60 void onDrawRect(const SkRect&, const SkPaint&) override; | 64 void onDrawRect(const SkRect&, const SkPaint&) override; |
61 void onDrawOval(const SkRect&, const SkPaint&) override; | 65 void onDrawOval(const SkRect&, const SkPaint&) override; |
62 void onDrawRRect(const SkRRect&, const SkPaint&) override; | 66 void onDrawRRect(const SkRRect&, const SkPaint&) override; |
63 void onDrawPath(const SkPath&, const SkPaint&) override; | 67 void onDrawPath(const SkPath&, const SkPaint&) override; |
64 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain
t*) override; | 68 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain
t*) override; |
65 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
const SkPaint*, | 69 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
const SkPaint*, |
66 SrcRectConstraint) override; | 70 SrcRectConstraint) override; |
67 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*
) override; | 71 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*
) override; |
68 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, | 72 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
69 const SkPaint*, SrcRectConstraint) override; | 73 const SkPaint*, SrcRectConstraint) override; |
70 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, | 74 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect&
dst, |
71 const SkPaint*) override; | 75 const SkPaint*) override; |
| 76 void onDrawImageNine(const SkImage* image, const SkIRect& center, |
| 77 const SkRect& dst, const SkPaint*) override; |
72 void onDrawVertices(VertexMode vmode, int vertexCount, | 78 void onDrawVertices(VertexMode vmode, int vertexCount, |
73 const SkPoint vertices[], const SkPoint texs[], | 79 const SkPoint vertices[], const SkPoint texs[], |
74 const SkColor colors[], SkXfermode* xmode, | 80 const SkColor colors[], SkXfermode* xmode, |
75 const uint16_t indices[], int indexCount, | 81 const uint16_t indices[], int indexCount, |
76 const SkPaint&) override; | 82 const SkPaint&) override; |
| 83 void onDrawAtlas(const SkImage* image, const SkRSXform xform[], |
| 84 const SkRect rects[], const SkColor colors[], |
| 85 int count, SkXfermode::Mode mode, |
| 86 const SkRect* cull, const SkPaint* paint) override; |
77 | 87 |
78 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; | 88 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
79 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; | 89 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
80 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; | 90 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
81 void onClipRegion(const SkRegion&, SkRegion::Op) override; | 91 void onClipRegion(const SkRegion&, SkRegion::Op) override; |
82 | 92 |
| 93 void onDrawDrawable(SkDrawable*, const SkMatrix*) override; |
83 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri
de; | 94 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri
de; |
84 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; | 95 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; |
85 | 96 |
86 class Iter; | 97 class Iter; |
87 | 98 |
88 private: | 99 private: |
| 100 SkCanvas* fCanvas; |
| 101 |
| 102 enum Type { |
| 103 kSave_Type, |
| 104 kClipRect_Type, |
| 105 kTrans_Type, |
| 106 kScaleTrans_Type, |
| 107 }; |
| 108 struct Rec { |
| 109 Type fType; |
| 110 union { |
| 111 SkRect fBounds; |
| 112 SkVector fTranslate; |
| 113 struct { |
| 114 SkVector fScale; |
| 115 SkVector fTrans; // post translate |
| 116 } fScaleTrans; |
| 117 } fData; |
| 118 |
| 119 bool isConcat(SkMatrix*) const; |
| 120 void getConcat(SkMatrix* mat) const { |
| 121 SkDEBUGCODE(bool isconcat = ) this->isConcat(mat); |
| 122 SkASSERT(isconcat); |
| 123 } |
| 124 void setConcat(const SkMatrix&); |
| 125 }; |
| 126 SkTDArray<Rec> fRecs; |
| 127 |
| 128 void push_save(); |
| 129 void push_cliprect(const SkRect&); |
| 130 bool push_concat(const SkMatrix&); |
| 131 |
| 132 void emit(const Rec& rec); |
| 133 |
| 134 void flush_all(); |
| 135 void flush_before_saves(); |
| 136 void flush_le(int index); |
| 137 void flush_translate(SkScalar* x, SkScalar* y, const SkPaint&); |
| 138 void flush_translate(SkScalar* x, SkScalar* y, const SkRect& bounds, const S
kPaint* = nullptr); |
| 139 void flush_check(SkRect* bounds, const SkPaint*, unsigned flags = 0); |
| 140 |
| 141 void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* bounds
OrNull); |
| 142 |
89 typedef SkCanvas INHERITED; | 143 typedef SkCanvas INHERITED; |
90 }; | 144 }; |
91 | 145 |
92 | 146 |
93 #endif | 147 #endif |
OLD | NEW |