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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 1424553002: SkRecord refactor: fill bounds array instead of BBH directly (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 | « no previous file | src/core/SkRecordDraw.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecorder.cpp
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index 6397ca00fa4ce31fac6c0b8d76d00fb8a30905ab..62fa0e968fa8c195a1e64bff45a70f09e8e7e503 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -72,11 +72,16 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() {
drawableList ? drawableList->newDrawableSnapshot() : nullptr;
if (fBBH.get()) {
+ SkAutoTMalloc<SkRect> bounds(fRecord->count());
if (saveLayerData) {
- SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), saveLayerData);
+ SkRecordComputeLayers(fCullRect, *fRecord, bounds, pictList, saveLayerData);
} else {
- SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
+ SkRecordFillBounds(fCullRect, *fRecord, bounds);
}
+ fBBH->insert(bounds, fRecord->count());
+
+ // Now that we've calculated content bounds, we can update fCullRect, often trimming it.
+ // TODO: get updated fCullRect from bounds instead of forcing the BBH to return it?
SkRect bbhBound = fBBH->getRootBound();
SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound))
|| (bbhBound.isEmpty() && fCullRect.isEmpty()));
@@ -153,14 +158,12 @@ protected:
}
SkAutoTUnref<SkLayerInfo> saveLayerData;
-
if (fBBH && fDoSaveLayerInfo) {
+ // TODO: can we avoid work by not allocating / filling these bounds?
+ SkAutoTMalloc<SkRect> scratchBounds(fRecord->count());
saveLayerData.reset(new SkLayerInfo);
- SkBBoxHierarchy* bbh = nullptr; // we've already computed fBBH (received in constructor)
- // TODO: update saveLayer info computation to reuse the already computed
- // bounds in 'fBBH'
- SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerData);
+ SkRecordComputeLayers(fBounds, *fRecord, scratchBounds, pictList, saveLayerData);
}
size_t subPictureBytes = 0;
@@ -183,7 +186,9 @@ SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
SkRecordOptimize(fRecord);
if (fBBH.get()) {
- SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
+ SkAutoTMalloc<SkRect> bounds(fRecord->count());
+ SkRecordFillBounds(fCullRect, *fRecord, bounds);
+ fBBH->insert(bounds, fRecord->count());
}
SkDrawable* drawable =
« no previous file with comments | « no previous file | src/core/SkRecordDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698