| 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); |
| 69 p.setAntiAlias(false); | 70 p.setAntiAlias(false); |
| 70 p.setColor(SK_ColorWHITE); | 71 p.setColor(SK_ColorWHITE); |
| 71 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p); | 72 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p); |
| 72 | 73 |
| 73 const double sqrt_3_over_2 = 0.8660254037844387; | 74 const double sqrt_3_over_2 = 0.8660254037844387; |
| 74 const SkScalar Z = 0.0f; | 75 const SkScalar Z = 0.0f; |
| 75 const SkScalar D = 0.3f * SkIntToScalar(SCALE); | 76 const SkScalar D = 0.3f * SkIntToScalar(SCALE); |
| 76 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); | 77 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); |
| 77 const SkScalar Y = D * SK_ScalarHalf; | 78 const SkScalar Y = D * SK_ScalarHalf; |
| 78 sk_tool_utils::set_portable_typeface(&p, NULL, SkTypeface::kBold); | 79 sk_tool_utils::set_portable_typeface(&p, NULL, SkTypeface::kBold); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 SkASSERT(src.colorType() == colorType); | 150 SkASSERT(src.colorType() == colorType); |
| 150 canvas->drawBitmap(src, 0.0f, 0.0f); | 151 canvas->drawBitmap(src, 0.0f, 0.0f); |
| 151 canvas->drawText(text, strlen(text), 0.0f, 12.0f, p); | 152 canvas->drawText(text, strlen(text), 0.0f, 12.0f, p); |
| 152 } | 153 } |
| 153 | 154 |
| 154 DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) { | 155 DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) { |
| 155 SkAutoCanvasRestore autoCanvasRestore(canvas, true); | 156 SkAutoCanvasRestore autoCanvasRestore(canvas, true); |
| 156 SkPaint p; | 157 SkPaint p; |
| 157 p.setColor(SK_ColorBLACK); | 158 p.setColor(SK_ColorBLACK); |
| 158 p.setAntiAlias(true); | 159 p.setAntiAlias(true); |
| 159 sk_tool_utils::set_portable_typeface(&p, NULL); | 160 sk_tool_utils::set_portable_typeface_always(&p, NULL); |
| 160 | 161 |
| 161 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); | 162 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); |
| 162 | 163 |
| 163 SkBitmap bitmap; | 164 SkBitmap bitmap; |
| 164 if (GetResourceAsBitmap("color_wheel.png", &bitmap)) { | 165 if (GetResourceAsBitmap("color_wheel.png", &bitmap)) { |
| 165 bitmap.setImmutable(); | 166 bitmap.setImmutable(); |
| 166 draw(canvas, p, bitmap, kN32_SkColorType, "Native 32"); | 167 draw(canvas, p, bitmap, kN32_SkColorType, "Native 32"); |
| 167 | 168 |
| 168 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 169 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
| 169 SkBitmap copy565 = copy_bitmap(bitmap, kRGB_565_SkColorType); | 170 SkBitmap copy565 = copy_bitmap(bitmap, kRGB_565_SkColorType); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 | 185 |
| 185 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 186 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
| 186 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); | 187 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); |
| 187 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); | 188 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); |
| 188 | 189 |
| 189 p.setColor(SK_ColorRED); | 190 p.setColor(SK_ColorRED); |
| 190 canvas->translate(0.0f, SkIntToScalar(SCALE)); | 191 canvas->translate(0.0f, SkIntToScalar(SCALE)); |
| 191 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); | 192 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); |
| 192 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); | 193 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); |
| 193 } | 194 } |
| OLD | NEW |