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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkSurface.h" | 9 #include "SkSurface.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 SkRect bounds; | 59 SkRect bounds; |
60 p->setColor(color); | 60 p->setColor(color); |
61 p->measureText(&c, 1, &bounds); | 61 p->measureText(&c, 1, &bounds); |
62 canvas->drawText(&c, 1, x - bounds.centerX(), y - bounds.centerY(), *p); | 62 canvas->drawText(&c, 1, x - bounds.centerX(), y - bounds.centerY(), *p); |
63 } | 63 } |
64 | 64 |
65 static void color_wheel_native(SkCanvas* canvas) { | 65 static void color_wheel_native(SkCanvas* canvas) { |
66 SkAutoCanvasRestore autoCanvasRestore(canvas, true); | 66 SkAutoCanvasRestore autoCanvasRestore(canvas, true); |
67 canvas->translate(0.5f * SCALE, 0.5f * SCALE); | 67 canvas->translate(0.5f * SCALE, 0.5f * SCALE); |
68 SkPaint p; | 68 SkPaint p; |
69 sk_tool_utils::set_portable_typeface_always(&p); | |
70 p.setAntiAlias(false); | 69 p.setAntiAlias(false); |
71 p.setColor(SK_ColorWHITE); | 70 p.setColor(SK_ColorWHITE); |
72 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p); | 71 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p); |
73 | 72 |
74 const double sqrt_3_over_2 = 0.8660254037844387; | 73 const double sqrt_3_over_2 = 0.8660254037844387; |
75 const SkScalar Z = 0.0f; | 74 const SkScalar Z = 0.0f; |
76 const SkScalar D = 0.3f * SkIntToScalar(SCALE); | 75 const SkScalar D = 0.3f * SkIntToScalar(SCALE); |
77 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); | 76 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); |
78 const SkScalar Y = D * SK_ScalarHalf; | 77 const SkScalar Y = D * SK_ScalarHalf; |
79 sk_tool_utils::set_portable_typeface(&p, NULL, SkTypeface::kBold); | 78 sk_tool_utils::set_portable_typeface_always(&p, NULL, SkTypeface::kBold); |
80 p.setTextSize(0.28125f * SCALE); | 79 p.setTextSize(0.28125f * SCALE); |
81 draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas); | 80 draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas); |
82 draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas); | 81 draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas); |
83 draw_center_letter('G', &p, SK_ColorGREEN, -X, -Y, canvas); | 82 draw_center_letter('G', &p, SK_ColorGREEN, -X, -Y, canvas); |
84 draw_center_letter('B', &p, SK_ColorBLUE, X, -Y, canvas); | 83 draw_center_letter('B', &p, SK_ColorBLUE, X, -Y, canvas); |
85 draw_center_letter('C', &p, SK_ColorCYAN, Z, -D, canvas); | 84 draw_center_letter('C', &p, SK_ColorCYAN, Z, -D, canvas); |
86 draw_center_letter('M', &p, SK_ColorMAGENTA, X, Y, canvas); | 85 draw_center_letter('M', &p, SK_ColorMAGENTA, X, Y, canvas); |
87 draw_center_letter('Y', &p, SK_ColorYELLOW, -X, Y, canvas); | 86 draw_center_letter('Y', &p, SK_ColorYELLOW, -X, Y, canvas); |
88 } | 87 } |
89 | 88 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 184 |
186 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 185 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
187 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); | 186 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); |
188 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); | 187 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); |
189 | 188 |
190 p.setColor(SK_ColorRED); | 189 p.setColor(SK_ColorRED); |
191 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 190 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
192 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); | 191 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); |
193 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); | 192 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); |
194 } | 193 } |
OLD | NEW |