aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2019-01-27 22:08:12 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-01-28 13:56:24 +0000
commitfd0bba81c0b2b38b8462f8ad91ec1a22b606d490 (patch)
treef03e698f4b375855eaaf95de133888c46fb1427f /tests
parent7f54fdc434cd5ba155ec486ee2c27f3a542b08c9 (diff)
downloadskqp-fd0bba81c0b2b38b8462f8ad91ec1a22b606d490.tar.gz
Revert "Revert "remove legacy code for text attributes on paint""
This reverts commit fb0e2aa8fdefb30d15372a16ddb0ecb919efd28e. Bug: skia: Change-Id: I16bf3c999233f7498a4d76dfbcfb26be725e88f5 Reviewed-on: https://skia-review.googlesource.com/c/187261 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com> Auto-Submit: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/FontObjTest.cpp93
-rw-r--r--tests/PaintTest.cpp53
2 files changed, 2 insertions, 144 deletions
diff --git a/tests/FontObjTest.cpp b/tests/FontObjTest.cpp
deleted file mode 100644
index 6ddb9f3a64..0000000000
--- a/tests/FontObjTest.cpp
+++ /dev/null
@@ -1,93 +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 "SkFont.h"
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "Test.h"
-
-#ifdef SK_SUPPORT_LEGACY_PAINT_TEXTMEASURE
-static void test_fontmetrics(skiatest::Reporter* reporter,
- const SkPaint& paint, const SkFont& font) {
- SkFontMetrics fm0, fm1;
- SkScalar h0 = paint.getFontMetrics(&fm0);
- SkScalar h1 = font.getMetrics(&fm1);
-
- REPORTER_ASSERT(reporter, h0 == h1);
-#define CMP(field) REPORTER_ASSERT(reporter, fm0.field == fm1.field)
- CMP(fFlags);
- CMP(fTop);
- CMP(fAscent);
- CMP(fDescent);
- CMP(fBottom);
- CMP(fLeading);
-#undef CMP
-}
-
-DEF_TEST(FontObj_test_cachedfont, reporter) {
- SkPaint paint;
- char txt[] = "long .text .with .lots .of.dots.";
- unsigned mask = SkPaint::kAntiAlias_Flag |
- SkPaint::kFakeBoldText_Flag |
- SkPaint::kLinearText_Flag |
- SkPaint::kSubpixelText_Flag |
- SkPaint::kLCDRenderText_Flag |
- SkPaint::kEmbeddedBitmapText_Flag |
- SkPaint::kAutoHinting_Flag;
-
- paint.setStrokeWidth(2);
- {
- for (unsigned flags = 0; flags <= 0xFFF; ++flags) {
- if (flags & ~mask) {
- continue;
- }
- paint.setFlags(flags);
- for (int hint = 0; hint <= 3; ++hint) {
- paint.setHinting((SkFontHinting)hint);
- {
- for (auto style : { SkPaint::kFill_Style, SkPaint::kStroke_Style}) {
- paint.setStyle(style);
-
- const SkFont font(SkFont::LEGACY_ExtractFromPaint(paint));
- test_fontmetrics(reporter, paint, font);
-
- SkRect pbounds, fbounds;
-
- // Requesting the bounds forces a generateMetrics call.
- SkScalar pwidth = paint.measureText(txt, strlen(txt), &pbounds);
- SkScalar fwidth = font.measureText(txt, strlen(txt), kUTF8_SkTextEncoding,
- &fbounds, &paint);
- REPORTER_ASSERT(reporter, pwidth == fwidth);
- REPORTER_ASSERT(reporter, pbounds == fbounds);
- }
- }
- }
- }
- }
-}
-#endif // SK_SUPPORT_LEGACY_PAINT_TEXTMEASURE
-
-#ifdef SK_SUPPORT_LEGACY_PAINT_FONT_FIELDS
-DEF_TEST(FontObj_test_aa_hinting, reporter) {
- SkPaint paint;
-
- for (bool aa : {false, true}) {
- paint.setAntiAlias(aa);
- for (int hint = 0; hint <= 3; ++hint) {
- paint.setHinting((SkFontHinting)hint);
- SkFont font = SkFont::LEGACY_ExtractFromPaint(paint);
-
- SkPaint p2;
- font.LEGACY_applyToPaint(&p2);
- REPORTER_ASSERT(reporter, paint.isAntiAlias() == p2.isAntiAlias());
- REPORTER_ASSERT(reporter, paint.getHinting() == p2.getHinting());
- }
- }
-}
-#endif
-
-// need tests for SkStrSearch
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index c34dc765f9..ae9d3d5475 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -267,10 +267,6 @@ DEF_TEST(Paint_regression_measureText, reporter) {
DEF_TEST(Paint_MoreFlattening, r) {
SkPaint paint;
paint.setColor(0x00AABBCC);
-#ifdef SK_SUPPORT_LEGACY_PAINT_FONT_FIELDS
- paint.setTextScaleX(1.0f); // Default value, ignored.
- paint.setTextSize(19);
-#endif
paint.setBlendMode(SkBlendMode::kModulate);
paint.setLooper(nullptr); // Default value, ignored.
@@ -304,18 +300,10 @@ DEF_TEST(Paint_getHash, r) {
paint.setColor(SK_ColorBLACK); // Reset to default value.
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
-#ifdef SK_SUPPORT_LEGACY_PAINT_FONT_FIELDS
- // SkTypeface is the first field we hash, so test it specially.
- paint.setTypeface(SkTypeface::MakeDefault());
- REPORTER_ASSERT(r, paint.getHash() != defaultHash);
- paint.setTypeface(nullptr);
- REPORTER_ASSERT(r, paint.getHash() == defaultHash);
-#endif
-
// This is part of fBitfields, the last field we hash.
- paint.setHinting(kSlight_SkFontHinting);
+ paint.setBlendMode(SkBlendMode::kSrc);
REPORTER_ASSERT(r, paint.getHash() != defaultHash);
- paint.setHinting(kNormal_SkFontHinting);
+ paint.setBlendMode(SkBlendMode::kSrcOver);
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
}
@@ -345,43 +333,6 @@ DEF_TEST(Paint_nothingToDraw, r) {
REPORTER_ASSERT(r, !paint.nothingToDraw());
}
-#ifdef SK_SUPPORT_LEGACY_PAINT_TEXTMEASURE
-DEF_TEST(Paint_getwidths, r) {
- SkPaint paint;
- const char text[] = "Hamburgefons!@#!#23425,./;'[]";
- int count = paint.countText(text, strlen(text));
- SkAutoTArray<uint16_t> glyphStorage(count * 2);
- uint16_t* glyphs = glyphStorage.get();
-
- (void)paint.textToGlyphs(text, strlen(text), glyphs);
- paint.setTextEncoding(kGlyphID_SkTextEncoding);
-
- SkAutoTArray<SkScalar> widthStorage(count * 2);
- SkScalar* widths = widthStorage.get();
- SkAutoTArray<SkRect> rectStorage(count * 2);
- SkRect* bounds = rectStorage.get();
-
- for (bool subpix : { false, true }) {
- paint.setSubpixelText(subpix);
- for (auto hint : { kNo_SkFontHinting, kSlight_SkFontHinting, kNormal_SkFontHinting, kFull_SkFontHinting}) {
- paint.setHinting(hint);
- for (auto size : { 1.0f, 12.0f, 100.0f }) {
- paint.setTextSize(size);
- paint.getTextWidths(glyphs, count * 2, widths, bounds);
-
- SkFont font = SkFont::LEGACY_ExtractFromPaint(paint);
- font.getWidths(glyphs, count, widths + count, bounds + count);
-
- for (int i = 0; i < count; ++i) {
- REPORTER_ASSERT(r, widths[i] == widths[i + count]);
- REPORTER_ASSERT(r, bounds[i] == bounds[i + count]);
- }
- }
- }
- }
-}
-#endif
-
DEF_TEST(Font_getpos, r) {
SkFont font;
const char text[] = "Hamburgefons!@#!#23425,./;'[]";