Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPaintFilterCanvas.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 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 SkPaintFilterCanvas_DEFINED
9#define SkPaintFilterCanvas_DEFINED
10
18#include "include/core/SkSize.h"
22
23#include <cstddef>
24
25namespace sktext {
26class GlyphRunList;
27}
28
30class SkData;
31class SkDrawable;
32class SkImage;
33class SkMatrix;
34class SkPaint;
35class SkPath;
36class SkPicture;
37class SkPixmap;
38class SkRRect;
39class SkRegion;
40class SkSurface;
41class SkSurfaceProps;
42class SkTextBlob;
43class SkVertices;
44enum class SkBlendMode;
45struct SkDrawShadowRec;
46struct SkPoint;
47struct SkRSXform;
48struct SkRect;
49
50/** \class SkPaintFilterCanvas
51
52 A utility proxy base class for implementing draw/paint filters.
53*/
55public:
56 /**
57 * The new SkPaintFilterCanvas is configured for forwarding to the
58 * specified canvas. Also copies the target canvas matrix and clip bounds.
59 */
61
62 enum Type {
64 };
65
66 // Forwarded to the wrapped canvas.
67 SkISize getBaseLayerSize() const override { return proxy()->getBaseLayerSize(); }
68 GrRecordingContext* recordingContext() const override { return proxy()->recordingContext(); }
69protected:
70 /**
71 * Called with the paint that will be used to draw the specified type.
72 * The implementation may modify the paint as they wish.
73 *
74 * The result bool is used to determine whether the draw op is to be
75 * executed (true) or skipped (false).
76 *
77 * Note: The base implementation calls onFilter() for top-level/explicit paints only.
78 * To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), clients may need to
79 * override the relevant methods (i.e. drawPicture, drawTextBlob).
80 */
81 virtual bool onFilter(SkPaint& paint) const = 0;
82
83 void onDrawPaint(const SkPaint&) override;
84 void onDrawBehind(const SkPaint&) override;
85 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
86 void onDrawRect(const SkRect&, const SkPaint&) override;
87 void onDrawRRect(const SkRRect&, const SkPaint&) override;
88 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
89 void onDrawRegion(const SkRegion&, const SkPaint&) override;
90 void onDrawOval(const SkRect&, const SkPaint&) override;
91 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
92 void onDrawPath(const SkPath&, const SkPaint&) override;
93
94 void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
95 const SkPaint*) override;
96 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
97 const SkPaint*, SrcRectConstraint) override;
98 void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
99 const SkPaint*) override;
100 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
101 SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
102
103 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
104 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
105 const SkPoint texCoords[4], SkBlendMode,
106 const SkPaint& paint) override;
107 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
108 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
109
110 void onDrawGlyphRunList(const sktext::GlyphRunList&, const SkPaint&) override;
111 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
112 const SkPaint& paint) override;
113 void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override;
114 void onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) override;
115
116 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
117 SkBlendMode) override;
118 void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
119 const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override;
120
121 // Forwarded to the wrapped canvas.
122 sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
123 bool onPeekPixels(SkPixmap* pixmap) override;
124 bool onAccessTopLayerPixels(SkPixmap* pixmap) override;
125 SkImageInfo onImageInfo() const override;
126 bool onGetProps(SkSurfaceProps* props, bool top) const override;
127
128private:
129 class AutoPaintFilter;
130
131 SkCanvas* proxy() const { SkASSERT(fList.size() == 1); return fList[0]; }
132
134 return const_cast<SkPaintFilterCanvas*>(this);
135 }
136
137 friend class SkAndroidFrameworkUtils;
138};
139
140#endif
int count
#define SK_API
Definition SkAPI.h:35
#define SkASSERT(cond)
Definition SkAssert.h:116
SkBlendMode
Definition SkBlendMode.h:38
uint32_t SkColor
Definition SkColor.h:37
SkFilterMode
void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint) override=0
void onDrawRect(const SkRect &rect, const SkPaint &paint) override=0
void onDrawRegion(const SkRegion &region, const SkPaint &paint) override=0
void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &) override=0
void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint) override=0
void onDrawBehind(const SkPaint &) override
void onDrawRRect(const SkRRect &rrect, const SkPaint &paint) override=0
void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override=0
void onDrawAnnotation(const SkRect &rect, const char key[], SkData *value) override=0
void onDrawOval(const SkRect &rect, const SkPaint &paint) override=0
void onDrawDrawable(SkDrawable *drawable, const SkMatrix *matrix) override=0
void onDrawArc(const SkRect &rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint) override=0
void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint) override=0
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint) override=0
void onDrawPath(const SkPath &path, const SkPaint &paint) override=0
void onDrawPaint(const SkPaint &paint) override=0
void onDrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode) override=0
SrcRectConstraint
Definition SkCanvas.h:1541
SkPaintFilterCanvas * internal_private_asPaintFilterCanvas() const override
SkISize getBaseLayerSize() const override
virtual bool onFilter(SkPaint &paint) const =0
GrRecordingContext * recordingContext() const override
const Paint & paint
float SkScalar
Definition extension.cpp:12
double y
double x