| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include <new> | 7 #include <new> |
| 8 #include "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
| 9 #include "SkDrawPictureCallback.h" | 9 #include "SkDrawPictureCallback.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 SkPictureData::SkPictureData(const SkPictureRecord& record, | 40 SkPictureData::SkPictureData(const SkPictureRecord& record, |
| 41 const SkPictInfo& info, | 41 const SkPictInfo& info, |
| 42 bool deepCopyOps) | 42 bool deepCopyOps) |
| 43 : fInfo(info) { | 43 : fInfo(info) { |
| 44 | 44 |
| 45 this->init(); | 45 this->init(); |
| 46 | 46 |
| 47 fOpData = record.opData(deepCopyOps); | 47 fOpData = record.opData(deepCopyOps); |
| 48 | 48 |
| 49 fBoundingHierarchy = record.fBoundingHierarchy; | |
| 50 fStateTree = record.fStateTree; | |
| 51 | |
| 52 SkSafeRef(fBoundingHierarchy); | |
| 53 SkSafeRef(fStateTree); | |
| 54 fContentInfo.set(record.fContentInfo); | 49 fContentInfo.set(record.fContentInfo); |
| 55 | 50 |
| 56 if (fBoundingHierarchy) { | |
| 57 fBoundingHierarchy->flushDeferredInserts(); | |
| 58 } | |
| 59 | |
| 60 // copy over the refcnt dictionary to our reader | 51 // copy over the refcnt dictionary to our reader |
| 61 record.fFlattenableHeap.setupPlaybacks(); | 52 record.fFlattenableHeap.setupPlaybacks(); |
| 62 | 53 |
| 63 fBitmaps = record.fBitmapHeap->extractBitmaps(); | 54 fBitmaps = record.fBitmapHeap->extractBitmaps(); |
| 64 fPaints = record.fPaints.unflattenToArray(); | 55 fPaints = record.fPaints.unflattenToArray(); |
| 65 | 56 |
| 66 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); | 57 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
| 67 fPathHeap.reset(SkSafeRef(record.pathHeap())); | 58 fPathHeap.reset(SkSafeRef(record.pathHeap())); |
| 68 | 59 |
| 69 this->initForPlayback(); | 60 this->initForPlayback(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 | 82 |
| 92 void SkPictureData::init() { | 83 void SkPictureData::init() { |
| 93 fBitmaps = NULL; | 84 fBitmaps = NULL; |
| 94 fPaints = NULL; | 85 fPaints = NULL; |
| 95 fPictureRefs = NULL; | 86 fPictureRefs = NULL; |
| 96 fPictureCount = 0; | 87 fPictureCount = 0; |
| 97 fTextBlobRefs = NULL; | 88 fTextBlobRefs = NULL; |
| 98 fTextBlobCount = 0; | 89 fTextBlobCount = 0; |
| 99 fOpData = NULL; | 90 fOpData = NULL; |
| 100 fFactoryPlayback = NULL; | 91 fFactoryPlayback = NULL; |
| 101 fBoundingHierarchy = NULL; | |
| 102 fStateTree = NULL; | |
| 103 } | 92 } |
| 104 | 93 |
| 105 SkPictureData::~SkPictureData() { | 94 SkPictureData::~SkPictureData() { |
| 106 SkSafeUnref(fOpData); | 95 SkSafeUnref(fOpData); |
| 107 | 96 |
| 108 SkSafeUnref(fBitmaps); | 97 SkSafeUnref(fBitmaps); |
| 109 SkSafeUnref(fPaints); | 98 SkSafeUnref(fPaints); |
| 110 SkSafeUnref(fBoundingHierarchy); | |
| 111 SkSafeUnref(fStateTree); | |
| 112 | 99 |
| 113 for (int i = 0; i < fPictureCount; i++) { | 100 for (int i = 0; i < fPictureCount; i++) { |
| 114 fPictureRefs[i]->unref(); | 101 fPictureRefs[i]->unref(); |
| 115 } | 102 } |
| 116 SkDELETE_ARRAY(fPictureRefs); | 103 SkDELETE_ARRAY(fPictureRefs); |
| 117 | 104 |
| 118 for (int i = 0; i < fTextBlobCount; i++) { | 105 for (int i = 0; i < fTextBlobCount; i++) { |
| 119 fTextBlobRefs[i]->unref(); | 106 fTextBlobRefs[i]->unref(); |
| 120 } | 107 } |
| 121 SkDELETE_ARRAY(fTextBlobRefs); | 108 SkDELETE_ARRAY(fTextBlobRefs); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (!this->parseBufferTag(buffer, tag, size)) { | 558 if (!this->parseBufferTag(buffer, tag, size)) { |
| 572 return false; // we're invalid | 559 return false; // we're invalid |
| 573 } | 560 } |
| 574 } | 561 } |
| 575 return true; | 562 return true; |
| 576 } | 563 } |
| 577 | 564 |
| 578 /////////////////////////////////////////////////////////////////////////////// | 565 /////////////////////////////////////////////////////////////////////////////// |
| 579 /////////////////////////////////////////////////////////////////////////////// | 566 /////////////////////////////////////////////////////////////////////////////// |
| 580 | 567 |
| 581 const SkPicture::OperationList* SkPictureData::getActiveOps(const SkRect& query)
const { | |
| 582 if (NULL == fStateTree || NULL == fBoundingHierarchy) { | |
| 583 return NULL; | |
| 584 } | |
| 585 | |
| 586 SkPicture::OperationList* activeOps = SkNEW(SkPicture::OperationList); | |
| 587 fBoundingHierarchy->search(query, &(activeOps->fOps)); | |
| 588 return activeOps; | |
| 589 } | |
| 590 | |
| 591 #if SK_SUPPORT_GPU | 568 #if SK_SUPPORT_GPU |
| 592 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, | 569 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, |
| 593 int sampleCount) const { | 570 int sampleCount) const { |
| 594 return fContentInfo.suitableForGpuRasterization(context, reason, sampleCount
); | 571 return fContentInfo.suitableForGpuRasterization(context, reason, sampleCount
); |
| 595 } | 572 } |
| 596 | 573 |
| 597 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, | 574 bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char *
*reason, |
| 598 GrPixelConfig config, SkScalar d
pi) const { | 575 GrPixelConfig config, SkScalar d
pi) const { |
| 599 | 576 |
| 600 if (context != NULL) { | 577 if (context != NULL) { |
| 601 return this->suitableForGpuRasterization(context, reason, | 578 return this->suitableForGpuRasterization(context, reason, |
| 602 context->getRecommendedSampleCo
unt(config, dpi)); | 579 context->getRecommendedSampleCo
unt(config, dpi)); |
| 603 } else { | 580 } else { |
| 604 return this->suitableForGpuRasterization(NULL, reason); | 581 return this->suitableForGpuRasterization(NULL, reason); |
| 605 } | 582 } |
| 606 } | 583 } |
| 607 | 584 |
| 608 bool SkPictureData::suitableForLayerOptimization() const { | 585 bool SkPictureData::suitableForLayerOptimization() const { |
| 609 return fContentInfo.numLayers() > 0; | 586 return fContentInfo.numLayers() > 0; |
| 610 } | 587 } |
| 611 #endif | 588 #endif |
| 612 /////////////////////////////////////////////////////////////////////////////// | 589 /////////////////////////////////////////////////////////////////////////////// |
| 613 | 590 |
| 614 | 591 |
| OLD | NEW |