OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); | 89 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); |
90 if (NULL == decoder.get()) { | 90 if (NULL == decoder.get()) { |
91 SkDebugf("couldn't decode %s\n", filename.c_str()); | 91 SkDebugf("couldn't decode %s\n", filename.c_str()); |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 bool success = decoder->decode(&stream, &bm8888, kN32_SkColorType, | 95 bool success = decoder->decode(&stream, &bm8888, kN32_SkColorType, |
96 SkImageDecoder::kDecodePixels_Mode); | 96 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; |
97 if (!success) { | 97 if (!success) { |
98 return; | 98 return; |
99 } | 99 } |
100 | 100 |
101 success = stream.rewind(); | 101 success = stream.rewind(); |
102 REPORTER_ASSERT(reporter, success); | 102 REPORTER_ASSERT(reporter, success); |
103 if (!success) { | 103 if (!success) { |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 decoder->setRequireUnpremultipliedColors(true); | 107 decoder->setRequireUnpremultipliedColors(true); |
108 success = decoder->decode(&stream, &bm8888Unpremul, kN32_SkColorType, | 108 success = decoder->decode(&stream, &bm8888Unpremul, kN32_SkColorType, |
109 SkImageDecoder::kDecodePixels_Mode); | 109 SkImageDecoder::kDecodePixels_Mode) != SkImageDeco
der::kFailure; |
110 if (!success) { | 110 if (!success) { |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 bool dimensionsMatch = bm8888.width() == bm8888Unpremul.width() | 114 bool dimensionsMatch = bm8888.width() == bm8888Unpremul.width() |
115 && bm8888.height() == bm8888Unpremul.height(); | 115 && bm8888.height() == bm8888Unpremul.height(); |
116 REPORTER_ASSERT(reporter, dimensionsMatch); | 116 REPORTER_ASSERT(reporter, dimensionsMatch); |
117 if (!dimensionsMatch) { | 117 if (!dimensionsMatch) { |
118 return; | 118 return; |
119 } | 119 } |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 805 |
806 pixels[pixelCount] = sentinal; // This value should not be changed. | 806 pixels[pixelCount] = sentinal; // This value should not be changed. |
807 | 807 |
808 SkAutoTUnref<SingleAllocator> allocator( | 808 SkAutoTUnref<SingleAllocator> allocator( |
809 SkNEW_ARGS(SingleAllocator, | 809 SkNEW_ARGS(SingleAllocator, |
810 ((void*)pixels.get(), sizeof(uint16_t) * pixelCount))); | 810 ((void*)pixels.get(), sizeof(uint16_t) * pixelCount))); |
811 decoder->setAllocator(allocator); | 811 decoder->setAllocator(allocator); |
812 decoder->setSampleSize(2); | 812 decoder->setSampleSize(2); |
813 SkBitmap bitmap; | 813 SkBitmap bitmap; |
814 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, | 814 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, |
815 SkImageDecoder::kDecodePixels_Mode); | 815 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; |
816 REPORTER_ASSERT(r, success); | 816 REPORTER_ASSERT(r, success); |
817 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory | 817 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory |
818 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); | 818 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); |
819 } | 819 } |
OLD | NEW |