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

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

Issue 10389109: Add gfx::Screen::IsEnabled() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Decided that the original approach with gfx::Sceren::IsDIPEnabled is better than the ifdef Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/screen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_piece.h" 16 #include "base/string_piece.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/data_pack.h" 22 #include "ui/base/resource/data_pack.h"
23 #include "ui/base/ui_base_paths.h" 23 #include "ui/base/ui_base_paths.h"
24 #include "ui/base/ui_base_switches.h" 24 #include "ui/base/ui_base_switches.h"
25 #include "ui/gfx/codec/jpeg_codec.h" 25 #include "ui/gfx/codec/jpeg_codec.h"
26 #include "ui/gfx/codec/png_codec.h" 26 #include "ui/gfx/codec/png_codec.h"
27 #include "ui/gfx/image/image_skia.h" 27 #include "ui/gfx/image/image_skia.h"
28 #include "ui/gfx/screen.h"
28 29
29 namespace ui { 30 namespace ui {
30 31
31 namespace { 32 namespace {
32 33
33 // Font sizes relative to base font. 34 // Font sizes relative to base font.
34 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) 35 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI)
35 const int kSmallFontSizeDelta = -3; 36 const int kSmallFontSizeDelta = -3;
36 const int kMediumFontSizeDelta = 2; 37 const int kMediumFontSizeDelta = 2;
37 const int kLargeFontSizeDelta = 7; 38 const int kLargeFontSizeDelta = 7;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (delegate_) 230 if (delegate_)
230 image = delegate_->GetImageNamed(resource_id); 231 image = delegate_->GetImageNamed(resource_id);
231 232
232 if (image.IsEmpty()) { 233 if (image.IsEmpty()) {
233 DCHECK(!delegate_ && !data_packs_.empty()) << 234 DCHECK(!delegate_ && !data_packs_.empty()) <<
234 "Missing call to SetResourcesDataDLL?"; 235 "Missing call to SetResourcesDataDLL?";
235 gfx::ImageSkia image_skia; 236 gfx::ImageSkia image_skia;
236 for (size_t i = 0; i < data_packs_.size(); ++i) { 237 for (size_t i = 0; i < data_packs_.size(); ++i) {
237 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id)); 238 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id));
238 if (bitmap.get()) { 239 if (bitmap.get()) {
239 #if defined(USE_AURA) 240 if (gfx::Screen::IsDIPEnabled())
240 image_skia.AddBitmapForScale(*bitmap, data_packs_[i]->GetScaleFactor()); 241 image_skia.AddBitmapForScale(*bitmap,
241 #else 242 data_packs_[i]->GetScaleFactor());
242 image_skia.AddBitmapForScale(*bitmap, 1.0f); 243 else
243 #endif 244 image_skia.AddBitmapForScale(*bitmap, 1.0f);
244 } 245 }
245 } 246 }
246 247
247 if (image_skia.empty()) { 248 if (image_skia.empty()) {
248 LOG(WARNING) << "Unable to load image with id " << resource_id; 249 LOG(WARNING) << "Unable to load image with id " << resource_id;
249 NOTREACHED(); // Want to assert in debug mode. 250 NOTREACHED(); // Want to assert in debug mode.
250 // The load failed to retrieve the image; show a debugging red square. 251 // The load failed to retrieve the image; show a debugging red square.
251 return GetEmptyImage(); 252 return GetEmptyImage();
252 } 253 }
253 254
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 SkBitmap bitmap; 471 SkBitmap bitmap;
471 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); 472 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
472 bitmap.allocPixels(); 473 bitmap.allocPixels();
473 bitmap.eraseARGB(255, 255, 0, 0); 474 bitmap.eraseARGB(255, 255, 0, 0);
474 empty_image_ = gfx::Image(bitmap); 475 empty_image_ = gfx::Image(bitmap);
475 } 476 }
476 return empty_image_; 477 return empty_image_;
477 } 478 }
478 479
479 } // namespace ui 480 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698