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 namespace sktext::gpu { class Slug; } 49 50 class SK_API SkNWayCanvas : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> { 51 public: 52 SkNWayCanvas(int width, int height); 53 ~SkNWayCanvas() override; 54 55 virtual void addCanvas(SkCanvas*); 56 virtual void removeCanvas(SkCanvas*); 57 virtual void removeAll(); 58 59 protected: 60 SkTDArray<SkCanvas*> fList; 61 62 void willSave() override; 63 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; 64 bool onDoSaveBehind(const SkRect*) override; 65 void willRestore() override; 66 67 void didConcat44(const SkM44&) override; 68 void didSetM44(const SkM44&) override; 69 void didScale(SkScalar, SkScalar) override; 70 void didTranslate(SkScalar, SkScalar) override; 71 72 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; 73 void onDrawGlyphRunList(const sktext::GlyphRunList&, const SkPaint&) override; 74 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 75 const SkPaint& paint) override; 76 void onDrawSlug(const sktext::gpu::Slug* slug, const SkPaint& paint) override; 77 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 78 const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override; 79 80 void onDrawPaint(const SkPaint&) override; 81 void onDrawBehind(const SkPaint&) override; 82 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override; 83 void onDrawRect(const SkRect&, const SkPaint&) override; 84 void onDrawRegion(const SkRegion&, const SkPaint&) override; 85 void onDrawOval(const SkRect&, const SkPaint&) override; 86 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override; 87 void onDrawRRect(const SkRRect&, const SkPaint&) override; 88 void onDrawPath(const SkPath&, const SkPaint&) override; 89 90 void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&, 91 const SkPaint*) override; 92 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&, 93 const SkPaint*, SrcRectConstraint) override; 94 void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode, 95 const SkPaint*) override; 96 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, 97 SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override; 98 99 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override; 100 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override; 101 102 void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override; 103 void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override; 104 void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override; 105 void onClipShader(sk_sp<SkShader>, SkClipOp) override; 106 void onClipRegion(const SkRegion&, SkClipOp) override; 107 void onResetClip() override; 108 109 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; 110 void onDrawDrawable(SkDrawable*, const SkMatrix*) override; 111 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; 112 113 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&, 114 SkBlendMode) override; 115 void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], 116 const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override; 117 class Iter; 118 private: 119 using INHERITED = SkCanvasVirtualEnforcer<SkNoDrawCanvas>; 120 }; 121 122 123 #endif 124