diff options
Diffstat (limited to 'skia/ext/bitmap_platform_device_mac.cc')
-rw-r--r-- | skia/ext/bitmap_platform_device_mac.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc index 834655d..fd8a3a8 100644 --- a/skia/ext/bitmap_platform_device_mac.cc +++ b/skia/ext/bitmap_platform_device_mac.cc @@ -209,10 +209,17 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context, 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 @@ BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data, 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 |