aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-05-21 16:10:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-21 21:53:54 +0000
commit1e7c65806f3fbde13b5d8064dc5734d98c32a284 (patch)
treee758fae7c14f09ba185b8aaa8f8306dad5cd4905 /gm
parent4bfb50b904e0e92d10145398eb3a6f8dd7868867 (diff)
drawPosText no longer obeys paint alignment
Change-Id: Iac498b54dea4aa1b203d2b9c58e15bb5f2147f82 Reviewed-on: https://skia-review.googlesource.com/129462 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/glyph_pos_align.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/gm/glyph_pos_align.cpp b/gm/glyph_pos_align.cpp
deleted file mode 100644
index 50bcf82742..0000000000
--- a/gm/glyph_pos_align.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm.h"
-#include "SkCanvas.h"
-#include "SkGradientShader.h"
-
-/**
- * This test exercises drawPosTextH and drawPosText with every text align.
- */
-constexpr int kWidth = 480;
-constexpr int kHeight = 600;
-constexpr SkScalar kTextHeight = 64.0f;
-constexpr int kMaxStringLength = 12;
-
-static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&);
-
-DEF_SIMPLE_GM_BG(glyph_pos_align, canvas, kWidth, kHeight, SK_ColorBLACK) {
- SkPaint paint;
- paint.setTextSize(kTextHeight);
- paint.setFakeBoldText(true);
- const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
- const SkPoint pts[] = {{0, 0}, {kWidth, kHeight}};
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kMirror_TileMode));
- paint.setTextAlign(SkPaint::kRight_Align);
- drawTestCase(canvas, "Right Align", kTextHeight, paint);
-
- paint.setTextAlign(SkPaint::kCenter_Align);
- drawTestCase(canvas, "Center Align", 4 * kTextHeight, paint);
-
- paint.setTextAlign(SkPaint::kLeft_Align);
- drawTestCase(canvas, "Left Align", 7 * kTextHeight, paint);
-}
-
-void drawTestCase(SkCanvas* canvas, const char* text, SkScalar y, const SkPaint& paint) {
- SkScalar widths[kMaxStringLength];
- SkScalar posX[kMaxStringLength];
- SkPoint pos[kMaxStringLength];
- int length = SkToInt(strlen(text));
- SkASSERT(length <= kMaxStringLength);
-
- paint.getTextWidths(text, length, widths);
-
- float originX;
- switch (paint.getTextAlign()) {
- case SkPaint::kRight_Align: originX = 1; break;
- case SkPaint::kCenter_Align: originX = 0.5f; break;
- case SkPaint::kLeft_Align: originX = 0; break;
- default: SK_ABORT("Invalid paint origin"); return;
- }
-
- float x = kTextHeight;
- for (int i = 0; i < length; ++i) {
- posX[i] = x + originX * widths[i];
- pos[i].set(posX[i], i ? pos[i - 1].y() + 3 : y + kTextHeight);
- x += widths[i];
- }
-
- canvas->drawPosTextH(text, length, posX, y, paint);
- canvas->drawPosText(text, length, pos, paint);
-}