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 SkOverdrawCanvas_DEFINED 9 #define SkOverdrawCanvas_DEFINED 10 11 #include "include/core/SkCanvasVirtualEnforcer.h" 12 #include "include/utils/SkNWayCanvas.h" 13 14 /** 15 * Captures all drawing commands. Rather than draw the actual content, this device 16 * increments the alpha channel of each pixel every time it would have been touched 17 * by a draw call. This is useful for detecting overdraw. 18 */ 19 class SK_API SkOverdrawCanvas : public SkCanvasVirtualEnforcer<SkNWayCanvas> { 20 public: 21 /* Does not take ownership of canvas */ 22 SkOverdrawCanvas(SkCanvas*); 23 24 void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override; 25 void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override; 26 void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode, 27 const SkPaint&) override; 28 void onDrawPaint(const SkPaint&) override; 29 void onDrawBehind(const SkPaint& paint) override; 30 void onDrawRect(const SkRect&, const SkPaint&) override; 31 void onDrawRegion(const SkRegion&, const SkPaint&) override; 32 void onDrawOval(const SkRect&, const SkPaint&) override; 33 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override; 34 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; 35 void onDrawRRect(const SkRRect&, const SkPaint&) override; 36 void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override; 37 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override; 38 void onDrawPath(const SkPath&, const SkPaint&) override; 39 40 void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&, 41 const SkPaint*) override; 42 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&, 43 const SkPaint*, SrcRectConstraint) override; 44 void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode, 45 const SkPaint*) override; 46 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, 47 SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override; 48 49 void onDrawDrawable(SkDrawable*, const SkMatrix*) override; 50 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; 51 52 void onDrawAnnotation(const SkRect&, const char key[], SkData* value) override; 53 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override; 54 55 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], SkCanvas::QuadAAFlags, const SkColor4f&, 56 SkBlendMode) override; 57 void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], 58 const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override; 59 60 private: 61 inline SkPaint overdrawPaint(const SkPaint& paint); 62 63 SkPaint fPaint; 64 65 using INHERITED = SkCanvasVirtualEnforcer<SkNWayCanvas>; 66 }; 67 68 #endif 69