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

Side by Side Diff: bench/DisplacementBench.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Moved code around to make code review easier Created 7 years, 4 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 | Annotate | Revision Log
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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkBitmapSource.h" 8 #include "SkBitmapSource.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 17 matching lines...) Expand all
28 make_checkerboard(); 28 make_checkerboard();
29 fInitialized = true; 29 fInitialized = true;
30 } 30 }
31 } 31 }
32 32
33 void make_bitmap() { 33 void make_bitmap() {
34 const int w = isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 34 const int w = isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
35 const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; 35 const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
36 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); 36 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
37 fBitmap.allocPixels(); 37 fBitmap.allocPixels();
38 SkDevice device(fBitmap); 38 SkRasterDevice device(fBitmap);
39 SkCanvas canvas(&device); 39 SkCanvas canvas(&device);
40 canvas.clear(0x00000000); 40 canvas.clear(0x00000000);
41 SkPaint paint; 41 SkPaint paint;
42 paint.setAntiAlias(true); 42 paint.setAntiAlias(true);
43 paint.setColor(0xFF884422); 43 paint.setColor(0xFF884422);
44 paint.setTextSize(SkIntToScalar(96)); 44 paint.setTextSize(SkIntToScalar(96));
45 const char* str = "g"; 45 const char* str = "g";
46 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint); 46 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint);
47 } 47 }
48 48
49 void make_checkerboard() { 49 void make_checkerboard() {
50 const int w = isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 50 const int w = isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
51 const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; 51 const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
52 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); 52 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
53 fCheckerboard.allocPixels(); 53 fCheckerboard.allocPixels();
54 SkDevice device(fCheckerboard); 54 SkRasterDevice device(fCheckerboard);
55 SkCanvas canvas(&device); 55 SkCanvas canvas(&device);
56 canvas.clear(0x00000000); 56 canvas.clear(0x00000000);
57 SkPaint darkPaint; 57 SkPaint darkPaint;
58 darkPaint.setColor(0xFF804020); 58 darkPaint.setColor(0xFF804020);
59 SkPaint lightPaint; 59 SkPaint lightPaint;
60 lightPaint.setColor(0xFF244484); 60 lightPaint.setColor(0xFF244484);
61 for (int y = 0; y < h; y += 16) { 61 for (int y = 0; y < h; y += 16) {
62 for (int x = 0; x < w; x += 16) { 62 for (int x = 0; x < w; x += 16) {
63 canvas.save(); 63 canvas.save();
64 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 64 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 }; 161 };
162 162
163 /////////////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////////////
164 164
165 DEF_BENCH( return new DisplacementZeroBench(p, true); ) 165 DEF_BENCH( return new DisplacementZeroBench(p, true); )
166 DEF_BENCH( return new DisplacementAlphaBench(p, true); ) 166 DEF_BENCH( return new DisplacementAlphaBench(p, true); )
167 DEF_BENCH( return new DisplacementFullBench(p, true); ) 167 DEF_BENCH( return new DisplacementFullBench(p, true); )
168 DEF_BENCH( return new DisplacementZeroBench(p, false); ) 168 DEF_BENCH( return new DisplacementZeroBench(p, false); )
169 DEF_BENCH( return new DisplacementAlphaBench(p, false); ) 169 DEF_BENCH( return new DisplacementAlphaBench(p, false); )
170 DEF_BENCH( return new DisplacementFullBench(p, false); ) 170 DEF_BENCH( return new DisplacementFullBench(p, false); )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698