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 "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 if (colors) { | 770 if (colors) { |
771 fWriter.write(colors, count * sizeof(SkColor)); | 771 fWriter.write(colors, count * sizeof(SkColor)); |
772 this->addInt(mode); | 772 this->addInt(mode); |
773 } | 773 } |
774 if (cull) { | 774 if (cull) { |
775 fWriter.write(cull, sizeof(SkRect)); | 775 fWriter.write(cull, sizeof(SkRect)); |
776 } | 776 } |
777 this->validate(initialOffset, size); | 777 this->validate(initialOffset, size); |
778 } | 778 } |
779 | 779 |
780 void SkPictureRecord::onDrawAnnotation(const SkRect& rect, const char key[], SkD
ata* value) { | |
781 size_t keyLen = fWriter.WriteStringSize(key); | |
782 size_t valueLen = fWriter.WriteDataSize(value); | |
783 size_t size = 4 + sizeof(SkRect) + keyLen + valueLen; | |
784 | |
785 size_t initialOffset = this->addDraw(DRAW_ANNOTATION, &size); | |
786 this->addRect(rect); | |
787 fWriter.writeString(key); | |
788 fWriter.writeData(value); | |
789 this->validate(initialOffset, size); | |
790 } | |
791 | |
792 /////////////////////////////////////////////////////////////////////////////// | 780 /////////////////////////////////////////////////////////////////////////////// |
793 | 781 |
794 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac
eProps&) { | 782 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac
eProps&) { |
795 return nullptr; | 783 return nullptr; |
796 } | 784 } |
797 | 785 |
798 // If we already have a stored, can we reuse it instead of also storing b? | 786 // If we already have a stored, can we reuse it instead of also storing b? |
799 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { | 787 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { |
800 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { | 788 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { |
801 // Requiring a.info() == b.info() may be overkill in some cases (alphaty
pe mismatch), | 789 // Requiring a.info() == b.info() may be overkill in some cases (alphaty
pe mismatch), |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 957 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
970 int index = fTextBlobRefs.count(); | 958 int index = fTextBlobRefs.count(); |
971 *fTextBlobRefs.append() = blob; | 959 *fTextBlobRefs.append() = blob; |
972 blob->ref(); | 960 blob->ref(); |
973 // follow the convention of recording a 1-based index | 961 // follow the convention of recording a 1-based index |
974 this->addInt(index + 1); | 962 this->addInt(index + 1); |
975 } | 963 } |
976 | 964 |
977 /////////////////////////////////////////////////////////////////////////////// | 965 /////////////////////////////////////////////////////////////////////////////// |
978 | 966 |
OLD | NEW |