blob: ae3dcabdbe33ef098863ec235affa11c873fad08 [file] [log] [blame]
Florin Malitaee424ac2016-12-01 12:47:59 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkCanvas.h"
12#include "include/core/SkCanvasVirtualEnforcer.h"
13#include "include/core/SkVertices.h"
Florin Malitaee424ac2016-12-01 12:47:59 -050014
Florin Malita439ace92016-12-02 12:05:41 -050015struct SkIRect;
16
Florin Malitaee424ac2016-12-01 12:47:59 -050017// 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//
Brian Osman37886ce2018-03-09 13:40:31 -050025class SK_API SkNoDrawCanvas : public SkCanvasVirtualEnforcer<SkCanvas> {
Florin Malitaee424ac2016-12-01 12:47:59 -050026public:
27 SkNoDrawCanvas(int width, int height);
28
Florin Malita439ace92016-12-02 12:05:41 -050029 // TODO: investigate the users of this ctor.
30 SkNoDrawCanvas(const SkIRect&);
31
Herb Derbyefe39bc2018-05-01 17:06:20 -040032 explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
Herb Derby76d69b42018-03-15 17:34:40 -040033
Adrienne Walker6a280a52017-05-01 13:45:01 -070034 // Optimization to reset state to be the same as after construction.
35 void resetCanvas(int width, int height) {
36 resetForNextPicture(SkIRect::MakeWH(width, height));
37 }
38
Florin Malitaee424ac2016-12-01 12:47:59 -050039protected:
40 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
Mike Reed148b7fd2018-12-18 17:38:18 -050041 bool onDoSaveBehind(const SkRect*) override;
Florin Malitaee424ac2016-12-01 12:47:59 -050042
Florin Malitad8c278a2016-12-04 11:44:52 -050043 // No-op overrides for aborting rasterization earlier than SkNullBlitter.
Brian Osman37886ce2018-03-09 13:40:31 -050044 void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050045 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
46 void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050047 void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
48 void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
49 const SkPaint&) override {}
50
51 void onDrawPaint(const SkPaint&) override {}
Mike Reedd5674082019-04-19 15:00:47 -040052 void onDrawBehind(const SkPaint&) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050053 void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
54 void onDrawRect(const SkRect&, const SkPaint&) override {}
55 void onDrawRegion(const SkRegion&, const SkPaint&) override {}
56 void onDrawOval(const SkRect&, const SkPaint&) override {}
57 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
58 void onDrawRRect(const SkRRect&, const SkPaint&) override {}
59 void onDrawPath(const SkPath&, const SkPaint&) override {}
60 void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
61 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
62 SrcRectConstraint) override {}
63 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
64 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
65 SrcRectConstraint) override {}
66 void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
67 void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
68 const SkPaint*) override {}
69 void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
70 const SkPaint*) override {}
71 void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
72 const SkPaint*) override {}
Ruiqi Maoc97a3392018-08-15 10:44:19 -040073 void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone[], int, SkBlendMode,
Ruiqi Maof5101492018-06-29 14:32:21 -040074 const SkPaint&) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050075 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
76 int, SkBlendMode, const SkRect*, const SkPaint*) override {}
Brian Osman3adc1222018-03-08 14:52:20 -050077 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
Brian Osman37886ce2018-03-09 13:40:31 -050078 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050079
Michael Ludwig390f0cc2019-03-19 09:16:38 -040080 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, SkColor,
81 SkBlendMode) override {}
82 void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
83 const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
84
Florin Malitaee424ac2016-12-01 12:47:59 -050085private:
Brian Osman37886ce2018-03-09 13:40:31 -050086 typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
Florin Malitaee424ac2016-12-01 12:47:59 -050087};
88
Florin Malita4b7b6f02016-12-01 15:46:26 -050089#endif // SkNoDrawCanvas_DEFINED