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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 175293002: Factory methods for heap-allocated SkColorFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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/colormatrix.cpp ('k') | include/effects/SkColorMatrixFilter.h » ('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 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 canvas->translate(SkIntToScalar(100), 0); 135 canvas->translate(SkIntToScalar(100), 0);
136 } 136 }
137 { 137 {
138 SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5)); 138 SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5));
139 139
140 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, 140 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
141 0, SK_Scalar1, 0, 0, 0, 141 0, SK_Scalar1, 0, 0, 0,
142 0, 0, SK_Scalar1, 0, 0, 142 0, 0, SK_Scalar1, 0, 0,
143 0, 0, 0, 0.5f, 0 }; 143 0, 0, 0, 0.5f, 0 };
144 144
145 SkAutoTUnref<SkColorFilter> matrixFilter(new SkColorMatrixFilter(mat rix)); 145 SkAutoTUnref<SkColorFilter> matrixFilter(SkColorMatrixFilter::Create (matrix));
146 SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Cre ate(matrixFilter, morph)); 146 SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Cre ate(matrixFilter, morph));
147 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOve r_Mode)); 147 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOve r_Mode));
148 SkAutoTUnref<SkImageFilter> blendColor(new SkXfermodeImageFilter(mod e, colorMorph)); 148 SkAutoTUnref<SkImageFilter> blendColor(new SkXfermodeImageFilter(mod e, colorMorph));
149 149
150 SkPaint paint; 150 SkPaint paint;
151 paint.setImageFilter(blendColor); 151 paint.setImageFilter(blendColor);
152 drawClippedBitmap(canvas, fBitmap, paint); 152 drawClippedBitmap(canvas, fBitmap, paint);
153 canvas->translate(SkIntToScalar(100), 0); 153 canvas->translate(SkIntToScalar(100), 0);
154 } 154 }
155 { 155 {
156 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, 156 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
157 0, SK_Scalar1, 0, 0, 0, 157 0, SK_Scalar1, 0, 0, 0,
158 0, 0, SK_Scalar1, 0, 0, 158 0, 0, SK_Scalar1, 0, 0,
159 0, 0, 0, 0.5f, 0 }; 159 0, 0, 0, 0.5f, 0 };
160 SkColorMatrixFilter matrixCF(matrix); 160 SkAutoTUnref<SkColorMatrixFilter> matrixCF(SkColorMatrixFilter::Crea te(matrix));
161 SkAutoTUnref<SkImageFilter> matrixFilter(SkColorFilterImageFilter::C reate(&matrixCF)); 161 SkAutoTUnref<SkImageFilter> matrixFilter(SkColorFilterImageFilter::C reate(matrixCF));
162 SimpleOffsetFilter offsetFilter(SkIntToScalar(10), SkIntToScalar(10) , matrixFilter); 162 SimpleOffsetFilter offsetFilter(SkIntToScalar(10), SkIntToScalar(10) , matrixFilter);
163 163
164 SkAutoTUnref<SkXfermode> arith(SkArithmeticMode::Create(0, SK_Scalar 1, SK_Scalar1, 0)); 164 SkAutoTUnref<SkXfermode> arith(SkArithmeticMode::Create(0, SK_Scalar 1, SK_Scalar1, 0));
165 SkXfermodeImageFilter arithFilter(arith, matrixFilter, &offsetFilter ); 165 SkXfermodeImageFilter arithFilter(arith, matrixFilter, &offsetFilter );
166 166
167 SkPaint paint; 167 SkPaint paint;
168 paint.setImageFilter(&arithFilter); 168 paint.setImageFilter(&arithFilter);
169 drawClippedBitmap(canvas, fBitmap, paint); 169 drawClippedBitmap(canvas, fBitmap, paint);
170 canvas->translate(SkIntToScalar(100), 0); 170 canvas->translate(SkIntToScalar(100), 0);
171 } 171 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 private: 206 private:
207 typedef GM INHERITED; 207 typedef GM INHERITED;
208 SkBitmap fBitmap; 208 SkBitmap fBitmap;
209 bool fInitialized; 209 bool fInitialized;
210 }; 210 };
211 211
212 /////////////////////////////////////////////////////////////////////////////// 212 ///////////////////////////////////////////////////////////////////////////////
213 213
214 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 214 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
215 static skiagm::GMRegistry reg(MyFactory); 215 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/colormatrix.cpp ('k') | include/effects/SkColorMatrixFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698