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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 void onOnceBeforeDraw() SK_OVERRIDE { | 53 void onOnceBeforeDraw() SK_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) SK_OVERRIDE { |
58 SkPaint paint; | 58 SkPaint paint; |
59 | 59 |
60 paint.setAntiAlias(true); | 60 paint.setAntiAlias(true); |
61 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); | 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 |