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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkImage.h" | 9 #include "SkImage.h" |
10 #include "SkImageSource.h" | 10 #include "SkImageSource.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 sk_tool_utils::color_to_56
5(0xFFA0A0A0), | 40 sk_tool_utils::color_to_56
5(0xFFA0A0A0), |
41 sk_tool_utils::color_to_56
5(0xFF404040), | 41 sk_tool_utils::color_to_56
5(0xFF404040), |
42 8)); | 42 8)); |
43 } | 43 } |
44 | 44 |
45 void onDraw(SkCanvas* canvas) override { | 45 void onDraw(SkCanvas* canvas) override { |
46 canvas->clear(SK_ColorBLACK); | 46 canvas->clear(SK_ColorBLACK); |
47 SkPaint paint; | 47 SkPaint paint; |
48 | 48 |
49 for (int i = 0; i < 4; i++) { | 49 for (int i = 0; i < 4; i++) { |
50 const SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.ge
t(); | 50 SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.get(); |
51 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, | 51 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, |
52 i * 8, | 52 i * 8, |
53 image->width() - i * 8, | 53 image->width() - i * 8, |
54 image->height() - i * 12); | 54 image->height() - i * 12); |
55 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); | 55 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); |
56 SkAutoTUnref<SkImageFilter> tileInput(SkImageSource::Create(image)); | 56 SkAutoTUnref<SkImageFilter> tileInput(SkImageSource::Create(image)); |
57 SkScalar dx = SkIntToScalar(i*5); | 57 SkScalar dx = SkIntToScalar(i*5); |
58 SkScalar dy = SkIntToScalar(i*10); | 58 SkScalar dy = SkIntToScalar(i*10); |
59 SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(dx, d
y, tileInput, | 59 SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(dx, d
y, tileInput, |
60 &rect
)); | 60 &rect
)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 // crop==clip==dst | 199 // crop==clip==dst |
200 canvas->translate(100, 0); | 200 canvas->translate(100, 0); |
201 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr2
), &r2); | 201 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr2
), &r2); |
202 } | 202 } |
203 | 203 |
204 private: | 204 private: |
205 typedef skiagm::GM INHERITED; | 205 typedef skiagm::GM INHERITED; |
206 }; | 206 }; |
207 DEF_GM( return new SimpleOffsetImageFilterGM; ) | 207 DEF_GM( return new SimpleOffsetImageFilterGM; ) |
OLD | NEW |