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

Unified Diff: chrome/browser/chromeos/login/wallpaper_manager.cc

Issue 10823358: image: Specify the resize-method when resizing ImageSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deep-copy Created 8 years, 4 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 | « ash/system/user/tray_user.cc ('k') | chrome/browser/icon_loader_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/wallpaper_manager.cc
diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc
index 06837af7f81472e8c14528b795c9c96883445016..27a0b76545af566cb8c9d5424d0f85774592ccc7 100644
--- a/chrome/browser/chromeos/login/wallpaper_manager.cc
+++ b/chrome/browser/chromeos/login/wallpaper_manager.cc
@@ -31,8 +31,8 @@
#include "chromeos/dbus/power_manager_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
-#include "skia/ext/image_operations.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/skia_util.h"
using content::BrowserThread;
@@ -66,6 +66,33 @@ const char kNewWallpaperLayoutNodeName[] = "layout";
const char kNewWallpaperFileNodeName[] = "file";
const char kNewWallpaperTypeNodeName[] = "type";
+gfx::ImageSkia GetWallpaperThumbnail(const gfx::ImageSkia& wallpaper) {
+ gfx::ImageSkia thumbnail = gfx::ImageSkiaOperations::CreateResizedImage(
+ wallpaper,
+ skia::ImageOperations::RESIZE_LANCZOS3,
+ gfx::Size(kThumbnailWidth, kThumbnailHeight));
+
+ // Ideally, this would call thumbnail.GetRepresentations(). But since that
+ // isn't exposed on non-mac yet, we have to do this here.
+ std::vector<ui::ScaleFactor> scales = ui::GetSupportedScaleFactors();
+ for (size_t i = 0; i < scales.size(); ++i) {
+ if (wallpaper.HasRepresentation(scales[i]))
+ thumbnail.GetRepresentation(scales[i]);
+ }
+
+ return thumbnail;
+}
+
+gfx::ImageSkia ImageSkiaDeepCopy(const gfx::ImageSkia& image) {
sadrul 2012/08/16 20:32:56 Perhaps this should be ImageSkia::DeepCopy instead
+ gfx::ImageSkia copy;
+ std::vector<gfx::ImageSkiaRep> reps = image.image_reps();
+ for (std::vector<gfx::ImageSkiaRep>::iterator iter = reps.begin();
+ iter != reps.end(); ++iter) {
+ copy.AddRepresentation(*iter);
+ }
+ return copy;
+}
+
} // namespace
namespace chromeos {
@@ -511,7 +538,8 @@ void WallpaperManager::CacheWallpaper(const std::string& email,
BrowserThread::FILE,
FROM_HERE,
base::Bind(&WallpaperManager::CacheThumbnail,
- base::Unretained(this), email, wallpaper.image()));
+ base::Unretained(this), email,
+ ImageSkiaDeepCopy(wallpaper.image())));
custom_wallpaper_cache_.insert(std::make_pair(email, wallpaper.image()));
}
@@ -519,11 +547,7 @@ void WallpaperManager::CacheWallpaper(const std::string& email,
void WallpaperManager::CacheThumbnail(const std::string& email,
const gfx::ImageSkia& wallpaper) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- gfx::ImageSkia thumbnail =
- skia::ImageOperations::Resize(wallpaper,
- skia::ImageOperations::RESIZE_LANCZOS3,
- kThumbnailWidth, kThumbnailHeight);
- custom_wallpaper_thumbnail_cache_[email] = thumbnail;
+ custom_wallpaper_thumbnail_cache_[email] = GetWallpaperThumbnail(wallpaper);
}
void WallpaperManager::FetchWallpaper(const std::string& email,
@@ -535,7 +559,8 @@ void WallpaperManager::FetchWallpaper(const std::string& email,
BrowserThread::FILE,
FROM_HERE,
base::Bind(&WallpaperManager::CacheThumbnail,
- base::Unretained(this), email, wallpaper.image()));
+ base::Unretained(this), email,
+ ImageSkiaDeepCopy(wallpaper.image())));
custom_wallpaper_cache_.insert(std::make_pair(email, wallpaper.image()));
ash::Shell::GetInstance()->desktop_background_controller()->
@@ -582,12 +607,7 @@ void WallpaperManager::GenerateUserWallpaperThumbnail(
base::WeakPtr<WallpaperDelegate> delegate,
const gfx::ImageSkia& wallpaper) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- gfx::ImageSkia thumbnail =
- skia::ImageOperations::Resize(wallpaper,
- skia::ImageOperations::RESIZE_LANCZOS3,
- kThumbnailWidth, kThumbnailHeight);
-
- custom_wallpaper_thumbnail_cache_[email] = thumbnail;
+ custom_wallpaper_thumbnail_cache_[email] = GetWallpaperThumbnail(wallpaper);
// Notify thumbnail is ready.
BrowserThread::PostTask(
@@ -644,8 +664,7 @@ void WallpaperManager::SetWallpaper(const std::string& username,
void WallpaperManager::OnWallpaperLoaded(ash::WallpaperLayout layout,
const UserImage& user_image) {
- const SkBitmap& wallpaper = user_image.image();
- SetWallpaperFromImageSkia(wallpaper, layout);
+ SetWallpaperFromImageSkia(user_image.image(), layout);
}
void WallpaperManager::SystemResumed() {
« no previous file with comments | « ash/system/user/tray_user.cc ('k') | chrome/browser/icon_loader_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698