• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/SkBlurTypes.h"
12 #include "include/core/SkCanvas.h"
13 #include "include/core/SkCanvasVirtualEnforcer.h"
14 
15 struct SkIRect;
16 
17 // SkNoDrawCanvas is a helper for SkCanvas subclasses which do not need to
18 // actually rasterize (e.g., analysis of the draw calls).
19 //
20 // It provides the following simplifications:
21 //
22 //   * not backed by any device/pixels
23 //   * conservative clipping (clipping calls only use rectangles)
24 //
25 class SK_API SkNoDrawCanvas : public SkCanvasVirtualEnforcer<SkCanvas> {
26 public:
27     SkNoDrawCanvas(int width, int height);
28     SkNoDrawCanvas(const SkIRect&);
29 
30     explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
31 
32     // Optimization to reset state to be the same as after construction.
resetCanvas(int w,int h)33     void resetCanvas(int w, int h)        { this->resetForNextPicture(SkIRect::MakeWH(w, h)); }
resetCanvas(const SkIRect & rect)34     void resetCanvas(const SkIRect& rect) { this->resetForNextPicture(rect); }
35 
36 protected:
37     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
38     bool onDoSaveBehind(const SkRect*) override;
39 
40     // No-op overrides for aborting rasterization earlier than SkNullBlitter.
onDrawAnnotation(const SkRect &,const char[],SkData *)41     void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
onDrawDRRect(const SkRRect &,const SkRRect &,const SkPaint &)42     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
onDrawDrawable(SkDrawable *,const SkMatrix *)43     void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
onDrawTextBlob(const SkTextBlob *,SkScalar,SkScalar,const SkPaint &)44     void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
onDrawPatch(const SkPoint[12],const SkColor[4],const SkPoint[4],SkBlendMode,const SkPaint &)45     void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
46                      const SkPaint&) override {}
47 
onDrawPaint(const SkPaint &)48     void onDrawPaint(const SkPaint&) override {}
onDrawBehind(const SkPaint &)49     void onDrawBehind(const SkPaint&) override {}
onDrawPoints(PointMode,size_t,const SkPoint[],const SkPaint &)50     void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
onDrawRect(const SkRect &,const SkPaint &)51     void onDrawRect(const SkRect&, const SkPaint&) override {}
onDrawRegion(const SkRegion &,const SkPaint &)52     void onDrawRegion(const SkRegion&, const SkPaint&) override {}
onDrawOval(const SkRect &,const SkPaint &)53     void onDrawOval(const SkRect&, const SkPaint&) override {}
onDrawArc(const SkRect &,SkScalar,SkScalar,bool,const SkPaint &)54     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
onDrawRRect(const SkRRect &,const SkPaint &)55     void onDrawRRect(const SkRRect&, const SkPaint&) override {}
onDrawPath(const SkPath &,const SkPaint &)56     void onDrawPath(const SkPath&, const SkPaint&) override {}
57 
onDrawImage2(const SkImage *,SkScalar,SkScalar,const SkSamplingOptions &,const SkPaint *)58     void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
59                       const SkPaint*) override {}
onDrawImageRect2(const SkImage *,const SkRect &,const SkRect &,const SkSamplingOptions &,const SkPaint *,SrcRectConstraint)60     void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
61                           const SkPaint*, SrcRectConstraint) override {}
onDrawImageLattice2(const SkImage *,const Lattice &,const SkRect &,SkFilterMode,const SkPaint *)62     void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
63                              const SkPaint*) override {}
onDrawAtlas2(const SkImage *,const SkRSXform[],const SkRect[],const SkColor[],int,SkBlendMode,const SkSamplingOptions &,const SkRect *,const SkPaint *)64     void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
65                   SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override {}
66 
onDrawVerticesObject(const SkVertices *,SkBlendMode,const SkPaint &)67     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
onDrawShadowRec(const SkPath &,const SkDrawShadowRec &)68     void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
onDrawPicture(const SkPicture *,const SkMatrix *,const SkPaint *)69     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
70 
onDrawEdgeAAQuad(const SkRect &,const SkPoint[4],QuadAAFlags,const SkColor4f &,SkBlendMode)71     void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
72                           SkBlendMode) override {}
onDrawEdgeAAImageSet2(const ImageSetEntry[],int,const SkPoint[],const SkMatrix[],const SkSamplingOptions &,const SkPaint *,SrcRectConstraint)73     void onDrawEdgeAAImageSet2(const ImageSetEntry[], int, const SkPoint[], const SkMatrix[],
74                                const SkSamplingOptions&, const SkPaint*,
75                                SrcRectConstraint) override {}
76 
onDrawBlurImage(const SkImage * image,const SkBlurArg & blurArg)77     bool onDrawBlurImage(const SkImage* image, const SkBlurArg& blurArg) override { return false; }
78 
79 private:
80     using INHERITED = SkCanvasVirtualEnforcer<SkCanvas>;
81 };
82 
83 #endif // SkNoDrawCanvas_DEFINED
84