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

Side by Side Diff: bench/MergeBench.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/MagnifierBench.cpp ('k') | bench/PictureRecordBench.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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 private: 45 private:
46 SkImageFilter* mergeBitmaps() { 46 SkImageFilter* mergeBitmaps() {
47 SkImageFilter* first = SkBitmapSource::Create(fCheckerboard); 47 SkImageFilter* first = SkBitmapSource::Create(fCheckerboard);
48 SkImageFilter* second = SkBitmapSource::Create(fBitmap); 48 SkImageFilter* second = SkBitmapSource::Create(fBitmap);
49 SkAutoUnref aur0(first); 49 SkAutoUnref aur0(first);
50 SkAutoUnref aur1(second); 50 SkAutoUnref aur1(second);
51 return SkMergeImageFilter::Create(first, second); 51 return SkMergeImageFilter::Create(first, second);
52 } 52 }
53 53
54 void make_bitmap() { 54 void make_bitmap() {
55 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); 55 fBitmap.allocN32Pixels(80, 80);
56 fBitmap.allocPixels(); 56 SkCanvas canvas(fBitmap);
57 SkBitmapDevice device(fBitmap);
58 SkCanvas canvas(&device);
59 canvas.clear(0x00000000); 57 canvas.clear(0x00000000);
60 SkPaint paint; 58 SkPaint paint;
61 paint.setAntiAlias(true); 59 paint.setAntiAlias(true);
62 paint.setColor(0xFF884422); 60 paint.setColor(0xFF884422);
63 paint.setTextSize(SkIntToScalar(96)); 61 paint.setTextSize(SkIntToScalar(96));
64 const char* str = "g"; 62 const char* str = "g";
65 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint); 63 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint);
66 } 64 }
67 65
68 void make_checkerboard() { 66 void make_checkerboard() {
69 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); 67 fCheckerboard.allocN32Pixels(80, 80);
70 fCheckerboard.allocPixels(); 68 SkCanvas canvas(fCheckerboard);
71 SkBitmapDevice device(fCheckerboard);
72 SkCanvas canvas(&device);
73 canvas.clear(0x00000000); 69 canvas.clear(0x00000000);
74 SkPaint darkPaint; 70 SkPaint darkPaint;
75 darkPaint.setColor(0xFF804020); 71 darkPaint.setColor(0xFF804020);
76 SkPaint lightPaint; 72 SkPaint lightPaint;
77 lightPaint.setColor(0xFF244484); 73 lightPaint.setColor(0xFF244484);
78 for (int y = 0; y < 80; y += 16) { 74 for (int y = 0; y < 80; y += 16) {
79 for (int x = 0; x < 80; x += 16) { 75 for (int x = 0; x < 80; x += 16) {
80 canvas.save(); 76 canvas.save();
81 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 77 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
82 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 78 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
83 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 79 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
84 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 80 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
85 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 81 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
86 canvas.restore(); 82 canvas.restore();
87 } 83 }
88 } 84 }
89 } 85 }
90 86
91 bool fIsSmall; 87 bool fIsSmall;
92 bool fInitialized; 88 bool fInitialized;
93 SkBitmap fBitmap, fCheckerboard; 89 SkBitmap fBitmap, fCheckerboard;
94 90
95 typedef SkBenchmark INHERITED; 91 typedef SkBenchmark INHERITED;
96 }; 92 };
97 93
98 /////////////////////////////////////////////////////////////////////////////// 94 ///////////////////////////////////////////////////////////////////////////////
99 95
100 DEF_BENCH( return new MergeBench(true); ) 96 DEF_BENCH( return new MergeBench(true); )
101 DEF_BENCH( return new MergeBench(false); ) 97 DEF_BENCH( return new MergeBench(false); )
OLDNEW
« no previous file with comments | « bench/MagnifierBench.cpp ('k') | bench/PictureRecordBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698