Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
skiagm::ImageFilterFastBoundGM Class Reference
Inheritance diagram for skiagm::ImageFilterFastBoundGM:
skiagm::GM

Public Member Functions

 ImageFilterFastBoundGM ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Static Protected Member Functions

static void draw_geom_with_paint (drawMth draw, const SkIPoint &off, SkCanvas *canvas, const SkPaint &p)
 
static void draw_savelayer_with_paint (const SkIPoint &off, SkCanvas *canvas, const SkPaint &p)
 

Static Protected Attributes

static constexpr int kTileWidth = 100
 
static constexpr int kTileHeight = 100
 
static constexpr int kNumVertTiles = 7
 
static constexpr int kNumXtraCols = 2
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 155 of file filterfastbounds.cpp.

Constructor & Destructor Documentation

◆ ImageFilterFastBoundGM()

skiagm::ImageFilterFastBoundGM::ImageFilterFastBoundGM ( )
inline

Definition at line 157 of file filterfastbounds.cpp.

157 {
158 this->setBGColor(0xFFCCCCCC);
159 }
void setBGColor(SkColor)
Definition gm.cpp:159

Member Function Documentation

◆ draw_geom_with_paint()

static void skiagm::ImageFilterFastBoundGM::draw_geom_with_paint ( drawMth  draw,
const SkIPoint off,
SkCanvas canvas,
const SkPaint p 
)
inlinestaticprotected

Definition at line 174 of file filterfastbounds.cpp.

175 {
176 SkPaint redStroked;
177 redStroked.setColor(SK_ColorRED);
179
180 SkPaint blueStroked;
181 blueStroked.setColor(SK_ColorBLUE);
182 blueStroked.setStyle(SkPaint::kStroke_Style);
183
184 const SkRect r = SkRect::MakeLTRB(20, 20, 30, 30);
185 SkRect storage;
186
187 canvas->save();
188 canvas->translate(SkIntToScalar(off.fX), SkIntToScalar(off.fY));
189 canvas->scale(1.5f, 1.5f);
190
191 const SkRect& fastBound = p.computeFastBounds(r, &storage);
192
193 canvas->save();
194 canvas->clipRect(fastBound);
195 (*draw)(canvas, r, p);
196 canvas->restore();
197
198 canvas->drawRect(r, redStroked);
199 canvas->drawRect(fastBound, blueStroked);
200 canvas->restore();
201 }
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
#define SkIntToScalar(x)
Definition SkScalar.h:57
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void scale(SkScalar sx, SkScalar sy)
void setStyle(Style style)
Definition SkPaint.cpp:105
void setColor(SkColor color)
Definition SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
int32_t fX
x-axis value
int32_t fY
y-axis value
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

◆ draw_savelayer_with_paint()

static void skiagm::ImageFilterFastBoundGM::draw_savelayer_with_paint ( const SkIPoint off,
SkCanvas canvas,
const SkPaint p 
)
inlinestaticprotected

Definition at line 203 of file filterfastbounds.cpp.

205 {
206 SkPaint redStroked;
207 redStroked.setColor(SK_ColorRED);
209
210 SkPaint blueStroked;
211 blueStroked.setColor(SK_ColorBLUE);
212 blueStroked.setStyle(SkPaint::kStroke_Style);
213
214 const SkRect bounds = SkRect::MakeWH(10, 10);
215 SkRect storage;
216
217 canvas->save();
218 canvas->translate(30, 30);
219 canvas->translate(SkIntToScalar(off.fX), SkIntToScalar(off.fY));
220 canvas->scale(1.5f, 1.5f);
221
222 const SkRect& fastBound = p.computeFastBounds(bounds, &storage);
223
224 canvas->saveLayer(&fastBound, &p);
225 canvas->restore();
226
227 canvas->drawRect(bounds, redStroked);
228 canvas->drawRect(fastBound, blueStroked);
229 canvas->restore();
230 }
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition SkCanvas.cpp:500
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
Optional< SkRect > bounds
Definition SkRecords.h:189
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ getISize()

SkISize skiagm::ImageFilterFastBoundGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 169 of file filterfastbounds.cpp.

169 {
170 return SkISize::Make((std::size(gDrawMthds) + kNumXtraCols) * kTileWidth,
172 }
constexpr drawMth gDrawMthds[]
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString skiagm::ImageFilterFastBoundGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 167 of file filterfastbounds.cpp.

167{ return SkString("filterfastbounds"); }

◆ onDraw()

void skiagm::ImageFilterFastBoundGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 232 of file filterfastbounds.cpp.

232 {
233
234 SkPaint blackFill;
235
236 //-----------
237 // Normal paints (no source)
238 TArray<SkPaint> paints;
239 create_paints(&paints, nullptr);
240
241 //-----------
242 // Paints with a PictureImageFilter as a source
244
245 {
247
248 SkCanvas* c = rec.beginRecording(10, 10);
249 c->drawRect(SkRect::MakeWH(10, 10), blackFill);
250 pic = rec.finishRecordingAsPicture();
251 }
252
253 TArray<SkPaint> pifPaints;
254 create_paints(&pifPaints, SkImageFilters::Picture(pic));
255
256 //-----------
257 // Paints with a SkImageSource as a source
258
260 {
261 SkPaint p;
262 SkCanvas* temp = surface->getCanvas();
263 temp->clear(SK_ColorYELLOW);
264 p.setColor(SK_ColorBLUE);
265 temp->drawRect(SkRect::MakeLTRB(5, 5, 10, 10), p);
266 p.setColor(SK_ColorGREEN);
267 temp->drawRect(SkRect::MakeLTRB(5, 0, 10, 5), p);
268 }
269
270 sk_sp<SkImage> image(surface->makeImageSnapshot());
271 sk_sp<SkImageFilter> imageSource(SkImageFilters::Image(std::move(image),
273 TArray<SkPaint> bmsPaints;
274 create_paints(&bmsPaints, std::move(imageSource));
275
276 //-----------
277 SkASSERT(paints.size() == kNumVertTiles);
278 SkASSERT(paints.size() == pifPaints.size());
279 SkASSERT(paints.size() == bmsPaints.size());
280
281 // horizontal separators
282 for (int i = 1; i < paints.size(); ++i) {
283 canvas->drawLine(0,
287 blackFill);
288 }
289 // vertical separators
290 for (int i = 0; i < (int)std::size(gDrawMthds) + kNumXtraCols; ++i) {
291 canvas->drawLine(SkIntToScalar(i * kTileWidth),
292 0,
294 SkIntToScalar(paints.size() * kTileWidth),
295 blackFill);
296 }
297
298 // A column of saveLayers with PictureImageFilters
299 for (int i = 0; i < pifPaints.size(); ++i) {
301 canvas, pifPaints[i]);
302 }
303
304 // A column of saveLayers with BitmapSources
305 for (int i = 0; i < pifPaints.size(); ++i) {
307 canvas, bmsPaints[i]);
308 }
309
310 // Multiple columns with different geometry
311 for (int i = 0; i < (int)std::size(gDrawMthds); ++i) {
312 for (int j = 0; j < paints.size(); ++j) {
315 canvas, paints[j]);
316 }
317 }
318
319 }
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr SkColor SK_ColorYELLOW
Definition SkColor.h:139
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
Type::kYUV Type::kRGBA() int(0.7 *637)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void clear(SkColor color)
Definition SkCanvas.h:1199
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic, const SkRect &targetRect)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
int size() const
Definition SkTArray.h:416
static void draw_savelayer_with_paint(const SkIPoint &off, SkCanvas *canvas, const SkPaint &p)
static void draw_geom_with_paint(drawMth draw, const SkIPoint &off, SkCanvas *canvas, const SkPaint &p)
VkSurfaceKHR surface
Definition main.cc:49
sk_sp< SkImage > image
Definition examples.cpp:29
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static void create_paints(TArray< SkPaint > *paints, sk_sp< SkImageFilter > source)
static constexpr SkIPoint Make(int32_t x, int32_t y)
static SkImageInfo MakeN32Premul(int width, int height)

Member Data Documentation

◆ kNumVertTiles

constexpr int skiagm::ImageFilterFastBoundGM::kNumVertTiles = 7
inlinestaticconstexprprotected

Definition at line 164 of file filterfastbounds.cpp.

◆ kNumXtraCols

constexpr int skiagm::ImageFilterFastBoundGM::kNumXtraCols = 2
inlinestaticconstexprprotected

Definition at line 165 of file filterfastbounds.cpp.

◆ kTileHeight

constexpr int skiagm::ImageFilterFastBoundGM::kTileHeight = 100
inlinestaticconstexprprotected

Definition at line 163 of file filterfastbounds.cpp.

◆ kTileWidth

constexpr int skiagm::ImageFilterFastBoundGM::kTileWidth = 100
inlinestaticconstexprprotected

Definition at line 162 of file filterfastbounds.cpp.


The documentation for this class was generated from the following file: