| 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/capturer.h" | 5 #include "remoting/host/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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // CapturerGdi captures 32bit RGB using GDI. | 32 // CapturerGdi captures 32bit RGB using GDI. |
| 33 // | 33 // |
| 34 // CapturerGdi is double-buffered as required by Capturer. See | 34 // CapturerGdi is double-buffered as required by Capturer. See |
| 35 // remoting/host/capturer.h. | 35 // remoting/host/capturer.h. |
| 36 class CapturerGdi : public Capturer { | 36 class CapturerGdi : public Capturer { |
| 37 public: | 37 public: |
| 38 CapturerGdi(); | 38 CapturerGdi(); |
| 39 virtual ~CapturerGdi(); | 39 virtual ~CapturerGdi(); |
| 40 | 40 |
| 41 // Capturer interface. | 41 // Capturer interface. |
| 42 virtual void Start() OVERRIDE; | 42 virtual void Start(const CursorShapeChangedCallback& callback) OVERRIDE; |
| 43 virtual void Stop() OVERRIDE; | 43 virtual void Stop() OVERRIDE; |
| 44 virtual void ScreenConfigurationChanged() OVERRIDE; | 44 virtual void ScreenConfigurationChanged() OVERRIDE; |
| 45 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; | 45 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; |
| 46 virtual void ClearInvalidRegion() OVERRIDE; | 46 virtual void ClearInvalidRegion() OVERRIDE; |
| 47 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; | 47 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; |
| 48 virtual void InvalidateScreen(const SkISize& size) OVERRIDE; | 48 virtual void InvalidateScreen(const SkISize& size) OVERRIDE; |
| 49 virtual void InvalidateFullScreen() OVERRIDE; | 49 virtual void InvalidateFullScreen() OVERRIDE; |
| 50 virtual void CaptureInvalidRegion( | 50 virtual void CaptureInvalidRegion( |
| 51 const CaptureCompletedCallback& callback) OVERRIDE; | 51 const CaptureCompletedCallback& callback) OVERRIDE; |
| 52 virtual const SkISize& size_most_recent() const OVERRIDE; | 52 virtual const SkISize& size_most_recent() const OVERRIDE; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 desktop_window_ = NULL; | 207 desktop_window_ = NULL; |
| 208 desktop_dc_ = NULL; | 208 desktop_dc_ = NULL; |
| 209 } | 209 } |
| 210 | 210 |
| 211 if (memory_dc_) { | 211 if (memory_dc_) { |
| 212 DeleteDC(memory_dc_); | 212 DeleteDC(memory_dc_); |
| 213 memory_dc_ = NULL; | 213 memory_dc_ = NULL; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CapturerGdi::Start() { | 217 void CapturerGdi::Start( |
| 218 const CursorShapeChangedCallback& callback) { |
| 219 cursor_shape_changed_callback_ = callback; |
| 220 |
| 218 // Load dwmapi.dll dynamically since it is not available on XP. | 221 // Load dwmapi.dll dynamically since it is not available on XP. |
| 219 if (dwmapi_library_ == NULL) { | 222 if (dwmapi_library_ == NULL) { |
| 220 std::string error; | 223 std::string error; |
| 221 dwmapi_library_ = base::LoadNativeLibrary( | 224 dwmapi_library_ = base::LoadNativeLibrary( |
| 222 FilePath(base::GetNativeLibraryName(kDwmapiLibraryName)), &error); | 225 FilePath(base::GetNativeLibraryName(kDwmapiLibraryName)), &error); |
| 223 } | 226 } |
| 224 | 227 |
| 225 if (dwmapi_library_ != NULL && composition_func_ == NULL) { | 228 if (dwmapi_library_ != NULL && composition_func_ == NULL) { |
| 226 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( | 229 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( |
| 227 base::GetFunctionPointerFromNativeLibrary(dwmapi_library_, | 230 base::GetFunctionPointerFromNativeLibrary(dwmapi_library_, |
| 228 "DwmEnableComposition")); | 231 "DwmEnableComposition")); |
| 229 } | 232 } |
| 230 | 233 |
| 231 // Vote to disable Aero composited desktop effects while capturing. Windows | 234 // Vote to disable Aero composited desktop effects while capturing. Windows |
| 232 // will restore Aero automatically if the process exits. This has no effect | 235 // will restore Aero automatically if the process exits. This has no effect |
| 233 // under Windows 8 or higher. See crbug.com/124018. | 236 // under Windows 8 or higher. See crbug.com/124018. |
| 234 if (composition_func_ != NULL) { | 237 if (composition_func_ != NULL) { |
| 235 (*composition_func_)(DWM_EC_DISABLECOMPOSITION); | 238 (*composition_func_)(DWM_EC_DISABLECOMPOSITION); |
| 236 } | 239 } |
| 237 } | 240 } |
| 238 | 241 |
| 239 void CapturerGdi::Stop() { | 242 void CapturerGdi::Stop() { |
| 240 // Restore Aero. | 243 // Restore Aero. |
| 241 if (composition_func_ != NULL) { | 244 if (composition_func_ != NULL) { |
| 242 (*composition_func_)(DWM_EC_ENABLECOMPOSITION); | 245 (*composition_func_)(DWM_EC_ENABLECOMPOSITION); |
| 243 } | 246 } |
| 244 } | 247 } |
| 245 | 248 |
| 249 void CapturerGdi::SetCursorShapeChangedCallback( |
| 250 const CursorShapeChangedCallback& callback) { |
| 251 // TODO(garykac) Implement this. Although as with the screen config changes, |
| 252 // we'll need to poll to look for cursor shape changes. (crbug.com/116299) |
| 253 } |
| 254 |
| 246 void CapturerGdi::ScreenConfigurationChanged() { | 255 void CapturerGdi::ScreenConfigurationChanged() { |
| 247 // We poll for screen configuration changes, so ignore notifications. | 256 // We poll for screen configuration changes, so ignore notifications. |
| 248 } | 257 } |
| 249 | 258 |
| 250 void CapturerGdi::UpdateBufferCapture(const SkISize& size) { | 259 void CapturerGdi::UpdateBufferCapture(const SkISize& size) { |
| 251 // Switch to the desktop receiving user input if different from the current | 260 // Switch to the desktop receiving user input if different from the current |
| 252 // one. | 261 // one. |
| 253 scoped_ptr<DesktopWin> input_desktop = DesktopWin::GetInputDesktop(); | 262 scoped_ptr<DesktopWin> input_desktop = DesktopWin::GetInputDesktop(); |
| 254 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { | 263 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { |
| 255 // Release GDI resources otherwise SetThreadDesktop will fail. | 264 // Release GDI resources otherwise SetThreadDesktop will fail. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 431 } |
| 423 | 432 |
| 424 } // namespace | 433 } // namespace |
| 425 | 434 |
| 426 // static | 435 // static |
| 427 Capturer* Capturer::Create() { | 436 Capturer* Capturer::Create() { |
| 428 return new CapturerGdi(); | 437 return new CapturerGdi(); |
| 429 } | 438 } |
| 430 | 439 |
| 431 } // namespace remoting | 440 } // namespace remoting |
| OLD | NEW |