Commit b81742a8 authored by jbudorick's avatar jbudorick Committed by Commit bot

[Android] Stop using skia globals for font overriding in layout tests.

The layout tests have been using globals in skia to provide custom
font files. Skia would like to get rid of those globals. This change
adds a chromium-side SkFontMgr::Factory for the layout tests to use
instead.

BUG=chromium:567947,skia:2817

Review-Url: https://codereview.chromium.org/2599933002
Cr-Commit-Position: refs/heads/master@{#441404}
parent cee1ec7c
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "content/shell/app/blink_test_platform_support.h" #include "content/shell/app/blink_test_platform_support.h"
#include "skia/ext/fontmgr_default_android.h"
#include "third_party/skia/include/ports/SkFontMgr_android.h" #include "third_party/skia/include/ports/SkFontMgr_android.h"
namespace { namespace {
...@@ -33,9 +34,14 @@ bool CheckLayoutSystemDeps() { ...@@ -33,9 +34,14 @@ bool CheckLayoutSystemDeps() {
bool BlinkTestPlatformInitialize() { bool BlinkTestPlatformInitialize() {
// Initialize Skia with the font configuration files crafted for layout tests. // Initialize Skia with the font configuration files crafted for layout tests.
SkUseTestFontConfigFile( SkFontMgr_Android_CustomFonts custom;
kPrimaryFontConfig, kFallbackFontConfig, kFontDirectory); custom.fSystemFontUse = SkFontMgr_Android_CustomFonts::kOnlyCustom;
custom.fBasePath = kFontDirectory;
custom.fFontsXml = kPrimaryFontConfig;
custom.fFallbackFontsXml = kFallbackFontConfig;
custom.fIsolated = false;
SetDefaultSkiaFactory(SkFontMgr_New_Android(&custom));
return true; return true;
} }
......
...@@ -200,6 +200,7 @@ component("skia") { ...@@ -200,6 +200,7 @@ component("skia") {
"ext/benchmarking_canvas.cc", "ext/benchmarking_canvas.cc",
"ext/convolver.cc", "ext/convolver.cc",
"ext/event_tracer_impl.cc", "ext/event_tracer_impl.cc",
"ext/fontmgr_default_android.cc",
"ext/fontmgr_default_linux.cc", "ext/fontmgr_default_linux.cc",
"ext/fontmgr_default_win.cc", "ext/fontmgr_default_win.cc",
"ext/google_logging.cc", "ext/google_logging.cc",
...@@ -245,7 +246,6 @@ component("skia") { ...@@ -245,7 +246,6 @@ component("skia") {
"//third_party/skia/src/ports/SkFontHost_win.cpp", "//third_party/skia/src/ports/SkFontHost_win.cpp",
"//third_party/skia/src/ports/SkFontMgr_FontConfigInterface.cpp", "//third_party/skia/src/ports/SkFontMgr_FontConfigInterface.cpp",
"//third_party/skia/src/ports/SkFontMgr_android.cpp", "//third_party/skia/src/ports/SkFontMgr_android.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_parser.cpp", "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
"//third_party/skia/src/ports/SkFontMgr_win_dw.cpp", "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
"//third_party/skia/src/ports/SkGlobalInitialization_default.cpp", "//third_party/skia/src/ports/SkGlobalInitialization_default.cpp",
...@@ -339,13 +339,6 @@ component("skia") { ...@@ -339,13 +339,6 @@ component("skia") {
"//third_party/skia/src/ports/SkTypeface_win_dw.cpp", "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
] ]
} }
if (!is_android) {
sources -= [
"//third_party/skia/src/ports/SkFontMgr_android.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
]
}
if (!is_mac) { if (!is_mac) {
sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ] sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
} }
...@@ -359,19 +352,15 @@ component("skia") { ...@@ -359,19 +352,15 @@ component("skia") {
] ]
} }
# Add the files for the SkFontMgr_Android. This is used to emulate android
# fonts on linux. See content/zygote/zygote_main_linux.cc
if (is_linux) {
sources += [
"//third_party/skia/src/ports/SkFontMgr_android.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
]
}
if (!is_linux && !is_android) { if (!is_linux && !is_android) {
sources -= [ sources -= [
"//third_party/skia/src/ports/SkFontHost_FreeType.cpp", "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
"//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp", "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
# Retain the files for the SkFontMgr_Android on linux to emulate android
# fonts. See content/zygote/zygote_main_linux.cc
"//third_party/skia/src/ports/SkFontMgr_android.cpp",
"//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
] ]
} }
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "skia/ext/fontmgr_default_android.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkFontMgr_android.h"
namespace {
SkFontMgr* g_default_fontmgr;
} // namespace
SK_API void SetDefaultSkiaFactory(SkFontMgr* fontmgr) {
g_default_fontmgr = fontmgr;
}
SK_API SkFontMgr* SkFontMgr::Factory() {
return g_default_fontmgr ? SkRef(g_default_fontmgr)
: SkFontMgr_New_Android(nullptr);
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKIA_EXT_FONTMGR_DEFAULT_ANDROID_H_
#define SKIA_EXT_FONTMGR_DEFAULT_ANDROID_H_
#include "third_party/skia/include/core/SkTypes.h"
class SkFontMgr;
SK_API void SetDefaultSkiaFactory(SkFontMgr* fontmgr);
#endif // SKIA_EXT_FONTMGR_DEFAULT_ANDROID_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment