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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « expectations/gm/ignored-tests.txt ('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 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_ Mode)); 176 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_ Mode));
177 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S kIntToScalar(100))); 177 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S kIntToScalar(100)));
178 SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, bl ur, NULL, &cropRect)); 178 SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, bl ur, NULL, &cropRect));
179 179
180 SkPaint paint; 180 SkPaint paint;
181 paint.setImageFilter(blend); 181 paint.setImageFilter(blend);
182 drawClippedBitmap(canvas, fBitmap, paint); 182 drawClippedBitmap(canvas, fBitmap, paint);
183 canvas->translate(SkIntToScalar(100), 0); 183 canvas->translate(SkIntToScalar(100), 0);
184 } 184 }
185 {
186 // Test that crop offsets are absolute, not relative to the parent's crop rect.
187 SkAutoTUnref<SkColorFilter> cf1(SkColorFilter::CreateModeFilter(SK_C olorBLUE,
188 SkXf ermode::kSrcIn_Mode));
189 SkAutoTUnref<SkColorFilter> cf2(SkColorFilter::CreateModeFilter(SK_C olorGREEN,
190 SkXf ermode::kSrcIn_Mode));
191 SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10) , SkIntToScalar(10),
192 SkIntToScalar(80) , SkIntToScalar(80)));
193 SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20) , SkIntToScalar(20),
194 SkIntToScalar(60) , SkIntToScalar(60)));
195 SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create( cf1, NULL, &outerRect));
196 SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create( cf2, color1, &innerRect));
197
198 SkPaint paint;
199 paint.setImageFilter(color2);
200 paint.setColor(0xFFFF0000);
201 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint);
202 canvas->translate(SkIntToScalar(100), 0);
203 }
185 } 204 }
186 205
187 private: 206 private:
188 typedef GM INHERITED; 207 typedef GM INHERITED;
189 SkBitmap fBitmap; 208 SkBitmap fBitmap;
190 bool fInitialized; 209 bool fInitialized;
191 }; 210 };
192 211
193 /////////////////////////////////////////////////////////////////////////////// 212 ///////////////////////////////////////////////////////////////////////////////
194 213
195 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 214 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
196 static skiagm::GMRegistry reg(MyFactory); 215 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698