OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkMatrixConvolutionImageFilter.h" | 10 #include "SkMatrixConvolutionImageFilter.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAl
pha, | 51 SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAl
pha, |
52 const SkImageFilter::CropRect* cropRect = nullptr) { | 52 const SkImageFilter::CropRect* cropRect = nullptr) { |
53 SkScalar kernel[9] = { | 53 SkScalar kernel[9] = { |
54 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 54 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
55 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 55 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
56 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 56 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
57 }; | 57 }; |
58 SkISize kernelSize = SkISize::Make(3, 3); | 58 SkISize kernelSize = SkISize::Make(3, 3); |
59 SkScalar gain = 0.3f, bias = SkIntToScalar(100); | 59 SkScalar gain = 0.3f, bias = SkIntToScalar(100); |
60 SkPaint paint; | 60 SkPaint paint; |
61 SkAutoTUnref<SkImageFilter> filter( | 61 paint.setImageFilter(SkMatrixConvolutionImageFilter::Make(kernelSize, |
62 SkMatrixConvolutionImageFilter::Create(kernelSize, | 62 kernel, |
63 kernel, | 63 gain, |
64 gain, | 64 bias, |
65 bias, | 65 kernelOffset, |
66 kernelOffset, | 66 tileMode, |
67 tileMode, | 67 convolveAlpha, |
68 convolveAlpha, | 68 nullptr, |
69 nullptr, | 69 cropRect)); |
70 cropRect)); | |
71 paint.setImageFilter(filter); | |
72 canvas->save(); | 70 canvas->save(); |
73 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 71 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
74 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), | 72 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), |
75 SkIntToScalar(fBitmap.height()))); | 73 SkIntToScalar(fBitmap.height()))); |
76 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 74 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
77 canvas->restore(); | 75 canvas->restore(); |
78 } | 76 } |
79 | 77 |
80 typedef SkMatrixConvolutionImageFilter MCIF; | 78 typedef SkMatrixConvolutionImageFilter MCIF; |
81 | 79 |
(...skipping 26 matching lines...) Expand all Loading... |
108 SkBitmap fBitmap; | 106 SkBitmap fBitmap; |
109 | 107 |
110 typedef GM INHERITED; | 108 typedef GM INHERITED; |
111 }; | 109 }; |
112 | 110 |
113 ////////////////////////////////////////////////////////////////////////////// | 111 ////////////////////////////////////////////////////////////////////////////// |
114 | 112 |
115 DEF_GM(return new MatrixConvolutionGM;) | 113 DEF_GM(return new MatrixConvolutionGM;) |
116 | 114 |
117 } | 115 } |
OLD | NEW |