summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorsenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 06:46:16 +0000
committersenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 06:46:16 +0000
commit9152f58fc51f32beb473e1198c2b118b24747057 (patch)
treec9baa9c0627864195b19d0cd5ada0e566e8e01a6 /skia
parent7f6c9d4626e3fa83cb8e13429e877bce8f213d2a (diff)
downloadchromium_src-9152f58fc51f32beb473e1198c2b118b24747057.zip
chromium_src-9152f58fc51f32beb473e1198c2b118b24747057.tar.gz
chromium_src-9152f58fc51f32beb473e1198c2b118b24747057.tar.bz2
In order to respect Win32 semantics (and appease Dr.Memory), stash the initial GDI bitmap created with the DC in BitmapPlatformDevice(win), and select it back into the DC just before destruction.
BUG=110783 Review URL: https://codereview.chromium.org/100393007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_win.cc9
-rw-r--r--skia/ext/bitmap_platform_device_win.h4
2 files changed, 8 insertions, 5 deletions
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc
index 0dfc324..ed01a35 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -147,11 +147,7 @@ HDC BitmapPlatformDevice::GetBitmapDC() {
if (!hdc_) {
hdc_ = CreateCompatibleDC(NULL);
InitializeDC(hdc_);
- HGDIOBJ old_bitmap = SelectObject(hdc_, hbitmap_);
- // When the memory DC is created, its display surface is exactly one
- // monochrome pixel wide and one monochrome pixel high. Since we select our
- // own bitmap, we must delete the previous one.
- DeleteObject(old_bitmap);
+ old_hbitmap_ = static_cast<HBITMAP>(SelectObject(hdc_, hbitmap_));
}
LoadConfig();
@@ -160,8 +156,10 @@ HDC BitmapPlatformDevice::GetBitmapDC() {
void BitmapPlatformDevice::ReleaseBitmapDC() {
SkASSERT(hdc_);
+ SelectObject(hdc_, old_hbitmap_);
DeleteDC(hdc_);
hdc_ = NULL;
+ old_hbitmap_ = NULL;
}
bool BitmapPlatformDevice::IsBitmapDCCreated()
@@ -248,6 +246,7 @@ BitmapPlatformDevice::BitmapPlatformDevice(
const SkBitmap& bitmap)
: SkBitmapDevice(bitmap),
hbitmap_(hbitmap),
+ old_hbitmap_(NULL),
hdc_(NULL),
config_dirty_(true), // Want to load the config next time.
transform_(SkMatrix::I()) {
diff --git a/skia/ext/bitmap_platform_device_win.h b/skia/ext/bitmap_platform_device_win.h
index d2c1603..5d8afdc 100644
--- a/skia/ext/bitmap_platform_device_win.h
+++ b/skia/ext/bitmap_platform_device_win.h
@@ -81,6 +81,10 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice
// It's only stored here in order to lazy-create the DC (below).
HBITMAP hbitmap_;
+ // Previous bitmap held by the DC. This will be selected back before the
+ // DC is destroyed.
+ HBITMAP old_hbitmap_;
+
// Lazily-created DC used to draw into the bitmap; see GetBitmapDC().
HDC hdc_;