From 61e978ad63e1963c41db50e7b9b40580391a6170 Mon Sep 17 00:00:00 2001 From: "jrg@chromium.org" Date: Sat, 7 Mar 2009 03:45:14 +0000 Subject: Fix memory leak of "screen size bitmap" (e.g. 1.5M if 750x548) that happened on *every page view* on OSX. VSIZE/RSIZE now hovers around 500M/30M instead of growing to 1.3G/260M within a few minutes. Surprisingly, Chromium.app seems quite a bit snappier! The essence of the change is that SkBitmap::setPixels() does NOT take ownership of the pointer, whereas SkBitmap::allocPixels() both allocates and owns. Review URL: http://codereview.chromium.org/39307 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11196 0039d316-1c4b-4281-b951-d872f2087c98 --- skia/ext/bitmap_platform_device_mac.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'skia') diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc index a0f0bf1..a3f5e74 100755 --- a/skia/ext/bitmap_platform_device_mac.cc +++ b/skia/ext/bitmap_platform_device_mac.cc @@ -146,12 +146,11 @@ BitmapPlatformDeviceMac* BitmapPlatformDeviceMac::Create(CGContextRef context, int width, int height, bool is_opaque) { - void* data = malloc(height * width * 4); - if (!data) return NULL; - SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - bitmap.setPixels(data); + if (bitmap.allocPixels() != true) + return NULL; + void* data = bitmap.getPixels(); // Note: The Windows implementation clears the Bitmap later on. // This bears mentioning since removal of this line makes the @@ -224,7 +223,7 @@ CGContextRef BitmapPlatformDeviceMac::GetBitmapContext() { return data_->GetBitmapContext(); } -void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform, +void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform, const SkRegion& region) { data_->SetMatrixClip(transform, region); } -- cgit v1.1