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

Side by Side Diff: gm/morphology.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/matrixconvolution.cpp ('k') | gm/offsetimagefilter.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 "SkMorphologyImageFilter.h" 9 #include "SkMorphologyImageFilter.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 { 140, 140, 2, 2 }, 67 { 140, 140, 2, 2 },
68 { 24, 24, 25, 25 }, 68 { 24, 24, 25, 25 },
69 }; 69 };
70 SkPaint paint; 70 SkPaint paint;
71 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(25, 20, 100, 80)); 71 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(25, 20, 100, 80));
72 72
73 for (unsigned j = 0; j < 4; ++j) { 73 for (unsigned j = 0; j < 4; ++j) {
74 for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) { 74 for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
75 const SkImageFilter::CropRect* cr = j & 0x02 ? &cropRect : NULL; 75 const SkImageFilter::CropRect* cr = j & 0x02 ? &cropRect : NULL;
76 if (j & 0x01) { 76 if (j & 0x01) {
77 paint.setImageFilter(new SkErodeImageFilter( 77 paint.setImageFilter(SkErodeImageFilter::Create(
78 samples[i].fRadiusX, 78 samples[i].fRadiusX,
79 samples[i].fRadiusY, 79 samples[i].fRadiusY,
80 NULL, 80 NULL,
81 cr))->unref(); 81 cr))->unref();
82 } else { 82 } else {
83 paint.setImageFilter(new SkDilateImageFilter( 83 paint.setImageFilter(SkDilateImageFilter::Create(
84 samples[i].fRadiusX, 84 samples[i].fRadiusX,
85 samples[i].fRadiusY, 85 samples[i].fRadiusY,
86 NULL, 86 NULL,
87 cr))->unref(); 87 cr))->unref();
88 } 88 }
89 drawClippedBitmap(canvas, paint, i * 140, j * 140); 89 drawClippedBitmap(canvas, paint, i * 140, j * 140);
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 private: 94 private:
95 typedef GM INHERITED; 95 typedef GM INHERITED;
96 SkBitmap fBitmap; 96 SkBitmap fBitmap;
97 bool fOnce; 97 bool fOnce;
98 }; 98 };
99 99
100 ////////////////////////////////////////////////////////////////////////////// 100 //////////////////////////////////////////////////////////////////////////////
101 101
102 static GM* MyFactory(void*) { return new MorphologyGM; } 102 static GM* MyFactory(void*) { return new MorphologyGM; }
103 static GMRegistry reg(MyFactory); 103 static GMRegistry reg(MyFactory);
104 104
105 } 105 }
OLDNEW
« no previous file with comments | « gm/matrixconvolution.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698