| 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 |
|
| 14 |
struct SkIRect; |
| 15 |
|
| 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 SkCanvasVirtualEnforcer<SkCanvas> { |
| 25 |
public: |
| 26 |
SkNoDrawCanvas(int width, int height); |
| 27 |
explicit SkNoDrawCanvas(const SkIRect&); |
| 28 |
|
| 29 |
// Optimization to reset state to be the same as after construction. |
| 30 |
void resetCanvas(int w, int h) { this->resetForNextPicture(SkIRect::MakeWH(w, h)); } |
| 31 |
void resetCanvas(const SkIRect& rect) { this->resetForNextPicture(rect); } |
| 32 |
|
| 33 |
protected: |
| 34 |
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override; |
| 35 |
bool onDoSaveBehind(const SkRect*) override; |
| 36 |
|
| 37 |
// No-op overrides for aborting rasterization earlier than SkNullBlitter. |
| 38 |
void onDrawAnnotation(const SkRect&, const char[], SkData*) override {} |
| 39 |
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override {} |
| 40 |
void onDrawDrawable(SkDrawable*, const SkMatrix*) override {} |
| 41 |
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {} |
| 42 |
void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode, |
| 43 |
const SkPaint&) override {} |
| 44 |
|
| 45 |
void onDrawPaint(const SkPaint&) override {} |
| 46 |
void onDrawBehind(const SkPaint&) override {} |
| 47 |
void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override {} |
| 48 |
void onDrawRect(const SkRect&, const SkPaint&) override {} |
| 49 |
void onDrawRegion(const SkRegion&, const SkPaint&) override {} |
| 50 |
void onDrawOval(const SkRect&, const SkPaint&) override {} |
| 51 |
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {} |
| 52 |
void onDrawRRect(const SkRRect&, const SkPaint&) override {} |
| 53 |
void onDrawPath(const SkPath&, const SkPaint&) override {} |
| 54 |
|
| 55 |
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&, |
| 56 |
const SkPaint*) override {} |
| 57 |
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&, |
| 58 |
const SkPaint*, SrcRectConstraint) override {} |
| 59 |
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode, |
| 60 |
const SkPaint*) override {} |
| 61 |
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, |
| 62 |
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override {} |
| 63 |
|
| 64 |
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {} |
| 65 |
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {} |
| 66 |
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {} |
| 67 |
|
| 68 |
void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&, |
| 69 |
SkBlendMode) override {} |
| 70 |
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int, const SkPoint[], const SkMatrix[], |
| 71 |
const SkSamplingOptions&, const SkPaint*, |
| 72 |
SrcRectConstraint) override {} |
| 73 |
|
| 74 |
private: |
| 75 |
using INHERITED = SkCanvasVirtualEnforcer<SkCanvas>; |
| 76 |
}; |
| 77 |
|
| 78 |
#endif // SkNoDrawCanvas_DEFINED |