OLD | NEW |
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 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilterImageFilter.h" | 10 #include "SkColorFilterImageFilter.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 return isSmall() ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMAL
L) : | 27 return isSmall() ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_SMAL
L) : |
28 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARG
E); | 28 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_LARG
E); |
29 } | 29 } |
30 | 30 |
31 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = n
ullptr) { | 31 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = n
ullptr) { |
32 SkScalar amount255 = SkScalarMul(amount, SkIntToScalar(255)); | 32 SkScalar amount255 = SkScalarMul(amount, SkIntToScalar(255)); |
33 SkScalar matrix[20] = { 1, 0, 0, 0, amount255, | 33 SkScalar matrix[20] = { 1, 0, 0, 0, amount255, |
34 0, 1, 0, 0, amount255, | 34 0, 1, 0, 0, amount255, |
35 0, 0, 1, 0, amount255, | 35 0, 0, 1, 0, amount255, |
36 0, 0, 0, 1, 0 }; | 36 0, 0, 0, 1, 0 }; |
37 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); | 37 auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix)); |
38 return SkColorFilterImageFilter::Create(filter, input); | 38 return SkColorFilterImageFilter::Create(filter.get(), input); |
39 } | 39 } |
40 | 40 |
41 static SkImageFilter* make_grayscale(SkImageFilter* input = nullptr) { | 41 static SkImageFilter* make_grayscale(SkImageFilter* input = nullptr) { |
42 SkScalar matrix[20]; | 42 SkScalar matrix[20]; |
43 memset(matrix, 0, 20 * sizeof(SkScalar)); | 43 memset(matrix, 0, 20 * sizeof(SkScalar)); |
44 matrix[0] = matrix[5] = matrix[10] = 0.2126f; | 44 matrix[0] = matrix[5] = matrix[10] = 0.2126f; |
45 matrix[1] = matrix[6] = matrix[11] = 0.7152f; | 45 matrix[1] = matrix[6] = matrix[11] = 0.7152f; |
46 matrix[2] = matrix[7] = matrix[12] = 0.0722f; | 46 matrix[2] = matrix[7] = matrix[12] = 0.0722f; |
47 matrix[18] = 1.0f; | 47 matrix[18] = 1.0f; |
48 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); | 48 auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix)); |
49 return SkColorFilterImageFilter::Create(filter, input); | 49 return SkColorFilterImageFilter::Create(filter.get(), input); |
50 } | 50 } |
51 | 51 |
52 static SkImageFilter* make_mode_blue(SkImageFilter* input = nullptr) { | 52 static SkImageFilter* make_mode_blue(SkImageFilter* input = nullptr) { |
53 SkAutoTUnref<SkColorFilter> filter( | 53 auto filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrc
In_Mode)); |
54 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e)); | 54 return SkColorFilterImageFilter::Create(filter.get(), input); |
55 return SkColorFilterImageFilter::Create(filter, input); | |
56 } | 55 } |
57 | 56 |
58 inline bool isSmall() const { return fIsSmall; } | 57 inline bool isSmall() const { return fIsSmall; } |
59 | 58 |
60 private: | 59 private: |
61 bool fIsSmall; | 60 bool fIsSmall; |
62 | 61 |
63 typedef Benchmark INHERITED; | 62 typedef Benchmark INHERITED; |
64 }; | 63 }; |
65 | 64 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 DEF_BENCH( return new ColorFilterGrayBench(true); ) | 289 DEF_BENCH( return new ColorFilterGrayBench(true); ) |
291 | 290 |
292 DEF_BENCH( return new ColorFilterDimBrightBench(false); ) | 291 DEF_BENCH( return new ColorFilterDimBrightBench(false); ) |
293 DEF_BENCH( return new ColorFilterBrightGrayBench(false); ) | 292 DEF_BENCH( return new ColorFilterBrightGrayBench(false); ) |
294 DEF_BENCH( return new ColorFilterGrayBrightBench(false); ) | 293 DEF_BENCH( return new ColorFilterGrayBrightBench(false); ) |
295 DEF_BENCH( return new ColorFilterBlueBrightBench(false); ) | 294 DEF_BENCH( return new ColorFilterBlueBrightBench(false); ) |
296 DEF_BENCH( return new ColorFilterBrightBlueBench(false); ) | 295 DEF_BENCH( return new ColorFilterBrightBlueBench(false); ) |
297 DEF_BENCH( return new ColorFilterBrightBench(false); ) | 296 DEF_BENCH( return new ColorFilterBrightBench(false); ) |
298 DEF_BENCH( return new ColorFilterBlueBench(false); ) | 297 DEF_BENCH( return new ColorFilterBlueBench(false); ) |
299 DEF_BENCH( return new ColorFilterGrayBench(false); ) | 298 DEF_BENCH( return new ColorFilterGrayBench(false); ) |
OLD | NEW |