Index: src/core/SkPicturePlayback.cpp |
=================================================================== |
--- src/core/SkPicturePlayback.cpp (revision 13658) |
+++ src/core/SkPicturePlayback.cpp (working copy) |
@@ -101,6 +101,8 @@ |
fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
fPathHeap.reset(SkSafeRef(record.fPathHeap)); |
+ fBitmapUseOffsets.reset(SkSafeRef(record.fBitmapUseOffsets)); |
+ |
// ensure that the paths bounds are pre-computed |
if (fPathHeap.get()) { |
for (int i = 0; i < fPathHeap->count(); i++) { |
@@ -686,6 +688,47 @@ |
return (DrawType) op; |
} |
+void SkPicturePlayback::preLoadBitmaps(const SkTDArray<void*> &results) { |
mtklein
2014/03/06 16:20:38
Can you add a note about the true type of the poin
robertphillips
2014/03/06 20:18:26
Done?
|
+ if (0 == results.count() || NULL == fBitmapUseOffsets) { |
+ return; |
+ } |
+ |
+ SkTDArray<int> active; |
+ |
+ SkAutoTDeleteArray<bool> needToCheck(new bool[fBitmapUseOffsets->numIDs()]); |
+ for (int i = 0; i < fBitmapUseOffsets->numIDs(); ++i) { |
+ needToCheck.get()[i] = true; |
+ } |
+ |
+ uint32_t max = ((SkPictureStateTree::Draw*)results[results.count()-1])->fOffset; |
+ |
+ for (int i = 0; i < results.count(); ++i) { |
+ SkPictureStateTree::Draw* draw = (SkPictureStateTree::Draw*) results[i]; |
+ |
+ for (int j = 0; j < fBitmapUseOffsets->numIDs(); ++j) { |
+ if (!needToCheck.get()[j]) { |
+ continue; |
+ } |
+ |
+ if (!fBitmapUseOffsets->overlap(j, draw->fOffset, max)) { |
+ needToCheck.get()[j] = false; |
+ continue; |
+ } |
+ |
+ if (!fBitmapUseOffsets->includes(j, draw->fOffset)) { |
+ continue; |
+ } |
+ |
+ *active.append() = j; |
+ needToCheck.get()[j] = false; |
+ } |
+ } |
+ |
+ for (int i = 0; i < active.count(); ++i) { |
+ SkDebugf("preload texture %d\n", active[i]); |
+ } |
+} |
+ |
void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { |
#ifdef ENABLE_TIME_DRAW |
SkAutoTime at("SkPicture::draw", 50); |
@@ -735,6 +778,8 @@ |
reader.setOffset(skipTo); |
} |
+ this->preLoadBitmaps(results); |
+ |
// Record this, so we can concat w/ it if we encounter a setMatrix() |
SkMatrix initialMatrix = canvas.getTotalMatrix(); |
int originalSaveCount = canvas.getSaveCount(); |