OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkImage.h" | 9 #include "SkImage.h" |
10 #include "SkRRect.h" | 10 #include "SkRRect.h" |
11 | 11 |
12 static void rotated_checkerboard_shader(SkPaint* paint, | 12 static void rotated_checkerboard_shader(SkPaint* paint, |
13 SkColor c1, | 13 SkColor c1, |
14 SkColor c2, | 14 SkColor c2, |
15 int size) { | 15 int size) { |
16 SkBitmap bm; | 16 SkBitmap bm; |
17 bm.allocN32Pixels(2 * size, 2 * size); | 17 bm.allocN32Pixels(2 * size, 2 * size); |
18 bm.eraseColor(c1); | 18 bm.eraseColor(c1); |
19 bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2); | 19 bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2); |
20 bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2); | 20 bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2); |
21 SkMatrix matrix; | 21 SkMatrix matrix; |
22 matrix.setScale(0.75f, 0.75f); | 22 matrix.setScale(0.75f, 0.75f); |
23 matrix.preRotate(30.0f); | 23 matrix.preRotate(30.0f); |
24 paint->setShader( | 24 SkAutoTUnref<SkShader> shader( |
25 SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader:
:kRepeat_TileMode, | 25 SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, |
26 &matrix)); | 26 SkShader::kRepeat_TileMode, &matrix)); |
| 27 paint->setShader(shader); |
27 } | 28 } |
28 | 29 |
29 static void exercise_draw_pos_text(SkCanvas* canvas, | 30 static void exercise_draw_pos_text(SkCanvas* canvas, |
30 const char* text, | 31 const char* text, |
31 SkScalar x, SkScalar y, | 32 SkScalar x, SkScalar y, |
32 const SkPaint& paint) { | 33 const SkPaint& paint) { |
33 size_t textLen = strlen(text); | 34 size_t textLen = strlen(text); |
34 int count = paint.countText(text, textLen); | 35 int count = paint.countText(text, textLen); |
35 SkAutoTArray<SkScalar> widths(count); | 36 SkAutoTArray<SkScalar> widths(count); |
36 paint.getTextWidths(text, textLen, &widths[0]); | 37 paint.getTextWidths(text, textLen, &widths[0]); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 SkPaint stroke; | 126 SkPaint stroke; |
126 stroke.setStyle(SkPaint::kStroke_Style); | 127 stroke.setStyle(SkPaint::kStroke_Style); |
127 stroke.setStrokeWidth(5); | 128 stroke.setStrokeWidth(5); |
128 stroke.setColor(SK_ColorCYAN); | 129 stroke.setColor(SK_ColorCYAN); |
129 canvas->drawCircle(size / 2, size / 2, size / 2 - 10, stroke); | 130 canvas->drawCircle(size / 2, size / 2, size / 2 - 10, stroke); |
130 canvas->drawCircle(3 * size / 2, size / 2, size / 2 - 10, stroke); | 131 canvas->drawCircle(3 * size / 2, size / 2, size / 2 - 10, stroke); |
131 canvas->drawCircle(size / 2, 384, size / 2 - 10, stroke); | 132 canvas->drawCircle(size / 2, 384, size / 2 - 10, stroke); |
132 canvas->translate(size, size); | 133 canvas->translate(size, size); |
133 test_text(canvas, size, SK_ColorCYAN, 0.0f); | 134 test_text(canvas, size, SK_ColorCYAN, 0.0f); |
134 } | 135 } |
OLD | NEW |