| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const char* str = "e"; | 42 const char* str = "e"; |
| 43 canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80),
paint); | 43 canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80),
paint); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual SkISize onISize() { | 46 virtual SkISize onISize() { |
| 47 return SkISize::Make(500, 300); | 47 return SkISize::Make(500, 300); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void draw(SkCanvas* canvas, int x, int y, const SkIPoint& kernelOffset, | 50 void draw(SkCanvas* canvas, int x, int y, const SkIPoint& kernelOffset, |
| 51 SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAl
pha, | 51 SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAl
pha, |
| 52 const SkImageFilter::CropRect* cropRect = NULL) { | 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 SkAutoTUnref<SkImageFilter> filter( |
| 62 SkMatrixConvolutionImageFilter::Create(kernelSize, | 62 SkMatrixConvolutionImageFilter::Create(kernelSize, |
| 63 kernel, | 63 kernel, |
| 64 gain, | 64 gain, |
| 65 bias, | 65 bias, |
| 66 kernelOffset, | 66 kernelOffset, |
| 67 tileMode, | 67 tileMode, |
| 68 convolveAlpha, | 68 convolveAlpha, |
| 69 NULL, | 69 nullptr, |
| 70 cropRect)); | 70 cropRect)); |
| 71 paint.setImageFilter(filter); | 71 paint.setImageFilter(filter); |
| 72 canvas->save(); | 72 canvas->save(); |
| 73 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 73 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 74 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), | 74 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), |
| 75 SkIntToScalar(fBitmap.height()))); | 75 SkIntToScalar(fBitmap.height()))); |
| 76 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 76 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
| 77 canvas->restore(); | 77 canvas->restore(); |
| 78 } | 78 } |
| 79 | 79 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 108 SkBitmap fBitmap; | 108 SkBitmap fBitmap; |
| 109 bool fInitialized; | 109 bool fInitialized; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 ////////////////////////////////////////////////////////////////////////////// | 112 ////////////////////////////////////////////////////////////////////////////// |
| 113 | 113 |
| 114 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } | 114 static GM* MyFactory(void*) { return new MatrixConvolutionGM; } |
| 115 static GMRegistry reg(MyFactory); | 115 static GMRegistry reg(MyFactory); |
| 116 | 116 |
| 117 } | 117 } |
| OLD | NEW |