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

Unified Diff: components/wallpaper/wallpaper_resizer.cc

Issue 2868943003: Fixed the WallpaperResizer to ensure the image isn't destroyed prematurely. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/wallpaper/wallpaper_resizer.cc
diff --git a/components/wallpaper/wallpaper_resizer.cc b/components/wallpaper/wallpaper_resizer.cc
index e5f7f9680a1472ad8039ebd038cd3fa1725eff45..0bfa3d4648c52ee7a343c6bb2764e42f73bae96a 100644
--- a/components/wallpaper/wallpaper_resizer.cc
+++ b/components/wallpaper/wallpaper_resizer.cc
@@ -24,14 +24,19 @@ int RoundPositive(double x) {
return static_cast<int>(floor(x + 0.5));
}
-// Resizes |orig_bitmap| to |target_size| using |layout| and stores the
+// Resizes |image| to |target_size| using |layout| and stores the
// resulting bitmap at |resized_bitmap_out|.
-void Resize(SkBitmap orig_bitmap,
+//
+// NOTE: |image| is intentionally a copy to ensure it exists for the duration of
+// the function.
+void Resize(const gfx::ImageSkia image,
const gfx::Size& target_size,
WallpaperLayout layout,
SkBitmap* resized_bitmap_out,
base::TaskRunner* task_runner) {
DCHECK(task_runner->RunsTasksOnCurrentThread());
+
+ SkBitmap orig_bitmap = *image.bitmap();
SkBitmap new_bitmap = orig_bitmap;
const int orig_width = orig_bitmap.width();
@@ -127,8 +132,8 @@ void WallpaperResizer::StartResize() {
SkBitmap* resized_bitmap = new SkBitmap;
if (!task_runner_->PostTaskAndReply(
FROM_HERE,
- base::Bind(&Resize, *image_.bitmap(), target_size_, layout_,
- resized_bitmap, base::RetainedRef(task_runner_)),
+ base::Bind(&Resize, image_, target_size_, layout_, resized_bitmap,
+ base::RetainedRef(task_runner_)),
base::Bind(&WallpaperResizer::OnResizeFinished,
weak_ptr_factory_.GetWeakPtr(),
base::Owned(resized_bitmap)))) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698