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/offsetimagefilter.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo 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
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 SkPaint paint; 83 SkPaint paint;
84 84
85 int x = 0, y = 0; 85 int x = 0, y = 0;
86 for (int i = 0; i < 4; i++) { 86 for (int i = 0; i < 4; i++) {
87 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; 87 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap;
88 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, 88 SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
89 i * 8, 89 i * 8,
90 bitmap->width() - i * 8, 90 bitmap->width() - i * 8,
91 bitmap->height() - i * 12); 91 bitmap->height() - i * 12);
92 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); 92 SkImageFilter::CropRect rect(SkRect::Make(cropRect));
93 SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*b itmap))); 93 SkAutoTUnref<SkImageFilter> tileInput(SkBitmapSource::Create(*bitmap ));
94 SkScalar dx = SkIntToScalar(i*5); 94 SkScalar dx = SkIntToScalar(i*5);
95 SkScalar dy = SkIntToScalar(i*10); 95 SkScalar dy = SkIntToScalar(i*10);
96 SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( 96 SkAutoTUnref<SkImageFilter> filter(
97 SkOffsetImageFilter, (dx, dy, tileInput, &rect))); 97 SkOffsetImageFilter::Create(dx, dy, tileInput, &rect));
98 paint.setImageFilter(filter); 98 paint.setImageFilter(filter);
99 drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToS calar(y)); 99 drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToS calar(y));
100 x += bitmap->width() + MARGIN; 100 x += bitmap->width() + MARGIN;
101 if (x + bitmap->width() > WIDTH) { 101 if (x + bitmap->width() > WIDTH) {
102 x = 0; 102 x = 0;
103 y += bitmap->height() + MARGIN; 103 y += bitmap->height() + MARGIN;
104 } 104 }
105 } 105 }
106 } 106 }
107 private: 107 private:
108 typedef GM INHERITED; 108 typedef GM INHERITED;
109 SkBitmap fBitmap, fCheckerboard; 109 SkBitmap fBitmap, fCheckerboard;
110 bool fInitialized; 110 bool fInitialized;
111 }; 111 };
112 112
113 ////////////////////////////////////////////////////////////////////////////// 113 //////////////////////////////////////////////////////////////////////////////
114 114
115 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } 115 static GM* MyFactory(void*) { return new OffsetImageFilterGM; }
116 static GMRegistry reg(MyFactory); 116 static GMRegistry reg(MyFactory);
117 117
118 } 118 }
OLDNEW
« no previous file with comments | « gm/morphology.cpp ('k') | gm/pictureimagefilter.cpp » ('j') | include/effects/SkBitmapSource.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698