45SkPicture::SkPicture() {
46 static std::atomic<uint32_t> nextID{1};
48 fUniqueID = nextID.fetch_add(+1, std::memory_order_relaxed);
49 }
while (fUniqueID == 0);
53 if (fAddedToCache.load()) {
58static const char kMagic[] = {
's',
'k',
'i',
'a',
'p',
'i',
'c',
't' };
63 static_assert(
sizeof(
kMagic) == 8,
"");
64 static_assert(
sizeof(
kMagic) ==
sizeof(
info.fMagic),
"");
96 if (!
stream->readU32(&version)) {
return false; }
97 info.setVersion(version);
98 if (!
stream->readScalar(&
info.fCullRect.fLeft )) {
return false; }
99 if (!
stream->readScalar(&
info.fCullRect.fTop )) {
return false; }
100 if (!
stream->readScalar(&
info.fCullRect.fRight )) {
return false; }
101 if (!
stream->readScalar(&
info.fCullRect.fBottom)) {
return false; }
106 return IsValidPictInfo(
info);
110 return SkPicture::StreamIsSKP(stream, pInfo);
123 if (IsValidPictInfo(
info)) {
124 if (pInfo) { *pInfo =
info; }
136 if (!
data->opData()) {
170 if (recursionLimit <= 0) {
174 if (!StreamIsSKP(stream, &
info)) {
183 uint8_t trailingStreamByteAfterPictInfo;
184 if (!
stream->readU8(&trailingStreamByteAfterPictInfo)) {
return nullptr; }
185 switch (trailingStreamByteAfterPictInfo) {
187 std::unique_ptr<SkPictureData>
data(
190 return Forwardport(
info,
data.get(),
nullptr);
202 if (
stream->read(
data->writable_data(), size) != size) {
215 if (!SkPicture::BufferIsSKP(&
buffer, &
info)) {
219 int32_t ssize =
buffer.read32();
233 return SkPicture::Forwardport(
info, data.get(), &
buffer);
239 rec.beginRecording();
251 this->
serialize(&stream, procs,
nullptr);
252 return stream.detachAsData();
259 size_t size = data->size();
260 if (!SkTFitsIn<int32_t>(size) || size <= 1) {
270 if (!stream->write(data, size)) {
275 return stream->write(&zero, 4 - (size & 3));
284 SkRefCntSet* typefaceSet,
bool textBlobsOnly)
const {
305 std::unique_ptr<SkPictureData>
data(this->backport());
308 data->serialize(stream, procs, typefaceSet, textBlobsOnly);
316 std::unique_ptr<SkPictureData> data(picture->backport());
323 int32_t size =
SkToS32(custom->size());
325 buffer.writePad32(custom->data(), size);
339 explicit Placeholder(
SkRect cull) : fCull(cull) {}
345 int approximateOpCount(
bool)
const override {
348 size_t approximateBytesUsed()
const override {
return sizeof(*this); }
349 SkRect cullRect()
const override {
return fCull; }
353 return sk_make_sp<Placeholder>(cull);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
constexpr int kMaxPictureOpsToUnrollInsteadOfRef
static size_t sk_negate_to_size_t(int32_t value)
static bool write_pad32(SkWStream *stream, const void *data, size_t size)
@ kCustom_TrailingStreamByteAfterPictInfo
@ kFailure_TrailingStreamByteAfterPictInfo
@ kPictureData_TrailingStreamByteAfterPictInfo
bool SkPicture_StreamIsSKP(SkStream *stream, SkPictInfo *pInfo)
static sk_sp< SkData > custom_serialize(const SkPicture *picture, const SkSerialProcs &procs)
static const int kNestedSKPLimit
static const char kMagic[]
bool StreamRemainingLengthIsBelow(SkStream *stream, size_t len)
constexpr int32_t SkToS32(S x)
static sk_sp< SkData > MakeUninitialized(size_t length)
static sk_sp< SkData > MakeEmpty()
static SkPictureData * CreateFromStream(SkStream *, const SkPictInfo &, const SkDeserialProcs &, SkTypefacePlayback *, int recursionLimit)
static SkPictureData * CreateFromBuffer(SkReadBuffer &, const SkPictInfo &)
static uint64_t MakeSharedID(uint32_t pictureID)
static void Flatten(const sk_sp< const SkPicture >, SkWriteBuffer &buffer)
static sk_sp< SkPicture > MakeFromBuffer(SkReadBuffer &buffer)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
friend class SkPictureData
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
virtual SkRect cullRect() const =0
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
static sk_sp< SkPicture > MakePlaceholder(SkRect cull)
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
static void PostPurgeSharedID(uint64_t sharedID)
static const uint8_t buffer[]
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
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
SkDeserialPictureProc fPictureProc
SkSerialPictureProc fPictureProc