| 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 | 7 |
| 8 #include "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 this->validate(initialOffset, size); | 840 this->validate(initialOffset, size); |
| 841 } | 841 } |
| 842 | 842 |
| 843 void SkPictureRecord::endCommentGroup() { | 843 void SkPictureRecord::endCommentGroup() { |
| 844 // op/size | 844 // op/size |
| 845 size_t size = 1 * kUInt32Size; | 845 size_t size = 1 * kUInt32Size; |
| 846 size_t initialOffset = this->addDraw(END_COMMENT_GROUP, &size); | 846 size_t initialOffset = this->addDraw(END_COMMENT_GROUP, &size); |
| 847 this->validate(initialOffset, size); | 847 this->validate(initialOffset, size); |
| 848 } | 848 } |
| 849 | 849 |
| 850 // [op/size] [rect] [skip offset] | |
| 851 static const uint32_t kPushCullOpSize = 2 * kUInt32Size + sizeof(SkRect); | |
| 852 void SkPictureRecord::onPushCull(const SkRect& cullRect) { | |
| 853 size_t size = kPushCullOpSize; | |
| 854 size_t initialOffset = this->addDraw(PUSH_CULL, &size); | |
| 855 // PUSH_CULL's size should stay constant (used to rewind). | |
| 856 SkASSERT(size == kPushCullOpSize); | |
| 857 | |
| 858 this->addRect(cullRect); | |
| 859 fCullOffsetStack.push(SkToU32(fWriter.bytesWritten())); | |
| 860 this->addInt(0); | |
| 861 this->validate(initialOffset, size); | |
| 862 } | |
| 863 | |
| 864 void SkPictureRecord::onPopCull() { | |
| 865 SkASSERT(!fCullOffsetStack.isEmpty()); | |
| 866 | |
| 867 uint32_t cullSkipOffset = fCullOffsetStack.top(); | |
| 868 fCullOffsetStack.pop(); | |
| 869 | |
| 870 // op only | |
| 871 size_t size = kUInt32Size; | |
| 872 size_t initialOffset = this->addDraw(POP_CULL, &size); | |
| 873 | |
| 874 // update the cull skip offset to point past this op. | |
| 875 fWriter.overwriteTAt<uint32_t>(cullSkipOffset, SkToU32(fWriter.bytesWritten(
))); | |
| 876 | |
| 877 this->validate(initialOffset, size); | |
| 878 } | |
| 879 | |
| 880 /////////////////////////////////////////////////////////////////////////////// | 850 /////////////////////////////////////////////////////////////////////////////// |
| 881 | 851 |
| 882 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac
eProps&) { | 852 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac
eProps&) { |
| 883 return NULL; | 853 return NULL; |
| 884 } | 854 } |
| 885 | 855 |
| 886 // If we already have a stored, can we reuse it instead of also storing b? | 856 // If we already have a stored, can we reuse it instead of also storing b? |
| 887 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { | 857 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { |
| 888 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { | 858 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { |
| 889 // Requiring a.info() == b.info() may be overkill in some cases (alphaty
pe mismatch), | 859 // Requiring a.info() == b.info() may be overkill in some cases (alphaty
pe mismatch), |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1013 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
| 1044 int index = fTextBlobRefs.count(); | 1014 int index = fTextBlobRefs.count(); |
| 1045 *fTextBlobRefs.append() = blob; | 1015 *fTextBlobRefs.append() = blob; |
| 1046 blob->ref(); | 1016 blob->ref(); |
| 1047 // follow the convention of recording a 1-based index | 1017 // follow the convention of recording a 1-based index |
| 1048 this->addInt(index + 1); | 1018 this->addInt(index + 1); |
| 1049 } | 1019 } |
| 1050 | 1020 |
| 1051 /////////////////////////////////////////////////////////////////////////////// | 1021 /////////////////////////////////////////////////////////////////////////////// |
| 1052 | 1022 |
| OLD | NEW |