| 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" |
| 11 #include "SkPictureRecord.h" | 11 #include "SkPictureRecord.h" |
| 12 #include "SkPictureStateTree.h" | 12 #include "SkPictureStateTree.h" |
| 13 #include "SkReadBuffer.h" | 13 #include "SkReadBuffer.h" |
| 14 #include "SkTypeface.h" | 14 #include "SkTypeface.h" |
| 15 #include "SkTSort.h" | 15 #include "SkTSort.h" |
| 16 #include "SkWriteBuffer.h" | 16 #include "SkWriteBuffer.h" |
| 17 | 17 |
| 18 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
| 19 #include "GrContext.h" | 19 #include "GrContext.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 template <typename T> int SafeCount(const T* obj) { | 22 template <typename T> int SafeCount(const T* obj) { |
| 23 return obj ? obj->count() : 0; | 23 return obj ? obj->count() : 0; |
| 24 } | 24 } |
| 25 | 25 |
| 26 /* Define this to spew out a debug statement whenever we skip the remainder of | |
| 27 a save/restore block because a clip... command returned false (empty). | |
| 28 */ | |
| 29 #define SPEW_CLIP_SKIPPINGx | |
| 30 | |
| 31 SkPictureData::SkPictureData(const SkPictInfo& info) | 26 SkPictureData::SkPictureData(const SkPictInfo& info) |
| 32 : fInfo(info) { | 27 : fInfo(info) { |
| 33 this->init(); | 28 this->init(); |
| 34 } | 29 } |
| 35 | 30 |
| 36 void SkPictureData::initForPlayback() const { | 31 void SkPictureData::initForPlayback() const { |
| 37 // ensure that the paths bounds are pre-computed | 32 // ensure that the paths bounds are pre-computed |
| 38 if (NULL != fPathHeap.get()) { | 33 if (NULL != fPathHeap.get()) { |
| 39 for (int i = 0; i < fPathHeap->count(); i++) { | 34 for (int i = 0; i < fPathHeap->count(); i++) { |
| 40 (*fPathHeap.get())[i].updateBoundsCache(); | 35 (*fPathHeap.get())[i].updateBoundsCache(); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 if (!this->parseBufferTag(buffer, tag, size)) { | 661 if (!this->parseBufferTag(buffer, tag, size)) { |
| 667 return false; // we're invalid | 662 return false; // we're invalid |
| 668 } | 663 } |
| 669 } | 664 } |
| 670 return true; | 665 return true; |
| 671 } | 666 } |
| 672 | 667 |
| 673 /////////////////////////////////////////////////////////////////////////////// | 668 /////////////////////////////////////////////////////////////////////////////// |
| 674 /////////////////////////////////////////////////////////////////////////////// | 669 /////////////////////////////////////////////////////////////////////////////// |
| 675 | 670 |
| 676 #ifdef SPEW_CLIP_SKIPPING | |
| 677 struct SkipClipRec { | |
| 678 int fCount; | |
| 679 size_t fSize; | |
| 680 | |
| 681 SkipClipRec() { | |
| 682 fCount = 0; | |
| 683 fSize = 0; | |
| 684 } | |
| 685 | |
| 686 void recordSkip(size_t bytes) { | |
| 687 fCount += 1; | |
| 688 fSize += bytes; | |
| 689 } | |
| 690 }; | |
| 691 #endif | |
| 692 | |
| 693 uint32_t SkPictureData::OperationList::offset(int index) const { | |
| 694 SkASSERT(index < fOps.count()); | |
| 695 return ((SkPictureStateTree::Draw*)fOps[index])->fOffset; | |
| 696 } | |
| 697 | |
| 698 const SkMatrix& SkPictureData::OperationList::matrix(int index) const { | |
| 699 SkASSERT(index < fOps.count()); | |
| 700 return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix; | |
| 701 } | |
| 702 | |
| 703 const SkPicture::OperationList* SkPictureData::getActiveOps(const SkIRect& query
) const { | 671 const SkPicture::OperationList* SkPictureData::getActiveOps(const SkIRect& query
) const { |
| 704 if (NULL == fStateTree || NULL == fBoundingHierarchy) { | 672 if (NULL == fStateTree || NULL == fBoundingHierarchy) { |
| 705 return NULL; | 673 return NULL; |
| 706 } | 674 } |
| 707 | 675 |
| 708 OperationList* activeOps = SkNEW(OperationList); | 676 SkPicture::OperationList* activeOps = SkNEW(SkPicture::OperationList); |
| 709 | 677 |
| 710 fBoundingHierarchy->search(query, &(activeOps->fOps)); | 678 fBoundingHierarchy->search(query, &(activeOps->fOps)); |
| 711 if (0 != activeOps->fOps.count()) { | 679 if (0 != activeOps->fOps.count()) { |
| 712 SkTQSort<SkPictureStateTree::Draw>( | 680 SkTQSort<SkPictureStateTree::Draw>( |
| 713 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.begin()
), | 681 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.begin()
), |
| 714 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.end()-1
)); | 682 reinterpret_cast<SkPictureStateTree::Draw**>(activeOps->fOps.end()-1
)); |
| 715 } | 683 } |
| 716 | 684 |
| 717 return activeOps; | 685 return activeOps; |
| 718 } | 686 } |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 for (index = 0; index < fPictureCount; index++) | 1235 for (index = 0; index < fPictureCount; index++) |
| 1268 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1236 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
| 1269 "picture%p, ", fPictureRefs[index]); | 1237 "picture%p, ", fPictureRefs[index]); |
| 1270 if (fPictureCount > 0) | 1238 if (fPictureCount > 0) |
| 1271 SkDebugf("%s0};\n", pBuffer); | 1239 SkDebugf("%s0};\n", pBuffer); |
| 1272 | 1240 |
| 1273 const_cast<SkPictureData*>(this)->dumpStream(); | 1241 const_cast<SkPictureData*>(this)->dumpStream(); |
| 1274 } | 1242 } |
| 1275 | 1243 |
| 1276 #endif | 1244 #endif |
| OLD | NEW |