Flutter Engine
The Flutter Engine
Functions
Picture_MakePlaceholder.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Picture_MakePlaceholder, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Picture_MakePlaceholder  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file Picture_MakePlaceholder.cpp.

4 {
5class MyCanvas : public SkCanvas {
6public:
7 MyCanvas(SkCanvas* c) : canvas(c) {}
8 void onDrawPicture(const SkPicture* picture, const SkMatrix* ,
9 const SkPaint* ) override {
10 const SkRect rect = picture->cullRect();
11 SkPaint redPaint;
12 redPaint.setColor(SK_ColorRED);
13 canvas->drawRect(rect, redPaint);
14 }
15 SkCanvas* canvas;
16};
17
18void draw(SkCanvas* canvas) {
19 SkPictureRecorder recorder;
20 SkCanvas* pictureCanvas = recorder.beginRecording({0, 0, 256, 256});
21 sk_sp<SkPicture> placeholder = SkPicture::MakePlaceholder({10, 40, 80, 110});
22 pictureCanvas->drawPicture(placeholder);
24 MyCanvas myCanvas(canvas);
25 myCanvas.drawPicture(picture);
26}
27} // END FIDDLE
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
virtual void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
Definition: SkCanvas.cpp:2762
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
void setColor(SkColor color)
Definition: SkPaint.cpp:119
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
virtual SkRect cullRect() const =0
static sk_sp< SkPicture > MakePlaceholder(SkRect cull)
Definition: SkPicture.cpp:337
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350