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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 #elif defined(OS_MACOSX) | 622 #elif defined(OS_MACOSX) |
623 if (base::mac::IsOSLionOrLater()) | 623 if (base::mac::IsOSLionOrLater()) |
624 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 624 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
625 #elif defined(OS_CHROMEOS) | 625 #elif defined(OS_CHROMEOS) |
626 // TODO(oshima): Include 200P only if the device support 200P | 626 // TODO(oshima): Include 200P only if the device support 200P |
627 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 627 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
628 #elif defined(OS_LINUX) && defined(ENABLE_HIDPI) | 628 #elif defined(OS_LINUX) && defined(ENABLE_HIDPI) |
629 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 629 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
630 #elif defined(OS_WIN) | 630 #elif defined(OS_WIN) |
631 bool default_to_100P = true; | 631 bool default_to_100P = true; |
632 if (gfx::IsHighDPIEnabled()) { | 632 // On Windows if the dpi scale is greater than 1.25 on high dpi machines |
633 // On Windows if the dpi scale is greater than 1.25 on high dpi machines | 633 // downscaling from 200 percent looks better than scaling up from 100 |
634 // downscaling from 200 percent looks better than scaling up from 100 | 634 // percent. |
635 // percent. | 635 if (gfx::GetDPIScale() > 1.25) { |
636 if (gfx::GetDPIScale() > 1.25) { | 636 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
637 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 637 default_to_100P = false; |
638 default_to_100P = false; | |
639 } | |
640 } | 638 } |
641 if (default_to_100P) | 639 if (default_to_100P) |
642 supported_scale_factors.push_back(SCALE_FACTOR_100P); | 640 supported_scale_factors.push_back(SCALE_FACTOR_100P); |
643 #endif | 641 #endif |
644 ui::SetSupportedScaleFactors(supported_scale_factors); | 642 ui::SetSupportedScaleFactors(supported_scale_factors); |
645 #if defined(OS_WIN) | 643 #if defined(OS_WIN) |
646 // Must be called _after_ supported scale factors are set since it | 644 // Must be called _after_ supported scale factors are set since it |
647 // uses them. | 645 // uses them. |
648 // Don't initialize the device scale factor if it has already been | 646 gfx::InitDeviceScaleFactor(gfx::GetDPIScale()); |
649 // initialized. | |
650 if (!gfx::win::IsDeviceScaleFactorSet()) | |
651 gfx::InitDeviceScaleFactor(gfx::GetDPIScale()); | |
652 #endif | 647 #endif |
653 } | 648 } |
654 | 649 |
655 void ResourceBundle::FreeImages() { | 650 void ResourceBundle::FreeImages() { |
656 images_.clear(); | 651 images_.clear(); |
657 } | 652 } |
658 | 653 |
659 void ResourceBundle::AddDataPackFromPathInternal(const base::FilePath& path, | 654 void ResourceBundle::AddDataPackFromPathInternal(const base::FilePath& path, |
660 ScaleFactor scale_factor, | 655 ScaleFactor scale_factor, |
661 bool optional) { | 656 bool optional) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 // static | 853 // static |
859 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 854 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
860 size_t size, | 855 size_t size, |
861 SkBitmap* bitmap, | 856 SkBitmap* bitmap, |
862 bool* fell_back_to_1x) { | 857 bool* fell_back_to_1x) { |
863 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 858 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
864 return gfx::PNGCodec::Decode(buf, size, bitmap); | 859 return gfx::PNGCodec::Decode(buf, size, bitmap); |
865 } | 860 } |
866 | 861 |
867 } // namespace ui | 862 } // namespace ui |
OLD | NEW |