| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
| 51 #include "ui/gfx/platform_font_linux.h" | 51 #include "ui/gfx/platform_font_linux.h" |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 55 #include "ui/display/win/dpi.h" | 55 #include "ui/display/win/dpi.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 59 #include "base/mac/mac_util.h" | |
| 60 #endif | |
| 61 | |
| 62 namespace ui { | 58 namespace ui { |
| 63 | 59 |
| 64 namespace { | 60 namespace { |
| 65 | 61 |
| 66 // PNG-related constants. | 62 // PNG-related constants. |
| 67 const unsigned char kPngMagic[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 }; | 63 const unsigned char kPngMagic[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 }; |
| 68 const size_t kPngChunkMetadataSize = 12; // length, type, crc32 | 64 const size_t kPngChunkMetadataSize = 12; // length, type, crc32 |
| 69 const unsigned char kPngScaleChunkType[4] = { 'c', 's', 'C', 'l' }; | 65 const unsigned char kPngScaleChunkType[4] = { 'c', 's', 'C', 'l' }; |
| 70 const unsigned char kPngDataChunkType[4] = { 'I', 'D', 'A', 'T' }; | 66 const unsigned char kPngDataChunkType[4] = { 'I', 'D', 'A', 'T' }; |
| 71 | 67 |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 660 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
| 665 if (display.device_scale_factor() > 2.0) { | 661 if (display.device_scale_factor() > 2.0) { |
| 666 DCHECK_EQ(3.0, display.device_scale_factor()); | 662 DCHECK_EQ(3.0, display.device_scale_factor()); |
| 667 supported_scale_factors.push_back(SCALE_FACTOR_300P); | 663 supported_scale_factors.push_back(SCALE_FACTOR_300P); |
| 668 } else if (display.device_scale_factor() > 1.0) { | 664 } else if (display.device_scale_factor() > 1.0) { |
| 669 DCHECK_EQ(2.0, display.device_scale_factor()); | 665 DCHECK_EQ(2.0, display.device_scale_factor()); |
| 670 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 666 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
| 671 } else { | 667 } else { |
| 672 supported_scale_factors.push_back(SCALE_FACTOR_100P); | 668 supported_scale_factors.push_back(SCALE_FACTOR_100P); |
| 673 } | 669 } |
| 674 #elif defined(OS_MACOSX) | 670 #elif defined(OS_MACOSX) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \ |
| 675 if (base::mac::IsOSLionOrLater()) | 671 defined(OS_WIN) |
| 676 supported_scale_factors.push_back(SCALE_FACTOR_200P); | |
| 677 #elif defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_WIN) | |
| 678 supported_scale_factors.push_back(SCALE_FACTOR_200P); | 672 supported_scale_factors.push_back(SCALE_FACTOR_200P); |
| 679 #endif | 673 #endif |
| 680 ui::SetSupportedScaleFactors(supported_scale_factors); | 674 ui::SetSupportedScaleFactors(supported_scale_factors); |
| 681 } | 675 } |
| 682 | 676 |
| 683 void ResourceBundle::FreeImages() { | 677 void ResourceBundle::FreeImages() { |
| 684 images_.clear(); | 678 images_.clear(); |
| 685 } | 679 } |
| 686 | 680 |
| 687 void ResourceBundle::LoadChromeResources() { | 681 void ResourceBundle::LoadChromeResources() { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 // static | 865 // static |
| 872 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 866 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 873 size_t size, | 867 size_t size, |
| 874 SkBitmap* bitmap, | 868 SkBitmap* bitmap, |
| 875 bool* fell_back_to_1x) { | 869 bool* fell_back_to_1x) { |
| 876 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 870 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 877 return gfx::PNGCodec::Decode(buf, size, bitmap); | 871 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 878 } | 872 } |
| 879 | 873 |
| 880 } // namespace ui | 874 } // namespace ui |
| OLD | NEW |