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

Side by Side Diff: tests/BitmapTest.cpp

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt 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/BitmapCopyTest.cpp ('k') | tests/BlitRowTest.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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 9
10 #include "Test.h" 10 #include "Test.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 REPORTER_ASSERT(reporter, !success); 44 REPORTER_ASSERT(reporter, !success);
45 REPORTER_ASSERT(reporter, bm.isNull()); 45 REPORTER_ASSERT(reporter, bm.isNull());
46 } 46 }
47 47
48 static void test_bigwidth(skiatest::Reporter* reporter) { 48 static void test_bigwidth(skiatest::Reporter* reporter) {
49 SkBitmap bm; 49 SkBitmap bm;
50 int width = 1 << 29; // *4 will be the high-bit of 32bit int 50 int width = 1 << 29; // *4 will be the high-bit of 32bit int
51 51
52 SkImageInfo info = SkImageInfo::MakeA8(width, 1); 52 SkImageInfo info = SkImageInfo::MakeA8(width, 1);
53 REPORTER_ASSERT(reporter, bm.setInfo(info)); 53 REPORTER_ASSERT(reporter, bm.setInfo(info));
54 info.fColorType = kRGB_565_SkColorType; 54 REPORTER_ASSERT(reporter, bm.setInfo(info.makeColorType(kRGB_565_SkColorType )));
55 REPORTER_ASSERT(reporter, bm.setInfo(info));
56 55
57 // for a 4-byte config, this width will compute a rowbytes of 0x80000000, 56 // for a 4-byte config, this width will compute a rowbytes of 0x80000000,
58 // which does not fit in a int32_t. setConfig should detect this, and fail. 57 // which does not fit in a int32_t. setConfig should detect this, and fail.
59 58
60 // TODO: perhaps skia can relax this, and only require that rowBytes fit 59 // TODO: perhaps skia can relax this, and only require that rowBytes fit
61 // in a uint32_t (or larger), but for now this is the constraint. 60 // in a uint32_t (or larger), but for now this is the constraint.
62 61
63 info.fColorType = kN32_SkColorType; 62 REPORTER_ASSERT(reporter, !bm.setInfo(info.makeColorType(kN32_SkColorType))) ;
64 REPORTER_ASSERT(reporter, !bm.setInfo(info));
65 } 63 }
66 64
67 /** 65 /**
68 * This test contains basic sanity checks concerning bitmaps. 66 * This test contains basic sanity checks concerning bitmaps.
69 */ 67 */
70 DEF_TEST(Bitmap, reporter) { 68 DEF_TEST(Bitmap, reporter) {
71 // Zero-sized bitmaps are allowed 69 // Zero-sized bitmaps are allowed
72 for (int width = 0; width < 2; ++width) { 70 for (int width = 0; width < 2; ++width) {
73 for (int height = 0; height < 2; ++height) { 71 for (int height = 0; height < 2; ++height) {
74 SkBitmap bm; 72 SkBitmap bm;
75 bool setConf = bm.setInfo(SkImageInfo::MakeN32Premul(width, height)) ; 73 bool setConf = bm.setInfo(SkImageInfo::MakeN32Premul(width, height)) ;
76 REPORTER_ASSERT(reporter, setConf); 74 REPORTER_ASSERT(reporter, setConf);
77 if (setConf) { 75 if (setConf) {
78 bm.allocPixels(); 76 bm.allocPixels();
79 } 77 }
80 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); 78 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
81 } 79 }
82 } 80 }
83 81
84 test_bigwidth(reporter); 82 test_bigwidth(reporter);
85 test_allocpixels(reporter); 83 test_allocpixels(reporter);
86 } 84 }
OLDNEW
« no previous file with comments | « tests/BitmapCopyTest.cpp ('k') | tests/BlitRowTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698