summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 23:49:18 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 23:49:18 +0000
commit60406bca86bce05065b961cb6cd09348c77be949 (patch)
treea27028cc70d6c8b7d8039e60d40edc6480eed29a /skia
parent1e5f53afece084581248c135205399dd33e9631e (diff)
downloadchromium_src-60406bca86bce05065b961cb6cd09348c77be949.zip
chromium_src-60406bca86bce05065b961cb6cd09348c77be949.tar.gz
chromium_src-60406bca86bce05065b961cb6cd09348c77be949.tar.bz2
Stop leaking CGBitmapContextRefs. Regression from r18363.
BUG=14105 TEST=sh tools/valgrind/chrome_tests.sh --build_dir xcodebuild/Debug --test unit --gtest_filter=RenderWidgetHostTest.Resize Review URL: http://codereview.chromium.org/126159 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_mac.cc20
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