OLD | NEW |
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 |
11 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" | 11 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" |
12 | 12 |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "webrtc/system_wrappers/include/logging.h" | |
16 | |
17 namespace webrtc { | 15 namespace webrtc { |
18 | 16 |
19 DesktopFrameWin::DesktopFrameWin(DesktopSize size, | 17 DesktopFrameWin::DesktopFrameWin(DesktopSize size, |
20 int stride, | 18 int stride, |
21 uint8_t* data, | 19 uint8_t* data, |
22 std::unique_ptr<SharedMemory> shared_memory, | 20 std::unique_ptr<SharedMemory> shared_memory, |
23 HBITMAP bitmap) | 21 HBITMAP bitmap) |
24 : DesktopFrame(size, stride, data, shared_memory.get()), | 22 : DesktopFrame(size, stride, data, shared_memory.get()), |
25 bitmap_(bitmap), | 23 bitmap_(bitmap), |
26 owned_shared_memory_(std::move(shared_memory)) {} | 24 owned_shared_memory_(std::move(shared_memory)) {} |
(...skipping 22 matching lines...) Expand all Loading... |
49 std::unique_ptr<SharedMemory> shared_memory; | 47 std::unique_ptr<SharedMemory> shared_memory; |
50 HANDLE section_handle = nullptr; | 48 HANDLE section_handle = nullptr; |
51 if (shared_memory_factory) { | 49 if (shared_memory_factory) { |
52 shared_memory = shared_memory_factory->CreateSharedMemory(buffer_size); | 50 shared_memory = shared_memory_factory->CreateSharedMemory(buffer_size); |
53 section_handle = shared_memory->handle(); | 51 section_handle = shared_memory->handle(); |
54 } | 52 } |
55 void* data = nullptr; | 53 void* data = nullptr; |
56 HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, | 54 HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, |
57 section_handle, 0); | 55 section_handle, 0); |
58 if (!bitmap) { | 56 if (!bitmap) { |
59 LOG(LS_WARNING) << "Failed to allocate new window frame " << GetLastError(); | |
60 return nullptr; | 57 return nullptr; |
61 } | 58 } |
62 | 59 |
63 return std::unique_ptr<DesktopFrameWin>( | 60 return std::unique_ptr<DesktopFrameWin>( |
64 new DesktopFrameWin(size, bytes_per_row, reinterpret_cast<uint8_t*>(data), | 61 new DesktopFrameWin(size, bytes_per_row, reinterpret_cast<uint8_t*>(data), |
65 std::move(shared_memory), bitmap)); | 62 std::move(shared_memory), bitmap)); |
66 } | 63 } |
67 | 64 |
68 } // namespace webrtc | 65 } // namespace webrtc |
OLD | NEW |