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

Side by Side Diff: gm/matrixconvolution.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years, 9 months 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
« no previous file with comments | « gm/imageresizetiled.cpp ('k') | gm/morphology.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 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
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
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 }
OLDNEW
« no previous file with comments | « gm/imageresizetiled.cpp ('k') | gm/morphology.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698