aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureData.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-08-18 08:29:59 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-18 08:29:59 -0700
commit0c263fa9f80b9a20b6f6161a2e9a263c2c586a9b (patch)
tree64e5dea42a1fe90995313c798ad39dea4ded1145 /src/core/SkPictureData.h
parenta83593b88a38765eba5f349d4e12d66b3e626af9 (diff)
Deduplicate typefaces across sub-pictures
Old flow to serialize a picture: 1) serialize picture ops 2) serialize all sub pictures recursively 3) flatten the rest of this picture into a buffer, deduping flattenable factories and typefaces as we go 4) serialize the factories and typefaces 5) serialize the bytes from 3) This allows the data in step 5) to refer to the deduplicated factories and typefaces from step 4). But, each sub picture in step 2) is completely siloed, so they can't dedup with the parent picture or each other. New flow: 1) serialize picture ops 2) flatten the rest of this picture into a buffer, deduping flattenable factories and typefaces as we go 3) dummy-serialize sub pictures into /dev/null, with the effect of adding any new typefaces to our dedup set 4) serialize the factories and typefaces 5) serialize the bytes from 2) 6) serialize all sub pictures recursively, with perfect deduplication because of step 3). Now all typefaces in the top-level picture and all sub pictures recursively should end up deduplicated in the top-level typeface set. Decoding changes are similar: we just thread through the top-level typefaces to the sub pictures. What's convenient / surprising is that this new code correctly reads old pictures if we just have each picture prefer its local typeface set over the top-level one: old pictures always just use their own typefaces, and new pictures always use the top-level ones. BUG=skia:4092 Review URL: https://codereview.chromium.org/1233953004
Diffstat (limited to 'src/core/SkPictureData.h')
-rw-r--r--src/core/SkPictureData.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/SkPictureData.h b/src/core/SkPictureData.h
index 1a490ce6e4..a68a8c8317 100644
--- a/src/core/SkPictureData.h
+++ b/src/core/SkPictureData.h
@@ -62,12 +62,13 @@ public:
// Does not affect ownership of SkStream.
static SkPictureData* CreateFromStream(SkStream*,
const SkPictInfo&,
- SkPicture::InstallPixelRefProc);
+ SkPicture::InstallPixelRefProc,
+ SkTypefacePlayback*);
static SkPictureData* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&);
virtual ~SkPictureData();
- void serialize(SkWStream*, SkPixelSerializer*) const;
+ void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet*) const;
void flatten(SkWriteBuffer&) const;
bool containsBitmaps() const;
@@ -82,7 +83,7 @@ protected:
explicit SkPictureData(const SkPictInfo& info);
// Does not affect ownership of SkStream.
- bool parseStream(SkStream*, SkPicture::InstallPixelRefProc);
+ bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayback*);
bool parseBuffer(SkReadBuffer& buffer);
public:
@@ -95,7 +96,7 @@ public:
const int index = reader->readInt();
return fImageRefs[index];
}
-
+
const SkPath& getPath(SkReader32* reader) const {
int index = reader->readInt() - 1;
return fPaths[index];
@@ -144,7 +145,8 @@ private:
// these help us with reading/writing
// Does not affect ownership of SkStream.
- bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::InstallPixelRefProc);
+ bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size,
+ SkPicture::InstallPixelRefProc, SkTypefacePlayback*);
bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size);
void flattenToBuffer(SkWriteBuffer&) const;