• 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 #include "include/core/SkVertices.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 
29     // TODO: investigate the users of this ctor.
30     SkNoDrawCanvas(const SkIRect&);
31 
32     explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
33 
34     // Optimization to reset state to be the same as after construction.
resetCanvas(int width,int height)35     void resetCanvas(int width, int height) {
36         resetForNextPicture(SkIRect::MakeWH(width, height));
37     }
38 
39 protected:
40     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
41     bool onDoSaveBehind(const SkRect*) override;
42 
43     // No-op overrides for aborting rasterization earlier than SkNullBlitter.
onDrawAnnotation(const SkRect &,const char[],SkData *)44     void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
onDrawDRRect(const SkRRect &,const SkRRect &,const SkPaint &)45     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
onDrawDrawable(SkDrawable *,const SkMatrix *)46     void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
onDrawTextBlob(const SkTextBlob *,SkScalar,SkScalar,const SkPaint &)47     void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
onDrawPatch(const SkPoint[12],const SkColor[4],const SkPoint[4],SkBlendMode,const SkPaint &)48     void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
49                      const SkPaint&) override {}
50 
onDrawPaint(const SkPaint &)51     void onDrawPaint(const SkPaint&) override {}
onDrawBehind(const SkPaint &)52     void onDrawBehind(const SkPaint&) override {}
onDrawPoints(PointMode,size_t,const SkPoint[],const SkPaint &)53     void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
onDrawRect(const SkRect &,const SkPaint &)54     void onDrawRect(const SkRect&, const SkPaint&) override {}
onDrawRegion(const SkRegion &,const SkPaint &)55     void onDrawRegion(const SkRegion&, const SkPaint&) override {}
onDrawOval(const SkRect &,const SkPaint &)56     void onDrawOval(const SkRect&, const SkPaint&) override {}
onDrawArc(const SkRect &,SkScalar,SkScalar,bool,const SkPaint &)57     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
onDrawRRect(const SkRRect &,const SkPaint &)58     void onDrawRRect(const SkRRect&, const SkPaint&) override {}
onDrawPath(const SkPath &,const SkPaint &)59     void onDrawPath(const SkPath&, const SkPaint&) override {}
onDrawBitmap(const SkBitmap &,SkScalar,SkScalar,const SkPaint *)60     void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
onDrawBitmapRect(const SkBitmap &,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)61     void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
62                           SrcRectConstraint) override {}
onDrawImage(const SkImage *,SkScalar,SkScalar,const SkPaint *)63     void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
onDrawImageRect(const SkImage *,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)64     void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
65                          SrcRectConstraint) override {}
onDrawImageNine(const SkImage *,const SkIRect &,const SkRect &,const SkPaint *)66     void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
onDrawBitmapNine(const SkBitmap &,const SkIRect &,const SkRect &,const SkPaint *)67     void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
68                           const SkPaint*) override {}
onDrawImageLattice(const SkImage *,const Lattice &,const SkRect &,const SkPaint *)69     void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
70                             const SkPaint*) override {}
onDrawBitmapLattice(const SkBitmap &,const Lattice &,const SkRect &,const SkPaint *)71     void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
72                              const SkPaint*) override {}
onDrawVerticesObject(const SkVertices *,const SkVertices::Bone[],int,SkBlendMode,const SkPaint &)73     void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone[], int, SkBlendMode,
74                               const SkPaint&) override {}
onDrawAtlas(const SkImage *,const SkRSXform[],const SkRect[],const SkColor[],int,SkBlendMode,const SkRect *,const SkPaint *)75     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
76                      int, SkBlendMode, const SkRect*, const SkPaint*) override {}
onDrawShadowRec(const SkPath &,const SkDrawShadowRec &)77     void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
onDrawPicture(const SkPicture *,const SkMatrix *,const SkPaint *)78     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
79 
onDrawEdgeAAQuad(const SkRect &,const SkPoint[4],QuadAAFlags,SkColor,SkBlendMode)80     void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, SkColor,
81                           SkBlendMode) override {}
onDrawEdgeAAImageSet(const ImageSetEntry[],int,const SkPoint[],const SkMatrix[],const SkPaint *,SrcRectConstraint)82     void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
83                               const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
84 
85 private:
86     typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
87 };
88 
89 #endif // SkNoDrawCanvas_DEFINED
90