| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * This test exercises drawPosTextH and drawPosText with every text align. | 13 * This test exercises drawPosTextH and drawPosText with every text align. |
| 14 */ | 14 */ |
| 15 static const int kWidth = 480; | 15 constexpr int kWidth = 480; |
| 16 static const int kHeight = 600; | 16 constexpr int kHeight = 600; |
| 17 static const SkScalar kTextHeight = 64.0f; | 17 constexpr SkScalar kTextHeight = 64.0f; |
| 18 static const int kMaxStringLength = 12; | 18 constexpr int kMaxStringLength = 12; |
| 19 | 19 |
| 20 static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&); | 20 static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&); |
| 21 | 21 |
| 22 DEF_SIMPLE_GM_BG(glyph_pos_align, canvas, kWidth, kHeight, SK_ColorBLACK) { | 22 DEF_SIMPLE_GM_BG(glyph_pos_align, canvas, kWidth, kHeight, SK_ColorBLACK) { |
| 23 SkPaint paint; | 23 SkPaint paint; |
| 24 paint.setTextSize(kTextHeight); | 24 paint.setTextSize(kTextHeight); |
| 25 paint.setFakeBoldText(true); | 25 paint.setFakeBoldText(true); |
| 26 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; | 26 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; |
| 27 const SkPoint pts[] = {{0, 0}, {kWidth, kHeight}}; | 27 const SkPoint pts[] = {{0, 0}, {kWidth, kHeight}}; |
| 28 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_AR
RAY_COUNT(colors), | 28 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_AR
RAY_COUNT(colors), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 float x = kTextHeight; | 57 float x = kTextHeight; |
| 58 for (int i = 0; i < length; ++i) { | 58 for (int i = 0; i < length; ++i) { |
| 59 posX[i] = x + originX * widths[i]; | 59 posX[i] = x + originX * widths[i]; |
| 60 pos[i].set(posX[i], i ? pos[i - 1].y() + 3 : y + kTextHeight); | 60 pos[i].set(posX[i], i ? pos[i - 1].y() + 3 : y + kTextHeight); |
| 61 x += widths[i]; | 61 x += widths[i]; |
| 62 } | 62 } |
| 63 | 63 |
| 64 canvas->drawPosTextH(text, length, posX, y, paint); | 64 canvas->drawPosTextH(text, length, posX, y, paint); |
| 65 canvas->drawPosText(text, length, pos, paint); | 65 canvas->drawPosText(text, length, pos, paint); |
| 66 } | 66 } |
| OLD | NEW |