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

Unified Diff: chrome/browser/extensions/image_loading_tracker.cc

Issue 10868003: chromeos: Fix pixelated icons in app list and launcher (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/image_loading_tracker.h ('k') | chrome/browser/ui/app_list/extension_app_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/image_loading_tracker.cc
diff --git a/chrome/browser/extensions/image_loading_tracker.cc b/chrome/browser/extensions/image_loading_tracker.cc
index e6c88913b8b7db189dccee2776be7f83f3feca16..865bf86682715a3f1a582f562eec531cba7b3ab9 100644
--- a/chrome/browser/extensions/image_loading_tracker.cc
+++ b/chrome/browser/extensions/image_loading_tracker.cc
@@ -140,7 +140,7 @@ class ImageLoadingTracker::ImageLoader
std::string file_contents;
FilePath path = image_info.resource.GetFilePath();
if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) {
- ReportBack(NULL, image_info, gfx::Size(), id, false);
+ ReportBack(NULL, image_info, gfx::Size(), id);
return;
}
@@ -157,21 +157,14 @@ class ImageLoadingTracker::ImageLoader
// Chrome is therefore decoding bitmaps here that were generated by Chrome.
*decoded = decoder.Decode(data, file_contents.length());
if (decoded->empty()) {
- ReportBack(NULL, image_info, gfx::Size(), id, false);
+ ReportBack(NULL, image_info, gfx::Size(), id);
return; // Unable to decode.
}
gfx::Size original_size(decoded->width(), decoded->height());
- if (ShouldResizeImageRepresentation(image_info.resize_method,
- original_size,
- image_info.desired_size)) {
- *decoded = skia::ImageOperations::Resize(
- *decoded, skia::ImageOperations::RESIZE_LANCZOS3,
- image_info.desired_size.width(), image_info.desired_size.height());
- }
+ *decoded = ResizeIfNeeded(*decoded, image_info);
- ReportBack(decoded.release(), image_info, original_size, id,
- true /* delete bitmap */);
+ ReportBack(decoded.release(), image_info, original_size, id);
}
// Instructs the loader to load a resource on the File thread.
@@ -189,33 +182,35 @@ class ImageLoadingTracker::ImageLoader
int id,
int resource_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- const SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetImageNamed(
- resource_id).ToSkBitmap();
- ReportBack(bitmap, image_info, image_info.desired_size, id,
- false /* don't delete bitmap */);
+ // TODO(xiyuan): Clean up to use SkBitmap here and in LoadOnFileThread.
+ scoped_ptr<SkBitmap> bitmap(new SkBitmap);
+ *bitmap = ResourceBundle::GetSharedInstance().GetImageNamed(
+ resource_id).AsBitmap();
+
+ *bitmap = ResizeIfNeeded(*bitmap, image_info);
+ ReportBack(bitmap.release(), image_info, image_info.desired_size, id);
}
void ReportBack(const SkBitmap* bitmap, const ImageRepresentation& image_info,
- const gfx::Size& original_size, int id, bool delete_bitmap) {
+ const gfx::Size& original_size, int id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
BrowserThread::PostTask(
callback_thread_id_, FROM_HERE,
base::Bind(&ImageLoader::ReportOnCallingThread, this,
- bitmap, image_info, original_size, id, delete_bitmap));
+ bitmap, image_info, original_size, id));
}
void ReportOnCallingThread(const SkBitmap* bitmap,
const ImageRepresentation& image_info,
const gfx::Size& original_size,
- int id,
- bool delete_bitmap) {
+ int id) {
DCHECK(BrowserThread::CurrentlyOn(callback_thread_id_));
if (tracker_)
tracker_->OnBitmapLoaded(bitmap, image_info, original_size, id, true);
- if (bitmap && delete_bitmap)
+ if (bitmap)
delete bitmap;
}
@@ -223,6 +218,20 @@ class ImageLoadingTracker::ImageLoader
friend class base::RefCountedThreadSafe<ImageLoader>;
~ImageLoader() {}
+ SkBitmap ResizeIfNeeded(const SkBitmap& bitmap,
+ const ImageRepresentation& image_info) {
+ gfx::Size original_size(bitmap.width(), bitmap.height());
+ if (ShouldResizeImageRepresentation(image_info.resize_method,
+ original_size,
+ image_info.desired_size)) {
+ return skia::ImageOperations::Resize(
+ bitmap, skia::ImageOperations::RESIZE_LANCZOS3,
+ image_info.desired_size.width(), image_info.desired_size.height());
+ }
+
+ return bitmap;
+ }
+
// The tracker we are loading the bitmap for. If NULL, it means the tracker is
// no longer interested in the reply.
ImageLoadingTracker* tracker_;
@@ -236,6 +245,13 @@ class ImageLoadingTracker::ImageLoader
////////////////////////////////////////////////////////////////////////////////
// ImageLoadingTracker
+// static
+bool ImageLoadingTracker::IsSpecialBundledExtensionId(
+ const std::string& extension_id) {
+ int resource_id = -1;
+ return FindSpecialExtensionResourceId(extension_id, &resource_id);
+}
+
ImageLoadingTracker::ImageLoadingTracker(Observer* observer)
: observer_(observer),
next_id_(0) {
« no previous file with comments | « chrome/browser/extensions/image_loading_tracker.h ('k') | chrome/browser/ui/app_list/extension_app_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698