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