Flutter Engine
The Flutter Engine
Picture_MakePlaceholder.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Picture_MakePlaceholder, 256, 256, false, 0) {
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
REG_FIDDLE(Picture_MakePlaceholder, 256, 256, false, 0)
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