| 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 21 matching lines...) Expand all Loading... |
| 32 #include "ui/gfx/codec/png_codec.h" | 32 #include "ui/gfx/codec/png_codec.h" |
| 33 #include "ui/gfx/geometry/safe_integer_conversions.h" | 33 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 34 #include "ui/gfx/geometry/size_conversions.h" | 34 #include "ui/gfx/geometry/size_conversions.h" |
| 35 #include "ui/gfx/image/image_skia.h" | 35 #include "ui/gfx/image/image_skia.h" |
| 36 #include "ui/gfx/image/image_skia_source.h" | 36 #include "ui/gfx/image/image_skia_source.h" |
| 37 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
| 38 #include "ui/strings/grit/app_locale_settings.h" | 38 #include "ui/strings/grit/app_locale_settings.h" |
| 39 | 39 |
| 40 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 41 #include "ui/base/resource/resource_bundle_android.h" | 41 #include "ui/base/resource/resource_bundle_android.h" |
| 42 #include "ui/gfx/android/device_display_info.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 45 #include "ui/gfx/platform_font_linux.h" | 46 #include "ui/gfx/platform_font_linux.h" |
| 46 #endif | 47 #endif |
| 47 | 48 |
| 48 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 49 #include "ui/gfx/win/dpi.h" | 50 #include "ui/gfx/win/dpi.h" |
| 50 #endif | 51 #endif |
| 51 | 52 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 void ResourceBundle::InitSharedInstance(Delegate* delegate) { | 602 void ResourceBundle::InitSharedInstance(Delegate* delegate) { |
| 602 DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; | 603 DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; |
| 603 g_shared_instance_ = new ResourceBundle(delegate); | 604 g_shared_instance_ = new ResourceBundle(delegate); |
| 604 static std::vector<ScaleFactor> supported_scale_factors; | 605 static std::vector<ScaleFactor> supported_scale_factors; |
| 605 #if !defined(OS_IOS) && !defined(OS_WIN) | 606 #if !defined(OS_IOS) && !defined(OS_WIN) |
| 606 // On platforms other than iOS, 100P is always a supported scale factor. | 607 // On platforms other than iOS, 100P is always a supported scale factor. |
| 607 // For Windows we have a separate case in this function. | 608 // For Windows we have a separate case in this function. |
| 608 supported_scale_factors.push_back(SCALE_FACTOR_100P); | 609 supported_scale_factors.push_back(SCALE_FACTOR_100P); |
| 609 #endif | 610 #endif |
| 610 #if defined(OS_ANDROID) | 611 #if defined(OS_ANDROID) |
| 611 const gfx::Display display = | 612 float display_density; |
| 612 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 613 if (gfx::Display::HasForceDeviceScaleFactor()) { |
| 613 const float display_density = display.device_scale_factor(); | 614 display_density = gfx::Display::GetForcedDeviceScaleFactor(); |
| 615 } else { |
| 616 gfx::DeviceDisplayInfo device_info; |
| 617 display_density = device_info.GetDIPScale(); |
| 618 } |
| 614 const ScaleFactor closest = FindClosestScaleFactorUnsafe(display_density); | 619 const ScaleFactor closest = FindClosestScaleFactorUnsafe(display_density); |
| 615 if (closest != SCALE_FACTOR_100P) | 620 if (closest != SCALE_FACTOR_100P) |
| 616 supported_scale_factors.push_back(closest); | 621 supported_scale_factors.push_back(closest); |
| 617 #elif defined(OS_IOS) | 622 #elif defined(OS_IOS) |
| 618 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 623 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 619 if (display.device_scale_factor() > 2.0) { | 624 if (display.device_scale_factor() > 2.0) { |
| 620 DCHECK_EQ(3.0, display.device_scale_factor()); | 625 DCHECK_EQ(3.0, display.device_scale_factor()); |
| 621 supported_scale_factors.push_back(SCALE_FACTOR_300P); | 626 supported_scale_factors.push_back(SCALE_FACTOR_300P); |
| 622 } else if (display.device_scale_factor() > 1.0) { | 627 } else if (display.device_scale_factor() > 1.0) { |
| 623 DCHECK_EQ(2.0, display.device_scale_factor()); | 628 DCHECK_EQ(2.0, display.device_scale_factor()); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 // static | 918 // static |
| 914 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 919 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 915 size_t size, | 920 size_t size, |
| 916 SkBitmap* bitmap, | 921 SkBitmap* bitmap, |
| 917 bool* fell_back_to_1x) { | 922 bool* fell_back_to_1x) { |
| 918 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 923 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 919 return gfx::PNGCodec::Decode(buf, size, bitmap); | 924 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 920 } | 925 } |
| 921 | 926 |
| 922 } // namespace ui | 927 } // namespace ui |
| OLD | NEW |