| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 // We need to merge updated region with the one from last frame, since current | 143 // We need to merge updated region with the one from last frame, since current |
| 144 // frame contains the content one frame before. Note, this is for double | 144 // frame contains the content one frame before. Note, this is for double |
| 145 // buffering implementation, as what we have in ScreenCapturerWinDirectx. If | 145 // buffering implementation, as what we have in ScreenCapturerWinDirectx. If |
| 146 // a consumer uses single buffering, we should clear context->updated_region | 146 // a consumer uses single buffering, we should clear context->updated_region |
| 147 // after it has been merged to updated_region. | 147 // after it has been merged to updated_region. |
| 148 DesktopRegion updated_region; | 148 DesktopRegion updated_region; |
| 149 updated_region.Swap(&context->updated_region); | 149 updated_region.Swap(&context->updated_region); |
| 150 if (error.Error() == S_OK && frame_info.AccumulatedFrames > 0) { | 150 if (error.Error() == S_OK && |
| 151 frame_info.AccumulatedFrames > 0 && |
| 152 resource) { |
| 151 DetectUpdatedRegion(frame_info, offset, &context->updated_region); | 153 DetectUpdatedRegion(frame_info, offset, &context->updated_region); |
| 152 if (!texture_->CopyFrom(frame_info, resource.Get(), | 154 if (!texture_->CopyFrom(frame_info, resource.Get(), |
| 153 context->updated_region)) { | 155 context->updated_region)) { |
| 154 return false; | 156 return false; |
| 155 } | 157 } |
| 156 SpreadContextChange(context); | 158 SpreadContextChange(context); |
| 157 updated_region.AddRegion(context->updated_region); | 159 updated_region.AddRegion(context->updated_region); |
| 158 | 160 |
| 159 const DesktopFrame& source = texture_->AsDesktopFrame(); | 161 const DesktopFrame& source = texture_->AsDesktopFrame(); |
| 160 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); | 162 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 219 |
| 218 if (metadata.capacity() < frame_info.TotalMetadataBufferSize) { | 220 if (metadata.capacity() < frame_info.TotalMetadataBufferSize) { |
| 219 metadata.clear(); // Avoid data copy | 221 metadata.clear(); // Avoid data copy |
| 220 metadata.reserve(frame_info.TotalMetadataBufferSize); | 222 metadata.reserve(frame_info.TotalMetadataBufferSize); |
| 221 } | 223 } |
| 222 | 224 |
| 223 UINT buff_size = 0; | 225 UINT buff_size = 0; |
| 224 DXGI_OUTDUPL_MOVE_RECT* move_rects = | 226 DXGI_OUTDUPL_MOVE_RECT* move_rects = |
| 225 reinterpret_cast<DXGI_OUTDUPL_MOVE_RECT*>(metadata.data()); | 227 reinterpret_cast<DXGI_OUTDUPL_MOVE_RECT*>(metadata.data()); |
| 226 size_t move_rects_count = 0; | 228 size_t move_rects_count = 0; |
| 227 _com_error error = _com_error(duplication_->GetFrameMoveRects( | 229 _com_error error = duplication_->GetFrameMoveRects( |
| 228 static_cast<UINT>(metadata.capacity()), move_rects, &buff_size)); | 230 static_cast<UINT>(metadata.capacity()), move_rects, &buff_size); |
| 229 if (error.Error() != S_OK) { | 231 if (error.Error() != S_OK) { |
| 230 LOG(LS_ERROR) << "Failed to get move rectangles, error " | 232 LOG(LS_ERROR) << "Failed to get move rectangles, error " |
| 231 << error.ErrorMessage() << ", code " << error.Error(); | 233 << error.ErrorMessage() << ", code " << error.Error(); |
| 232 return false; | 234 return false; |
| 233 } | 235 } |
| 234 move_rects_count = buff_size / sizeof(DXGI_OUTDUPL_MOVE_RECT); | 236 move_rects_count = buff_size / sizeof(DXGI_OUTDUPL_MOVE_RECT); |
| 235 | 237 |
| 236 RECT* dirty_rects = reinterpret_cast<RECT*>(metadata.data() + buff_size); | 238 RECT* dirty_rects = reinterpret_cast<RECT*>(metadata.data() + buff_size); |
| 237 size_t dirty_rects_count = 0; | 239 size_t dirty_rects_count = 0; |
| 238 error = _com_error(duplication_->GetFrameDirtyRects( | 240 error = duplication_->GetFrameDirtyRects( |
| 239 static_cast<UINT>(metadata.capacity()) - buff_size, dirty_rects, | 241 static_cast<UINT>(metadata.capacity()) - buff_size, dirty_rects, |
| 240 &buff_size)); | 242 &buff_size); |
| 241 if (error.Error() != S_OK) { | 243 if (error.Error() != S_OK) { |
| 242 LOG(LS_ERROR) << "Failed to get dirty rectangles, error " | 244 LOG(LS_ERROR) << "Failed to get dirty rectangles, error " |
| 243 << error.ErrorMessage() << ", code " << error.Error(); | 245 << error.ErrorMessage() << ", code " << error.Error(); |
| 244 return false; | 246 return false; |
| 245 } | 247 } |
| 246 dirty_rects_count = buff_size / sizeof(RECT); | 248 dirty_rects_count = buff_size / sizeof(RECT); |
| 247 | 249 |
| 248 while (move_rects_count > 0) { | 250 while (move_rects_count > 0) { |
| 249 updated_region->AddRect(DesktopRect::MakeXYWH( | 251 updated_region->AddRect(DesktopRect::MakeXYWH( |
| 250 move_rects->SourcePoint.x, move_rects->SourcePoint.y, | 252 move_rects->SourcePoint.x, move_rects->SourcePoint.y, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 310 } |
| 309 | 311 |
| 310 DesktopRect DxgiOutputDuplicator::TargetRect(DesktopRect rect, | 312 DesktopRect DxgiOutputDuplicator::TargetRect(DesktopRect rect, |
| 311 DesktopVector offset) { | 313 DesktopVector offset) { |
| 312 rect = SourceRect(rect); | 314 rect = SourceRect(rect); |
| 313 rect.Translate(offset); | 315 rect.Translate(offset); |
| 314 return rect; | 316 return rect; |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace webrtc | 319 } // namespace webrtc |
| OLD | NEW |