| 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 "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 if (a.pixelRef() == b.pixelRef()) { | 897 if (a.pixelRef() == b.pixelRef()) { |
| 898 return true; // Same shape and same pixels -> same bitmap. | 898 return true; // Same shape and same pixels -> same bitmap. |
| 899 } | 899 } |
| 900 | 900 |
| 901 // From here down we're going to have to look at the bitmap data, so we requ
ire pixelRefs(). | 901 // From here down we're going to have to look at the bitmap data, so we requ
ire pixelRefs(). |
| 902 if (!a.pixelRef() || !b.pixelRef()) { | 902 if (!a.pixelRef() || !b.pixelRef()) { |
| 903 return false; | 903 return false; |
| 904 } | 904 } |
| 905 | 905 |
| 906 // If the bitmaps have encoded data, check first before locking pixels so th
ey don't decode. | 906 // If the bitmaps have encoded data, check first before locking pixels so th
ey don't decode. |
| 907 SkAutoTUnref<SkData> encA(a.pixelRef()->refEncodedData()), | 907 sk_sp<SkData> encA(a.pixelRef()->refEncodedData()), |
| 908 encB(b.pixelRef()->refEncodedData()); | 908 encB(b.pixelRef()->refEncodedData()); |
| 909 if (encA && encB) { | 909 if (encA && encB) { |
| 910 return encA->equals(encB); | 910 return encA->equals(encB.get()); |
| 911 } else if (encA || encB) { | 911 } else if (encA || encB) { |
| 912 return false; // One has encoded data but the other does not. | 912 return false; // One has encoded data but the other does not. |
| 913 } | 913 } |
| 914 | 914 |
| 915 // As a last resort, we have to look at the pixels. This will read back tex
tures. | 915 // As a last resort, we have to look at the pixels. This will read back tex
tures. |
| 916 SkAutoLockPixels al(a), bl(b); | 916 SkAutoLockPixels al(a), bl(b); |
| 917 const char* ap = (const char*)a.getPixels(); | 917 const char* ap = (const char*)a.getPixels(); |
| 918 const char* bp = (const char*)b.getPixels(); | 918 const char* bp = (const char*)b.getPixels(); |
| 919 if (ap && bp) { | 919 if (ap && bp) { |
| 920 // We check row by row; row bytes might differ. | 920 // We check row by row; row bytes might differ. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 | 1071 |
| 1072 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1072 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
| 1073 int index = fTextBlobRefs.count(); | 1073 int index = fTextBlobRefs.count(); |
| 1074 *fTextBlobRefs.append() = blob; | 1074 *fTextBlobRefs.append() = blob; |
| 1075 blob->ref(); | 1075 blob->ref(); |
| 1076 // follow the convention of recording a 1-based index | 1076 // follow the convention of recording a 1-based index |
| 1077 this->addInt(index + 1); | 1077 this->addInt(index + 1); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 /////////////////////////////////////////////////////////////////////////////// | 1080 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |