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

Side by Side Diff: bench/BitmapRectBench.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/BitmapBench.cpp ('k') | bench/BitmapScaleBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 BitmapRectBench(U8CPU alpha, SkPaint::FilterLevel filterLevel, 52 BitmapRectBench(U8CPU alpha, SkPaint::FilterLevel filterLevel,
53 bool slightMatrix) { 53 bool slightMatrix) {
54 fAlpha = SkToU8(alpha); 54 fAlpha = SkToU8(alpha);
55 fFilterLevel = filterLevel; 55 fFilterLevel = filterLevel;
56 fSlightMatrix = slightMatrix; 56 fSlightMatrix = slightMatrix;
57 57
58 fBitmap.setInfo(SkImageInfo::MakeN32Premul(kWidth, kHeight)); 58 fBitmap.setInfo(SkImageInfo::MakeN32Premul(kWidth, kHeight));
59 } 59 }
60 60
61 protected: 61 protected:
62 virtual const char* onGetName() SK_OVERRIDE { 62 const char* onGetName() SK_OVERRIDE {
63 fName.printf("bitmaprect_%02X_%sfilter_%s", 63 fName.printf("bitmaprect_%02X_%sfilter_%s",
64 fAlpha, 64 fAlpha,
65 SkPaint::kNone_FilterLevel == fFilterLevel ? "no" : "", 65 SkPaint::kNone_FilterLevel == fFilterLevel ? "no" : "",
66 fSlightMatrix ? "trans" : "identity"); 66 fSlightMatrix ? "trans" : "identity");
67 return fName.c_str(); 67 return fName.c_str();
68 } 68 }
69 69
70 virtual void onPreDraw() SK_OVERRIDE { 70 void onPreDraw() SK_OVERRIDE {
71 fBitmap.allocPixels(); 71 fBitmap.allocPixels();
72 fBitmap.setAlphaType(kOpaque_SkAlphaType); 72 fBitmap.setAlphaType(kOpaque_SkAlphaType);
73 fBitmap.eraseColor(SK_ColorBLACK); 73 fBitmap.eraseColor(SK_ColorBLACK);
74 draw_into_bitmap(fBitmap); 74 draw_into_bitmap(fBitmap);
75 75
76 fSrcR.iset(0, 0, kWidth, kHeight); 76 fSrcR.iset(0, 0, kWidth, kHeight);
77 fDstR.iset(0, 0, kWidth, kHeight); 77 fDstR.iset(0, 0, kWidth, kHeight);
78 78
79 if (fSlightMatrix) { 79 if (fSlightMatrix) {
80 // want fractional translate 80 // want fractional translate
81 fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7); 81 fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7);
82 // want enough to create a scale matrix, but not enough to scare 82 // want enough to create a scale matrix, but not enough to scare
83 // off our sniffer which tries to see if the matrix is "effectively" 83 // off our sniffer which tries to see if the matrix is "effectively"
84 // translate-only. 84 // translate-only.
85 fDstR.fRight += SK_Scalar1 / (kWidth * 60); 85 fDstR.fRight += SK_Scalar1 / (kWidth * 60);
86 } 86 }
87 } 87 }
88 88
89 89
90 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 90 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
91 SkRandom rand; 91 SkRandom rand;
92 92
93 SkPaint paint; 93 SkPaint paint;
94 this->setupPaint(&paint); 94 this->setupPaint(&paint);
95 paint.setFilterLevel(fFilterLevel); 95 paint.setFilterLevel(fFilterLevel);
96 paint.setAlpha(fAlpha); 96 paint.setAlpha(fAlpha);
97 97
98 for (int i = 0; i < loops; i++) { 98 for (int i = 0; i < loops; i++) {
99 canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint); 99 canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint);
100 } 100 }
101 } 101 }
102 102
103 private: 103 private:
104 typedef Benchmark INHERITED; 104 typedef Benchmark INHERITED;
105 }; 105 };
106 106
107 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, false)) 107 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, false))
108 DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kNone_FilterLevel, false)) 108 DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kNone_FilterLevel, false))
109 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, false)) 109 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, false))
110 DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kLow_FilterLevel, false)) 110 DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kLow_FilterLevel, false))
111 111
112 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, true)) 112 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, true))
113 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, true)) 113 DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, true))
OLDNEW
« no previous file with comments | « bench/BitmapBench.cpp ('k') | bench/BitmapScaleBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698