blob: 7475956704f95e5b9bb4f283840d2a5872ba8917 [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
Adrienne Walker6a280a52017-05-01 13:45:01 -070032 // Optimization to reset state to be the same as after construction.
33 void resetCanvas(int width, int height) {
34 resetForNextPicture(SkIRect::MakeWH(width, height));
35 }
36
Florin Malitaee424ac2016-12-01 12:47:59 -050037protected:
38 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
39
Florin Malitad8c278a2016-12-04 11:44:52 -050040 // No-op overrides for aborting rasterization earlier than SkNullBlitter.
Brian Osman37886ce2018-03-09 13:40:31 -050041 void onDrawAnnotation(const SkRect&, const char[], SkData*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050042 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {}
43 void onDrawDrawable(SkDrawable*, const SkMatrix*) override {}
44 void onDrawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override {}
45 void onDrawPosText(const void*, size_t, const SkPoint[], const SkPaint&) override {}
46 void onDrawPosTextH(const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override {}
47 void onDrawTextOnPath(const void*, size_t, const SkPath&, const SkMatrix*,
48 const SkPaint&) override {}
49 void onDrawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*,
50 const SkPaint&) override {}
51 void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
52 void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
53 const SkPaint&) override {}
54
55 void onDrawPaint(const SkPaint&) override {}
56 void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {}
57 void onDrawRect(const SkRect&, const SkPaint&) override {}
58 void onDrawRegion(const SkRegion&, const SkPaint&) override {}
59 void onDrawOval(const SkRect&, const SkPaint&) override {}
60 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
61 void onDrawRRect(const SkRRect&, const SkPaint&) override {}
62 void onDrawPath(const SkPath&, const SkPaint&) override {}
63 void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {}
64 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
65 SrcRectConstraint) override {}
66 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
67 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
68 SrcRectConstraint) override {}
69 void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {}
70 void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
71 const SkPaint*) override {}
72 void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
73 const SkPaint*) override {}
74 void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
75 const SkPaint*) override {}
Mike Reede88a1cb2017-03-17 09:50:46 -040076 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050077 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
78 int, SkBlendMode, const SkRect*, const SkPaint*) override {}
Brian Osman3adc1222018-03-08 14:52:20 -050079 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
Brian Osman37886ce2018-03-09 13:40:31 -050080 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}
Florin Malitad8c278a2016-12-04 11:44:52 -050081
Florin Malitaee424ac2016-12-01 12:47:59 -050082private:
Brian Osman37886ce2018-03-09 13:40:31 -050083 typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
Florin Malitaee424ac2016-12-01 12:47:59 -050084};
85
Florin Malita4b7b6f02016-12-01 15:46:26 -050086#endif // SkNoDrawCanvas_DEFINED