Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SkPicturePlayback.h" | 8 #include "SkPicturePlayback.h" |
| 9 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
| 10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 94 |
| 95 // copy over the refcnt dictionary to our reader | 95 // copy over the refcnt dictionary to our reader |
| 96 record.fFlattenableHeap.setupPlaybacks(); | 96 record.fFlattenableHeap.setupPlaybacks(); |
| 97 | 97 |
| 98 fBitmaps = record.fBitmapHeap->extractBitmaps(); | 98 fBitmaps = record.fBitmapHeap->extractBitmaps(); |
| 99 fPaints = record.fPaints.unflattenToArray(); | 99 fPaints = record.fPaints.unflattenToArray(); |
| 100 | 100 |
| 101 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); | 101 fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap)); |
| 102 fPathHeap.reset(SkSafeRef(record.fPathHeap)); | 102 fPathHeap.reset(SkSafeRef(record.fPathHeap)); |
| 103 | 103 |
| 104 fBitmapUseOffsets.reset(SkSafeRef(record.fBitmapUseOffsets)); | |
| 105 | |
| 104 // ensure that the paths bounds are pre-computed | 106 // ensure that the paths bounds are pre-computed |
| 105 if (fPathHeap.get()) { | 107 if (fPathHeap.get()) { |
| 106 for (int i = 0; i < fPathHeap->count(); i++) { | 108 for (int i = 0; i < fPathHeap->count(); i++) { |
| 107 (*fPathHeap)[i].updateBoundsCache(); | 109 (*fPathHeap)[i].updateBoundsCache(); |
| 108 } | 110 } |
| 109 } | 111 } |
| 110 | 112 |
| 111 const SkTDArray<SkPicture* >& pictures = record.getPictureRefs(); | 113 const SkTDArray<SkPicture* >& pictures = record.getPictureRefs(); |
| 112 fPictureCount = pictures.count(); | 114 fPictureCount = pictures.count(); |
| 113 if (fPictureCount > 0) { | 115 if (fPictureCount > 0) { |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 *size = 0; | 681 *size = 0; |
| 680 } else { | 682 } else { |
| 681 UNPACK_8_24(temp, op, *size); | 683 UNPACK_8_24(temp, op, *size); |
| 682 if (MASK_24 == *size) { | 684 if (MASK_24 == *size) { |
| 683 *size = reader->readInt(); | 685 *size = reader->readInt(); |
| 684 } | 686 } |
| 685 } | 687 } |
| 686 return (DrawType) op; | 688 return (DrawType) op; |
| 687 } | 689 } |
| 688 | 690 |
| 691 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?
| |
| 692 if (0 == results.count() || NULL == fBitmapUseOffsets) { | |
| 693 return; | |
| 694 } | |
| 695 | |
| 696 SkTDArray<int> active; | |
| 697 | |
| 698 SkAutoTDeleteArray<bool> needToCheck(new bool[fBitmapUseOffsets->numIDs()]); | |
| 699 for (int i = 0; i < fBitmapUseOffsets->numIDs(); ++i) { | |
| 700 needToCheck.get()[i] = true; | |
| 701 } | |
| 702 | |
| 703 uint32_t max = ((SkPictureStateTree::Draw*)results[results.count()-1])->fOff set; | |
| 704 | |
| 705 for (int i = 0; i < results.count(); ++i) { | |
| 706 SkPictureStateTree::Draw* draw = (SkPictureStateTree::Draw*) results[i]; | |
| 707 | |
| 708 for (int j = 0; j < fBitmapUseOffsets->numIDs(); ++j) { | |
| 709 if (!needToCheck.get()[j]) { | |
| 710 continue; | |
| 711 } | |
| 712 | |
| 713 if (!fBitmapUseOffsets->overlap(j, draw->fOffset, max)) { | |
| 714 needToCheck.get()[j] = false; | |
| 715 continue; | |
| 716 } | |
| 717 | |
| 718 if (!fBitmapUseOffsets->includes(j, draw->fOffset)) { | |
| 719 continue; | |
| 720 } | |
| 721 | |
| 722 *active.append() = j; | |
| 723 needToCheck.get()[j] = false; | |
| 724 } | |
| 725 } | |
| 726 | |
| 727 for (int i = 0; i < active.count(); ++i) { | |
| 728 SkDebugf("preload texture %d\n", active[i]); | |
| 729 } | |
| 730 } | |
| 731 | |
| 689 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { | 732 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { |
| 690 #ifdef ENABLE_TIME_DRAW | 733 #ifdef ENABLE_TIME_DRAW |
| 691 SkAutoTime at("SkPicture::draw", 50); | 734 SkAutoTime at("SkPicture::draw", 50); |
| 692 #endif | 735 #endif |
| 693 | 736 |
| 694 #ifdef SPEW_CLIP_SKIPPING | 737 #ifdef SPEW_CLIP_SKIPPING |
| 695 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; | 738 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; |
| 696 int opCount = 0; | 739 int opCount = 0; |
| 697 #endif | 740 #endif |
| 698 | 741 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 728 fStateTree->getIterator(results, &canvas); | 771 fStateTree->getIterator(results, &canvas); |
| 729 | 772 |
| 730 if (it.isValid()) { | 773 if (it.isValid()) { |
| 731 uint32_t skipTo = it.draw(); | 774 uint32_t skipTo = it.draw(); |
| 732 if (kDrawComplete == skipTo) { | 775 if (kDrawComplete == skipTo) { |
| 733 return; | 776 return; |
| 734 } | 777 } |
| 735 reader.setOffset(skipTo); | 778 reader.setOffset(skipTo); |
| 736 } | 779 } |
| 737 | 780 |
| 781 this->preLoadBitmaps(results); | |
| 782 | |
| 738 // Record this, so we can concat w/ it if we encounter a setMatrix() | 783 // Record this, so we can concat w/ it if we encounter a setMatrix() |
| 739 SkMatrix initialMatrix = canvas.getTotalMatrix(); | 784 SkMatrix initialMatrix = canvas.getTotalMatrix(); |
| 740 int originalSaveCount = canvas.getSaveCount(); | 785 int originalSaveCount = canvas.getSaveCount(); |
| 741 | 786 |
| 742 #ifdef SK_BUILD_FOR_ANDROID | 787 #ifdef SK_BUILD_FOR_ANDROID |
| 743 fAbortCurrentPlayback = false; | 788 fAbortCurrentPlayback = false; |
| 744 #endif | 789 #endif |
| 745 | 790 |
| 746 #ifdef SK_DEVELOPER | 791 #ifdef SK_DEVELOPER |
| 747 int opIndex = -1; | 792 int opIndex = -1; |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 for (index = 0; index < fPictureCount; index++) | 1693 for (index = 0; index < fPictureCount; index++) |
| 1649 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), | 1694 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), |
| 1650 "picture%p, ", fPictureRefs[index]); | 1695 "picture%p, ", fPictureRefs[index]); |
| 1651 if (fPictureCount > 0) | 1696 if (fPictureCount > 0) |
| 1652 SkDebugf("%s0};\n", pBuffer); | 1697 SkDebugf("%s0};\n", pBuffer); |
| 1653 | 1698 |
| 1654 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1699 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
| 1655 } | 1700 } |
| 1656 | 1701 |
| 1657 #endif | 1702 #endif |
| OLD | NEW |