Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: webrtc/modules/desktop_capture/win/dxgi_frame.cc

Issue 2937663003: Ensure Dxgi duplicator works correctly in session 0 (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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. Out of "
51 "memory?";
Sergey Ulanov 2017/06/26 23:41:41 nit: Maybe remove the second sentence? It doesn't
Hzj_jie 2017/06/27 04:37:33 Done.
49 return false; 52 return false;
50 } 53 }
51 // DirectX capturer won't paint each pixel in the frame due to its one 54 // 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 55 // 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 56 // clear it to avoid the legacy image to be remained on it. See
54 // http://crbug.com/708766. 57 // http://crbug.com/708766.
55 RTC_DCHECK_EQ(frame->stride(), 58 RTC_DCHECK_EQ(frame->stride(),
56 frame->size().width() * DesktopFrame::kBytesPerPixel); 59 frame->size().width() * DesktopFrame::kBytesPerPixel);
57 memset(frame->data(), 0, frame->stride() * frame->size().height()); 60 memset(frame->data(), 0, frame->stride() * frame->size().height());
58 61
59 frame_ = SharedDesktopFrame::Wrap(std::move(frame)); 62 frame_ = SharedDesktopFrame::Wrap(std::move(frame));
60 } 63 }
61 64
62 return !!frame_; 65 return !!frame_;
63 } 66 }
64 67
65 SharedDesktopFrame* DxgiFrame::frame() const { 68 SharedDesktopFrame* DxgiFrame::frame() const {
66 RTC_DCHECK(frame_); 69 RTC_DCHECK(frame_);
67 return frame_.get(); 70 return frame_.get();
68 } 71 }
69 72
70 DxgiFrame::Context* DxgiFrame::context() { 73 DxgiFrame::Context* DxgiFrame::context() {
71 RTC_DCHECK(frame_); 74 RTC_DCHECK(frame_);
72 return &context_; 75 return &context_;
73 } 76 }
74 77
75 } // namespace webrtc 78 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698