| 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 "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 10 #include "SkOffsetImageFilter.h" | 10 #include "SkOffsetImageFilter.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 SkString onShortName() override { | 24 SkString onShortName() override { |
| 25 return SkString("offsetimagefilter"); | 25 return SkString("offsetimagefilter"); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void make_bitmap() { | 28 void make_bitmap() { |
| 29 fBitmap.allocN32Pixels(80, 80); | 29 fBitmap.allocN32Pixels(80, 80); |
| 30 SkCanvas canvas(fBitmap); | 30 SkCanvas canvas(fBitmap); |
| 31 canvas.clear(0); | 31 canvas.clear(0); |
| 32 SkPaint paint; | 32 SkPaint paint; |
| 33 paint.setAntiAlias(true); | 33 paint.setAntiAlias(true); |
| 34 sk_tool_utils::set_portable_typeface(&paint); | 34 sk_tool_utils::set_portable_typeface_always(&paint); |
| 35 paint.setColor(0xD000D000); | 35 paint.setColor(sk_tool_utils::color_to_565(0xD000D000)); |
| 36 paint.setTextSize(96); | 36 paint.setTextSize(96); |
| 37 canvas.drawText("e", 1, 15, 65, paint); | 37 canvas.drawText("e", 1, 15, 65, paint); |
| 38 } | 38 } |
| 39 | 39 |
| 40 SkISize onISize() override { | 40 SkISize onISize() override { |
| 41 return SkISize::Make(WIDTH, HEIGHT); | 41 return SkISize::Make(WIDTH, HEIGHT); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
nt& paint, | 44 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai
nt& paint, |
| 45 SkScalar scale, const SkIRect& cropRect) { | 45 SkScalar scale, const SkIRect& cropRect) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 strokePaint.setColor(SK_ColorRED); | 60 strokePaint.setColor(SK_ColorRED); |
| 61 canvas->drawRect(clipRect, strokePaint); | 61 canvas->drawRect(clipRect, strokePaint); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void onOnceBeforeDraw() override { | 65 void onOnceBeforeDraw() override { |
| 66 make_bitmap(); | 66 make_bitmap(); |
| 67 | 67 |
| 68 fCheckerboard.allocN32Pixels(80, 80); | 68 fCheckerboard.allocN32Pixels(80, 80); |
| 69 SkCanvas checkerboardCanvas(fCheckerboard); | 69 SkCanvas checkerboardCanvas(fCheckerboard); |
| 70 sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF40
4040, 8); | 70 sk_tool_utils::draw_checkerboard(&checkerboardCanvas, |
| 71 sk_tool_utils::color_to_565(0xFFA0A0A0), |
| 72 sk_tool_utils::color_to_565(0xFF404040), 8); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void onDraw(SkCanvas* canvas) override { | 75 void onDraw(SkCanvas* canvas) override { |
| 74 canvas->clear(SK_ColorBLACK); | 76 canvas->clear(SK_ColorBLACK); |
| 75 SkPaint paint; | 77 SkPaint paint; |
| 76 | 78 |
| 77 for (int i = 0; i < 4; i++) { | 79 for (int i = 0; i < 4; i++) { |
| 78 const SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; | 80 const SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; |
| 79 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, | 81 SkIRect cropRect = SkIRect::MakeXYWH(i * 12, |
| 80 i * 8, | 82 i * 8, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 205 |
| 204 // crop==clip==dst | 206 // crop==clip==dst |
| 205 canvas->translate(100, 0); | 207 canvas->translate(100, 0); |
| 206 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2),
&r2); | 208 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2),
&r2); |
| 207 } | 209 } |
| 208 | 210 |
| 209 private: | 211 private: |
| 210 typedef skiagm::GM INHERITED; | 212 typedef skiagm::GM INHERITED; |
| 211 }; | 213 }; |
| 212 DEF_GM( return new SimpleOffsetImageFilterGM; ) | 214 DEF_GM( return new SimpleOffsetImageFilterGM; ) |
| OLD | NEW |