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 <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 | 28 |
29 #if defined(USE_AURA) | |
30 #include "ui/compositor/dip_util.h" | |
31 #endif | |
32 | |
29 namespace ui { | 33 namespace ui { |
30 | 34 |
31 namespace { | 35 namespace { |
32 | 36 |
33 // Font sizes relative to base font. | 37 // Font sizes relative to base font. |
34 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) | 38 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) |
35 const int kSmallFontSizeDelta = -3; | 39 const int kSmallFontSizeDelta = -3; |
36 const int kMediumFontSizeDelta = 2; | 40 const int kMediumFontSizeDelta = 2; |
37 const int kLargeFontSizeDelta = 7; | 41 const int kLargeFontSizeDelta = 7; |
38 #else | 42 #else |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 if (delegate_) | 233 if (delegate_) |
230 image = delegate_->GetImageNamed(resource_id); | 234 image = delegate_->GetImageNamed(resource_id); |
231 | 235 |
232 if (image.IsEmpty()) { | 236 if (image.IsEmpty()) { |
233 DCHECK(!delegate_ && !data_packs_.empty()) << | 237 DCHECK(!delegate_ && !data_packs_.empty()) << |
234 "Missing call to SetResourcesDataDLL?"; | 238 "Missing call to SetResourcesDataDLL?"; |
235 gfx::ImageSkia image_skia; | 239 gfx::ImageSkia image_skia; |
236 for (size_t i = 0; i < data_packs_.size(); ++i) { | 240 for (size_t i = 0; i < data_packs_.size(); ++i) { |
237 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id)); | 241 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id)); |
238 if (bitmap.get()) { | 242 if (bitmap.get()) { |
239 #if defined(ENABLE_DIP) | 243 float image_scale_factor = 1.0f; |
240 image_skia.AddBitmapForScale(*bitmap, data_packs_[i]->GetScaleFactor()); | 244 #if defined(USE_AURA) |
241 #else | 245 if (ui::IsDIPEnabled()) |
sky
2012/05/14 14:09:58
Can we define this for all platforms so that we do
| |
242 image_skia.AddBitmapForScale(*bitmap, 1.0f); | 246 image_scale_factor = data_packs_[i]->GetScaleFactor(); |
243 #endif | 247 #endif |
248 image_skia.AddBitmapForScale(*bitmap, image_scale_factor); | |
244 } | 249 } |
245 } | 250 } |
246 | 251 |
247 if (image_skia.empty()) { | 252 if (image_skia.empty()) { |
248 LOG(WARNING) << "Unable to load image with id " << resource_id; | 253 LOG(WARNING) << "Unable to load image with id " << resource_id; |
249 NOTREACHED(); // Want to assert in debug mode. | 254 NOTREACHED(); // Want to assert in debug mode. |
250 // The load failed to retrieve the image; show a debugging red square. | 255 // The load failed to retrieve the image; show a debugging red square. |
251 return GetEmptyImage(); | 256 return GetEmptyImage(); |
252 } | 257 } |
253 | 258 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 SkBitmap* bitmap = new SkBitmap(); | 475 SkBitmap* bitmap = new SkBitmap(); |
471 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 476 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
472 bitmap->allocPixels(); | 477 bitmap->allocPixels(); |
473 bitmap->eraseARGB(255, 255, 0, 0); | 478 bitmap->eraseARGB(255, 255, 0, 0); |
474 empty_image_ = gfx::Image(bitmap); | 479 empty_image_ = gfx::Image(bitmap); |
475 } | 480 } |
476 return empty_image_; | 481 return empty_image_; |
477 } | 482 } |
478 | 483 |
479 } // namespace ui | 484 } // namespace ui |
OLD | NEW |