c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
74 lines
2.0 KiB
C++
74 lines
2.0 KiB
C++
/*
|
|
* 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/gm.h"
|
|
#include "tools/ToolUtils.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkFontMetrics.h"
|
|
#include "include/core/SkStream.h"
|
|
#include "include/core/SkTypeface.h"
|
|
#include "include/private/SkTo.h"
|
|
#include "tools/Resources.h"
|
|
|
|
namespace skiagm {
|
|
class ScaledEmojiRenderingGM : public GM {
|
|
public:
|
|
ScaledEmojiRenderingGM() {}
|
|
|
|
protected:
|
|
sk_sp<SkTypeface> typefaces[4];
|
|
|
|
void onOnceBeforeDraw() override {
|
|
typefaces[0] = MakeResourceAsTypeface("fonts/colr.ttf");
|
|
typefaces[1] = MakeResourceAsTypeface("fonts/sbix.ttf");
|
|
typefaces[2] = MakeResourceAsTypeface("fonts/cbdt.ttf");
|
|
typefaces[3] = ToolUtils::create_portable_typeface("Emoji", SkFontStyle());
|
|
}
|
|
|
|
SkString onShortName() override {
|
|
return SkString("scaledemoji_rendering");
|
|
}
|
|
|
|
SkISize onISize() override { return SkISize::Make(1200, 1200); }
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
|
|
canvas->drawColor(SK_ColorGRAY);
|
|
SkScalar y = 0;
|
|
|
|
for (const auto& typeface: typefaces) {
|
|
SkFont font(typeface);
|
|
font.setEdging(SkFont::Edging::kAlias);
|
|
|
|
SkPaint paint;
|
|
const char* text = ToolUtils::emoji_sample_text();
|
|
SkFontMetrics metrics;
|
|
|
|
for (SkScalar textSize : { 70, 150 }) {
|
|
font.setSize(textSize);
|
|
font.getMetrics(&metrics);
|
|
// All typefaces should support subpixel mode
|
|
font.setSubpixel(true);
|
|
y += -metrics.fAscent;
|
|
|
|
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding,
|
|
10, y, font, paint);
|
|
y += metrics.fDescent + metrics.fLeading;
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_GM(return new ScaledEmojiRenderingGM;)
|
|
}
|