Add scaled emoji GM.

Draws string at four scales to test each method of emoji rendering.

Bug: skia:7562
Change-Id: Id28fea702aef36e3d2d5a9ca24c1685517979b3c
Reviewed-on: https://skia-review.googlesource.com/107020
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Jim Van Verth 2018-02-13 15:21:34 -05:00 committed by Skia Commit-Bot
parent 4f9647efb7
commit 1b12545a9c
2 changed files with 72 additions and 0 deletions

71
gm/scaledemoji.cpp Normal file
View File

@ -0,0 +1,71 @@
/*
* Copyright 2018 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 "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
#include "SkStream.h"
#include "SkTypeface.h"
namespace skiagm {
class ScaledEmojiGM : public GM {
public:
ScaledEmojiGM() { }
protected:
struct EmojiFont {
sk_sp<SkTypeface> fTypeface;
const char* fText;
} fEmojiFont;
void onOnceBeforeDraw() override {
fEmojiFont.fTypeface = sk_tool_utils::emoji_typeface();
fEmojiFont.fText = sk_tool_utils::emoji_sample_text();
}
SkString onShortName() override {
SkString name("scaledemoji");
name.append(sk_tool_utils::platform_font_manager());
return name;
}
SkISize onISize() override { return SkISize::Make(1200, 1200); }
void onDraw(SkCanvas* canvas) override {
canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorGRAY));
SkPaint paint;
paint.setTypeface(fEmojiFont.fTypeface);
const char* text = fEmojiFont.fText;
// draw text at different point sizes
// Testing GPU bitmap path, SDF path with no scaling,
// SDF path with scaling, path rendering with scaling
SkPaint::FontMetrics metrics;
SkScalar y = 0;
for (SkScalar textSize : { 70, 180, 270, 340 }) {
paint.setTextSize(textSize);
paint.getFontMetrics(&metrics);
y += -metrics.fAscent;
canvas->drawString(text, 10, y, paint);
y += metrics.fDescent + metrics.fLeading;
}
}
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new ScaledEmojiGM;)
}

View File

@ -262,6 +262,7 @@ gm_sources = [
"$_gm/samplerstress.cpp",
"$_gm/savelayer.cpp",
"$_gm/scaledstrokes.cpp",
"$_gm/scaledemoji.cpp",
"$_gm/shadermaskfilter.cpp",
"$_gm/shadertext.cpp",
"$_gm/shadertext2.cpp",