0

Disable subpixel font rendering on OLED panel

Default FreeType geometry doesn't work well with OLED's pixel layout.

Bug: 377929384
Test: covered by unittests

Change-Id: I83dfb9085a0538e432e4f75b5ba7ab0589617730
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6221115
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Vincent Chiang <vincentchiang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414495}
This commit is contained in:
Mitsuru Oshima
2025-01-31 17:38:38 -08:00
committed by Chromium LUCI CQ
parent 1393b7b062
commit e13b020555
4 changed files with 39 additions and 2 deletions

@ -40,6 +40,7 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chromeos/ui/base/app_types.h"
#include "chromeos/ui/base/window_properties.h"
@ -50,6 +51,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/display/display.h"
#include "ui/display/display_features.h"
#include "ui/display/display_layout.h"
#include "ui/display/display_layout_builder.h"
#include "ui/display/display_observer.h"
@ -70,6 +72,7 @@
#include "ui/events/devices/touchscreen_device.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/font_render_params_linux.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/wm/core/compound_event_filter.h"
@ -5530,4 +5533,25 @@ TEST_F(DisplayManagerTest, VirtualDisplayUtilAddRemove) {
EXPECT_EQ(screen->GetNumDisplays(), initial_display_count);
}
TEST_F(DisplayManagerTest, FontConfig) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII("form-factor", "CHROMEBOX");
display_manager()->RefreshFontParams();
EXPECT_TRUE(gfx::GetFontRenderParamsSubpixelRenderingEnabledForTesting());
command_line->AppendSwitchASCII("form-factor", "CLAMSHELL");
display_manager()->RefreshFontParams();
EXPECT_FALSE(gfx::GetFontRenderParamsSubpixelRenderingEnabledForTesting());
{
base::test::ScopedFeatureList feature_list_;
feature_list_.InitAndEnableFeature(
display::features::kOledScaleFactorEnabled);
display_manager()->RefreshFontParams();
EXPECT_TRUE(gfx::GetFontRenderParamsSubpixelRenderingEnabledForTesting());
}
display_manager()->RefreshFontParams();
EXPECT_FALSE(gfx::GetFontRenderParamsSubpixelRenderingEnabledForTesting());
}
} // namespace ash

@ -538,10 +538,16 @@ void DisplayManager::UpdateInternalDisplay(
}
void DisplayManager::RefreshFontParams() {
bool force_disable_subpixel_font_rendering = false;
if (features::DoesFormFactorControlSubpixelRendering()) {
gfx::SetForceDisableSubpixelFontRendering(
chromeos::GetFormFactor() != chromeos::form_factor::kClamshell);
force_disable_subpixel_font_rendering =
chromeos::GetFormFactor() != chromeos::form_factor::kClamshell;
}
if (features::IsOledScaleFactorEnabled()) {
force_disable_subpixel_font_rendering = true;
}
gfx::SetForceDisableSubpixelFontRendering(
force_disable_subpixel_font_rendering);
gfx::SetFontRenderParamsDeviceScaleFactor(
chromeos::GetRepresentativeDeviceScaleFactor(active_display_list_));

@ -188,6 +188,10 @@ void SetForceDisableSubpixelFontRendering(bool disable) {
force_disable_subpixel_font_rendering = disable;
}
bool GetFontRenderParamsSubpixelRenderingEnabledForTesting() {
return force_disable_subpixel_font_rendering;
}
FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
std::string* family_out) {
TRACE_EVENT0("fonts", "gfx::GetFontRenderParams");

@ -20,6 +20,9 @@ bool QueryFontconfig(const FontRenderParamsQuery& query,
COMPONENT_EXPORT(GFX)
void SetForceDisableSubpixelFontRendering(bool disable);
COMPONENT_EXPORT(GFX)
bool GetFontRenderParamsSubpixelRenderingEnabledForTesting();
} // namespace gfx
#endif // UI_GFX_FONT_RENDER_PARAMS_LINUX_H_