OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace skiagm { | 25 namespace skiagm { |
26 | 26 |
27 class TiledScaledBitmapGM : public GM { | 27 class TiledScaledBitmapGM : public GM { |
28 public: | 28 public: |
29 | 29 |
30 TiledScaledBitmapGM() { | 30 TiledScaledBitmapGM() { |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 SkString onShortName() SK_OVERRIDE { | 34 SkString onShortName() override { |
35 return SkString("tiledscaledbitmap"); | 35 return SkString("tiledscaledbitmap"); |
36 } | 36 } |
37 | 37 |
38 SkISize onISize() SK_OVERRIDE { | 38 SkISize onISize() override { |
39 return SkISize::Make(1016, 616); | 39 return SkISize::Make(1016, 616); |
40 } | 40 } |
41 | 41 |
42 static SkBitmap make_bm(int width, int height) { | 42 static SkBitmap make_bm(int width, int height) { |
43 SkBitmap bm; | 43 SkBitmap bm; |
44 bm.allocN32Pixels(width, height); | 44 bm.allocN32Pixels(width, height); |
45 bm.eraseColor(SK_ColorTRANSPARENT); | 45 bm.eraseColor(SK_ColorTRANSPARENT); |
46 SkCanvas canvas(bm); | 46 SkCanvas canvas(bm); |
47 SkPaint paint; | 47 SkPaint paint; |
48 paint.setAntiAlias(true); | 48 paint.setAntiAlias(true); |
49 canvas.drawCircle(width/2.f, height/2.f, width/4.f, paint); | 49 canvas.drawCircle(width/2.f, height/2.f, width/4.f, paint); |
50 return bm; | 50 return bm; |
51 } | 51 } |
52 | 52 |
53 void onOnceBeforeDraw() SK_OVERRIDE { | 53 void onOnceBeforeDraw() override { |
54 fBitmap = make_bm(360, 288); | 54 fBitmap = make_bm(360, 288); |
55 } | 55 } |
56 | 56 |
57 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 57 void onDraw(SkCanvas* canvas) override { |
58 SkPaint paint; | 58 SkPaint paint; |
59 | 59 |
60 paint.setAntiAlias(true); | 60 paint.setAntiAlias(true); |
61 paint.setFilterQuality(kHigh_SkFilterQuality); | 61 paint.setFilterQuality(kHigh_SkFilterQuality); |
62 | 62 |
63 SkMatrix mat; | 63 SkMatrix mat; |
64 mat.setScale(121.f/360.f, 93.f/288.f); | 64 mat.setScale(121.f/360.f, 93.f/288.f); |
65 mat.postTranslate(-72, -72); | 65 mat.postTranslate(-72, -72); |
66 | 66 |
67 SkShader *shader = SkShader::CreateBitmapShader(fBitmap, SkShader::kRepe
at_TileMode, SkShader::kRepeat_TileMode, &mat); | 67 SkShader *shader = SkShader::CreateBitmapShader(fBitmap, SkShader::kRepe
at_TileMode, SkShader::kRepeat_TileMode, &mat); |
68 paint.setShader(shader); | 68 paint.setShader(shader); |
69 | 69 |
70 SkSafeUnref(shader); | 70 SkSafeUnref(shader); |
71 canvas->drawRectCoords(8,8,1008, 608, paint); | 71 canvas->drawRectCoords(8,8,1008, 608, paint); |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 SkBitmap fBitmap; | 75 SkBitmap fBitmap; |
76 | 76 |
77 typedef GM INHERITED; | 77 typedef GM INHERITED; |
78 }; | 78 }; |
79 | 79 |
80 ////////////////////////////////////////////////////////////////////////////// | 80 ////////////////////////////////////////////////////////////////////////////// |
81 | 81 |
82 DEF_GM(return SkNEW(TiledScaledBitmapGM);) | 82 DEF_GM(return SkNEW(TiledScaledBitmapGM);) |
83 | 83 |
84 } | 84 } |
OLD | NEW |