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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (!texture_->CopyFrom(frame_info, resource.Get(), | 156 if (!texture_->CopyFrom(frame_info, resource.Get(), |
157 context->updated_region)) { | 157 context->updated_region)) { |
158 return false; | 158 return false; |
159 } | 159 } |
160 SpreadContextChange(context); | 160 SpreadContextChange(context); |
161 updated_region.AddRegion(context->updated_region); | 161 updated_region.AddRegion(context->updated_region); |
162 | 162 |
163 const DesktopFrame& source = texture_->AsDesktopFrame(); | 163 const DesktopFrame& source = texture_->AsDesktopFrame(); |
164 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); | 164 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); |
165 it.Advance()) { | 165 it.Advance()) { |
166 target->CopyPixelsFrom(source, SourceRect(it.rect()).top_left(), | 166 target->CopyPixelsFrom( |
167 TargetRect(it.rect(), offset)); | 167 source, SourceRect(it.rect()).top_left(), it.rect()); |
168 } | 168 } |
169 last_frame_ = target->Share(); | 169 last_frame_ = target->Share(); |
170 last_frame_offset_ = offset; | 170 last_frame_offset_ = offset; |
171 target->mutable_updated_region()->AddRegion(updated_region); | 171 target->mutable_updated_region()->AddRegion(updated_region); |
172 return texture_->Release() && ReleaseFrame(); | 172 return texture_->Release() && ReleaseFrame(); |
173 } | 173 } |
174 | 174 |
175 if (last_frame_) { | 175 if (last_frame_) { |
176 // No change since last frame or AcquireNextFrame() timed out, we will | 176 // No change since last frame or AcquireNextFrame() timed out, we will |
177 // export last frame to the target. | 177 // export last frame to the target. |
178 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); | 178 for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd(); |
179 it.Advance()) { | 179 it.Advance()) { |
180 target->CopyPixelsFrom(*last_frame_, SourceRect(it.rect()).top_left(), | 180 target->CopyPixelsFrom(*last_frame_, it.rect().top_left(), it.rect()); |
181 TargetRect(it.rect(), offset)); | |
182 } | 181 } |
183 target->mutable_updated_region()->AddRegion(updated_region); | 182 target->mutable_updated_region()->AddRegion(updated_region); |
184 } | 183 } |
185 // If AcquireNextFrame() failed with timeout error, we do not need to release | 184 // If AcquireNextFrame() failed with timeout error, we do not need to release |
186 // the frame. | 185 // the frame. |
187 return error.Error() == DXGI_ERROR_WAIT_TIMEOUT || ReleaseFrame(); | 186 return error.Error() == DXGI_ERROR_WAIT_TIMEOUT || ReleaseFrame(); |
188 } | 187 } |
189 | 188 |
190 DesktopRect DxgiOutputDuplicator::TranslatedDesktopRect(DesktopVector offset) { | 189 DesktopRect DxgiOutputDuplicator::TranslatedDesktopRect(DesktopVector offset) { |
191 DesktopRect result(DesktopRect::MakeSize(desktop_rect_.size())); | 190 DesktopRect result(DesktopRect::MakeSize(desktop_rect_.size())); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 294 } |
296 } | 295 } |
297 } | 296 } |
298 | 297 |
299 DesktopRect DxgiOutputDuplicator::SourceRect(DesktopRect rect) { | 298 DesktopRect DxgiOutputDuplicator::SourceRect(DesktopRect rect) { |
300 // |texture_|->AsDesktopFrame() starts from (0, 0). | 299 // |texture_|->AsDesktopFrame() starts from (0, 0). |
301 rect.Translate(-desktop_rect_.left(), -desktop_rect_.top()); | 300 rect.Translate(-desktop_rect_.left(), -desktop_rect_.top()); |
302 return rect; | 301 return rect; |
303 } | 302 } |
304 | 303 |
305 DesktopRect DxgiOutputDuplicator::TargetRect(DesktopRect rect, | |
306 DesktopVector offset) { | |
307 rect = SourceRect(rect); | |
308 rect.Translate(offset); | |
309 return rect; | |
310 } | |
311 | |
312 } // namespace webrtc | 304 } // namespace webrtc |
OLD | NEW |