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

Side by Side Diff: bench/ColorFilterBench.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years 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
« no previous file with comments | « bench/BlurRectBench.cpp ('k') | bench/MatrixBench.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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorFilterImageFilter.h" 9 #include "SkColorFilterImageFilter.h"
10 #include "SkColorMatrixFilter.h" 10 #include "SkColorMatrixFilter.h"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 ColorFilterBaseBench(bool small) : fIsSmall(small) { } 22 ColorFilterBaseBench(bool small) : fIsSmall(small) { }
23 23
24 protected: 24 protected:
25 SkRect getFilterRect() const { 25 SkRect getFilterRect() const {
26 return isSmall() ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMAL L) : 26 return isSmall() ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMAL L) :
27 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARG E); 27 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARG E);
28 } 28 }
29 29
30 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = N ULL) { 30 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = N ULL) {
31 SkScalar amount255 = SkScalarMul(SkFloatToScalar(amount), SkIntToScalar( 255)); 31 SkScalar amount255 = SkScalarMul(amount, SkIntToScalar(255));
32 SkScalar matrix[20] = { 1, 0, 0, 0, amount255, 32 SkScalar matrix[20] = { 1, 0, 0, 0, amount255,
33 0, 1, 0, 0, amount255, 33 0, 1, 0, 0, amount255,
34 0, 0, 1, 0, amount255, 34 0, 0, 1, 0, amount255,
35 0, 0, 0, 1, 0 }; 35 0, 0, 0, 1, 0 };
36 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); 36 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix));
37 return SkColorFilterImageFilter::Create(filter, input); 37 return SkColorFilterImageFilter::Create(filter, input);
38 } 38 }
39 39
40 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL) { 40 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL) {
41 SkScalar matrix[20]; 41 SkScalar matrix[20];
42 memset(matrix, 0, 20 * sizeof(SkScalar)); 42 memset(matrix, 0, 20 * sizeof(SkScalar));
43 matrix[0] = matrix[5] = matrix[10] = SkFloatToScalar(0.2126f); 43 matrix[0] = matrix[5] = matrix[10] = 0.2126f;
44 matrix[1] = matrix[6] = matrix[11] = SkFloatToScalar(0.7152f); 44 matrix[1] = matrix[6] = matrix[11] = 0.7152f;
45 matrix[2] = matrix[7] = matrix[12] = SkFloatToScalar(0.0722f); 45 matrix[2] = matrix[7] = matrix[12] = 0.0722f;
46 matrix[18] = SkFloatToScalar(1.0f); 46 matrix[18] = 1.0f;
47 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); 47 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix));
48 return SkColorFilterImageFilter::Create(filter, input); 48 return SkColorFilterImageFilter::Create(filter, input);
49 } 49 }
50 50
51 static SkImageFilter* make_mode_blue(SkImageFilter* input = NULL) { 51 static SkImageFilter* make_mode_blue(SkImageFilter* input = NULL) {
52 SkAutoTUnref<SkColorFilter> filter( 52 SkAutoTUnref<SkColorFilter> filter(
53 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e)); 53 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e));
54 return SkColorFilterImageFilter::Create(filter, input); 54 return SkColorFilterImageFilter::Create(filter, input);
55 } 55 }
56 56
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 DEF_BENCH( return new ColorFilterDimBrightBench(false); ) 358 DEF_BENCH( return new ColorFilterDimBrightBench(false); )
359 DEF_BENCH( return new ColorFilterBrightGrayBench(false); ) 359 DEF_BENCH( return new ColorFilterBrightGrayBench(false); )
360 DEF_BENCH( return new ColorFilterGrayBrightBench(false); ) 360 DEF_BENCH( return new ColorFilterGrayBrightBench(false); )
361 DEF_BENCH( return new ColorFilterBlueBrightBench(false); ) 361 DEF_BENCH( return new ColorFilterBlueBrightBench(false); )
362 DEF_BENCH( return new ColorFilterBrightBlueBench(false); ) 362 DEF_BENCH( return new ColorFilterBrightBlueBench(false); )
363 DEF_BENCH( return new ColorFilterBrightBench(false); ) 363 DEF_BENCH( return new ColorFilterBrightBench(false); )
364 DEF_BENCH( return new ColorFilterBlueBench(false); ) 364 DEF_BENCH( return new ColorFilterBlueBench(false); )
365 DEF_BENCH( return new ColorFilterGrayBench(false); ) 365 DEF_BENCH( return new ColorFilterGrayBench(false); )
366 DEF_BENCH( return new TableColorFilterBench(false); ) 366 DEF_BENCH( return new TableColorFilterBench(false); )
367 DEF_BENCH( return new LumaColorFilterBench(false); ) 367 DEF_BENCH( return new LumaColorFilterBench(false); )
OLDNEW
« no previous file with comments | « bench/BlurRectBench.cpp ('k') | bench/MatrixBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698