Flutter Engine
The Flutter Engine
Functions
SkMultiPictureDocument Namespace Reference

Functions

SK_API sk_sp< SkDocumentMake (SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
 
SK_API int ReadPageCount (SkStreamSeekable *src)
 
SK_API bool Read (SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
 
bool ReadPageSizes (SkStreamSeekable *stream, SkDocumentPage *dstArray, int dstArrayCount)
 

Function Documentation

◆ Make()

sk_sp< SkDocument > SkMultiPictureDocument::Make ( SkWStream dst,
const SkSerialProcs procs = nullptr,
std::function< void(const SkPicture *)>  onEndPage = nullptr 
)

Writes into a file format that is similar to SkPicture::serialize() Accepts a callback for endPage behavior

Definition at line 150 of file SkMultiPictureDocument.cpp.

152 {
153 return sk_make_sp<MultiPictureDocument>(dst, procs, std::move(onEndPage));
154}
dst
Definition: cp.py:12

◆ Read()

bool SkMultiPictureDocument::Read ( SkStreamSeekable src,
SkDocumentPage dstArray,
int  dstArrayCount,
const SkDeserialProcs procs = nullptr 
)

Read the SkMultiPictureDocument into the provided array of pages. dstArrayCount must equal SkMultiPictureDocumentReadPageCount(). Return false on error.

Definition at line 199 of file SkMultiPictureDocument.cpp.

202 {
203 if (!ReadPageSizes(src, dstArray, dstArrayCount)) {
204 return false;
205 }
206 SkSize joined = {0.0f, 0.0f};
207 for (int i = 0; i < dstArrayCount; ++i) {
208 joined = SkSize{std::max(joined.width(), dstArray[i].fSize.width()),
209 std::max(joined.height(), dstArray[i].fSize.height())};
210 }
211
213 if (!picture) {
214 return false;
215 }
216
217 PagerCanvas canvas(joined.toCeil(), dstArray, dstArrayCount);
218 // Must call playback(), not drawPicture() to reach
219 // PagerCanvas::onDrawAnnotation().
220 picture->playback(&canvas);
221 if (canvas.fIndex != dstArrayCount) {
222 SkDEBUGF("Malformed SkMultiPictureDocument: canvas.fIndex=%d dstArrayCount=%d\n",
223 canvas.fIndex, dstArrayCount);
224 }
225 return true;
226}
#define SkDEBUGF(...)
Definition: SkDebug.h:24
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
Definition: SkPicture.cpp:147
static float max(float r, float g, float b)
Definition: hsl.cpp:49
bool ReadPageSizes(SkStreamSeekable *stream, SkDocumentPage *dstArray, int dstArrayCount)
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
Definition: SkSize.h:52
SkISize toCeil() const
Definition: SkSize.h:83
SkScalar width() const
Definition: SkSize.h:76
SkScalar height() const
Definition: SkSize.h:77

◆ ReadPageCount()

int SkMultiPictureDocument::ReadPageCount ( SkStreamSeekable src)

Returns the number of pages in the SkMultiPictureDocument.

Definition at line 156 of file SkMultiPictureDocument.cpp.

156 {
157 if (!src) {
158 return 0;
159 }
160 src->seek(0);
161 const size_t size = sizeof(kMagic) - 1;
162 char buffer[size];
163 if (size != src->read(buffer, size) || 0 != memcmp(kMagic, buffer, size)) {
164 src = nullptr;
165 return 0;
166 }
167 uint32_t versionNumber;
168 if (!src->readU32(&versionNumber) || versionNumber != kVersion) {
169 return 0;
170 }
171 uint32_t pageCount;
172 if (!src->readU32(&pageCount) || pageCount > INT_MAX) {
173 return 0;
174 }
175 // leave stream position right here.
176 return SkTo<int>(pageCount);
177}
static const char kMagic[]
Definition: SkPicture.cpp:58
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ ReadPageSizes()

bool SkMultiPictureDocument::ReadPageSizes ( SkStreamSeekable src,
SkDocumentPage dstArray,
int  dstArrayCount 
)

Additional API allows one to read the array of page-sizes without parsing the entire file. Used by DM.

Definition at line 179 of file SkMultiPictureDocument.cpp.

181 {
182 if (!dstArray || dstArrayCount < 1) {
183 return false;
184 }
185 int pageCount = ReadPageCount(stream);
186 if (pageCount < 1 || pageCount != dstArrayCount) {
187 return false;
188 }
189 for (int i = 0; i < pageCount; ++i) {
190 SkSize& s = dstArray[i].fSize;
191 if (sizeof(s) != stream->read(&s, sizeof(s))) {
192 return false;
193 }
194 }
195 // leave stream position right here.
196 return true;
197}
struct MyStruct s
SK_API int ReadPageCount(SkStreamSeekable *src)