aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPicturePlayback.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-18 13:56:09 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-18 13:56:09 +0000
commit14bdd527eebb3616227ef37a9ed23bc450a8bb5a (patch)
treebe59196ee13440c314e6fa8b2236acbe7981caa1 /src/core/SkPicturePlayback.cpp
parent92362383a4de7b0d819c88fa8b74242bb2507602 (diff)
Revert of r13836 due to Chromium cc_unittests failures
Diffstat (limited to 'src/core/SkPicturePlayback.cpp')
-rw-r--r--src/core/SkPicturePlayback.cpp76
1 files changed, 15 insertions, 61 deletions
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index fc1d98e093..d61e616c4d 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -69,7 +69,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCop
record.validate(record.writeStream().bytesWritten(), 0);
const SkWriter32& writer = record.writeStream();
- this->init();
+ init();
SkASSERT(!fOpData);
if (writer.bytesWritten() == 0) {
fOpData = SkData::NewEmpty();
@@ -261,7 +261,6 @@ void SkPicturePlayback::init() {
fFactoryPlayback = NULL;
fBoundingHierarchy = NULL;
fStateTree = NULL;
- fCachedActiveOps = NULL;
}
SkPicturePlayback::~SkPicturePlayback() {
@@ -272,8 +271,6 @@ SkPicturePlayback::~SkPicturePlayback() {
SkSafeUnref(fBoundingHierarchy);
SkSafeUnref(fStateTree);
- SkDELETE(fCachedActiveOps);
-
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->unref();
}
@@ -757,13 +754,8 @@ static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) {
// The activeOps parameter is actually "const SkTDArray<SkPictureStateTree::Draw*>&".
// It represents the operations about to be drawn, as generated by some spatial
// subdivision helper class. It should already be in 'fOffset' sorted order.
-void SkPicturePlayback::preLoadBitmaps(const SkTDArray<void*>* activeOps) {
- if ((NULL != activeOps && 0 == activeOps->count()) || NULL == fBitmapUseOffsets) {
- return;
- }
-
- if (NULL == activeOps) {
- // going to need everything
+void SkPicturePlayback::preLoadBitmaps(const SkTDArray<void*>& activeOps) {
+ if (0 == activeOps.count() || NULL == fBitmapUseOffsets) {
return;
}
@@ -774,10 +766,10 @@ void SkPicturePlayback::preLoadBitmaps(const SkTDArray<void*>* activeOps) {
needToCheck.get()[i] = true;
}
- uint32_t max = ((SkPictureStateTree::Draw*)(*activeOps)[(*activeOps).count()-1])->fOffset;
+ uint32_t max = ((SkPictureStateTree::Draw*)activeOps[activeOps.count()-1])->fOffset;
- for (int i = 0; i < activeOps->count(); ++i) {
- SkPictureStateTree::Draw* draw = (SkPictureStateTree::Draw*) (*activeOps)[i];
+ for (int i = 0; i < activeOps.count(); ++i) {
+ SkPictureStateTree::Draw* draw = (SkPictureStateTree::Draw*) activeOps[i];
for (int j = 0; j < fBitmapUseOffsets->numIDs(); ++j) {
if (!needToCheck.get()[j]) {
@@ -803,41 +795,6 @@ void SkPicturePlayback::preLoadBitmaps(const SkTDArray<void*>* activeOps) {
}
}
-uint32_t SkPicturePlayback::CachedOperationList::offset(int index) const {
- SkASSERT(index < fOps.count());
- return ((SkPictureStateTree::Draw*)fOps[index])->fOffset;
-}
-
-const SkMatrix& SkPicturePlayback::CachedOperationList::matrix(int index) const {
- SkASSERT(index < fOps.count());
- return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix;
-}
-
-const SkPicture::OperationList& SkPicturePlayback::getActiveOps(const SkIRect& query) {
- if (NULL == fStateTree || NULL == fBoundingHierarchy) {
- return SkPicture::OperationList::InvalidList();
- }
-
- if (NULL == fCachedActiveOps) {
- fCachedActiveOps = SkNEW(CachedOperationList);
- }
-
- if (query == fCachedActiveOps->fCacheQueryRect) {
- return *fCachedActiveOps;
- }
-
- fCachedActiveOps->fOps.rewind();
-
- fBoundingHierarchy->search(query, &(fCachedActiveOps->fOps));
-
- SkTQSort<SkPictureStateTree::Draw>(
- reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps.begin()),
- reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps.end()-1));
-
- fCachedActiveOps->fCacheQueryRect = query;
- return *fCachedActiveOps;
-}
-
void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
#ifdef ENABLE_TIME_DRAW
SkAutoTime at("SkPicture::draw", 50);
@@ -858,29 +815,26 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
SkReader32 reader(fOpData->bytes(), fOpData->size());
TextContainer text;
- const SkTDArray<void*>* activeOps = NULL;
+ SkTDArray<void*> activeOps;
if (NULL != fStateTree && NULL != fBoundingHierarchy) {
SkRect clipBounds;
if (canvas.getClipBounds(&clipBounds)) {
SkIRect query;
clipBounds.roundOut(&query);
-
- const SkPicture::OperationList& activeOpsList = this->getActiveOps(query);
- if (activeOpsList.valid()) {
- if (0 == activeOpsList.numOps()) {
- return; // nothing to draw
- }
-
- // Since the opList is valid we know it is our derived class
- activeOps = &((const CachedOperationList&)activeOpsList).fOps;
+ fBoundingHierarchy->search(query, &activeOps);
+ if (activeOps.count() == 0) {
+ return;
}
+ SkTQSort<SkPictureStateTree::Draw>(
+ reinterpret_cast<SkPictureStateTree::Draw**>(activeOps.begin()),
+ reinterpret_cast<SkPictureStateTree::Draw**>(activeOps.end()-1));
}
}
- SkPictureStateTree::Iterator it = (NULL == activeOps) ?
+ SkPictureStateTree::Iterator it = (NULL == fStateTree) ?
SkPictureStateTree::Iterator() :
- fStateTree->getIterator(*activeOps, &canvas);
+ fStateTree->getIterator(activeOps, &canvas);
if (it.isValid()) {
uint32_t skipTo = it.draw();