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

Side by Side Diff: tests/BitmapTest.cpp

Issue 234833003: Revert of Rename kPMColor_SkColorType to kN32_SkColorType. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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/BitmapGetColorTest.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"
11 11
12 static void test_bigwidth(skiatest::Reporter* reporter) { 12 static void test_bigwidth(skiatest::Reporter* reporter) {
13 SkBitmap bm; 13 SkBitmap bm;
14 int width = 1 << 29; // *4 will be the high-bit of 32bit int 14 int width = 1 << 29; // *4 will be the high-bit of 32bit int
15 15
16 SkImageInfo info = SkImageInfo::Make(width, 1, kAlpha_8_SkColorType, 16 SkImageInfo info = SkImageInfo::Make(width, 1, kAlpha_8_SkColorType,
17 kPremul_SkAlphaType); 17 kPremul_SkAlphaType);
18 REPORTER_ASSERT(reporter, bm.setConfig(info)); 18 REPORTER_ASSERT(reporter, bm.setConfig(info));
19 info.fColorType = kRGB_565_SkColorType; 19 info.fColorType = kRGB_565_SkColorType;
20 REPORTER_ASSERT(reporter, bm.setConfig(info)); 20 REPORTER_ASSERT(reporter, bm.setConfig(info));
21 21
22 // for a 4-byte config, this width will compute a rowbytes of 0x80000000, 22 // for a 4-byte config, this width will compute a rowbytes of 0x80000000,
23 // which does not fit in a int32_t. setConfig should detect this, and fail. 23 // which does not fit in a int32_t. setConfig should detect this, and fail.
24 24
25 // TODO: perhaps skia can relax this, and only require that rowBytes fit 25 // TODO: perhaps skia can relax this, and only require that rowBytes fit
26 // in a uint32_t (or larger), but for now this is the constraint. 26 // in a uint32_t (or larger), but for now this is the constraint.
27 27
28 info.fColorType = kN32_SkColorType; 28 info.fColorType = kPMColor_SkColorType;
29 REPORTER_ASSERT(reporter, !bm.setConfig(info)); 29 REPORTER_ASSERT(reporter, !bm.setConfig(info));
30 } 30 }
31 31
32 /** 32 /**
33 * This test contains basic sanity checks concerning bitmaps. 33 * This test contains basic sanity checks concerning bitmaps.
34 */ 34 */
35 DEF_TEST(Bitmap, reporter) { 35 DEF_TEST(Bitmap, reporter) {
36 // Zero-sized bitmaps are allowed 36 // Zero-sized bitmaps are allowed
37 for (int width = 0; width < 2; ++width) { 37 for (int width = 0; width < 2; ++width) {
38 for (int height = 0; height < 2; ++height) { 38 for (int height = 0; height < 2; ++height) {
39 SkBitmap bm; 39 SkBitmap bm;
40 bool setConf = bm.setConfig(SkImageInfo::MakeN32Premul(width, 40 bool setConf = bm.setConfig(SkImageInfo::MakeN32Premul(width,
41 height)); 41 height));
42 REPORTER_ASSERT(reporter, setConf); 42 REPORTER_ASSERT(reporter, setConf);
43 if (setConf) { 43 if (setConf) {
44 REPORTER_ASSERT(reporter, bm.allocPixels(NULL)); 44 REPORTER_ASSERT(reporter, bm.allocPixels(NULL));
45 } 45 }
46 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); 46 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
47 } 47 }
48 } 48 }
49 49
50 test_bigwidth(reporter); 50 test_bigwidth(reporter);
51 } 51 }
OLDNEW
« no previous file with comments | « tests/BitmapGetColorTest.cpp ('k') | tests/BlitRowTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698