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

Side by Side Diff: tests/MipMapTest.cpp

Issue 2036313002: SkMipMap::ComputeLevelSize to return SkISize (Closed) Base URL: https://skia.googlesource.com/skia.git@pipe-mipmap-levels-to-creation
Patch Set: Created 4 years, 6 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 | « src/core/SkMipMap.cpp ('k') | 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"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 for (auto& currentTest : tests) { 148 for (auto& currentTest : tests) {
149 int levelCount = SkMipMap::ComputeLevelCount(currentTest.fWidth, current Test.fHeight); 149 int levelCount = SkMipMap::ComputeLevelCount(currentTest.fWidth, current Test.fHeight);
150 REPORTER_ASSERT(reporter, currentTest.fExpectedLevelCount == levelCount) ; 150 REPORTER_ASSERT(reporter, currentTest.fExpectedLevelCount == levelCount) ;
151 } 151 }
152 } 152 }
153 153
154 struct LevelSizeScenario { 154 struct LevelSizeScenario {
155 int fBaseWidth; 155 int fBaseWidth;
156 int fBaseHeight; 156 int fBaseHeight;
157 int fLevel; 157 int fLevel;
158 SkSize fExpectedMipMapLevelSize; 158 SkISize fExpectedMipMapLevelSize;
159 }; 159 };
160 160
161 DEF_TEST(MipMap_ComputeLevelSize, reporter) { 161 DEF_TEST(MipMap_ComputeLevelSize, reporter) {
162 const LevelSizeScenario tests[] = { 162 const LevelSizeScenario tests[] = {
163 // Test mipmaps with negative sizes 163 // Test mipmaps with negative sizes
164 {-100, 100, 1, SkSize::Make(0, 0)}, 164 {-100, 100, 1, SkISize::Make(0, 0)},
165 {100, -100, 1, SkSize::Make(0, 0)}, 165 {100, -100, 1, SkISize::Make(0, 0)},
166 {-100, -100, 1, SkSize::Make(0, 0)}, 166 {-100, -100, 1, SkISize::Make(0, 0)},
167 167
168 // Test mipmaps with 0, 1, 2 as dimensions 168 // Test mipmaps with 0, 1, 2 as dimensions
169 // (SkMipMap::Build requires a min size of 1) 169 // (SkMipMap::Build requires a min size of 1)
170 // 170 //
171 // 0 171 // 0
172 {0, 100, 1, SkSize::Make(0, 0)}, 172 {0, 100, 1, SkISize::Make(0, 0)},
173 {100, 0, 1, SkSize::Make(0, 0)}, 173 {100, 0, 1, SkISize::Make(0, 0)},
174 {0, 0, 1, SkSize::Make(0, 0)}, 174 {0, 0, 1, SkISize::Make(0, 0)},
175 // 1 175 // 1
176 176
177 {1, 100, 1, SkSize::Make(1, 50)}, 177 {1, 100, 1, SkISize::Make(1, 50)},
178 {100, 1, 1, SkSize::Make(50, 1)}, 178 {100, 1, 1, SkISize::Make(50, 1)},
179 {1, 1, 1, SkSize::Make(0, 0)}, 179 {1, 1, 1, SkISize::Make(0, 0)},
180 // 2 180 // 2
181 {2, 100, 1, SkSize::Make(1, 50)}, 181 {2, 100, 1, SkISize::Make(1, 50)},
182 {100, 2, 2, SkSize::Make(25, 1)}, 182 {100, 2, 2, SkISize::Make(25, 1)},
183 {2, 2, 1, SkSize::Make(1, 1)}, 183 {2, 2, 1, SkISize::Make(1, 1)},
184 184
185 // Test a handful of cases 185 // Test a handful of cases
186 {63, 63, 3, SkSize::Make(7, 7)}, 186 {63, 63, 3, SkISize::Make(7, 7)},
187 {64, 64, 3, SkSize::Make(8, 8)}, 187 {64, 64, 3, SkISize::Make(8, 8)},
188 {127, 127, 3, SkSize::Make(15, 15)}, 188 {127, 127, 3, SkISize::Make(15, 15)},
189 {64, 129, 4, SkSize::Make(4, 8)}, 189 {64, 129, 4, SkISize::Make(4, 8)},
190 {255, 32, 7, SkSize::Make(1, 1)}, 190 {255, 32, 7, SkISize::Make(1, 1)},
191 {500, 1000, 2, SkSize::Make(125, 250)}, 191 {500, 1000, 2, SkISize::Make(125, 250)},
192 }; 192 };
193 193
194 for (auto& currentTest : tests) { 194 for (auto& currentTest : tests) {
195 SkSize levelSize = SkMipMap::ComputeLevelSize(currentTest.fBaseWidth, 195 SkISize levelSize = SkMipMap::ComputeLevelSize(currentTest.fBaseWidth,
196 currentTest.fBaseHeight, c urrentTest.fLevel); 196 currentTest.fBaseHeight,
197 currentTest.fLevel);
197 REPORTER_ASSERT(reporter, currentTest.fExpectedMipMapLevelSize == levelS ize); 198 REPORTER_ASSERT(reporter, currentTest.fExpectedMipMapLevelSize == levelS ize);
198 } 199 }
199 } 200 }
OLDNEW
« no previous file with comments | « src/core/SkMipMap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698