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