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

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

Issue 10391179: Revert 137622 - Fix a couple of bugs with the image skia implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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/image/image_skia.cc » ('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"
29 28
30 namespace ui { 29 namespace ui {
31 30
32 namespace { 31 namespace {
33 32
34 // Font sizes relative to base font. 33 // Font sizes relative to base font.
35 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) 34 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI)
36 const int kSmallFontSizeDelta = -3; 35 const int kSmallFontSizeDelta = -3;
37 const int kMediumFontSizeDelta = 2; 36 const int kMediumFontSizeDelta = 2;
38 const int kLargeFontSizeDelta = 7; 37 const int kLargeFontSizeDelta = 7;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (delegate_) 229 if (delegate_)
231 image = delegate_->GetImageNamed(resource_id); 230 image = delegate_->GetImageNamed(resource_id);
232 231
233 if (image.IsEmpty()) { 232 if (image.IsEmpty()) {
234 DCHECK(!delegate_ && !data_packs_.empty()) << 233 DCHECK(!delegate_ && !data_packs_.empty()) <<
235 "Missing call to SetResourcesDataDLL?"; 234 "Missing call to SetResourcesDataDLL?";
236 gfx::ImageSkia image_skia; 235 gfx::ImageSkia image_skia;
237 for (size_t i = 0; i < data_packs_.size(); ++i) { 236 for (size_t i = 0; i < data_packs_.size(); ++i) {
238 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id)); 237 scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id));
239 if (bitmap.get()) { 238 if (bitmap.get()) {
240 if (gfx::Screen::IsDIPEnabled()) 239 #if defined(ENABLE_DIP)
241 image_skia.AddBitmapForScale(*bitmap, 240 image_skia.AddBitmapForScale(*bitmap, data_packs_[i]->GetScaleFactor());
242 data_packs_[i]->GetScaleFactor()); 241 #else
243 else 242 image_skia.AddBitmapForScale(*bitmap, 1.0f);
244 image_skia.AddBitmapForScale(*bitmap, 1.0f); 243 #endif
245 } 244 }
246 } 245 }
247 246
248 if (image_skia.empty()) { 247 if (image_skia.empty()) {
249 LOG(WARNING) << "Unable to load image with id " << resource_id; 248 LOG(WARNING) << "Unable to load image with id " << resource_id;
250 NOTREACHED(); // Want to assert in debug mode. 249 NOTREACHED(); // Want to assert in debug mode.
251 // The load failed to retrieve the image; show a debugging red square. 250 // The load failed to retrieve the image; show a debugging red square.
252 return GetEmptyImage(); 251 return GetEmptyImage();
253 } 252 }
254 253
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 SkBitmap bitmap; 470 SkBitmap bitmap;
472 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); 471 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
473 bitmap.allocPixels(); 472 bitmap.allocPixels();
474 bitmap.eraseARGB(255, 255, 0, 0); 473 bitmap.eraseARGB(255, 255, 0, 0);
475 empty_image_ = gfx::Image(bitmap); 474 empty_image_ = gfx::Image(bitmap);
476 } 475 }
477 return empty_image_; 476 return empty_image_;
478 } 477 }
479 478
480 } // namespace ui 479 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698