Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/ImageCacheTest.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 SkFILEStream stream(fullName.c_str()); 271 SkFILEStream stream(fullName.c_str());
272 272
273 if (!stream.isValid()) { 273 if (!stream.isValid()) {
274 SkDebugf("file %s missing from resource directoy %s\n", 274 SkDebugf("file %s missing from resource directoy %s\n",
275 basename.c_str(), resourcePath.c_str()); 275 basename.c_str(), resourcePath.c_str());
276 continue; 276 continue;
277 } 277 }
278 278
279 // This should never fail since we know the images we're decoding. 279 // This should never fail since we know the images we're decoding.
280 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); 280 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream));
281 REPORTER_ASSERT(reporter, NULL != decoder.get()); 281 REPORTER_ASSERT(reporter, decoder.get());
282 if (NULL == decoder.get()) { 282 if (NULL == decoder.get()) {
283 continue; 283 continue;
284 } 284 }
285 285
286 // Test unpremultiplied. We know what color this should result in. 286 // Test unpremultiplied. We know what color this should result in.
287 decoder->setRequireUnpremultipliedColors(true); 287 decoder->setRequireUnpremultipliedColors(true);
288 bool success = decoder->decode(&stream, &bm, kN32_SkColorType, 288 bool success = decoder->decode(&stream, &bm, kN32_SkColorType,
289 SkImageDecoder::kDecodePixels_Mode); 289 SkImageDecoder::kDecodePixels_Mode);
290 REPORTER_ASSERT(reporter, success); 290 REPORTER_ASSERT(reporter, success);
291 if (!success) { 291 if (!success) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 * A test for the SkDecodingImageGenerator::Create and 503 * A test for the SkDecodingImageGenerator::Create and
504 * SkInstallDiscardablePixelRef functions. 504 * SkInstallDiscardablePixelRef functions.
505 */ 505 */
506 DEF_TEST(ImprovedBitmapFactory, reporter) { 506 DEF_TEST(ImprovedBitmapFactory, reporter) {
507 SkString pngFilename = GetResourcePath("randPixels.png"); 507 SkString pngFilename = GetResourcePath("randPixels.png");
508 SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c_ str())); 508 SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c_ str()));
509 if (sk_exists(pngFilename.c_str())) { 509 if (sk_exists(pngFilename.c_str())) {
510 SkBitmap bm; 510 SkBitmap bm;
511 SkAssertResult(bm.setInfo(SkImageInfo::MakeN32Premul(1, 1))); 511 SkAssertResult(bm.setInfo(SkImageInfo::MakeN32Premul(1, 1)));
512 REPORTER_ASSERT(reporter, 512 REPORTER_ASSERT(reporter,
513 NULL != install_pixel_ref(&bm, stream.detach(), 1, true)); 513 install_pixel_ref(&bm, stream.detach(), 1, true));
514 SkAutoLockPixels alp(bm); 514 SkAutoLockPixels alp(bm);
515 REPORTER_ASSERT(reporter, NULL != bm.getPixels()); 515 REPORTER_ASSERT(reporter, bm.getPixels());
516 } 516 }
517 } 517 }
518 518
519 519
520 //////////////////////////////////////////////////////////////////////////////// 520 ////////////////////////////////////////////////////////////////////////////////
521 521
522 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) 522 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
523 static inline bool check_rounding(int value, int dividend, int divisor) { 523 static inline bool check_rounding(int value, int dividend, int divisor) {
524 // returns true if the value is greater than floor(dividend/divisor) 524 // returns true if the value is greater than floor(dividend/divisor)
525 // and less than SkNextPow2(ceil(dividend - divisor)) 525 // and less than SkNextPow2(ceil(dividend - divisor))
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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 }
OLDNEW
« no previous file with comments | « tests/ImageCacheTest.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698