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

Side by Side Diff: tests/BitmapCopyTest.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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/ARGBImageEncoderTest.cpp ('k') | tests/BitmapHasherTest.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkRect.h" 9 #include "SkRect.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 int subW = 2; 380 int subW = 2;
381 int subH = 2; 381 int subH = 2;
382 382
383 // Create bitmap to act as source for copies and subsets. 383 // Create bitmap to act as source for copies and subsets.
384 SkBitmap src, subset; 384 SkBitmap src, subset;
385 SkColorTable* ct = NULL; 385 SkColorTable* ct = NULL;
386 if (kIndex_8_SkColorType == src.colorType()) { 386 if (kIndex_8_SkColorType == src.colorType()) {
387 ct = init_ctable(kPremul_SkAlphaType); 387 ct = init_ctable(kPremul_SkAlphaType);
388 } 388 }
389 389
390 int localSubW;
390 if (isExtracted[copyCase]) { // A larger image to extract from. 391 if (isExtracted[copyCase]) { // A larger image to extract from.
391 src.allocPixels(SkImageInfo::Make(2 * subW + 1, subH, 392 localSubW = 2 * subW + 1;
392 gPairs[i].fColorType,
393 kPremul_SkAlphaType));
394 } else { // Tests expect a 2x2 bitmap, so make smaller. 393 } else { // Tests expect a 2x2 bitmap, so make smaller.
395 src.allocPixels(SkImageInfo::Make(subW, subH, 394 localSubW = subW;
396 gPairs[i].fColorType, 395 }
397 kPremul_SkAlphaType)); 396 // could fail if we pass kIndex_8 for the colortype
397 if (src.tryAllocPixels(SkImageInfo::Make(localSubW, subH, gPairs[i]. fColorType,
398 kPremul_SkAlphaType))) {
399 // failure is fine, as we will notice later on
398 } 400 }
399 SkSafeUnref(ct); 401 SkSafeUnref(ct);
400 402
401 // Either copy src or extract into 'subset', which is used 403 // Either copy src or extract into 'subset', which is used
402 // for subsequent calls to copyPixelsTo/From. 404 // for subsequent calls to copyPixelsTo/From.
403 bool srcReady = false; 405 bool srcReady = false;
404 // Test relies on older behavior that extractSubset will fail on 406 // Test relies on older behavior that extractSubset will fail on
405 // kUnknown_SkColorType 407 // kUnknown_SkColorType
406 if (kUnknown_SkColorType != src.colorType() && 408 if (kUnknown_SkColorType != src.colorType() &&
407 isExtracted[copyCase]) { 409 isExtracted[copyCase]) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy)) ; 630 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy)) ;
629 } else { 631 } else {
630 REPORTER_ASSERT(reporter, 0 == dstC); 632 REPORTER_ASSERT(reporter, 0 == dstC);
631 } 633 }
632 } 634 }
633 } 635 }
634 } 636 }
635 } 637 }
636 } 638 }
637 639
OLDNEW
« no previous file with comments | « tests/ARGBImageEncoderTest.cpp ('k') | tests/BitmapHasherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698