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

Side by Side Diff: tests/MipMapTest.cpp

Issue 1831983003: SkMipMap::Build supports 1xN and Nx1 inputs, so remove the special case from the test harness. Updat (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update no-longer-correct comment. Created 4 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 | « no previous file | no next file » | 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 #include "SkMipMap.h" 9 #include "SkMipMap.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 static void make_bitmap(SkBitmap* bm, int width, int height) { 13 static void make_bitmap(SkBitmap* bm, int width, int height) {
14 bm->allocN32Pixels(width, height); 14 bm->allocN32Pixels(width, height);
15 bm->eraseColor(SK_ColorWHITE); 15 bm->eraseColor(SK_ColorWHITE);
16 } 16 }
17 17
18 DEF_TEST(MipMap, reporter) { 18 DEF_TEST(MipMap, reporter) {
19 SkBitmap bm; 19 SkBitmap bm;
20 SkRandom rand; 20 SkRandom rand;
21 21
22 for (int i = 0; i < 500; ++i) { 22 for (int i = 0; i < 500; ++i) {
23 // for now, Build needs a min size of 2, otherwise it will return nullpt r. 23 int width = 1 + rand.nextU() % 1000;
24 // should fix that to support 1 X N, where N > 1 to return non-null. 24 int height = 1 + rand.nextU() % 1000;
25 int width = 2 + rand.nextU() % 1000;
26 int height = 2 + rand.nextU() % 1000;
27 make_bitmap(&bm, width, height); 25 make_bitmap(&bm, width, height);
28 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm, nullptr)); 26 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(bm, nullptr));
29 27
30 REPORTER_ASSERT(reporter, mm->countLevels() == SkMipMap::ComputeLevelCou nt(width, height)); 28 REPORTER_ASSERT(reporter, mm->countLevels() == SkMipMap::ComputeLevelCou nt(width, height));
31 REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1, SK_ Scalar1), 29 REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1, SK_ Scalar1),
32 nullptr)); 30 nullptr));
33 REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1 * 2, SK_Scalar1 * 2), 31 REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1 * 2, SK_Scalar1 * 2),
34 nullptr)); 32 nullptr));
35 33
36 SkMipMap::Level prevLevel; 34 SkMipMap::Level prevLevel;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }; 109 };
112 110
113 DEF_TEST(MipMap_ComputeLevelCount, reporter) { 111 DEF_TEST(MipMap_ComputeLevelCount, reporter) {
114 const LevelCountScenario tests[] = { 112 const LevelCountScenario tests[] = {
115 // Test mipmaps with negative sizes 113 // Test mipmaps with negative sizes
116 {-100, 100, 0}, 114 {-100, 100, 0},
117 {100, -100, 0}, 115 {100, -100, 0},
118 {-100, -100, 0}, 116 {-100, -100, 0},
119 117
120 // Test mipmaps with 0, 1, 2 as dimensions 118 // Test mipmaps with 0, 1, 2 as dimensions
121 // (SkMipMap::Build requires a min size of 2) 119 // (SkMipMap::Build requires a min size of 1)
122 // 120 //
123 // 0 121 // 0
124 {0, 100, 0}, 122 {0, 100, 0},
125 {100, 0, 0}, 123 {100, 0, 0},
126 {0, 0, 0}, 124 {0, 0, 0},
127 // 1 125 // 1
128 {1, 100, 6}, 126 {1, 100, 6},
129 {100, 1, 6}, 127 {100, 1, 6},
130 {1, 1, 0}, 128 {1, 1, 0},
131 // 2 129 // 2
(...skipping 13 matching lines...) Expand all
145 {64, 129, 7}, 143 {64, 129, 7},
146 {255, 32, 7}, 144 {255, 32, 7},
147 {500, 1000, 9} 145 {500, 1000, 9}
148 }; 146 };
149 147
150 for (auto& currentTest : tests) { 148 for (auto& currentTest : tests) {
151 int levelCount = SkMipMap::ComputeLevelCount(currentTest.fWidth, current Test.fHeight); 149 int levelCount = SkMipMap::ComputeLevelCount(currentTest.fWidth, current Test.fHeight);
152 REPORTER_ASSERT(reporter, currentTest.fExpectedLevelCount == levelCount) ; 150 REPORTER_ASSERT(reporter, currentTest.fExpectedLevelCount == levelCount) ;
153 } 151 }
154 } 152 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698