Florin Malita | ee424ac | 2016-12-01 12:47:59 -0500 | [diff] [blame] | 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 "SkCanvas.h" |
Brian Salomon | 199fb87 | 2017-02-06 09:41:10 -0500 | [diff] [blame] | 12 | #include "SkVertices.h" |
Florin Malita | ee424ac | 2016-12-01 12:47:59 -0500 | [diff] [blame] | 13 | |
Florin Malita | 439ace9 | 2016-12-02 12:05:41 -0500 | [diff] [blame] | 14 | struct SkIRect; |
| 15 | |
Florin Malita | ee424ac | 2016-12-01 12:47:59 -0500 | [diff] [blame] | 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 SkCanvas { |
| 25 | public: |
| 26 | SkNoDrawCanvas(int width, int height); |
| 27 | |
Florin Malita | 439ace9 | 2016-12-02 12:05:41 -0500 | [diff] [blame] | 28 | // TODO: investigate the users of this ctor. |
| 29 | SkNoDrawCanvas(const SkIRect&); |
| 30 | |
Adrienne Walker | 6a280a5 | 2017-05-01 13:45:01 -0700 | [diff] [blame] | 31 | // Optimization to reset state to be the same as after construction. |
| 32 | void resetCanvas(int width, int height) { |
| 33 | resetForNextPicture(SkIRect::MakeWH(width, height)); |
| 34 | } |
| 35 | |
Florin Malita | ee424ac | 2016-12-01 12:47:59 -0500 | [diff] [blame] | 36 | protected: |
| 37 | SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override; |
| 38 | |
Florin Malita | d8c278a | 2016-12-04 11:44:52 -0500 | [diff] [blame] | 39 | // No-op overrides for aborting rasterization earlier than SkNullBlitter. |
| 40 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {} |
| 41 | void onDrawDrawable(SkDrawable*, const SkMatrix*) override {} |
| 42 | void onDrawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override {} |
| 43 | void onDrawPosText(const void*, size_t, const SkPoint[], const SkPaint&) override {} |
| 44 | void onDrawPosTextH(const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override {} |
| 45 | void onDrawTextOnPath(const void*, size_t, const SkPath&, const SkMatrix*, |
| 46 | const SkPaint&) override {} |
| 47 | void onDrawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*, |
| 48 | const SkPaint&) override {} |
| 49 | void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {} |
| 50 | void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode, |
| 51 | const SkPaint&) override {} |
| 52 | |
| 53 | void onDrawPaint(const SkPaint&) override {} |
| 54 | void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {} |
| 55 | void onDrawRect(const SkRect&, const SkPaint&) override {} |
| 56 | void onDrawRegion(const SkRegion&, const SkPaint&) override {} |
| 57 | void onDrawOval(const SkRect&, const SkPaint&) override {} |
| 58 | void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {} |
| 59 | void onDrawRRect(const SkRRect&, const SkPaint&) override {} |
| 60 | void onDrawPath(const SkPath&, const SkPaint&) override {} |
| 61 | void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override {} |
| 62 | void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, |
| 63 | SrcRectConstraint) override {} |
| 64 | void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {} |
| 65 | void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, |
| 66 | SrcRectConstraint) override {} |
| 67 | void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override {} |
| 68 | void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, |
| 69 | const SkPaint*) override {} |
| 70 | void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&, |
| 71 | const SkPaint*) override {} |
| 72 | void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&, |
| 73 | const SkPaint*) override {} |
Mike Reed | e88a1cb | 2017-03-17 09:50:46 -0400 | [diff] [blame] | 74 | void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {} |
Florin Malita | d8c278a | 2016-12-04 11:44:52 -0500 | [diff] [blame] | 75 | void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], |
| 76 | int, SkBlendMode, const SkRect*, const SkPaint*) override {} |
| 77 | |
Florin Malita | ee424ac | 2016-12-01 12:47:59 -0500 | [diff] [blame] | 78 | private: |
| 79 | typedef SkCanvas INHERITED; |
| 80 | }; |
| 81 | |
Florin Malita | 4b7b6f0 | 2016-12-01 15:46:26 -0500 | [diff] [blame] | 82 | #endif // SkNoDrawCanvas_DEFINED |