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

Unified Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 126159: Stop leaking CGBitmapContextRefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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: skia/ext/bitmap_platform_device_mac.cc
===================================================================
--- skia/ext/bitmap_platform_device_mac.cc (revision 18420)
+++ skia/ext/bitmap_platform_device_mac.cc (working copy)
@@ -209,10 +209,17 @@
if (!context)
context = CGContextForData(data, width, height);
+ else
+ CGContextRetain(context);
- // The device object will take ownership of the graphics context.
- return new BitmapPlatformDevice(
+ BitmapPlatformDevice* rv = new BitmapPlatformDevice(
new BitmapPlatformDeviceData(context), bitmap);
+
+ // The device object took ownership of the graphics context with its own
+ // CGContextRetain call.
+ CGContextRelease(context);
+
+ return rv;
}
BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data,
@@ -223,7 +230,14 @@
if (data)
context = CGContextForData(data, width, height);
- return Create(context, width, height, is_opaque);
+ BitmapPlatformDevice* rv = Create(context, width, height, is_opaque);
+
+ // The device object took ownership of the graphics context with its own
+ // CGContextRetain call.
+ if (context)
+ CGContextRelease(context);
+
+ return rv;
}
// The device will own the bitmap, which corresponds to also owning the pixel
« 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