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

Side by Side Diff: chrome/browser/icon_loader_chromeos.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. 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
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 "chrome/browser/icon_loader.h" 5 #include "chrome/browser/icon_loader.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "chrome/browser/icon_loader.h" 15 #include "chrome/browser/icon_loader.h"
16 #include "grit/component_extension_resources.h" 16 #include "grit/component_extension_resources.h"
17 #include "skia/ext/image_operations.h" 17 #include "skia/ext/image_operations.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/base/layout.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/codec/png_codec.h" 22 #include "ui/gfx/codec/png_codec.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "webkit/glue/image_decoder.h" 24 #include "webkit/glue/image_decoder.h"
24 25
25 namespace { 26 namespace {
26 27
27 // Used with GenerateBitmapWithSize() to indicate that the image shouldn't be 28 // Used with GenerateBitmapWithSize() to indicate that the image shouldn't be
28 // resized. 29 // resized.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 191 }
191 192
192 } // namespace 193 } // namespace
193 194
194 void IconLoader::ReadIcon() { 195 void IconLoader::ReadIcon() {
195 static base::LazyInstance<IconMapper>::Leaky icon_mapper = 196 static base::LazyInstance<IconMapper>::Leaky icon_mapper =
196 LAZY_INSTANCE_INITIALIZER; 197 LAZY_INSTANCE_INITIALIZER;
197 int idr = icon_mapper.Get().Lookup(group_, icon_size_); 198 int idr = icon_mapper.Get().Lookup(group_, icon_size_);
198 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 199 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
199 scoped_refptr<base::RefCountedStaticMemory> bytes( 200 scoped_refptr<base::RefCountedStaticMemory> bytes(
200 rb.LoadDataResourceBytes(idr)); 201 rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_100P));
201 DCHECK(bytes.get()); 202 DCHECK(bytes.get());
202 SkBitmap bitmap; 203 SkBitmap bitmap;
203 if (!gfx::PNGCodec::Decode(bytes->front(), bytes->size(), &bitmap)) 204 if (!gfx::PNGCodec::Decode(bytes->front(), bytes->size(), &bitmap))
204 NOTREACHED(); 205 NOTREACHED();
205 image_.reset(new gfx::Image( 206 image_.reset(new gfx::Image(
206 GenerateBitmapWithSize(bitmap, IconSizeToPixelSize(icon_size_)))); 207 GenerateBitmapWithSize(bitmap, IconSizeToPixelSize(icon_size_))));
207 target_message_loop_->PostTask( 208 target_message_loop_->PostTask(
208 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); 209 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this));
209 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698