blob: a172632e84b5a3c00512acee3b82fe0a0eb6450d [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
11#include "SkCanvas.h"
Brian Osman37886ce2018-03-09 13:40:31 -050012#include "SkCanvasVirtualEnforcer.h"
Brian Salomon199fb872017-02-06 09:41:10 -050013#include "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 {}
52 void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
53 void onDrawRect(const SkRect&, const SkPaint&) override {}
54 void onDrawRegion(const SkRegion&, const SkPaint&) override {}
55 void onDrawOval(const SkRect&, const SkPaint&) override {}
56 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
57 void onDrawRRect(const SkRRect&, const SkPaint&) override {}
58 void onDrawPath(const SkPath&, const SkPaint&) override {}
59 void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
60 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
61 SrcRectConstraint) override {}
62 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
63 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
64 SrcRectConstraint) override {}
65 void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
66 void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
67 const SkPaint*) override {}
68 void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
69 const SkPaint*) override {}
70 void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
71 const SkPaint*) override {}
Ruiqi Maoc97a3392018-08-15 10:44:19 -040072 void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone[], int, SkBlendMode,
Ruiqi Maof5101492018-06-29 14:32:21 -040073 const SkPaint&) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050074 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
75 int, SkBlendMode, const SkRect*, const SkPaint*) override {}
Brian Osman3adc1222018-03-08 14:52:20 -050076 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
Brian Osman37886ce2018-03-09 13:40:31 -050077 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050078
Michael Ludwig390f0cc2019-03-19 09:16:38 -040079 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, SkColor,
80 SkBlendMode) override {}
81 void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
82 const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
83
Florin Malitaee424ac2016-12-01 12:47:59 -050084private:
Brian Osman37886ce2018-03-09 13:40:31 -050085 typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
Florin Malitaee424ac2016-12-01 12:47:59 -050086};
87
Florin Malita4b7b6f02016-12-01 15:46:26 -050088#endif // SkNoDrawCanvas_DEFINED