Commit 13e6126c authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Remove incorrect code that disable font smoothing

This CL is removing the code that is forcing the font smoothing.
The setting is system-wide and can't be used with other unittests.

see: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa
  "Retrieves or sets the value of one of the system-wide parameters.
   This function can also update the user profile while setting a
   parameter."

The unittests should be able to detect both states if needed.

R=robliao@chromium.org,
CC=tapted@chromium.org

Bug: 759870,953293
Change-Id: I2f79320daef4bcbdade6076960f4a13f235bd3f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570527
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657348}
parent 3b4e6563
......@@ -73,6 +73,19 @@ enum {
UNDERLINE_MASK = 1 << TEXT_STYLE_UNDERLINE,
};
bool IsFontsSmoothingEnabled() {
#if defined(OS_WIN)
BOOL antialiasing = TRUE;
BOOL result = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &antialiasing, 0);
if (result == FALSE) {
ADD_FAILURE() << "Failed to retrieve font aliasing configuration.";
}
return antialiasing;
#else
return true;
#endif
}
// Checks whether |range| contains |index|. This is not the same as calling
// range.Contains(Range(index)), which returns true if |index| == |range.end()|.
bool IndexInRange(const Range& range, size_t index) {
......@@ -4496,6 +4509,11 @@ TEST_F(RenderTextTest, StylePropagated) {
// Ensure the painter adheres to RenderText::subpixel_rendering_suppressed().
TEST_F(RenderTextTest, SubpixelRenderingSuppressed) {
ASSERT_TRUE(IsFontsSmoothingEnabled())
<< "The test requires that fonts smoothing (anti-aliasing) is activated. "
"If this assert is failing you need to manually activate the flag in "
"your system fonts settings.";
RenderText* render_text = GetRenderText();
render_text->SetText(UTF8ToUTF16("x"));
......
......@@ -19,7 +19,6 @@
#if defined(OS_WIN)
#include <windows.h>
#include <winuser.h>
#include "ui/gfx/win/direct_write.h"
#endif
......@@ -32,9 +31,6 @@ namespace {
class GfxTestSuite : public base::TestSuite {
public:
GfxTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {
#if defined(OS_WIN)
reset_antialiasing_on_shutdown_ = false;
#endif
}
protected:
......@@ -53,34 +49,15 @@ class GfxTestSuite : public base::TestSuite {
#if defined(OS_WIN)
gfx::win::InitializeDirectWrite();
// Force antialiasing to true if DirectWrite is enabled for font metrics.
// With antialiasing off, Skia returns GDI compatible metrics which are
// larger by 1-2 points which cause some tests to fail.
// TODO(ananta): Investigate and fix.
BOOL antialiasing = TRUE;
SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &antialiasing, 0);
if (!antialiasing) {
SystemParametersInfo(SPI_SETFONTSMOOTHING, TRUE, NULL, 0);
reset_antialiasing_on_shutdown_ = true;
}
#endif
}
void Shutdown() override {
ui::ResourceBundle::CleanupSharedInstance();
base::TestSuite::Shutdown();
#if defined(OS_WIN)
if (reset_antialiasing_on_shutdown_)
SystemParametersInfo(SPI_SETFONTSMOOTHING, FALSE, NULL, 0);
#endif
}
private:
#if defined(OS_WIN)
// Set to true if we forced antialiasing to true on Windows for the
// duration of the test. We reset antialiasing back on shutdown
bool reset_antialiasing_on_shutdown_;
#endif
DISALLOW_COPY_AND_ASSIGN(GfxTestSuite);
};
......
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