summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 23:29:57 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 23:29:57 +0000
commitf698a68d0ae5bbcfdc42db2aaedae226353c3da7 (patch)
tree71cb3aac0ded7f4f000dd2192d33a1bdfd597dff
parente59778a222e87268dd3241ce5f2d44f9f427d6f0 (diff)
downloadchromium_src-f698a68d0ae5bbcfdc42db2aaedae226353c3da7.zip
chromium_src-f698a68d0ae5bbcfdc42db2aaedae226353c3da7.tar.gz
chromium_src-f698a68d0ae5bbcfdc42db2aaedae226353c3da7.tar.bz2
Unselect GDI bitmaps after use to make sure that the device context and bitmaps can be destroyed independently.
BUG=160477 Review URL: https://codereview.chromium.org/11410038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167261 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/video_frame_capturer_win.cc16
-rw-r--r--tools/valgrind/drmemory/suppressions.txt9
2 files changed, 10 insertions, 15 deletions
diff --git a/remoting/host/video_frame_capturer_win.cc b/remoting/host/video_frame_capturer_win.cc
index 3386c11..cfa0836 100644
--- a/remoting/host/video_frame_capturer_win.cc
+++ b/remoting/host/video_frame_capturer_win.cc
@@ -103,15 +103,15 @@ class VideoFrameCapturerWin : public VideoFrameCapturer {
scoped_array<uint8> last_cursor_;
SkISize last_cursor_size_;
- // Queue of the frames buffers.
- VideoFrameQueue queue_;
-
ScopedThreadDesktop desktop_;
// GDI resources used for screen capture.
scoped_ptr<base::win::ScopedGetDC> desktop_dc_;
base::win::ScopedCreateDC memory_dc_;
+ // Queue of the frames buffers.
+ VideoFrameQueue queue_;
+
// Rectangle describing the bounds of the desktop device context.
SkIRect desktop_dc_rect_;
@@ -348,14 +348,18 @@ void VideoFrameCapturerWin::CaptureImage() {
// Select the target bitmap into the memory dc and copy the rect from desktop
// to memory.
- VideoFrameWin* current =
- static_cast<VideoFrameWin*>(queue_.current_frame());
- if (SelectObject(memory_dc_, current->GetBitmap()) != NULL) {
+ VideoFrameWin* current = static_cast<VideoFrameWin*>(queue_.current_frame());
+ HGDIOBJ previous_object = SelectObject(memory_dc_, current->GetBitmap());
+ if (previous_object != NULL) {
BitBlt(memory_dc_,
0, 0, desktop_dc_rect_.width(), desktop_dc_rect_.height(),
*desktop_dc_,
desktop_dc_rect_.x(), desktop_dc_rect_.y(),
SRCCOPY | CAPTUREBLT);
+
+ // Select back the previously selected object to that the device contect
+ // could be destroyed independently of the bitmap if needed.
+ SelectObject(memory_dc_, previous_object);
}
}
diff --git a/tools/valgrind/drmemory/suppressions.txt b/tools/valgrind/drmemory/suppressions.txt
index bf23272..dc11b73 100644
--- a/tools/valgrind/drmemory/suppressions.txt
+++ b/tools/valgrind/drmemory/suppressions.txt
@@ -390,12 +390,3 @@ content.dll!*
KERNEL32.dll!*
ntdll.dll!*
ntdll.dll!*
-
-GDI USAGE ERROR
-name=http://crbug.com/160477
-system call NtGdiDeleteObjectApp
-GDI32.dll!DeleteDC
-*!base::win::CreateDCTraits::CloseHandle
-*!base::win::GenericScopedHandle<base::win::CreateDCTraits,base::win::VerifierTraits>::Close
-*!base::win::GenericScopedHandle<base::win::CreateDCTraits,base::win::VerifierTraits>::~GenericScopedHandle<base::win::CreateDCTraits,base::win::VerifierTraits>
-*!remoting::`anonymous namespace'::VideoFrameCapturerWin::~VideoFrameCapturerWin