| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 13 matching lines...) Expand all Loading... |
| 24 #include "webrtc/modules/desktop_capture/win/dxgi_texture_mapping.h" | 24 #include "webrtc/modules/desktop_capture/win/dxgi_texture_mapping.h" |
| 25 #include "webrtc/modules/desktop_capture/win/dxgi_texture_staging.h" | 25 #include "webrtc/modules/desktop_capture/win/dxgi_texture_staging.h" |
| 26 | 26 |
| 27 namespace webrtc { | 27 namespace webrtc { |
| 28 | 28 |
| 29 using Microsoft::WRL::ComPtr; | 29 using Microsoft::WRL::ComPtr; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // Timeout for AcquireNextFrame() call. | 33 // Timeout for AcquireNextFrame() call. |
| 34 const int kAcquireTimeoutMs = 10; | 34 // DxgiDuplicatorController leverages external components to do the capture |
| 35 // scheduling. So here DxgiOutputDuplicator does not need to actively wait for a |
| 36 // new frame. 1 millisecond is the minimium value AcquireNextFrame() accepts. |
| 37 const int kAcquireTimeoutMs = 1; |
| 35 | 38 |
| 36 DesktopRect RECTToDesktopRect(const RECT& rect) { | 39 DesktopRect RECTToDesktopRect(const RECT& rect) { |
| 37 return DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom); | 40 return DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom); |
| 38 } | 41 } |
| 39 | 42 |
| 40 Rotation DxgiRotationToRotation(DXGI_MODE_ROTATION rotation) { | 43 Rotation DxgiRotationToRotation(DXGI_MODE_ROTATION rotation) { |
| 41 switch (rotation) { | 44 switch (rotation) { |
| 42 case DXGI_MODE_ROTATION_IDENTITY: | 45 case DXGI_MODE_ROTATION_IDENTITY: |
| 43 case DXGI_MODE_ROTATION_UNSPECIFIED: | 46 case DXGI_MODE_ROTATION_UNSPECIFIED: |
| 44 return Rotation::CLOCK_WISE_0; | 47 return Rotation::CLOCK_WISE_0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } else { | 200 } else { |
| 198 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); | 201 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); |
| 199 it.Advance()) { | 202 it.Advance()) { |
| 200 target->CopyPixelsFrom( | 203 target->CopyPixelsFrom( |
| 201 source, ReverseTranslate(it.rect(), offset).top_left(), it.rect()); | 204 source, ReverseTranslate(it.rect(), offset).top_left(), it.rect()); |
| 202 } | 205 } |
| 203 } | 206 } |
| 204 last_frame_ = target->Share(); | 207 last_frame_ = target->Share(); |
| 205 last_frame_offset_ = offset; | 208 last_frame_offset_ = offset; |
| 206 target->mutable_updated_region()->AddRegion(updated_region); | 209 target->mutable_updated_region()->AddRegion(updated_region); |
| 210 num_frames_captured_++; |
| 207 return texture_->Release() && ReleaseFrame(); | 211 return texture_->Release() && ReleaseFrame(); |
| 208 } | 212 } |
| 209 | 213 |
| 210 if (last_frame_) { | 214 if (last_frame_) { |
| 211 // No change since last frame or AcquireNextFrame() timed out, we will | 215 // No change since last frame or AcquireNextFrame() timed out, we will |
| 212 // export last frame to the target. | 216 // export last frame to the target. |
| 213 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); | 217 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); |
| 214 it.Advance()) { | 218 it.Advance()) { |
| 215 target->CopyPixelsFrom(*last_frame_, it.rect().top_left(), it.rect()); | 219 target->CopyPixelsFrom(*last_frame_, it.rect().top_left(), it.rect()); |
| 216 } | 220 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 335 |
| 332 void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) { | 336 void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) { |
| 333 for (Context* dest : contexts_) { | 337 for (Context* dest : contexts_) { |
| 334 RTC_DCHECK(dest); | 338 RTC_DCHECK(dest); |
| 335 if (dest != source) { | 339 if (dest != source) { |
| 336 dest->updated_region.AddRegion(source->updated_region); | 340 dest->updated_region.AddRegion(source->updated_region); |
| 337 } | 341 } |
| 338 } | 342 } |
| 339 } | 343 } |
| 340 | 344 |
| 345 int64_t DxgiOutputDuplicator::num_frames_captured() const { |
| 346 #if !defined(NDEBUG) |
| 347 RTC_DCHECK_EQ(!!last_frame_, num_frames_captured_ > 0); |
| 348 #endif |
| 349 return num_frames_captured_; |
| 350 } |
| 351 |
| 341 } // namespace webrtc | 352 } // namespace webrtc |
| OLD | NEW |