Commit c7df6fa7 authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Disable subpixel positioning on chrome os

Subpixel positioning was needed because text layout was performed at 1x
device scale factor and then rastered to the final display device scale
factor leading to glyph artifacts and inconsistent glyph positioning.
With pixel canvas enabled on chrome os, the text layout is now always
performed at the final display device scale factor. This, coupled with
the replacement of ui scale with display zoom, the text on Chrome OS
is now always rastered with the correct glyph positioning and it no
longer requires subpixel positioning.

Updates unittests.

Bug: 835187,824154,716662
Change-Id: Ibcf6314321777da81335769927d65d52911855df
Component: Text render, subpixel positioning, font
Reviewed-on: https://chromium-review.googlesource.com/1027005Reviewed-by: default avatarDan Erat <derat@chromium.org>
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553738}
parent a3152c45
...@@ -3376,97 +3376,8 @@ class FontTestHelper : public AshTestBase { ...@@ -3376,97 +3376,8 @@ class FontTestHelper : public AshTestBase {
DISALLOW_COPY_AND_ASSIGN(FontTestHelper); DISALLOW_COPY_AND_ASSIGN(FontTestHelper);
}; };
bool IsTextSubpixelPositioningEnabled() {
gfx::FontRenderParams params =
gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
return params.subpixel_positioning;
}
gfx::FontRenderParams::Hinting GetFontHintingParams() {
gfx::FontRenderParams params =
gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
return params.hinting;
}
} // namespace } // namespace
using DisplayManagerFontTest = testing::Test;
TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) {
FontTestHelper helper(1.0f, FontTestHelper::INTERNAL);
ASSERT_DOUBLE_EQ(
1.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) {
FontTestHelper helper(2.0f, FontTestHelper::INTERNAL);
ASSERT_DOUBLE_EQ(
2.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
display::test::DisplayManagerTestApi(helper.display_manager())
.SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
2.0f);
ASSERT_DOUBLE_EQ(
1.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) {
FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL);
ASSERT_DOUBLE_EQ(
1.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) {
FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL);
ASSERT_DOUBLE_EQ(
1.25f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) {
FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL);
ASSERT_DOUBLE_EQ(
2.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerFontTest,
TextSubpixelPositioningWithDsf125InternalWithScaling) {
FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
ASSERT_DOUBLE_EQ(
1.0f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
display::test::DisplayManagerTestApi(helper.display_manager())
.SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
0.8f);
ASSERT_DOUBLE_EQ(
1.25f,
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
}
TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) { TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) {
int64_t id = display_manager()->GetDisplayAt(0).id(); int64_t id = display_manager()->GetDisplayAt(0).id();
display_manager()->RegisterDisplayProperty( display_manager()->RegisterDisplayProperty(
......
...@@ -279,7 +279,11 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, ...@@ -279,7 +279,11 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
params.subpixel_positioning = false; params.subpixel_positioning = false;
} else { } else {
#if !defined(OS_CHROMEOS)
params.subpixel_positioning = actual_query.device_scale_factor > 1.0f; params.subpixel_positioning = actual_query.device_scale_factor > 1.0f;
#else
params.subpixel_positioning = false;
#endif // !defined(OS_CHROMEOS)
// To enable subpixel positioning, we need to disable hinting. // To enable subpixel positioning, we need to disable hinting.
if (params.subpixel_positioning) if (params.subpixel_positioning)
......
...@@ -310,7 +310,11 @@ TEST_F(FontRenderParamsTest, ForceSubpixelPositioning) { ...@@ -310,7 +310,11 @@ TEST_F(FontRenderParamsTest, ForceSubpixelPositioning) {
FontRenderParams params = FontRenderParams params =
GetFontRenderParams(FontRenderParamsQuery(), NULL); GetFontRenderParams(FontRenderParamsQuery(), NULL);
EXPECT_TRUE(params.antialiasing); EXPECT_TRUE(params.antialiasing);
#if !defined(OS_CHROMEOS)
EXPECT_TRUE(params.subpixel_positioning); EXPECT_TRUE(params.subpixel_positioning);
#else
EXPECT_FALSE(params.subpixel_positioning);
#endif // !defined(OS_CHROMEOS)
SetFontRenderParamsDeviceScaleFactor(1.0f); SetFontRenderParamsDeviceScaleFactor(1.0f);
} }
} }
......
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