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

Side by Side Diff: webrtc/modules/desktop_capture/desktop_frame.cc

Issue 1678073003: Cleanup shared memory handling in DesktopCapturer interface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 memcpy(result->data() + y * result->stride(), 70 memcpy(result->data() + y * result->stride(),
71 frame.data() + y * frame.stride(), 71 frame.data() + y * frame.stride(),
72 frame.size().width() * kBytesPerPixel); 72 frame.size().width() * kBytesPerPixel);
73 } 73 }
74 result->set_dpi(frame.dpi()); 74 result->set_dpi(frame.dpi());
75 result->set_capture_time_ms(frame.capture_time_ms()); 75 result->set_capture_time_ms(frame.capture_time_ms());
76 *result->mutable_updated_region() = frame.updated_region(); 76 *result->mutable_updated_region() = frame.updated_region();
77 return result; 77 return result;
78 } 78 }
79 79
80 // static
81 rtc::scoped_ptr<DesktopFrame> SharedMemoryDesktopFrame::Create(
82 DesktopSize size,
83 SharedMemoryFactory* shared_memory_factory) {
84 size_t buffer_size =
85 size.width() * size.height() * DesktopFrame::kBytesPerPixel;
86 rtc::scoped_ptr<SharedMemory> shared_memory;
87 shared_memory = shared_memory_factory->CreateSharedMemory(buffer_size);
88 if (!shared_memory)
89 return nullptr;
90
91 return rtc_make_scoped_ptr(new SharedMemoryDesktopFrame(
92 size, size.width() * DesktopFrame::kBytesPerPixel,
93 std::move(shared_memory)));
94 }
95
96 SharedMemoryDesktopFrame::SharedMemoryDesktopFrame(DesktopSize size,
97 int stride,
98 SharedMemory* shared_memory)
99 : DesktopFrame(size,
100 stride,
101 reinterpret_cast<uint8_t*>(shared_memory->data()),
102 shared_memory) {}
80 103
81 SharedMemoryDesktopFrame::SharedMemoryDesktopFrame( 104 SharedMemoryDesktopFrame::SharedMemoryDesktopFrame(
82 DesktopSize size, 105 DesktopSize size,
83 int stride, 106 int stride,
84 SharedMemory* shared_memory) 107 rtc::scoped_ptr<SharedMemory> shared_memory)
85 : DesktopFrame(size, stride, 108 : DesktopFrame(size,
109 stride,
86 reinterpret_cast<uint8_t*>(shared_memory->data()), 110 reinterpret_cast<uint8_t*>(shared_memory->data()),
87 shared_memory) { 111 shared_memory.release()) {}
88 }
89 112
90 SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() { 113 SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() {
91 delete shared_memory_; 114 delete shared_memory_;
92 } 115 }
93 116
94 } // namespace webrtc 117 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/desktop_frame.h ('k') | webrtc/modules/desktop_capture/desktop_frame_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698