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

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

Issue 8983005: Made wallpaper smaller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed back resource_bundle.cc Created 9 years 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/resources/aura/wallpaper.jpg » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/data_pack.h" 19 #include "ui/base/resource/data_pack.h"
20 #include "ui/base/ui_base_paths.h" 20 #include "ui/base/ui_base_paths.h"
21 #include "ui/base/ui_base_switches.h" 21 #include "ui/base/ui_base_switches.h"
22 #include "ui/gfx/codec/jpeg_codec.h"
23 #include "ui/gfx/codec/png_codec.h" 22 #include "ui/gfx/codec/png_codec.h"
24 #include "ui/gfx/font.h" 23 #include "ui/gfx/font.h"
25 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
26 25
27 namespace ui { 26 namespace ui {
28 27
29 namespace { 28 namespace {
30 29
31 // Font sizes relative to base font. 30 // Font sizes relative to base font.
32 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI) 31 #if defined(OS_CHROMEOS) && defined(CROS_FONTS_USING_BCI)
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 362 }
364 363
365 /* static */ 364 /* static */
366 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) { 365 SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) {
367 scoped_refptr<RefCountedMemory> memory( 366 scoped_refptr<RefCountedMemory> memory(
368 LoadResourceBytes(data_handle, resource_id)); 367 LoadResourceBytes(data_handle, resource_id));
369 if (!memory) 368 if (!memory)
370 return NULL; 369 return NULL;
371 370
372 SkBitmap bitmap; 371 SkBitmap bitmap;
373 if (gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) 372 if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) {
374 return new SkBitmap(bitmap); 373 NOTREACHED() << "Unable to decode theme image resource " << resource_id;
374 return NULL;
375 }
375 376
376 // 99% of our assets are PNGs, however fallback to JPEG. 377 return new SkBitmap(bitmap);
377 SkBitmap* allocated_bitmap =
378 gfx::JPEGCodec::Decode(memory->front(), memory->size());
379 if (allocated_bitmap)
380 return allocated_bitmap;
381
382 NOTREACHED() << "Unable to decode theme image resource " << resource_id;
383 return NULL;
384 } 378 }
385 379
386 gfx::Image* ResourceBundle::GetEmptyImage() { 380 gfx::Image* ResourceBundle::GetEmptyImage() {
387 base::AutoLock lock(*lock_); 381 base::AutoLock lock(*lock_);
388 382
389 static gfx::Image* empty_image = NULL; 383 static gfx::Image* empty_image = NULL;
390 if (!empty_image) { 384 if (!empty_image) {
391 // The placeholder bitmap is bright red so people notice the problem. 385 // The placeholder bitmap is bright red so people notice the problem.
392 // This bitmap will be leaked, but this code should never be hit. 386 // This bitmap will be leaked, but this code should never be hit.
393 SkBitmap* bitmap = new SkBitmap(); 387 SkBitmap* bitmap = new SkBitmap();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 422 }
429 423
430 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory( 424 RefCountedStaticMemory* ResourceBundle::LoadedDataPack::GetStaticMemory(
431 int resource_id) const { 425 int resource_id) const {
432 if (!data_pack_.get()) 426 if (!data_pack_.get())
433 return NULL; 427 return NULL;
434 return data_pack_->GetStaticMemory(resource_id); 428 return data_pack_->GetStaticMemory(resource_id);
435 } 429 }
436 430
437 } // namespace ui 431 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/resources/aura/wallpaper.jpg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698