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 SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.get(); | 50 sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap; |
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 sk_sp<SkImageFilter> tileInput(SkImageSource::Create(image)); | 56 sk_sp<SkImageFilter> tileInput(SkImageSource::Make(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 paint.setImageFilter(SkOffsetImageFilter::Make(dx, dy, std::move(til
eInput), &rect)); | 59 paint.setImageFilter(SkOffsetImageFilter::Make(dx, dy, std::move(til
eInput), &rect)); |
60 DrawClippedImage(canvas, image, paint, 1, cropRect); | 60 DrawClippedImage(canvas, image.get(), paint, 1, cropRect); |
61 canvas->translate(SkIntToScalar(image->width() + MARGIN), 0); | 61 canvas->translate(SkIntToScalar(image->width() + MARGIN), 0); |
62 } | 62 } |
63 | 63 |
64 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100); | 64 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100); |
65 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); | 65 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); |
66 paint.setImageFilter(SkOffsetImageFilter::Make(-5, -10, nullptr, &rect))
; | 66 paint.setImageFilter(SkOffsetImageFilter::Make(-5, -10, nullptr, &rect))
; |
67 DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect); | 67 DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect); |
68 } | 68 } |
69 private: | 69 private: |
70 static void DrawClippedImage(SkCanvas* canvas, const SkImage* image, const S
kPaint& paint, | 70 static void DrawClippedImage(SkCanvas* canvas, const SkImage* image, const S
kPaint& paint, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 // crop==clip==dst | 196 // crop==clip==dst |
197 canvas->translate(100, 0); | 197 canvas->translate(100, 0); |
198 this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr2),
&r2); | 198 this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr2),
&r2); |
199 } | 199 } |
200 | 200 |
201 private: | 201 private: |
202 typedef skiagm::GM INHERITED; | 202 typedef skiagm::GM INHERITED; |
203 }; | 203 }; |
204 DEF_GM( return new SimpleOffsetImageFilterGM; ) | 204 DEF_GM( return new SimpleOffsetImageFilterGM; ) |
OLD | NEW |