Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: src/core/SkPictureRecord.cpp

Issue 1409373011: Dedup SkPaths by gen-ID when going to .skp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 28561c7e3f484f15447eaea6f7267720e9e9cafa..2b56b74dad844a6daa1ef647b1ece40bdd0f2705 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -587,7 +587,7 @@ void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c
size += sizeof(*src); // + rect
}
size += sizeof(dst); // + rect
-
+
size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size)
== fWriter.bytesWritten());
@@ -603,7 +603,7 @@ void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center,
const SkPaint* paint) {
// id + paint_index + image_index + center + dst
size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect);
-
+
size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size);
SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_NINE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -863,7 +863,7 @@ void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[],
flags |= DRAW_ATLAS_HAS_CULL;
size += sizeof(SkRect);
}
-
+
size_t initialOffset = this->addDraw(DRAW_ATLAS, &size);
SkASSERT(initialOffset+get_paint_offset(DRAW_ATLAS, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -987,8 +987,12 @@ void SkPictureRecord::addPaintPtr(const SkPaint* paint) {
}
int SkPictureRecord::addPathToHeap(const SkPath& path) {
- fPaths.push_back(path);
- return fPaths.count();
+ if (int* n = fPaths.find(path)) {
+ return *n;
+ }
+ int n = fPaths.count() + 1; // 0 is reserved for null / error.
+ fPaths.set(path, n);
+ return n;
}
void SkPictureRecord::addPath(const SkPath& path) {
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698