| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 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( |
| 85 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) { |
| 86 shared_memory_factory_ = std::move(shared_memory_factory); |
| 87 } |
| 88 |
| 84 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { | 89 void ScreenCapturerWinMagnifier::Capture(const DesktopRegion& region) { |
| 85 TickTime capture_start_time = TickTime::Now(); | 90 TickTime capture_start_time = TickTime::Now(); |
| 86 | 91 |
| 87 queue_.MoveToNextFrame(); | 92 queue_.MoveToNextFrame(); |
| 88 | 93 |
| 89 // Request that the system not power-down the system, or the display hardware. | 94 // Request that the system not power-down the system, or the display hardware. |
| 90 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { | 95 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { |
| 91 if (!set_thread_execution_state_failed_) { | 96 if (!set_thread_execution_state_failed_) { |
| 92 set_thread_execution_state_failed_ = true; | 97 set_thread_execution_state_failed_ = true; |
| 93 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " | 98 LOG_F(LS_WARNING) << "Failed to make system & display power assertion: " |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 420 |
| 416 magnifier_capture_succeeded_ = true; | 421 magnifier_capture_succeeded_ = true; |
| 417 } | 422 } |
| 418 | 423 |
| 419 void ScreenCapturerWinMagnifier::CreateCurrentFrameIfNecessary( | 424 void ScreenCapturerWinMagnifier::CreateCurrentFrameIfNecessary( |
| 420 const DesktopSize& size) { | 425 const DesktopSize& size) { |
| 421 // If the current buffer is from an older generation then allocate a new one. | 426 // If the current buffer is from an older generation then allocate a new one. |
| 422 // Note that we can't reallocate other buffers at this point, since the caller | 427 // Note that we can't reallocate other buffers at this point, since the caller |
| 423 // may still be reading from them. | 428 // may still be reading from them. |
| 424 if (!queue_.current_frame() || !queue_.current_frame()->size().equals(size)) { | 429 if (!queue_.current_frame() || !queue_.current_frame()->size().equals(size)) { |
| 425 size_t buffer_size = | 430 rtc::scoped_ptr<DesktopFrame> frame = |
| 426 size.width() * size.height() * DesktopFrame::kBytesPerPixel; | 431 shared_memory_factory_ |
| 427 SharedMemory* shared_memory = callback_->CreateSharedMemory(buffer_size); | 432 ? SharedMemoryDesktopFrame::Create(size, |
| 428 | 433 shared_memory_factory_.get()) |
| 429 rtc::scoped_ptr<DesktopFrame> buffer; | 434 : rtc_make_scoped_ptr(new BasicDesktopFrame(size)); |
| 430 if (shared_memory) { | 435 queue_.ReplaceCurrentFrame(frame.release()); |
| 431 buffer.reset(new SharedMemoryDesktopFrame( | |
| 432 size, size.width() * DesktopFrame::kBytesPerPixel, shared_memory)); | |
| 433 } else { | |
| 434 buffer.reset(new BasicDesktopFrame(size)); | |
| 435 } | |
| 436 queue_.ReplaceCurrentFrame(buffer.release()); | |
| 437 } | 436 } |
| 438 } | 437 } |
| 439 | 438 |
| 440 void ScreenCapturerWinMagnifier::StartFallbackCapturer() { | 439 void ScreenCapturerWinMagnifier::StartFallbackCapturer() { |
| 441 assert(fallback_capturer_); | 440 assert(fallback_capturer_); |
| 442 if (!fallback_capturer_started_) { | 441 if (!fallback_capturer_started_) { |
| 443 fallback_capturer_started_ = true; | 442 fallback_capturer_started_ = true; |
| 444 | 443 |
| 445 fallback_capturer_->Start(callback_); | 444 fallback_capturer_->Start(callback_); |
| 446 fallback_capturer_->SelectScreen(current_screen_id_); | 445 fallback_capturer_->SelectScreen(current_screen_id_); |
| 447 } | 446 } |
| 448 } | 447 } |
| 449 | 448 |
| 450 } // namespace webrtc | 449 } // namespace webrtc |
| OLD | NEW |