| 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 | 735 |
| 736 static const uint16_t sentinal = 0xBEEF; | 736 static const uint16_t sentinal = 0xBEEF; |
| 737 static const int pixelCount = 16; | 737 static const int pixelCount = 16; |
| 738 SkAutoTMalloc<uint16_t> pixels(pixelCount + 1); | 738 SkAutoTMalloc<uint16_t> pixels(pixelCount + 1); |
| 739 // pixels.get() should be 4-byte aligned. | 739 // pixels.get() should be 4-byte aligned. |
| 740 // This is necessary to reproduce the bug. | 740 // This is necessary to reproduce the bug. |
| 741 | 741 |
| 742 pixels[pixelCount] = sentinal; // This value should not be changed. | 742 pixels[pixelCount] = sentinal; // This value should not be changed. |
| 743 | 743 |
| 744 SkAutoTUnref<SingleAllocator> allocator( | 744 SkAutoTUnref<SingleAllocator> allocator( |
| 745 SkNEW_ARGS(SingleAllocator, | 745 new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCou
nt)); |
| 746 ((void*)pixels.get(), sizeof(uint16_t) * pixelCount))); | |
| 747 decoder->setAllocator(allocator); | 746 decoder->setAllocator(allocator); |
| 748 decoder->setSampleSize(2); | 747 decoder->setSampleSize(2); |
| 749 SkBitmap bitmap; | 748 SkBitmap bitmap; |
| 750 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, | 749 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, |
| 751 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; | 750 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; |
| 752 REPORTER_ASSERT(r, success); | 751 REPORTER_ASSERT(r, success); |
| 753 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory | 752 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory |
| 754 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); | 753 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); |
| 755 } | 754 } |
| OLD | NEW |