Move --nativeFonts to CommonFlags file
Also noticed while trying to build GMs in WASM with Bazel. Change-Id: I33d467a0da0893c1a5e376f4fd1a6096dad48af3 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459198 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
f541ddf785
commit
237dd2d94d
7
BUILD.gn
7
BUILD.gn
@ -1836,6 +1836,10 @@ if (skia_enable_tools) {
|
||||
sources = [ "tools/flags/CommonFlagsImages.cpp" ]
|
||||
deps = [ ":flags" ]
|
||||
}
|
||||
test_lib("common_flags_fontmgr") {
|
||||
sources = [ "tools/flags/CommonFlagsFontMgr.cpp" ]
|
||||
deps = [ ":flags" ]
|
||||
}
|
||||
test_lib("common_flags_aa") {
|
||||
sources = [ "tools/flags/CommonFlagsAA.cpp" ]
|
||||
deps = [ ":flags" ]
|
||||
@ -2119,6 +2123,7 @@ if (skia_enable_tools) {
|
||||
]
|
||||
deps = [
|
||||
":common_flags_aa",
|
||||
":common_flags_fontmgr",
|
||||
":common_flags_gpu",
|
||||
":flags",
|
||||
":gm",
|
||||
@ -2145,6 +2150,7 @@ if (skia_enable_tools) {
|
||||
deps = [
|
||||
":common_flags_aa",
|
||||
":common_flags_config",
|
||||
":common_flags_fontmgr",
|
||||
":common_flags_gpu",
|
||||
":common_flags_images",
|
||||
":flags",
|
||||
@ -2778,6 +2784,7 @@ if (skia_enable_tools) {
|
||||
libs = []
|
||||
|
||||
deps = [
|
||||
":common_flags_fontmgr",
|
||||
":common_flags_gpu",
|
||||
":flags",
|
||||
":gm",
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "tools/ToolUtils.h"
|
||||
#include "tools/flags/CommonFlags.h"
|
||||
#include "tools/flags/CommonFlagsConfig.h"
|
||||
#include "tools/flags/CommonFlagsFontMgr.h"
|
||||
#include "tools/ios_utils.h"
|
||||
#include "tools/trace/ChromeTracingTracer.h"
|
||||
#include "tools/trace/EventTracingPriv.h"
|
||||
@ -1488,7 +1489,7 @@ int main(int argc, char** argv) {
|
||||
setbuf(stdout, nullptr);
|
||||
setup_crash_handler();
|
||||
|
||||
ToolUtils::SetDefaultFontMgr();
|
||||
CommonFlags::SetDefaultFontMgr();
|
||||
SetAnalyticAAFromCommonFlags();
|
||||
|
||||
gSkForceRasterPipelineBlitter = FLAGS_forceRasterPipeline;
|
||||
|
@ -23,11 +23,8 @@
|
||||
#include "include/ports/SkTypeface_win.h"
|
||||
#include "include/private/SkColorData.h"
|
||||
#include "include/private/SkFloatingPoint.h"
|
||||
#include "src/core/SkFontMgrPriv.h"
|
||||
#include "src/core/SkFontPriv.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
#include "tools/fonts/TestFontMgr.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@ -471,23 +468,4 @@ sk_sp<SkSurface> makeSurface(SkCanvas* canvas,
|
||||
return surf;
|
||||
}
|
||||
|
||||
static DEFINE_bool(nativeFonts, true,
|
||||
"If true, use native font manager and rendering. "
|
||||
"If false, fonts will draw as portably as possible.");
|
||||
#if defined(SK_BUILD_FOR_WIN)
|
||||
static DEFINE_bool(gdi, false,
|
||||
"Use GDI instead of DirectWrite for font rendering.");
|
||||
#endif
|
||||
|
||||
void SetDefaultFontMgr() {
|
||||
if (!FLAGS_nativeFonts) {
|
||||
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
|
||||
}
|
||||
#if defined(SK_BUILD_FOR_WIN)
|
||||
if (FLAGS_gdi) {
|
||||
gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace ToolUtils
|
||||
|
@ -75,12 +75,6 @@ static inline sk_sp<SkTypeface> create_portable_typeface() {
|
||||
return create_portable_typeface(nullptr, SkFontStyle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on portable (--nonativeFonts) or GDI font rendering (--gdi).
|
||||
*/
|
||||
void SetDefaultFontMgr();
|
||||
|
||||
|
||||
void get_text_path(const SkFont&,
|
||||
const void* text,
|
||||
size_t length,
|
||||
|
29
tools/flags/CommonFlagsFontMgr.cpp
Normal file
29
tools/flags/CommonFlagsFontMgr.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/core/SkFontMgrPriv.h"
|
||||
#include "tools/flags/CommonFlagsFontMgr.h"
|
||||
#include "tools/fonts/TestFontMgr.h"
|
||||
|
||||
#if defined(SK_BUILD_FOR_WIN)
|
||||
#include "include/ports/SkTypeface_win.h"
|
||||
#endif
|
||||
|
||||
namespace CommonFlags {
|
||||
|
||||
void SetDefaultFontMgr() {
|
||||
if (!FLAGS_nativeFonts) {
|
||||
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
|
||||
}
|
||||
#if defined(SK_BUILD_FOR_WIN)
|
||||
if (FLAGS_gdi) {
|
||||
gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
26
tools/flags/CommonFlagsFontMgr.h
Normal file
26
tools/flags/CommonFlagsFontMgr.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
|
||||
namespace CommonFlags {
|
||||
/**
|
||||
* Turn on portable (--nonativeFonts) or GDI font rendering (--gdi).
|
||||
*/
|
||||
static DEFINE_bool(nativeFonts,
|
||||
true,
|
||||
"If true, use native font manager and rendering. "
|
||||
"If false, fonts will draw as portably as possible.");
|
||||
#if defined(SK_BUILD_FOR_WIN)
|
||||
static DEFINE_bool(gdi, false, "Use GDI instead of DirectWrite for font rendering.");
|
||||
#endif
|
||||
|
||||
void SetDefaultFontMgr();
|
||||
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
#include "tools/ToolUtils.h"
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
#include "tools/flags/CommonFlags.h"
|
||||
#include "tools/flags/CommonFlagsFontMgr.h"
|
||||
#include "tools/gpu/BackendSurfaceFactory.h"
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
#include "tools/gpu/MemoryCache.h"
|
||||
@ -392,7 +393,7 @@ int main(int argc, char** argv) {
|
||||
gSkVMJITViaDylib = FLAGS_dylib;
|
||||
|
||||
initializeEventTracingForTools();
|
||||
ToolUtils::SetDefaultFontMgr();
|
||||
CommonFlags::SetDefaultFontMgr();
|
||||
SetAnalyticAAFromCommonFlags();
|
||||
|
||||
GrContextOptions baseOptions;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "tools/ToolUtils.h"
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
#include "tools/flags/CommonFlags.h"
|
||||
#include "tools/flags/CommonFlagsFontMgr.h"
|
||||
#include "tools/trace/EventTracingPriv.h"
|
||||
#include "tools/viewer/BisectSlide.h"
|
||||
#include "tools/viewer/GMSlide.h"
|
||||
@ -374,7 +375,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
|
||||
gSkVMAllowJIT = FLAGS_jit;
|
||||
gSkVMJITViaDylib = FLAGS_dylib;
|
||||
|
||||
ToolUtils::SetDefaultFontMgr();
|
||||
CommonFlags::SetDefaultFontMgr();
|
||||
|
||||
initializeEventTracingForTools();
|
||||
static SkTaskGroup::Enabler kTaskGroupEnabler(FLAGS_threads);
|
||||
|
Loading…
Reference in New Issue
Block a user