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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const SkImageFilter::CropRect* cropRect = NULL) { | 50 const SkImageFilter::CropRect* cropRect = NULL) { |
51 SkScalar kernel[9] = { | 51 SkScalar kernel[9] = { |
52 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 52 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
53 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 53 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
54 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 54 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
55 }; | 55 }; |
56 SkISize kernelSize = SkISize::Make(3, 3); | 56 SkISize kernelSize = SkISize::Make(3, 3); |
57 SkScalar gain = 0.3f, bias = SkIntToScalar(100); | 57 SkScalar gain = 0.3f, bias = SkIntToScalar(100); |
58 SkPaint paint; | 58 SkPaint paint; |
59 SkAutoTUnref<SkImageFilter> filter( | 59 SkAutoTUnref<SkImageFilter> filter( |
60 SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, | 60 SkMatrixConvolutionImageFilter::Create(kernelSize, |
61 kernel, | 61 kernel, |
62 gain, | 62 gain, |
63 bias, | 63 bias, |
64 target, | 64 target, |
65 tileMode, | 65 tileMode, |
66 convolveAlpha, | 66 convolveAlpha, |
67 NULL, | 67 NULL, |
68 cropRect))); | 68 cropRect)); |
69 paint.setImageFilter(filter); | 69 paint.setImageFilter(filter); |
70 canvas->save(); | 70 canvas->save(); |
71 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 71 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
72 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), | 72 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), |
73 SkIntToScalar(fBitmap.height()))); | 73 SkIntToScalar(fBitmap.height()))); |
74 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 74 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
75 canvas->restore(); | 75 canvas->restore(); |
76 } | 76 } |
77 | 77 |
78 typedef SkMatrixConvolutionImageFilter MCIF; | 78 typedef SkMatrixConvolutionImageFilter MCIF; |
(...skipping 27 matching lines...) Expand all Loading... |
106 SkBitmap fBitmap; | 106 SkBitmap fBitmap; |
107 bool fInitialized; | 107 bool fInitialized; |
108 }; | 108 }; |
109 | 109 |
110 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
112 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } | 112 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } |
113 static GMRegistry reg(MyFactory); | 113 static GMRegistry reg(MyFactory); |
114 | 114 |
115 } | 115 } |
OLD | NEW |