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
This commit is contained in:
@@ -146,12 +146,11 @@ BitmapPlatformDeviceMac* BitmapPlatformDeviceMac::Create(CGContextRef context,
|
|||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
bool is_opaque) {
|
bool is_opaque) {
|
||||||
void* data = malloc(height * width * 4);
|
|
||||||
if (!data) return NULL;
|
|
||||||
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
|
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.
|
// Note: The Windows implementation clears the Bitmap later on.
|
||||||
// This bears mentioning since removal of this line makes the
|
// This bears mentioning since removal of this line makes the
|
||||||
@@ -224,7 +223,7 @@ CGContextRef BitmapPlatformDeviceMac::GetBitmapContext() {
|
|||||||
return data_->GetBitmapContext();
|
return data_->GetBitmapContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform,
|
void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform,
|
||||||
const SkRegion& region) {
|
const SkRegion& region) {
|
||||||
data_->SetMatrixClip(transform, region);
|
data_->SetMatrixClip(transform, region);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user