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

Side by Side Diff: gm/offsetimagefilter.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/morphology.cpp ('k') | gm/pictureimagefilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkOffsetImageFilter.h" 9 #include "SkOffsetImageFilter.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 canvas->clear(0x00000000); 94 canvas->clear(0x00000000);
95 SkPaint paint; 95 SkPaint paint;
96 96
97 for (int i = 0; i < 4; i++) { 97 for (int i = 0; i < 4; i++) {
98 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; 98 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap;
99 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, 99 SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
100 i * 8, 100 i * 8,
101 bitmap->width() - i * 8, 101 bitmap->width() - i * 8,
102 bitmap->height() - i * 12); 102 bitmap->height() - i * 12);
103 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); 103 SkImageFilter::CropRect rect(SkRect::Make(cropRect));
104 SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*b itmap))); 104 SkAutoTUnref<SkImageFilter> tileInput(SkBitmapSource::Create(*bitmap ));
105 SkScalar dx = SkIntToScalar(i*5); 105 SkScalar dx = SkIntToScalar(i*5);
106 SkScalar dy = SkIntToScalar(i*10); 106 SkScalar dy = SkIntToScalar(i*10);
107 SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( 107 SkAutoTUnref<SkImageFilter> filter(
108 SkOffsetImageFilter, (dx, dy, tileInput, &rect))); 108 SkOffsetImageFilter::Create(dx, dy, tileInput, &rect));
109 paint.setImageFilter(filter); 109 paint.setImageFilter(filter);
110 drawClippedBitmap(canvas, *bitmap, paint, SK_Scalar1, cropRect); 110 drawClippedBitmap(canvas, *bitmap, paint, SK_Scalar1, cropRect);
111 canvas->translate(SkIntToScalar(bitmap->width() + MARGIN), 0); 111 canvas->translate(SkIntToScalar(bitmap->width() + MARGIN), 0);
112 } 112 }
113 113
114 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100); 114 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
115 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); 115 SkImageFilter::CropRect rect(SkRect::Make(cropRect));
116 SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( 116 SkAutoTUnref<SkImageFilter> filter(
117 SkOffsetImageFilter, (SkIntToScalar(-5), SkIntToScalar(-10), NULL, & rect))); 117 SkOffsetImageFilter::Create(SkIntToScalar(-5), SkIntToScalar(-10), N ULL, &rect));
118 paint.setImageFilter(filter); 118 paint.setImageFilter(filter);
119 drawClippedBitmap(canvas, fBitmap, paint, SkIntToScalar(2), cropRect); 119 drawClippedBitmap(canvas, fBitmap, paint, SkIntToScalar(2), cropRect);
120 } 120 }
121 private: 121 private:
122 typedef GM INHERITED; 122 typedef GM INHERITED;
123 SkBitmap fBitmap, fCheckerboard; 123 SkBitmap fBitmap, fCheckerboard;
124 bool fInitialized; 124 bool fInitialized;
125 }; 125 };
126 126
127 ////////////////////////////////////////////////////////////////////////////// 127 //////////////////////////////////////////////////////////////////////////////
128 128
129 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } 129 static GM* MyFactory(void*) { return new OffsetImageFilterGM; }
130 static GMRegistry reg(MyFactory); 130 static GMRegistry reg(MyFactory);
131 131
132 } 132 }
OLDNEW
« no previous file with comments | « gm/morphology.cpp ('k') | gm/pictureimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698