Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win2 Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "skia/ext/image_operations.h" 23 #include "skia/ext/image_operations.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/layout.h" 26 #include "ui/base/layout.h"
27 #include "ui/base/resource/data_pack.h" 27 #include "ui/base/resource/data_pack.h"
28 #include "ui/base/ui_base_paths.h" 28 #include "ui/base/ui_base_paths.h"
29 #include "ui/base/ui_base_switches.h" 29 #include "ui/base/ui_base_switches.h"
30 #include "ui/gfx/codec/jpeg_codec.h" 30 #include "ui/gfx/codec/jpeg_codec.h"
31 #include "ui/gfx/codec/png_codec.h" 31 #include "ui/gfx/codec/png_codec.h"
32 #include "ui/gfx/dpi.h"
32 #include "ui/gfx/image/image_skia.h" 33 #include "ui/gfx/image/image_skia.h"
33 #include "ui/gfx/image/image_skia_source.h" 34 #include "ui/gfx/image/image_skia_source.h"
34 #include "ui/gfx/safe_integer_conversions.h" 35 #include "ui/gfx/safe_integer_conversions.h"
35 #include "ui/gfx/screen.h" 36 #include "ui/gfx/screen.h"
36 #include "ui/gfx/size_conversions.h" 37 #include "ui/gfx/size_conversions.h"
37 #include "ui/strings/grit/app_locale_settings.h" 38 #include "ui/strings/grit/app_locale_settings.h"
38 39
39 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
40 #include "ui/base/resource/resource_bundle_android.h" 41 #include "ui/base/resource/resource_bundle_android.h"
41 #endif 42 #endif
42 43
43 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
44 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
45 #include "ui/gfx/platform_font_pango.h" 46 #include "ui/gfx/platform_font_pango.h"
46 #endif 47 #endif
47 48
48 #if defined(OS_WIN)
49 #include "ui/base/win/dpi_setup.h"
50 #include "ui/gfx/win/dpi.h"
51 #endif
52
53 #if defined(OS_MACOSX) && !defined(OS_IOS) 49 #if defined(OS_MACOSX) && !defined(OS_IOS)
54 #include "base/mac/mac_util.h" 50 #include "base/mac/mac_util.h"
55 #endif 51 #endif
56 52
57 namespace ui { 53 namespace ui {
58 54
59 namespace { 55 namespace {
60 56
61 // Font sizes relative to base font. 57 // Font sizes relative to base font.
62 const int kSmallFontSizeDelta = -1; 58 const int kSmallFontSizeDelta = -1;
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 supported_scale_factors.push_back(SCALE_FACTOR_200P); 612 supported_scale_factors.push_back(SCALE_FACTOR_200P);
617 } else { 613 } else {
618 supported_scale_factors.push_back(SCALE_FACTOR_100P); 614 supported_scale_factors.push_back(SCALE_FACTOR_100P);
619 } 615 }
620 #elif defined(OS_MACOSX) 616 #elif defined(OS_MACOSX)
621 if (base::mac::IsOSLionOrLater()) 617 if (base::mac::IsOSLionOrLater())
622 supported_scale_factors.push_back(SCALE_FACTOR_200P); 618 supported_scale_factors.push_back(SCALE_FACTOR_200P);
623 #elif defined(OS_CHROMEOS) 619 #elif defined(OS_CHROMEOS)
624 // TODO(oshima): Include 200P only if the device support 200P 620 // TODO(oshima): Include 200P only if the device support 200P
625 supported_scale_factors.push_back(SCALE_FACTOR_200P); 621 supported_scale_factors.push_back(SCALE_FACTOR_200P);
626 #elif defined(OS_LINUX) && defined(ENABLE_HIDPI) 622 #elif defined(OS_LINUX)
623 supported_scale_factors.push_back(SCALE_FACTOR_125P);
ananta 2014/10/17 00:49:06 Why do we need to push the fractional scale factor
scottmg 2014/10/17 23:18:41 Done.
624 supported_scale_factors.push_back(SCALE_FACTOR_133P);
625 supported_scale_factors.push_back(SCALE_FACTOR_140P);
626 supported_scale_factors.push_back(SCALE_FACTOR_150P);
627 supported_scale_factors.push_back(SCALE_FACTOR_180P);
627 supported_scale_factors.push_back(SCALE_FACTOR_200P); 628 supported_scale_factors.push_back(SCALE_FACTOR_200P);
628 #elif defined(OS_WIN) 629 #elif defined(OS_WIN)
629 bool default_to_100P = true; 630 bool default_to_100P = true;
630 if (gfx::IsHighDPIEnabled()) { 631 if (gfx::IsHighDPIEnabled()) {
631 // On Windows if the dpi scale is greater than 1.25 on high dpi machines 632 // On Windows if the dpi scale is greater than 1.25 on high dpi machines
632 // downscaling from 200 percent looks better than scaling up from 100 633 // downscaling from 200 percent looks better than scaling up from 100
633 // percent. 634 // percent.
634 if (gfx::GetDPIScale() > 1.25) { 635 if (gfx::GetDPIScale() > 1.25) {
635 supported_scale_factors.push_back(SCALE_FACTOR_200P); 636 supported_scale_factors.push_back(SCALE_FACTOR_200P);
636 default_to_100P = false; 637 default_to_100P = false;
637 } 638 }
638 } 639 }
639 if (default_to_100P) 640 if (default_to_100P)
640 supported_scale_factors.push_back(SCALE_FACTOR_100P); 641 supported_scale_factors.push_back(SCALE_FACTOR_100P);
641 #endif 642 #endif
642 ui::SetSupportedScaleFactors(supported_scale_factors); 643 ui::SetSupportedScaleFactors(supported_scale_factors);
643 #if defined(OS_WIN) 644 #if defined(OS_WIN) || defined(OS_LINUX)
644 // Must be called _after_ supported scale factors are set since it 645 // Must be called _after_ supported scale factors are set since it
645 // uses them. 646 // uses them.
646 // Don't initialize the device scale factor if it has already been 647 // Don't initialize the device scale factor if it has already been
647 // initialized. 648 // initialized.
648 if (!gfx::win::IsDeviceScaleFactorSet()) 649 if (!gfx::IsDeviceScaleFactorSet())
649 ui::win::InitDeviceScaleFactor(); 650 gfx::InitDeviceScaleFactor(gfx::GetDPIScale());
650 #endif 651 #endif
651 } 652 }
652 653
653 void ResourceBundle::FreeImages() { 654 void ResourceBundle::FreeImages() {
654 images_.clear(); 655 images_.clear();
655 } 656 }
656 657
657 void ResourceBundle::AddDataPackFromPathInternal(const base::FilePath& path, 658 void ResourceBundle::AddDataPackFromPathInternal(const base::FilePath& path,
658 ScaleFactor scale_factor, 659 ScaleFactor scale_factor,
659 bool optional) { 660 bool optional) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // static 857 // static
857 bool ResourceBundle::DecodePNG(const unsigned char* buf, 858 bool ResourceBundle::DecodePNG(const unsigned char* buf,
858 size_t size, 859 size_t size,
859 SkBitmap* bitmap, 860 SkBitmap* bitmap,
860 bool* fell_back_to_1x) { 861 bool* fell_back_to_1x) {
861 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 862 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
862 return gfx::PNGCodec::Decode(buf, size, bitmap); 863 return gfx::PNGCodec::Decode(buf, size, bitmap);
863 } 864 }
864 865
865 } // namespace ui 866 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/layout.cc ('k') | ui/base/resource/resource_bundle_win.cc » ('j') | ui/gfx/pango_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698