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

Go to the source code of this file.

Functions

 REG_FIDDLE (Picture_serialize_2, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Picture_serialize_2  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file Picture_serialize_2.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 SkPictureRecorder recorder;
7 SkCanvas* pictureCanvas = recorder.beginRecording({0, 0, 256, 256});
9 pictureCanvas->drawRect(SkRect::MakeWH(200, 200), paint);
10 paint.setColor(SK_ColorWHITE);
11 pictureCanvas->drawRect(SkRect::MakeLTRB(20, 20, 180, 180), paint);
13 SkDynamicMemoryWStream writableStream;
14 SkSerialProcs sProcs;
15 // One would override serialization behavior for images, typefaces, or even SkPictures
16 // themselves if desired by setting the fields on sProcs.
17 picture->serialize(&writableStream, &sProcs);
18 sk_sp<SkData> readableData = writableStream.detachAsData();
19 sk_sp<SkPicture> copy = SkPicture::MakeFromData(readableData->data(), readableData->size());
20 copy->playback(canvas);
21}
22} // END FIDDLE
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
const void * data() const
Definition: SkData.h:37
size_t size() const
Definition: SkData.h:30
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
Definition: SkPicture.cpp:249
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
Definition: SkPicture.cpp:160
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
Definition: copy.py:1
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646