• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 #ifndef SkNWayCanvas_DEFINED
10 #define SkNWayCanvas_DEFINED
11 
12 #include "include/core/SkCanvasVirtualEnforcer.h"
13 #include "include/core/SkColor.h"
14 #include "include/core/SkM44.h"
15 #include "include/core/SkRefCnt.h"
16 #include "include/core/SkSamplingOptions.h"
17 #include "include/core/SkScalar.h"
18 #include "include/core/SkTypes.h"
19 #include "include/private/base/SkTDArray.h"
20 #include "include/utils/SkNoDrawCanvas.h"
21 
22 #include <cstddef>
23 
24 namespace sktext {
25 class GlyphRunList;
26 }
27 
28 class SkCanvas;
29 class SkData;
30 class SkDrawable;
31 class SkImage;
32 class SkMatrix;
33 class SkPaint;
34 class SkPath;
35 class SkPicture;
36 class SkRRect;
37 class SkRegion;
38 class SkShader;
39 class SkTextBlob;
40 class SkVertices;
41 enum class SkBlendMode;
42 enum class SkClipOp;
43 struct SkDrawShadowRec;
44 struct SkPoint;
45 struct SkRSXform;
46 struct SkRect;
47 
48 #if defined(SK_GANESH)
49 namespace sktext::gpu {
50 class Slug;
51 }
52 #endif
53 
54 class SK_API SkNWayCanvas : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> {
55 public:
56     SkNWayCanvas(int width, int height);
57     ~SkNWayCanvas() override;
58 
59     virtual void addCanvas(SkCanvas*);
60     virtual void removeCanvas(SkCanvas*);
61     virtual void removeAll();
62 
63 protected:
64     SkTDArray<SkCanvas*> fList;
65 
66     void willSave() override;
67     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
68     bool onDoSaveBehind(const SkRect*) override;
69     void willRestore() override;
70 
71     void didConcat44(const SkM44&) override;
72     void didSetM44(const SkM44&) override;
73     void didScale(SkScalar, SkScalar) override;
74     void didTranslate(SkScalar, SkScalar) override;
75 
76     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
77     void onDrawGlyphRunList(const sktext::GlyphRunList&, const SkPaint&) override;
78     void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
79                         const SkPaint& paint) override;
80 #if defined(SK_GANESH)
81     void onDrawSlug(const sktext::gpu::Slug* slug) override;
82 #endif
83     void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
84                      const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;
85 
86     void onDrawPaint(const SkPaint&) override;
87     void onDrawBehind(const SkPaint&) override;
88     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
89     void onDrawRect(const SkRect&, const SkPaint&) override;
90     void onDrawRegion(const SkRegion&, const SkPaint&) override;
91     void onDrawOval(const SkRect&, const SkPaint&) override;
92     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
93     void onDrawRRect(const SkRRect&, const SkPaint&) override;
94     void onDrawPath(const SkPath&, const SkPaint&) override;
95 
96     void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
97                       const SkPaint*) override;
98     void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
99                           const SkPaint*, SrcRectConstraint) override;
100     void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
101                              const SkPaint*) override;
102     void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
103                   SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
104 
105     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
106     void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
107 
108     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
109     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
110     void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
111     void onClipShader(sk_sp<SkShader>, SkClipOp) override;
112     void onClipRegion(const SkRegion&, SkClipOp) override;
113     void onResetClip() override;
114 
115     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
116     void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
117     void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
118 
119     void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
120                           SkBlendMode) override;
121     void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
122                                const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override;
123 
124     void onFlush() override;
125 
126     class Iter;
127 
128 private:
129     using INHERITED = SkCanvasVirtualEnforcer<SkNoDrawCanvas>;
130 };
131 
132 
133 #endif
134