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 | 9 |
10 #include "SkPictureImageFilter.h" | 10 #include "SkPictureImageFilter.h" |
11 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
12 | 12 |
13 // This GM exercises the SkPictureImageFilter ImageFilter class. | 13 // This GM exercises the SkPictureImageFilter ImageFilter class. |
14 | 14 |
15 static void fill_rect_filtered(SkCanvas* canvas, | 15 static void fill_rect_filtered(SkCanvas* canvas, |
16 const SkRect& clipRect, | 16 const SkRect& clipRect, |
17 sk_sp<SkImageFilter> filter) { | 17 sk_sp<SkImageFilter> filter) { |
18 SkPaint paint; | 18 SkPaint paint; |
19 paint.setImageFilter(filter); | 19 paint.setImageFilter(filter); |
20 canvas->save(); | 20 canvas->save(); |
21 canvas->clipRect(clipRect); | 21 canvas->clipRect(clipRect); |
22 canvas->drawPaint(paint); | 22 canvas->drawPaint(paint); |
23 canvas->restore(); | 23 canvas->restore(); |
24 } | 24 } |
25 | 25 |
26 static sk_sp<SkPicture> make_picture() { | 26 static sk_sp<SkPicture> make_picture() { |
27 SkPictureRecorder recorder; | 27 SkPictureRecorder recorder; |
28 SkCanvas* canvas = recorder.beginRecording(100, 100, nullptr, 0); | 28 SkCanvas* canvas = recorder.beginRecording(100, 100, nullptr, 0); |
29 canvas->clear(SK_ColorBLACK); | |
30 SkPaint paint; | 29 SkPaint paint; |
31 paint.setAntiAlias(true); | 30 paint.setAntiAlias(true); |
32 sk_tool_utils::set_portable_typeface(&paint); | 31 sk_tool_utils::set_portable_typeface(&paint); |
33 paint.setColor(0xFFFFFFFF); | 32 paint.setColor(0xFFFFFFFF); |
34 paint.setTextSize(SkIntToScalar(96)); | 33 paint.setTextSize(SkIntToScalar(96)); |
35 const char* str = "e"; | 34 const char* str = "e"; |
36 canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), pai
nt); | 35 canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), pai
nt); |
37 return recorder.finishRecordingAsPicture(); | 36 return recorder.finishRecordingAsPicture(); |
38 } | 37 } |
39 | 38 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 private: | 143 private: |
145 sk_sp<SkPicture> fPicture; | 144 sk_sp<SkPicture> fPicture; |
146 sk_sp<SkPicture> fLCDPicture; | 145 sk_sp<SkPicture> fLCDPicture; |
147 | 146 |
148 typedef GM INHERITED; | 147 typedef GM INHERITED; |
149 }; | 148 }; |
150 | 149 |
151 /////////////////////////////////////////////////////////////////////////////// | 150 /////////////////////////////////////////////////////////////////////////////// |
152 | 151 |
153 DEF_GM( return new PictureImageFilterGM; ) | 152 DEF_GM( return new PictureImageFilterGM; ) |
OLD | NEW |