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 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 return descriptor; | 72 return descriptor; |
73 } | 73 } |
74 | 74 |
75 virtual SkISize onISize() { | 75 virtual SkISize onISize() { |
76 return SkISize::Make(300, 300); | 76 return SkISize::Make(300, 300); |
77 } | 77 } |
78 | 78 |
79 virtual void onDraw(SkCanvas* canvas) { | 79 virtual void onDraw(SkCanvas* canvas) { |
80 SkBitmap bmp = create_bitmap(); | 80 SkBitmap bmp = create_bitmap(); |
81 SkShader* shader = SkShader::CreateBitmapShader( | |
82 bmp, fMode, fMode); | |
83 | |
84 SkPaint paint; | |
85 SkMatrix s; | 81 SkMatrix s; |
86 s.reset(); | 82 s.reset(); |
87 s.setScale(8, 8); | 83 s.setScale(8, 8); |
88 s.postTranslate(SLIDE_SIZE / 2, SLIDE_SIZE / 2); | 84 s.postTranslate(SLIDE_SIZE / 2, SLIDE_SIZE / 2); |
89 shader->setLocalMatrix(s); | 85 SkShader* shader = SkShader::CreateBitmapShader( |
| 86 bmp, fMode, fMode, &s); |
| 87 |
| 88 SkPaint paint; |
90 paint.setShader(shader)->unref(); | 89 paint.setShader(shader)->unref(); |
91 | 90 |
92 if (fHQ) { | 91 if (fHQ) { |
93 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); | 92 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); |
94 } | 93 } |
95 | 94 |
96 SkScalar margin = (SLIDE_SIZE / 3 - RECT_SIZE) / 2; | 95 SkScalar margin = (SLIDE_SIZE / 3 - RECT_SIZE) / 2; |
97 for (int i = 0; i < 3; i++) { | 96 for (int i = 0; i < 3; i++) { |
98 SkScalar yOrigin = SLIDE_SIZE / 3 * i + margin; | 97 SkScalar yOrigin = SLIDE_SIZE / 3 * i + margin; |
99 for (int j = 0; j < 3; j++) { | 98 for (int j = 0; j < 3; j++) { |
(...skipping 20 matching lines...) Expand all Loading... |
120 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kRepeat_TileMode); ) | 119 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kRepeat_TileMode); ) |
121 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kMirror_TileMode); ) | 120 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kMirror_TileMode); ) |
122 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kClamp_TileMode); ) | 121 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kClamp_TileMode); ) |
123 | 122 |
124 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kRepeat_TileMode, true); ) | 123 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kRepeat_TileMode, true); ) |
125 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kMirror_TileMode, true); ) | 124 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kMirror_TileMode, true); ) |
126 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kClamp_TileMode, true); ) | 125 DEF_GM( return new ClippedBitmapShadersGM(SkShader::kClamp_TileMode, true); ) |
127 | 126 |
128 | 127 |
129 } | 128 } |
OLD | NEW |