OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/video_frame_capturer.h" | 5 #include "remoting/host/video_frame_capturer.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/scoped_native_library.h" | 12 #include "base/scoped_native_library.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
15 #include "base/win/scoped_hdc.h" | 15 #include "base/win/scoped_hdc.h" |
16 #include "remoting/base/capture_data.h" | 16 #include "remoting/base/capture_data.h" |
17 #include "remoting/host/desktop_win.h" | |
18 #include "remoting/host/differ.h" | 17 #include "remoting/host/differ.h" |
19 #include "remoting/host/scoped_thread_desktop_win.h" | |
20 #include "remoting/host/video_frame_capturer_helper.h" | 18 #include "remoting/host/video_frame_capturer_helper.h" |
| 19 #include "remoting/host/win/desktop.h" |
| 20 #include "remoting/host/win/scoped_thread_desktop.h" |
21 #include "remoting/proto/control.pb.h" | 21 #include "remoting/proto/control.pb.h" |
22 | 22 |
23 namespace remoting { | 23 namespace remoting { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Constants from dwmapi.h. | 27 // Constants from dwmapi.h. |
28 const UINT DWM_EC_DISABLECOMPOSITION = 0; | 28 const UINT DWM_EC_DISABLECOMPOSITION = 0; |
29 const UINT DWM_EC_ENABLECOMPOSITION = 1; | 29 const UINT DWM_EC_ENABLECOMPOSITION = 1; |
30 | 30 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Snapshot of the last cursor bitmap we sent to the client. This is used | 98 // Snapshot of the last cursor bitmap we sent to the client. This is used |
99 // to diff against the current cursor so we only send a cursor-change | 99 // to diff against the current cursor so we only send a cursor-change |
100 // message when the shape has changed. | 100 // message when the shape has changed. |
101 scoped_array<uint8> last_cursor_; | 101 scoped_array<uint8> last_cursor_; |
102 SkISize last_cursor_size_; | 102 SkISize last_cursor_size_; |
103 | 103 |
104 // There are two buffers for the screen images, as required by Capturer. | 104 // There are two buffers for the screen images, as required by Capturer. |
105 static const int kNumBuffers = 2; | 105 static const int kNumBuffers = 2; |
106 VideoFrameBuffer buffers_[kNumBuffers]; | 106 VideoFrameBuffer buffers_[kNumBuffers]; |
107 | 107 |
108 ScopedThreadDesktopWin desktop_; | 108 ScopedThreadDesktop desktop_; |
109 | 109 |
110 // GDI resources used for screen capture. | 110 // GDI resources used for screen capture. |
111 scoped_ptr<base::win::ScopedGetDC> desktop_dc_; | 111 scoped_ptr<base::win::ScopedGetDC> desktop_dc_; |
112 base::win::ScopedCreateDC memory_dc_; | 112 base::win::ScopedCreateDC memory_dc_; |
113 base::win::ScopedBitmap target_bitmap_[kNumBuffers]; | 113 base::win::ScopedBitmap target_bitmap_[kNumBuffers]; |
114 int resource_generation_; | 114 int resource_generation_; |
115 | 115 |
116 // Rectangle describing the bounds of the desktop device context. | 116 // Rectangle describing the bounds of the desktop device context. |
117 SkIRect desktop_dc_rect_; | 117 SkIRect desktop_dc_rect_; |
118 | 118 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void VideoFrameCapturerWin::Stop() { | 209 void VideoFrameCapturerWin::Stop() { |
210 // Restore Aero. | 210 // Restore Aero. |
211 if (composition_func_ != NULL) { | 211 if (composition_func_ != NULL) { |
212 (*composition_func_)(DWM_EC_ENABLECOMPOSITION); | 212 (*composition_func_)(DWM_EC_ENABLECOMPOSITION); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void VideoFrameCapturerWin::PrepareCaptureResources() { | 216 void VideoFrameCapturerWin::PrepareCaptureResources() { |
217 // Switch to the desktop receiving user input if different from the current | 217 // Switch to the desktop receiving user input if different from the current |
218 // one. | 218 // one. |
219 scoped_ptr<DesktopWin> input_desktop = DesktopWin::GetInputDesktop(); | 219 scoped_ptr<Desktop> input_desktop = Desktop::GetInputDesktop(); |
220 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { | 220 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { |
221 // Release GDI resources otherwise SetThreadDesktop will fail. | 221 // Release GDI resources otherwise SetThreadDesktop will fail. |
222 desktop_dc_.reset(); | 222 desktop_dc_.reset(); |
223 memory_dc_.Set(NULL); | 223 memory_dc_.Set(NULL); |
224 | 224 |
225 // If SetThreadDesktop() fails, the thread is still assigned a desktop. | 225 // If SetThreadDesktop() fails, the thread is still assigned a desktop. |
226 // So we can continue capture screen bits, just from the wrong desktop. | 226 // So we can continue capture screen bits, just from the wrong desktop. |
227 desktop_.SetThreadDesktop(input_desktop.Pass()); | 227 desktop_.SetThreadDesktop(input_desktop.Pass()); |
228 } | 228 } |
229 | 229 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 546 } |
547 | 547 |
548 } // namespace | 548 } // namespace |
549 | 549 |
550 // static | 550 // static |
551 VideoFrameCapturer* VideoFrameCapturer::Create() { | 551 VideoFrameCapturer* VideoFrameCapturer::Create() { |
552 return new VideoFrameCapturerWin(); | 552 return new VideoFrameCapturerWin(); |
553 } | 553 } |
554 | 554 |
555 } // namespace remoting | 555 } // namespace remoting |
OLD | NEW |