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

Side by Side Diff: gm/imagefilterscropped.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/imagefiltersclipped.cpp ('k') | gm/imagefiltersgraph.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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 virtual void onDraw(SkCanvas* canvas) { 127 virtual void onDraw(SkCanvas* canvas) {
128 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { 128 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
129 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text 129 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text
130 }; 130 };
131 131
132 SkAutoTUnref<SkColorFilter> cf( 132 SkAutoTUnref<SkColorFilter> cf(
133 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e)); 133 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e));
134 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge); 134 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge);
135 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, - 100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge); 135 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, - 100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge);
136 136
137 SkAutoTUnref<SkImageFilter> offset(new SkOffsetImageFilter( 137 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(
138 SkIntToScalar(-10), SkIntToScalar(-10))); 138 SkIntToScalar(-10), SkIntToScalar(-10)));
139 139
140 SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf .get(), offset.get())); 140 SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf .get(), offset.get()));
141 141
142 SkImageFilter* filters[] = { 142 SkImageFilter* filters[] = {
143 NULL, 143 NULL,
144 SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect), 144 SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect),
145 new SkBlurImageFilter(1.0f, 1.0f, NULL, &cropRect), 145 SkBlurImageFilter::Create(1.0f, 1.0f, NULL, &cropRect),
146 new SkBlurImageFilter(8.0f, 0.0f, NULL, &cropRect), 146 SkBlurImageFilter::Create(8.0f, 0.0f, NULL, &cropRect),
147 new SkBlurImageFilter(0.0f, 8.0f, NULL, &cropRect), 147 SkBlurImageFilter::Create(0.0f, 8.0f, NULL, &cropRect),
148 new SkBlurImageFilter(8.0f, 8.0f, NULL, &cropRect), 148 SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &cropRect),
149 new SkMergeImageFilter(NULL, cfOffset.get(), SkXfermode::kSrcOver_Mo de, &cropRect), 149 SkMergeImageFilter::Create(NULL, cfOffset.get(), SkXfermode::kSrcOve r_Mode, &cropRect),
150 new SkBlurImageFilter(8.0f, 8.0f, NULL, &bogusRect), 150 SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &bogusRect),
151 SkColorFilterImageFilter::Create(cf.get(), NULL, &bogusRect), 151 SkColorFilterImageFilter::Create(cf.get(), NULL, &bogusRect),
152 }; 152 };
153 153
154 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 154 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
155 SkScalar MARGIN = SkIntToScalar(16); 155 SkScalar MARGIN = SkIntToScalar(16);
156 SkScalar DX = r.width() + MARGIN; 156 SkScalar DX = r.width() + MARGIN;
157 SkScalar DY = r.height() + MARGIN; 157 SkScalar DY = r.height() + MARGIN;
158 158
159 canvas->translate(MARGIN, MARGIN); 159 canvas->translate(MARGIN, MARGIN);
160 for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) { 160 for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) {
(...skipping 12 matching lines...) Expand all
173 } 173 }
174 174
175 private: 175 private:
176 typedef GM INHERITED; 176 typedef GM INHERITED;
177 }; 177 };
178 178
179 /////////////////////////////////////////////////////////////////////////////// 179 ///////////////////////////////////////////////////////////////////////////////
180 180
181 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } 181 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; }
182 static skiagm::GMRegistry reg(MyFactory); 182 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/imagefiltersgraph.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698