| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/native_library.h" | 12 #include "base/native_library.h" |
| 13 #include "base/string16.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/stringize_macros.h" | |
| 15 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
| 16 #include "remoting/base/capture_data.h" | 15 #include "remoting/base/capture_data.h" |
| 17 #include "remoting/host/capturer_helper.h" | 16 #include "remoting/host/capturer_helper.h" |
| 18 #include "remoting/host/desktop_win.h" | 17 #include "remoting/host/desktop_win.h" |
| 19 #include "remoting/host/differ.h" | 18 #include "remoting/host/differ.h" |
| 20 #include "remoting/host/scoped_thread_desktop_win.h" | 19 #include "remoting/host/scoped_thread_desktop_win.h" |
| 21 #include "remoting/proto/control.pb.h" | 20 #include "remoting/proto/control.pb.h" |
| 22 | 21 |
| 23 namespace remoting { | 22 namespace remoting { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 // Constants from dwmapi.h. | 26 // Constants from dwmapi.h. |
| 28 const UINT DWM_EC_DISABLECOMPOSITION = 0; | 27 const UINT DWM_EC_DISABLECOMPOSITION = 0; |
| 29 const UINT DWM_EC_ENABLECOMPOSITION = 1; | 28 const UINT DWM_EC_ENABLECOMPOSITION = 1; |
| 30 | 29 |
| 31 typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT); | 30 typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT); |
| 32 | 31 |
| 33 const char16 kDwmapiLibraryName[] = TO_L_STRING("dwmapi"); | 32 const wchar_t kDwmapiLibraryName[] = L"dwmapi"; |
| 34 | 33 |
| 35 // Pixel colors used when generating cursor outlines. | 34 // Pixel colors used when generating cursor outlines. |
| 36 const uint32 kPixelBgraBlack = 0xff000000; | 35 const uint32 kPixelBgraBlack = 0xff000000; |
| 37 const uint32 kPixelBgraWhite = 0xffffffff; | 36 const uint32 kPixelBgraWhite = 0xffffffff; |
| 38 const uint32 kPixelBgraTransparent = 0x00000000; | 37 const uint32 kPixelBgraTransparent = 0x00000000; |
| 39 | 38 |
| 40 // CapturerGdi captures 32bit RGB using GDI. | 39 // CapturerGdi captures 32bit RGB using GDI. |
| 41 // | 40 // |
| 42 // CapturerGdi is double-buffered as required by Capturer. See | 41 // CapturerGdi is double-buffered as required by Capturer. See |
| 43 // remoting/host/capturer.h. | 42 // remoting/host/capturer.h. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 238 } |
| 240 | 239 |
| 241 void CapturerGdi::Start( | 240 void CapturerGdi::Start( |
| 242 const CursorShapeChangedCallback& callback) { | 241 const CursorShapeChangedCallback& callback) { |
| 243 cursor_shape_changed_callback_ = callback; | 242 cursor_shape_changed_callback_ = callback; |
| 244 | 243 |
| 245 // Load dwmapi.dll dynamically since it is not available on XP. | 244 // Load dwmapi.dll dynamically since it is not available on XP. |
| 246 if (dwmapi_library_ == NULL) { | 245 if (dwmapi_library_ == NULL) { |
| 247 std::string error; | 246 std::string error; |
| 248 dwmapi_library_ = base::LoadNativeLibrary( | 247 dwmapi_library_ = base::LoadNativeLibrary( |
| 249 FilePath(base::GetNativeLibraryName(kDwmapiLibraryName)), &error); | 248 FilePath(base::GetNativeLibraryName(WideToUTF16(kDwmapiLibraryName))), |
| 249 &error); |
| 250 } | 250 } |
| 251 | 251 |
| 252 if (dwmapi_library_ != NULL && composition_func_ == NULL) { | 252 if (dwmapi_library_ != NULL && composition_func_ == NULL) { |
| 253 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( | 253 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( |
| 254 base::GetFunctionPointerFromNativeLibrary(dwmapi_library_, | 254 base::GetFunctionPointerFromNativeLibrary(dwmapi_library_, |
| 255 "DwmEnableComposition")); | 255 "DwmEnableComposition")); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // Vote to disable Aero composited desktop effects while capturing. Windows | 258 // Vote to disable Aero composited desktop effects while capturing. Windows |
| 259 // will restore Aero automatically if the process exits. This has no effect | 259 // will restore Aero automatically if the process exits. This has no effect |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 621 } |
| 622 | 622 |
| 623 } // namespace | 623 } // namespace |
| 624 | 624 |
| 625 // static | 625 // static |
| 626 Capturer* Capturer::Create() { | 626 Capturer* Capturer::Create() { |
| 627 return new CapturerGdi(); | 627 return new CapturerGdi(); |
| 628 } | 628 } |
| 629 | 629 |
| 630 } // namespace remoting | 630 } // namespace remoting |
| OLD | NEW |