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

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

Issue 1955773002: Enable MD by default on Windows for Canary/Dev and local builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't break first run Created 4 years, 7 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #endif 50 #endif
51 51
52 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
53 #include "ui/gfx/platform_font_linux.h" 53 #include "ui/gfx/platform_font_linux.h"
54 #endif 54 #endif
55 55
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 #include "ui/display/win/dpi.h" 57 #include "ui/display/win/dpi.h"
58 #endif 58 #endif
59 59
60 // Helpers --------------------------------------------------------------------
61
60 namespace ui { 62 namespace ui {
61 63
62 namespace { 64 namespace {
63 65
64 // PNG-related constants. 66 // PNG-related constants.
65 const unsigned char kPngMagic[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 }; 67 const unsigned char kPngMagic[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
66 const size_t kPngChunkMetadataSize = 12; // length, type, crc32 68 const size_t kPngChunkMetadataSize = 12; // length, type, crc32
67 const unsigned char kPngScaleChunkType[4] = { 'c', 's', 'C', 'l' }; 69 const unsigned char kPngScaleChunkType[4] = { 'c', 's', 'C', 'l' };
68 const unsigned char kPngDataChunkType[4] = { 'I', 'D', 'A', 'T' }; 70 const unsigned char kPngDataChunkType[4] = { 'I', 'D', 'A', 'T' };
69 71
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 109
108 SkBitmap CreateEmptyBitmap() { 110 SkBitmap CreateEmptyBitmap() {
109 SkBitmap bitmap; 111 SkBitmap bitmap;
110 bitmap.allocN32Pixels(32, 32); 112 bitmap.allocN32Pixels(32, 32);
111 bitmap.eraseARGB(255, 255, 255, 0); 113 bitmap.eraseARGB(255, 255, 255, 0);
112 return bitmap; 114 return bitmap;
113 } 115 }
114 116
115 } // namespace 117 } // namespace
116 118
119
120 // ResourceBundle::TemporaryLoader --------------------------------------------
121
122 ResourceBundle::TemporaryLoader::TemporaryLoader() {
123 DCHECK(!ResourceBundle::HasSharedInstance());
124 std::string locale = l10n_util::GetApplicationLocale(std::string());
125 const char kUserDataDirDialogFallbackLocale[] = "en-US";
126 if (locale.empty())
127 locale = kUserDataDirDialogFallbackLocale;
128 ui::ResourceBundle::InitSharedInstanceWithLocale(
129 locale, NULL, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
sky 2016/05/13 15:49:56 nullptr
Peter Kasting 2016/05/16 19:53:16 Done.
130 }
131
132 ResourceBundle::TemporaryLoader::~TemporaryLoader() {
133 ResourceBundle::CleanupSharedInstance();
134 }
135
136
137 // ResourceBundle::ResourceBundleImageSource ----------------------------------
138
117 // An ImageSkiaSource that loads bitmaps for the requested scale factor from 139 // An ImageSkiaSource that loads bitmaps for the requested scale factor from
118 // ResourceBundle on demand for a given |resource_id|. If the bitmap for the 140 // ResourceBundle on demand for a given |resource_id|. If the bitmap for the
119 // requested scale factor does not exist, it will return the 1x bitmap scaled 141 // requested scale factor does not exist, it will return the 1x bitmap scaled
120 // by the scale factor. This may lead to broken UI if the correct size of the 142 // by the scale factor. This may lead to broken UI if the correct size of the
121 // scaled image is not exactly |scale_factor| * the size of the 1x resource. 143 // scaled image is not exactly |scale_factor| * the size of the 1x resource.
122 // When --highlight-missing-scaled-resources flag is specified, scaled 1x images 144 // When --highlight-missing-scaled-resources flag is specified, scaled 1x images
123 // are higlighted by blending them with red. 145 // are higlighted by blending them with red.
124 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { 146 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource {
125 public: 147 public:
126 ResourceBundleImageSource(ResourceBundle* rb, int resource_id) 148 ResourceBundleImageSource(ResourceBundle* rb, int resource_id)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return gfx::ImageSkiaRep(image, scale); 186 return gfx::ImageSkiaRep(image, scale);
165 } 187 }
166 188
167 private: 189 private:
168 ResourceBundle* rb_; 190 ResourceBundle* rb_;
169 const int resource_id_; 191 const int resource_id_;
170 192
171 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageSource); 193 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageSource);
172 }; 194 };
173 195
196
197 // ResourceBundle -------------------------------------------------------------
198
174 // static 199 // static
175 std::string ResourceBundle::InitSharedInstanceWithLocale( 200 std::string ResourceBundle::InitSharedInstanceWithLocale(
176 const std::string& pref_locale, 201 const std::string& pref_locale,
177 Delegate* delegate, 202 Delegate* delegate,
178 LoadResources load_resources) { 203 LoadResources load_resources) {
179 InitSharedInstance(delegate); 204 InitSharedInstance(delegate);
180 if (load_resources == LOAD_COMMON_RESOURCES) 205 if (load_resources == LOAD_COMMON_RESOURCES)
181 g_shared_instance_->LoadCommonResources(); 206 g_shared_instance_->LoadCommonResources();
182 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); 207 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale);
183 g_shared_instance_->InitDefaultFontList(); 208 g_shared_instance_->InitDefaultFontList();
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 // static 921 // static
897 bool ResourceBundle::DecodePNG(const unsigned char* buf, 922 bool ResourceBundle::DecodePNG(const unsigned char* buf,
898 size_t size, 923 size_t size,
899 SkBitmap* bitmap, 924 SkBitmap* bitmap,
900 bool* fell_back_to_1x) { 925 bool* fell_back_to_1x) {
901 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 926 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
902 return gfx::PNGCodec::Decode(buf, size, bitmap); 927 return gfx::PNGCodec::Decode(buf, size, bitmap);
903 } 928 }
904 929
905 } // namespace ui 930 } // namespace ui
OLDNEW
« ui/base/material_design/material_design_controller.h ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698