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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 /** | 430 /** |
431 * A test for the SkDecodingImageGenerator::Create | 431 * A test for the SkDecodingImageGenerator::Create |
432 */ | 432 */ |
433 DEF_TEST(ImprovedBitmapFactory, reporter) { | 433 DEF_TEST(ImprovedBitmapFactory, reporter) { |
434 SkString pngFilename = GetResourcePath("randPixels.png"); | 434 SkString pngFilename = GetResourcePath("randPixels.png"); |
435 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c
_str())); | 435 SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c
_str())); |
436 if (sk_exists(pngFilename.c_str())) { | 436 if (sk_exists(pngFilename.c_str())) { |
437 // example of how Android will do this inside their BitmapFactory | 437 // example of how Android will do this inside their BitmapFactory |
438 SkDecodingImageGenerator::Options opts(1, true, kN32_SkColorType); | 438 SkDecodingImageGenerator::Options opts(1, true, kN32_SkColorType); |
439 SkBitmap bm; | 439 SkBitmap bm; |
440 SkImageGenerator* gen = SkDecodingImageGenerator::Create(stream, opts); | 440 SkAutoTDelete<SkImageGenerator> gen(SkDecodingImageGenerator::Create(str
eam.detach(), |
| 441 opt
s)); |
441 REPORTER_ASSERT(reporter, gen->tryGenerateBitmap(&bm)); | 442 REPORTER_ASSERT(reporter, gen->tryGenerateBitmap(&bm)); |
442 } | 443 } |
443 } | 444 } |
444 | 445 |
445 //////////////////////////////////////////////////////////////////////////////// | 446 //////////////////////////////////////////////////////////////////////////////// |
446 | 447 |
447 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) | 448 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) |
448 static inline bool check_rounding(int value, int dividend, int divisor) { | 449 static inline bool check_rounding(int value, int dividend, int divisor) { |
449 // returns true if the value is greater than floor(dividend/divisor) | 450 // returns true if the value is greater than floor(dividend/divisor) |
450 // and less than SkNextPow2(ceil(dividend - divisor)) | 451 // and less than SkNextPow2(ceil(dividend - divisor)) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCou
nt)); | 723 new SingleAllocator((void*)pixels.get(), sizeof(uint16_t) * pixelCou
nt)); |
723 decoder->setAllocator(allocator); | 724 decoder->setAllocator(allocator); |
724 decoder->setSampleSize(2); | 725 decoder->setSampleSize(2); |
725 SkBitmap bitmap; | 726 SkBitmap bitmap; |
726 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, | 727 bool success = decoder->decode(stream, &bitmap, kRGB_565_SkColorType, |
727 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; | 728 SkImageDecoder::kDecodePixels_Mode) != SkImag
eDecoder::kFailure; |
728 REPORTER_ASSERT(r, success); | 729 REPORTER_ASSERT(r, success); |
729 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory | 730 REPORTER_ASSERT(r, !allocator->ready()); // Decoder used correct memory |
730 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); | 731 REPORTER_ASSERT(r, sentinal == pixels[pixelCount]); |
731 } | 732 } |
OLD | NEW |