diff options
author | reed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:50:20 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 17:50:20 +0000 |
commit | 36337d727cadd9198e6f8983a5e1d362bc672018 (patch) | |
tree | e5b0070eaa93588cc874664b53c60bc739ee97ce /skia | |
parent | ae3cf9bb850f1d1fd5bab996261646575c0ec443 (diff) | |
download | chromium_src-36337d727cadd9198e6f8983a5e1d362bc672018.zip chromium_src-36337d727cadd9198e6f8983a5e1d362bc672018.tar.gz chromium_src-36337d727cadd9198e6f8983a5e1d362bc672018.tar.bz2 |
Free the dibsection (HBITMAP) in PlatformBitmap's destructor, so we don't leak!
This adds an extra slot to PlatformBitmap, which is implemented for all platforms. To
do this simply, an intptr_t field is added (platform_extra_) which is initialized to 0.
At the moment, only the windows port uses this, but there is no cost to the other ports.
BUG=158931
Review URL: https://codereview.chromium.org/11293036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/bitmap_platform_device_win.cc | 6 | ||||
-rw-r--r-- | skia/ext/platform_canvas.cc | 2 | ||||
-rw-r--r-- | skia/ext/platform_canvas.h | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc index 12b9266..dc21673 100644 --- a/skia/ext/bitmap_platform_device_win.cc +++ b/skia/ext/bitmap_platform_device_win.cc @@ -273,6 +273,10 @@ SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( PlatformBitmap::~PlatformBitmap() { if (surface_) DeleteDC(surface_); + + HBITMAP hbitmap = (HBITMAP)platform_extra_; + if (hbitmap) + DeleteObject(hbitmap); } bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { @@ -287,6 +291,8 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { // monochrome pixel wide and one monochrome pixel high. Since we select our // own bitmap, we must delete the previous one. DeleteObject(old_bitmap); + // remember the hbitmap, so we can free it in our destructor + platform_extra_ = (intptr_t)hbitmap; return true; } diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc index 7e70165..11b1f5e 100644 --- a/skia/ext/platform_canvas.cc +++ b/skia/ext/platform_canvas.cc @@ -87,6 +87,6 @@ void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { canvas->drawRect(rect, paint); } -PlatformBitmap::PlatformBitmap() : surface_(0) {} +PlatformBitmap::PlatformBitmap() : surface_(0), platform_extra_(0) {} } // namespace skia diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h index 4d2b0c0..f20d62e 100644 --- a/skia/ext/platform_canvas.h +++ b/skia/ext/platform_canvas.h @@ -169,7 +169,8 @@ class SK_API PlatformBitmap { private: SkBitmap bitmap_; - PlatformSurface surface_; + PlatformSurface surface_; // initialized to 0 + intptr_t platform_extra_; // initialized to 0, specific to each platform DISALLOW_COPY_AND_ASSIGN(PlatformBitmap); }; |