Skip to content

Commit c8607e7

Browse files
esum26Chromium LUCI CQ
authored and
Chromium LUCI CQ
committed
Set global SkFontConfigInterface in the gpu process.
Why: It's a combination of 2 things: * ChromeOS is beginning to use Skottie for some of its animations. The animation may contain text embedded in it, in addition to specifying the font for said text. * ChromeOS uses OOP (out-of-process) raster, meaning all raster operations happen in the GPU process. More specifically in this case, a skottie animation object is instantiated in the GPU process and we call skottie::Animation::render() in it. As such, the GPU process must somehow have access to the font cache, or Skottie fails to load the appropriate font typeface when rendering. This follows the exact same pattern as what's done in the render process (see renderer_blink_platform_impl.cc) and utility process by connecting to the font service that's hosted in the browser process. Bug: b:217271404 Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome Change-Id: I4d6dfd1d96f8e412a21c71c0391401848efd4da3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3464510 Reviewed-by: Zhenyao Mo <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Commit-Queue: Eric Sum <[email protected]> Cr-Commit-Position: refs/heads/main@{#972745}
1 parent b29bc55 commit c8607e7

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

content/browser/gpu/gpu_process_host_receiver_bindings.cc

+14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "content/browser/gpu/gpu_process_host.h"
88

99
#include "build/build_config.h"
10+
#include "build/chromeos_buildflags.h"
1011
#include "content/public/browser/browser_task_traits.h"
1112
#include "content/public/browser/browser_thread.h"
1213
#include "content/public/browser/content_browser_client.h"
@@ -19,6 +20,11 @@
1920
#include "media/mojo/mojom/android_overlay.mojom.h"
2021
#endif
2122

23+
#if BUILDFLAG(IS_CHROMEOS_ASH)
24+
#include "components/services/font/public/mojom/font_service.mojom.h" // nogncheck
25+
#include "content/browser/font_service.h" // nogncheck
26+
#endif
27+
2228
namespace content {
2329

2430
namespace {
@@ -43,6 +49,14 @@ void GpuProcessHost::BindHostReceiver(
4349
}
4450
#endif
4551

52+
#if BUILDFLAG(IS_CHROMEOS_ASH)
53+
if (auto font_receiver =
54+
generic_receiver.As<font_service::mojom::FontService>()) {
55+
ConnectToFontService(std::move(font_receiver));
56+
return;
57+
}
58+
#endif
59+
4660
GetContentClient()->browser()->BindGpuHostReceiver(
4761
std::move(generic_receiver));
4862
}

content/gpu/BUILD.gn

+7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ target(link_target_type, "gpu_sources") {
9999
]
100100
}
101101

102+
if (is_chromeos_ash) {
103+
deps += [
104+
"//components/services/font/public/cpp",
105+
"//components/services/font/public/mojom",
106+
]
107+
}
108+
102109
if (is_android) {
103110
deps += [
104111
"//components/tracing:graphics_provider",

content/gpu/gpu_child_thread.cc

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "base/task/sequenced_task_runner.h"
2222
#include "base/threading/thread_checker.h"
2323
#include "build/build_config.h"
24+
#include "build/chromeos_buildflags.h"
2425
#include "content/child/child_process.h"
2526
#include "content/common/process_visibility_tracker.h"
2627
#include "content/gpu/browser_exposed_gpu_interfaces.h"
@@ -50,6 +51,13 @@
5051
#include "media/mojo/clients/mojo_android_overlay.h"
5152
#endif
5253

54+
#if BUILDFLAG(IS_CHROMEOS_ASH)
55+
#include "components/services/font/public/cpp/font_loader.h" // nogncheck
56+
#include "components/services/font/public/mojom/font_service.mojom.h" // nogncheck
57+
#include "third_party/skia/include/core/SkRefCnt.h"
58+
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
59+
#endif
60+
5361
namespace content {
5462
namespace {
5563

@@ -140,6 +148,15 @@ void GpuChildThread::Init(const base::Time& process_start_time) {
140148
}
141149
#endif
142150

151+
#if BUILDFLAG(IS_CHROMEOS_ASH)
152+
if (!in_process_gpu()) {
153+
mojo::PendingRemote<font_service::mojom::FontService> font_service;
154+
BindHostReceiver(font_service.InitWithNewPipeAndPassReceiver());
155+
SkFontConfigInterface::SetGlobal(
156+
sk_make_sp<font_service::FontLoader>(std::move(font_service)));
157+
}
158+
#endif
159+
143160
memory_pressure_listener_ = std::make_unique<base::MemoryPressureListener>(
144161
FROM_HERE, base::BindRepeating(&GpuChildThread::OnMemoryPressure,
145162
base::Unretained(this)));

0 commit comments

Comments
 (0)