OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_layout_store.h" | 10 #include "ash/display/display_layout_store.h" |
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 NOTREACHED(); | 1565 NOTREACHED(); |
1566 } | 1566 } |
1567 | 1567 |
1568 private: | 1568 private: |
1569 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); | 1569 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); |
1570 }; | 1570 }; |
1571 | 1571 |
1572 | 1572 |
1573 bool IsTextSubpixelPositioningEnabled() { | 1573 bool IsTextSubpixelPositioningEnabled() { |
1574 gfx::FontRenderParams params = | 1574 gfx::FontRenderParams params = |
1575 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); | 1575 gfx::GetCurrentFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); |
1576 return params.subpixel_positioning; | 1576 return params.subpixel_positioning; |
1577 } | 1577 } |
1578 | 1578 |
| 1579 gfx::FontRenderParams::Hinting GetFontHintingParams() { |
| 1580 gfx::FontRenderParams params = |
| 1581 gfx::GetCurrentFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); |
| 1582 return params.hinting; |
| 1583 } |
| 1584 |
1579 } // namespace | 1585 } // namespace |
1580 | 1586 |
1581 typedef testing::Test DisplayManagerFontTest; | 1587 typedef testing::Test DisplayManagerFontTest; |
1582 | 1588 |
1583 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { | 1589 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { |
1584 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); | 1590 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); |
1585 ASSERT_DOUBLE_EQ( | 1591 ASSERT_DOUBLE_EQ( |
1586 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1592 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1587 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1593 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1594 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1588 } | 1595 } |
1589 | 1596 |
1590 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { | 1597 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { |
1591 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1598 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
1592 ASSERT_DOUBLE_EQ( | 1599 ASSERT_DOUBLE_EQ( |
1593 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1600 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1594 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 1601 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1602 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1595 } | 1603 } |
1596 | 1604 |
1597 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { | 1605 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { |
1598 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); | 1606 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); |
1599 ASSERT_DOUBLE_EQ( | 1607 ASSERT_DOUBLE_EQ( |
1600 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1608 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1601 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 1609 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1610 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1611 |
| 1612 Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
| 1613 Shell::GetScreen()->GetPrimaryDisplay().id(), 2.0f); |
| 1614 |
| 1615 ASSERT_DOUBLE_EQ( |
| 1616 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1617 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1618 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1602 } | 1619 } |
1603 | 1620 |
1604 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { | 1621 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { |
1605 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); | 1622 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); |
1606 ASSERT_DOUBLE_EQ( | 1623 ASSERT_DOUBLE_EQ( |
1607 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1624 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1608 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1625 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1626 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1609 } | 1627 } |
1610 | 1628 |
1611 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { | 1629 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { |
1612 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); | 1630 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); |
1613 ASSERT_DOUBLE_EQ( | 1631 ASSERT_DOUBLE_EQ( |
1614 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1632 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1615 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1633 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1634 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1616 } | 1635 } |
1617 | 1636 |
1618 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { | 1637 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { |
1619 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); | 1638 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); |
1620 ASSERT_DOUBLE_EQ( | 1639 ASSERT_DOUBLE_EQ( |
1621 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1640 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1622 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1641 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1642 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
1623 } | 1643 } |
1624 | 1644 |
1625 TEST_F(DisplayManagerFontTest, | 1645 TEST_F(DisplayManagerFontTest, |
1626 TextSubpixelPositioningWithDsf125InternalWithScaling) { | 1646 TextSubpixelPositioningWithDsf125InternalWithScaling) { |
1627 DisplayInfo::SetUse125DSFForUIScaling(true); | 1647 DisplayInfo::SetUse125DSFForUIScaling(true); |
1628 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1648 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
1629 ASSERT_DOUBLE_EQ( | 1649 ASSERT_DOUBLE_EQ( |
1630 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1650 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1631 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1651 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1652 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1653 |
| 1654 Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
| 1655 Shell::GetScreen()->GetPrimaryDisplay().id(), 0.8f); |
| 1656 |
| 1657 ASSERT_DOUBLE_EQ( |
| 1658 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1659 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1660 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1661 |
1632 DisplayInfo::SetUse125DSFForUIScaling(false); | 1662 DisplayInfo::SetUse125DSFForUIScaling(false); |
1633 } | 1663 } |
1634 | 1664 |
1635 #endif // OS_CHROMEOS | 1665 #endif // OS_CHROMEOS |
1636 | 1666 |
1637 } // namespace ash | 1667 } // namespace ash |
OLD | NEW |