OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |