| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 |
| 11 #include "webrtc/modules/desktop_capture/win/dxgi_frame.h" | 11 #include "webrtc/modules/desktop_capture/win/dxgi_frame.h" |
| 12 | 12 |
| 13 #include <string.h> |
| 14 |
| 13 #include <utility> | 15 #include <utility> |
| 14 | 16 |
| 15 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 17 #include "webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h" | 19 #include "webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h" |
| 18 | 20 |
| 19 namespace webrtc { | 21 namespace webrtc { |
| 20 | 22 |
| 21 DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) | 23 DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) |
| 22 : factory_(factory) {} | 24 : factory_(factory) {} |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 if (!frame_) { | 41 if (!frame_) { |
| 40 std::unique_ptr<DesktopFrame> frame; | 42 std::unique_ptr<DesktopFrame> frame; |
| 41 if (factory_) { | 43 if (factory_) { |
| 42 frame = SharedMemoryDesktopFrame::Create(size, factory_); | 44 frame = SharedMemoryDesktopFrame::Create(size, factory_); |
| 43 } else { | 45 } else { |
| 44 frame.reset(new BasicDesktopFrame(size)); | 46 frame.reset(new BasicDesktopFrame(size)); |
| 45 } | 47 } |
| 46 if (!frame) { | 48 if (!frame) { |
| 47 return false; | 49 return false; |
| 48 } | 50 } |
| 51 // DirectX capturer won't paint each pixel in the frame due to its one |
| 52 // capturer per monitor design. So once the new frame is created, we should |
| 53 // clear it to avoid the legacy image to be remained on it. See |
| 54 // http://crbug.com/708766. |
| 55 RTC_DCHECK_EQ(frame->stride(), |
| 56 frame->size().width() * DesktopFrame::kBytesPerPixel); |
| 57 memset(frame->data(), 0, frame->stride() * frame->size().height()); |
| 49 | 58 |
| 50 frame_ = SharedDesktopFrame::Wrap(std::move(frame)); | 59 frame_ = SharedDesktopFrame::Wrap(std::move(frame)); |
| 51 } | 60 } |
| 52 | 61 |
| 53 return !!frame_; | 62 return !!frame_; |
| 54 } | 63 } |
| 55 | 64 |
| 56 SharedDesktopFrame* DxgiFrame::frame() const { | 65 SharedDesktopFrame* DxgiFrame::frame() const { |
| 57 RTC_DCHECK(frame_); | 66 RTC_DCHECK(frame_); |
| 58 return frame_.get(); | 67 return frame_.get(); |
| 59 } | 68 } |
| 60 | 69 |
| 61 DxgiFrame::Context* DxgiFrame::context() { | 70 DxgiFrame::Context* DxgiFrame::context() { |
| 62 RTC_DCHECK(frame_); | 71 RTC_DCHECK(frame_); |
| 63 return &context_; | 72 return &context_; |
| 64 } | 73 } |
| 65 | 74 |
| 66 } // namespace webrtc | 75 } // namespace webrtc |
| OLD | NEW |