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

Side by Side Diff: bench/GameBench.cpp

Issue 322963002: hide SkBitmap::setConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « bench/DisplacementBench.cpp ('k') | bench/ImageCacheBench.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 SkScalar fSaved[kNumBeforeClear][3]; 241 SkScalar fSaved[kNumBeforeClear][3];
242 242
243 SkBitmap fCheckerboard; 243 SkBitmap fCheckerboard;
244 SkBitmap fAtlas; 244 SkBitmap fAtlas;
245 SkIRect fAtlasRects[kNumAtlasedX][kNumAtlasedY]; 245 SkIRect fAtlasRects[kNumAtlasedX][kNumAtlasedY];
246 246
247 // Note: the resulting checker board has transparency 247 // Note: the resulting checker board has transparency
248 void makeCheckerboard() { 248 void makeCheckerboard() {
249 static int kCheckSize = 16; 249 static int kCheckSize = 16;
250 250
251 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 251 fCheckerboard.allocN32Pixels(kCheckerboardWidth, kCheckerboardHeight);
252 kCheckerboardWidth, kCheckerboardHeight);
253 fCheckerboard.allocPixels();
254 SkAutoLockPixels lock(fCheckerboard); 252 SkAutoLockPixels lock(fCheckerboard);
255 for (int y = 0; y < kCheckerboardHeight; ++y) { 253 for (int y = 0; y < kCheckerboardHeight; ++y) {
256 int even = (y / kCheckSize) % 2; 254 int even = (y / kCheckSize) % 2;
257 255
258 SkPMColor* scanline = fCheckerboard.getAddr32(0, y); 256 SkPMColor* scanline = fCheckerboard.getAddr32(0, y);
259 257
260 for (int x = 0; x < kCheckerboardWidth; ++x) { 258 for (int x = 0; x < kCheckerboardWidth; ++x) {
261 if (even == (x / kCheckSize) % 2) { 259 if (even == (x / kCheckSize) % 2) {
262 *scanline++ = 0xFFFF0000; 260 *scanline++ = 0xFFFF0000;
263 } else { 261 } else {
(...skipping 12 matching lines...) Expand all
276 for (int y = 0; y < kNumAtlasedY; ++y) { 274 for (int y = 0; y < kNumAtlasedY; ++y) {
277 for (int x = 0; x < kNumAtlasedX; ++x) { 275 for (int x = 0; x < kNumAtlasedX; ++x) {
278 colors[x][y] = rand.nextU() | 0xff000000; 276 colors[x][y] = rand.nextU() | 0xff000000;
279 fAtlasRects[x][y] = SkIRect::MakeXYWH(kAtlasSpacer + x * (kAtlas CellWidth + kAtlasSpacer), 277 fAtlasRects[x][y] = SkIRect::MakeXYWH(kAtlasSpacer + x * (kAtlas CellWidth + kAtlasSpacer),
280 kAtlasSpacer + y * (kAtlas CellHeight + kAtlasSpacer), 278 kAtlasSpacer + y * (kAtlas CellHeight + kAtlasSpacer),
281 kAtlasCellWidth, 279 kAtlasCellWidth,
282 kAtlasCellHeight); 280 kAtlasCellHeight);
283 } 281 }
284 } 282 }
285 283
286 fAtlas.setConfig(SkBitmap::kARGB_8888_Config, kTotAtlasWidth, kTotAtlasH eight); 284 fAtlas.allocN32Pixels(kTotAtlasWidth, kTotAtlasHeight);
287 fAtlas.allocPixels();
288 SkAutoLockPixels lock(fAtlas); 285 SkAutoLockPixels lock(fAtlas);
289 286
290 for (int y = 0; y < kTotAtlasHeight; ++y) { 287 for (int y = 0; y < kTotAtlasHeight; ++y) {
291 int colorY = y / (kAtlasCellHeight + kAtlasSpacer); 288 int colorY = y / (kAtlasCellHeight + kAtlasSpacer);
292 bool inColorY = (y % (kAtlasCellHeight + kAtlasSpacer)) >= kAtlasSpa cer; 289 bool inColorY = (y % (kAtlasCellHeight + kAtlasSpacer)) >= kAtlasSpa cer;
293 290
294 SkPMColor* scanline = fAtlas.getAddr32(0, y); 291 SkPMColor* scanline = fAtlas.getAddr32(0, y);
295 292
296 for (int x = 0; x < kTotAtlasWidth; ++x, ++scanline) { 293 for (int x = 0; x < kTotAtlasWidth; ++x, ++scanline) {
297 int colorX = x / (kAtlasCellWidth + kAtlasSpacer); 294 int colorX = x / (kAtlasCellWidth + kAtlasSpacer);
(...skipping 30 matching lines...) Expand all
328 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, 325 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
329 GameBench::kFull_Clear, true)); ) 326 GameBench::kFull_Clear, true)); )
330 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type, 327 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kRotate_Type,
331 GameBench::kFull_Clear)); ) 328 GameBench::kFull_Clear)); )
332 329
333 // Atlased 330 // Atlased
334 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, 331 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
335 GameBench::kFull_Clear, false, true) ); ) 332 GameBench::kFull_Clear, false, true) ); )
336 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type, 333 DEF_BENCH( return SkNEW_ARGS(GameBench, (GameBench::kTranslate_Type,
337 GameBench::kFull_Clear, false, true, true)); ) 334 GameBench::kFull_Clear, false, true, true)); )
OLDNEW
« no previous file with comments | « bench/DisplacementBench.cpp ('k') | bench/ImageCacheBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698