Commit 5bf5c7be authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Make platform image creation functions return autoreleased images.

BUG=908548

Change-Id: I1f471655a5e3f629c0d316b2617fbeaf62b7ba06
Reviewed-on: https://chromium-review.googlesource.com/c/1351499
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611295}
parent 0f3229d0
...@@ -457,7 +457,7 @@ UIImage* Image::ToUIImage() const { ...@@ -457,7 +457,7 @@ UIImage* Image::ToUIImage() const {
const internal::ImageRepPNG* png_rep = const internal::ImageRepPNG* png_rep =
GetRepresentation(kImageRepPNG, true)->AsImageRepPNG(); GetRepresentation(kImageRepPNG, true)->AsImageRepPNG();
scoped_rep.reset(new internal::ImageRepCocoaTouch( scoped_rep.reset(new internal::ImageRepCocoaTouch(
internal::CreateUIImageFromPNG(png_rep->image_reps()))); internal::UIImageFromPNG(png_rep->image_reps())));
break; break;
} }
case kImageRepSkia: { case kImageRepSkia: {
......
...@@ -72,8 +72,7 @@ scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage( ...@@ -72,8 +72,7 @@ scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage(
return png_bytes; return png_bytes;
} }
UIImage* CreateUIImageFromPNG( UIImage* UIImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps) {
const std::vector<gfx::ImagePNGRep>& image_png_reps) {
float ideal_scale = ImageSkia::GetMaxSupportedScale(); float ideal_scale = ImageSkia::GetMaxSupportedScale();
if (image_png_reps.empty()) if (image_png_reps.empty())
...@@ -91,7 +90,8 @@ UIImage* CreateUIImageFromPNG( ...@@ -91,7 +90,8 @@ UIImage* CreateUIImageFromPNG(
} }
} }
return CreateUIImageFromImagePNGRep(image_png_reps[closest_index]); return
[CreateUIImageFromImagePNGRep(image_png_reps[closest_index]) autorelease];
} }
scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia( scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia(
......
...@@ -97,7 +97,7 @@ NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps, ...@@ -97,7 +97,7 @@ NSImage* NSImageFromPNG(const std::vector<gfx::ImagePNGRep>& image_png_reps,
[image addRepresentation:ns_image_rep]; [image addRepresentation:ns_image_rep];
} }
return image.release(); return image.autorelease();
} }
gfx::Size NSImageSize(NSImage* image) { gfx::Size NSImageSize(NSImage* image) {
......
...@@ -35,13 +35,11 @@ namespace internal { ...@@ -35,13 +35,11 @@ namespace internal {
#if defined(OS_IOS) #if defined(OS_IOS)
scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage( scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage(
UIImage* uiimage); UIImage* uiimage);
// Caller takes ownership of the returned UIImage. UIImage* UIImageFromPNG(const std::vector<ImagePNGRep>& image_png_reps);
UIImage* CreateUIImageFromPNG(const std::vector<ImagePNGRep>& image_png_reps);
gfx::Size UIImageSize(UIImage* image); gfx::Size UIImageSize(UIImage* image);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromNSImage( scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromNSImage(
NSImage* nsimage); NSImage* nsimage);
// Caller takes ownership of the returned NSImage.
NSImage* NSImageFromPNG(const std::vector<ImagePNGRep>& image_png_reps, NSImage* NSImageFromPNG(const std::vector<ImagePNGRep>& image_png_reps,
CGColorSpaceRef color_space); CGColorSpaceRef color_space);
gfx::Size NSImageSize(NSImage* image); gfx::Size NSImageSize(NSImage* image);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment