| 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 "Checkerboard.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 10 #include "SkDisplacementMapEffect.h" | 10 #include "SkDisplacementMapEffect.h" |
| 11 #include "gm.h" | 11 #include "gm.h" |
| 12 | 12 |
| 13 namespace skiagm { | 13 namespace skiagm { |
| 14 | 14 |
| 15 class DisplacementMapGM : public GM { | 15 class DisplacementMapGM : public GM { |
| 16 public: | 16 public: |
| 17 DisplacementMapGM() : fInitialized(false) { | 17 DisplacementMapGM() : fInitialized(false) { |
| 18 this->setBGColor(0xFF000000); | 18 this->setBGColor(0xFF000000); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 sk_tool_utils::set_portable_typeface(&paint); | 41 sk_tool_utils::set_portable_typeface(&paint); |
| 42 paint.setColor(0xFF884422); | 42 paint.setColor(0xFF884422); |
| 43 paint.setTextSize(SkIntToScalar(96)); | 43 paint.setTextSize(SkIntToScalar(96)); |
| 44 const char* str = "g"; | 44 const char* str = "g"; |
| 45 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); | 45 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void make_checkerboard(SkBitmap* bitmap, int w, int h) { | 48 void make_checkerboard(SkBitmap* bitmap, int w, int h) { |
| 49 bitmap->allocN32Pixels(w, h); | 49 bitmap->allocN32Pixels(w, h); |
| 50 SkCanvas canvas(*bitmap); | 50 SkCanvas canvas(*bitmap); |
| 51 sk_tools::DrawCheckerboard(&canvas, 0xFF244484, 0xFF804020, 8); | 51 sk_tool_utils::draw_checkerboard(&canvas, 0xFF244484, 0xFF804020, 8); |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual SkISize onISize() { | 54 virtual SkISize onISize() { |
| 55 return SkISize::Make(500, 500); | 55 return SkISize::Make(500, 500); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint)
{ | 58 void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint)
{ |
| 59 canvas->save(); | 59 canvas->save(); |
| 60 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 60 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 61 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToS
calar(fBitmap.height()))); | 61 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToS
calar(fBitmap.height()))); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 207 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
| 208 bool fInitialized; | 208 bool fInitialized; |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 ////////////////////////////////////////////////////////////////////////////// | 211 ////////////////////////////////////////////////////////////////////////////// |
| 212 | 212 |
| 213 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 213 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
| 214 static GMRegistry reg(MyFactory); | 214 static GMRegistry reg(MyFactory); |
| 215 | 215 |
| 216 } | 216 } |
| OLD | NEW |