| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Verify that re-decoding gives the same result. It is interesting to chec
k this after | 123 // Verify that re-decoding gives the same result. It is interesting to chec
k this after |
| 124 // a decode to 565, since choosing to decode to 565 may result in some of th
e decode | 124 // a decode to 565, since choosing to decode to 565 may result in some of th
e decode |
| 125 // options being modified. These options should return to their defaults on
another | 125 // options being modified. These options should return to their defaults on
another |
| 126 // decode to kN32, so the new digest should match the old digest. | 126 // decode to kN32, so the new digest should match the old digest. |
| 127 test_info(r, codec, info, expectedResult, digest); | 127 test_info(r, codec, info, expectedResult, digest); |
| 128 | 128 |
| 129 { | 129 { |
| 130 // Check alpha type conversions | 130 // Check alpha type conversions |
| 131 if (info.alphaType() == kOpaque_SkAlphaType) { | 131 if (info.alphaType() == kOpaque_SkAlphaType) { |
| 132 test_info(r, codec, info.makeAlphaType(kUnpremul_SkAlphaType), | 132 test_info(r, codec, info.makeAlphaType(kUnpremul_SkAlphaType), |
| 133 SkCodec::kInvalidConversion, nullptr); | 133 expectedResult, digest); |
| 134 test_info(r, codec, info.makeAlphaType(kPremul_SkAlphaType), | 134 test_info(r, codec, info.makeAlphaType(kPremul_SkAlphaType), |
| 135 SkCodec::kInvalidConversion, nullptr); | 135 expectedResult, digest); |
| 136 } else { | 136 } else { |
| 137 // Decoding to opaque should fail | 137 // Decoding to opaque should fail |
| 138 test_info(r, codec, info.makeAlphaType(kOpaque_SkAlphaType), | 138 test_info(r, codec, info.makeAlphaType(kOpaque_SkAlphaType), |
| 139 SkCodec::kInvalidConversion, nullptr); | 139 SkCodec::kInvalidConversion, nullptr); |
| 140 SkAlphaType otherAt = info.alphaType(); | 140 SkAlphaType otherAt = info.alphaType(); |
| 141 if (kPremul_SkAlphaType == otherAt) { | 141 if (kPremul_SkAlphaType == otherAt) { |
| 142 otherAt = kUnpremul_SkAlphaType; | 142 otherAt = kUnpremul_SkAlphaType; |
| 143 } else { | 143 } else { |
| 144 otherAt = kPremul_SkAlphaType; | 144 otherAt = kPremul_SkAlphaType; |
| 145 } | 145 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 176 // Verify that re-decoding gives the same result. It is interesting to chec
k this after | 176 // Verify that re-decoding gives the same result. It is interesting to chec
k this after |
| 177 // a decode to 565, since choosing to decode to 565 may result in some of th
e decode | 177 // a decode to 565, since choosing to decode to 565 may result in some of th
e decode |
| 178 // options being modified. These options should return to their defaults on
another | 178 // options being modified. These options should return to their defaults on
another |
| 179 // decode to kN32, so the new digest should match the old digest. | 179 // decode to kN32, so the new digest should match the old digest. |
| 180 test_android_info(r, codec, info, expectedResult, digest); | 180 test_android_info(r, codec, info, expectedResult, digest); |
| 181 | 181 |
| 182 { | 182 { |
| 183 // Check alpha type conversions | 183 // Check alpha type conversions |
| 184 if (info.alphaType() == kOpaque_SkAlphaType) { | 184 if (info.alphaType() == kOpaque_SkAlphaType) { |
| 185 test_android_info(r, codec, info.makeAlphaType(kUnpremul_SkAlphaType
), | 185 test_android_info(r, codec, info.makeAlphaType(kUnpremul_SkAlphaType
), |
| 186 SkCodec::kInvalidConversion, nullptr); | 186 expectedResult, digest); |
| 187 test_android_info(r, codec, info.makeAlphaType(kPremul_SkAlphaType), | 187 test_android_info(r, codec, info.makeAlphaType(kPremul_SkAlphaType), |
| 188 SkCodec::kInvalidConversion, nullptr); | 188 expectedResult, digest); |
| 189 } else { | 189 } else { |
| 190 // Decoding to opaque should fail | 190 // Decoding to opaque should fail |
| 191 test_android_info(r, codec, info.makeAlphaType(kOpaque_SkAlphaType), | 191 test_android_info(r, codec, info.makeAlphaType(kOpaque_SkAlphaType), |
| 192 SkCodec::kInvalidConversion, nullptr); | 192 SkCodec::kInvalidConversion, nullptr); |
| 193 SkAlphaType otherAt = info.alphaType(); | 193 SkAlphaType otherAt = info.alphaType(); |
| 194 if (kPremul_SkAlphaType == otherAt) { | 194 if (kPremul_SkAlphaType == otherAt) { |
| 195 otherAt = kUnpremul_SkAlphaType; | 195 otherAt = kUnpremul_SkAlphaType; |
| 196 } else { | 196 } else { |
| 197 otherAt = kPremul_SkAlphaType; | 197 otherAt = kPremul_SkAlphaType; |
| 198 } | 198 } |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 // Now test an image which is too big. Any image with a larger header (i.e. | 969 // Now test an image which is too big. Any image with a larger header (i.e. |
| 970 // has bigger width/height) is also too big. | 970 // has bigger width/height) is also too big. |
| 971 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 971 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
| 972 0x84, 0x80, 0x00, // W: 65536 | 972 0x84, 0x80, 0x00, // W: 65536 |
| 973 0x84, 0x80, 0x00 }; // H: 65536 | 973 0x84, 0x80, 0x00 }; // H: 65536 |
| 974 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 974 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
| 975 codec.reset(SkCodec::NewFromStream(stream.detach())); | 975 codec.reset(SkCodec::NewFromStream(stream.detach())); |
| 976 | 976 |
| 977 REPORTER_ASSERT(r, !codec); | 977 REPORTER_ASSERT(r, !codec); |
| 978 } | 978 } |
| OLD | NEW |