Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Unified Diff: remoting/host/capturer_win.cc

Issue 10699046: Support remoting of all monitors on multi-monitor Windows systems (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/capturer_win.cc
diff --git a/remoting/host/capturer_win.cc b/remoting/host/capturer_win.cc
index cae0326b29e0bc96f18324f838439bf43f29df2a..3a7fe50fdfbcccd3f78ef75012e8a9e87b25ac11 100644
--- a/remoting/host/capturer_win.cc
+++ b/remoting/host/capturer_win.cc
@@ -88,7 +88,9 @@ class CapturerGdi : public Capturer {
void CaptureRegion(const SkRegion& region,
const CaptureCompletedCallback& callback);
- void ReleaseBuffers();
+ // Release all GDI resources, including bitmaps and device contexts.
+ void ReleaseGdiResources();
+
// Generates an image in the current buffer.
void CaptureImage();
@@ -121,8 +123,7 @@ class CapturerGdi : public Capturer {
ScopedThreadDesktopWin desktop_;
- // Gdi specific information about screen.
- HWND desktop_window_;
+ // GDI resources used for screen capture.
HDC desktop_dc_;
alexeypa (please no reviews) 2012/07/02 15:50:11 nit: There are ScopedGetDC and ScopedCreateDC avai
Wez 2012/07/03 20:56:26 Done.
HDC memory_dc_;
HBITMAP target_bitmap_[kNumBuffers];
alexeypa (please no reviews) 2012/07/02 15:50:11 nit: ScopedBitmap can be used here.
Wez 2012/07/03 20:56:26 Done.
@@ -153,7 +154,6 @@ static const int kBytesPerPixel = 4;
CapturerGdi::CapturerGdi()
: last_cursor_size_(SkISize::Make(0, 0)),
- desktop_window_(NULL),
desktop_dc_(NULL),
memory_dc_(NULL),
dc_size_(SkISize::Make(0, 0)),
@@ -166,7 +166,7 @@ CapturerGdi::CapturerGdi()
}
CapturerGdi::~CapturerGdi() {
- ReleaseBuffers();
+ ReleaseGdiResources();
}
media::VideoFrame::Format CapturerGdi::pixel_format() const {
@@ -208,7 +208,7 @@ const SkISize& CapturerGdi::size_most_recent() const {
return helper_.size_most_recent();
}
-void CapturerGdi::ReleaseBuffers() {
+void CapturerGdi::ReleaseGdiResources() {
for (int i = kNumBuffers - 1; i >= 0; i--) {
if (target_bitmap_[i]) {
DeleteObject(target_bitmap_[i]);
@@ -221,8 +221,7 @@ void CapturerGdi::ReleaseBuffers() {
}
if (desktop_dc_) {
- ReleaseDC(desktop_window_, desktop_dc_);
- desktop_window_ = NULL;
+ ReleaseDC(NULL, desktop_dc_);
desktop_dc_ = NULL;
}
@@ -272,46 +271,25 @@ void CapturerGdi::UpdateBufferCapture(const SkISize& size) {
scoped_ptr<DesktopWin> input_desktop = DesktopWin::GetInputDesktop();
if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) {
// Release GDI resources otherwise SetThreadDesktop will fail.
- if (desktop_dc_) {
- ReleaseDC(desktop_window_, desktop_dc_);
- desktop_window_ = NULL;
- desktop_dc_ = NULL;
- }
-
- if (memory_dc_) {
- DeleteDC(memory_dc_);
- memory_dc_ = NULL;
- }
-
- ReleaseBuffers();
+ ReleaseGdiResources();
// If SetThreadDesktop() fails, the thread is still assigned a desktop.
// So we can continue capture screen bits, just from a diffented desktop.
desktop_.SetThreadDesktop(input_desktop.Pass());
}
- // Make sure the DCs have the correct dimensions.
+ // If the display dimensions have changed then recreate GDI resources.
if (size != dc_size_) {
- // TODO(simonmorris): screen dimensions changing isn't equivalent to needing
- // a new DC, but it's good enough for now.
- if (desktop_dc_) {
- ReleaseDC(desktop_window_, desktop_dc_);
- desktop_window_ = NULL;
- desktop_dc_ = NULL;
- }
-
- if (memory_dc_) {
- DeleteDC(memory_dc_);
- memory_dc_ = NULL;
- }
+ ReleaseGdiResources();
}
+ // Create GDI device contexts to capture from the desktop into memory.
if (desktop_dc_ == NULL) {
- DCHECK(desktop_window_ == NULL);
DCHECK(memory_dc_ == NULL);
+ DCHECK(target_bitmap_[0] == NULL);
+ DCHECK(buffers_[0].data == NULL);
- desktop_window_ = GetDesktopWindow();
- desktop_dc_ = GetDC(desktop_window_);
+ desktop_dc_ = GetDC(NULL);
memory_dc_ = CreateCompatibleDC(desktop_dc_);
dc_size_ = size;
}
@@ -431,7 +409,8 @@ void CapturerGdi::CaptureImage() {
// And then copy the rect from desktop to memory.
BitBlt(memory_dc_, 0, 0, buffers_[current_buffer_].size.width(),
- buffers_[current_buffer_].size.height(), desktop_dc_, 0, 0,
+ buffers_[current_buffer_].size.height(), desktop_dc_,
+ GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN),
alexeypa (please no reviews) 2012/07/02 15:50:11 There is a race between this code and CapturerGdi:
Wez 2012/07/03 20:56:26 There's no race as such, since the width & height
SRCCOPY | CAPTUREBLT);
}
@@ -609,8 +588,8 @@ void CapturerGdi::CaptureCursor() {
}
SkISize CapturerGdi::GetScreenSize() {
- return SkISize::Make(GetSystemMetrics(SM_CXSCREEN),
- GetSystemMetrics(SM_CYSCREEN));
+ return SkISize::Make(GetSystemMetrics(SM_CXVIRTUALSCREEN),
+ GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698