| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification | 31 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification |
| 32 // API. The other strings can be anything. | 32 // API. The other strings can be anything. |
| 33 static LPCTSTR kMagnifierHostClass = L"ScreenCapturerWinMagnifierHost"; | 33 static LPCTSTR kMagnifierHostClass = L"ScreenCapturerWinMagnifierHost"; |
| 34 static LPCTSTR kHostWindowName = L"MagnifierHost"; | 34 static LPCTSTR kHostWindowName = L"MagnifierHost"; |
| 35 static LPCTSTR kMagnifierWindowClass = L"Magnifier"; | 35 static LPCTSTR kMagnifierWindowClass = L"Magnifier"; |
| 36 static LPCTSTR kMagnifierWindowName = L"MagnifierWindow"; | 36 static LPCTSTR kMagnifierWindowName = L"MagnifierWindow"; |
| 37 | 37 |
| 38 Atomic32 ScreenCapturerWinMagnifier::tls_index_(TLS_OUT_OF_INDEXES); | 38 Atomic32 ScreenCapturerWinMagnifier::tls_index_(TLS_OUT_OF_INDEXES); |
| 39 | 39 |
| 40 ScreenCapturerWinMagnifier::ScreenCapturerWinMagnifier( | 40 ScreenCapturerWinMagnifier::ScreenCapturerWinMagnifier( |
| 41 rtc::scoped_ptr<ScreenCapturer> fallback_capturer) | 41 std::unique_ptr<ScreenCapturer> fallback_capturer) |
| 42 : fallback_capturer_(std::move(fallback_capturer)), | 42 : fallback_capturer_(std::move(fallback_capturer)), |
| 43 fallback_capturer_started_(false), | 43 fallback_capturer_started_(false), |
| 44 callback_(NULL), | 44 callback_(NULL), |
| 45 current_screen_id_(kFullDesktopScreenId), | 45 current_screen_id_(kFullDesktopScreenId), |
| 46 excluded_window_(NULL), | 46 excluded_window_(NULL), |
| 47 set_thread_execution_state_failed_(false), | 47 set_thread_execution_state_failed_(false), |
| 48 desktop_dc_(NULL), | 48 desktop_dc_(NULL), |
| 49 mag_lib_handle_(NULL), | 49 mag_lib_handle_(NULL), |
| 50 mag_initialize_func_(NULL), | 50 mag_initialize_func_(NULL), |
| 51 mag_uninitialize_func_(NULL), | 51 mag_uninitialize_func_(NULL), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 76 void ScreenCapturerWinMagnifier::Start(Callback* callback) { | 76 void ScreenCapturerWinMagnifier::Start(Callback* callback) { |
| 77 assert(!callback_); | 77 assert(!callback_); |
| 78 assert(callback); | 78 assert(callback); |
| 79 callback_ = callback; | 79 callback_ = callback; |
| 80 | 80 |
| 81 InitializeMagnifier(); | 81 InitializeMagnifier(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory( | 84 void ScreenCapturerWinMagnifier::SetSharedMemoryFactory( |
| 85 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) { | 85 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) { |
| 86 shared_memory_factory_ = std::move(shared_memory_factory); | 86 shared_memory_factory_ = |
| 87 rtc::ScopedToUnique(std::move(shared_memory_factory)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { | 90 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { |
| 90 TickTime capture_start_time = TickTime::Now(); | 91 TickTime capture_start_time = TickTime::Now(); |
| 91 | 92 |
| 92 queue_.MoveToNextFrame(); | 93 queue_.MoveToNextFrame(); |
| 93 | 94 |
| 94 // Request that the system not power-down the system, or the display hardware. | 95 // Request that the system not power-down the system, or the display hardware. |
| 95 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { | 96 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { |
| 96 if (!set_thread_execution_state_failed_) { | 97 if (!set_thread_execution_state_failed_) { |
| 97 set_thread_execution_state_failed_ = true; | 98 set_thread_execution_state_failed_ = true; |
| 98 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " | 99 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " |
| 99 << GetLastError(); | 100 << GetLastError(); |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 // Switch to the desktop receiving user input if different from the current | 103 // Switch to the desktop receiving user input if different from the current |
| 103 // one. | 104 // one. |
| 104 rtc::scoped_ptr<Desktop> input_desktop(Desktop::GetInputDesktop()); | 105 std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop()); |
| 105 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { | 106 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { |
| 106 // Release GDI resources otherwise SetThreadDesktop will fail. | 107 // Release GDI resources otherwise SetThreadDesktop will fail. |
| 107 if (desktop_dc_) { | 108 if (desktop_dc_) { |
| 108 ReleaseDC(NULL, desktop_dc_); | 109 ReleaseDC(NULL, desktop_dc_); |
| 109 desktop_dc_ = NULL; | 110 desktop_dc_ = NULL; |
| 110 } | 111 } |
| 111 // If SetThreadDesktop() fails, the thread is still assigned a desktop. | 112 // If SetThreadDesktop() fails, the thread is still assigned a desktop. |
| 112 // So we can continue capture screen bits, just from the wrong desktop. | 113 // So we can continue capture screen bits, just from the wrong desktop. |
| 113 desktop_.SetThreadDesktop(input_desktop.release()); | 114 desktop_.SetThreadDesktop(input_desktop.release()); |
| 114 } | 115 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 421 |
| 421 magnifier_capture_succeeded_ = true; | 422 magnifier_capture_succeeded_ = true; |
| 422 } | 423 } |
| 423 | 424 |
| 424 void ScreenCapturerWinMagnifier::CreateCurrentFrameIfNecessary( | 425 void ScreenCapturerWinMagnifier::CreateCurrentFrameIfNecessary( |
| 425 const DesktopSize& size) { | 426 const DesktopSize& size) { |
| 426 // If the current buffer is from an older generation then allocate a new one. | 427 // If the current buffer is from an older generation then allocate a new one. |
| 427 // Note that we can't reallocate other buffers at this point, since the caller | 428 // Note that we can't reallocate other buffers at this point, since the caller |
| 428 // may still be reading from them. | 429 // may still be reading from them. |
| 429 if (!queue_.current_frame() || !queue_.current_frame()->size().equals(size)) { | 430 if (!queue_.current_frame() || !queue_.current_frame()->size().equals(size)) { |
| 430 rtc::scoped_ptr<DesktopFrame> frame = | 431 std::unique_ptr<DesktopFrame> frame = |
| 431 shared_memory_factory_ | 432 shared_memory_factory_ |
| 432 ? SharedMemoryDesktopFrame::Create(size, | 433 ? SharedMemoryDesktopFrame::Create(size, |
| 433 shared_memory_factory_.get()) | 434 shared_memory_factory_.get()) |
| 434 : rtc::scoped_ptr<DesktopFrame>(new BasicDesktopFrame(size)); | 435 : std::unique_ptr<DesktopFrame>(new BasicDesktopFrame(size)); |
| 435 queue_.ReplaceCurrentFrame(frame.release()); | 436 queue_.ReplaceCurrentFrame(frame.release()); |
| 436 } | 437 } |
| 437 } | 438 } |
| 438 | 439 |
| 439 void ScreenCapturerWinMagnifier::StartFallbackCapturer() { | 440 void ScreenCapturerWinMagnifier::StartFallbackCapturer() { |
| 440 assert(fallback_capturer_); | 441 assert(fallback_capturer_); |
| 441 if (!fallback_capturer_started_) { | 442 if (!fallback_capturer_started_) { |
| 442 fallback_capturer_started_ = true; | 443 fallback_capturer_started_ = true; |
| 443 | 444 |
| 444 fallback_capturer_->Start(callback_); | 445 fallback_capturer_->Start(callback_); |
| 445 fallback_capturer_->SelectScreen(current_screen_id_); | 446 fallback_capturer_->SelectScreen(current_screen_id_); |
| 446 } | 447 } |
| 447 } | 448 } |
| 448 | 449 |
| 449 } // namespace webrtc | 450 } // namespace webrtc |
| OLD | NEW |