| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include "ui/gfx/native_pixmap_handle.h" |
| 6 | 6 |
| 7 #include "ui/gfx/native_pixmap_handle.h" | 7 #if defined(USE_OZONE) |
| 8 #include "base/posix/eintr_wrapper.h" |
| 9 #endif |
| 8 | 10 |
| 9 namespace gfx { | 11 namespace gfx { |
| 10 | 12 |
| 11 NativePixmapPlane::NativePixmapPlane() | 13 NativePixmapPlane::NativePixmapPlane() |
| 12 : stride(0), offset(0), size(0), modifier(0) {} | 14 : stride(0), offset(0), size(0), modifier(0) {} |
| 13 | 15 |
| 14 NativePixmapPlane::NativePixmapPlane(int stride, | 16 NativePixmapPlane::NativePixmapPlane(int stride, |
| 15 int offset, | 17 int offset, |
| 16 uint64_t size, | 18 uint64_t size, |
| 17 uint64_t modifier) | 19 uint64_t modifier) |
| 18 : stride(stride), offset(offset), size(size), modifier(modifier) {} | 20 : stride(stride), offset(offset), size(size), modifier(modifier) {} |
| 19 | 21 |
| 20 NativePixmapPlane::NativePixmapPlane(const NativePixmapPlane& other) = default; | 22 NativePixmapPlane::NativePixmapPlane(const NativePixmapPlane& other) = default; |
| 21 | 23 |
| 22 NativePixmapPlane::~NativePixmapPlane() {} | 24 NativePixmapPlane::~NativePixmapPlane() {} |
| 23 | 25 |
| 24 NativePixmapHandle::NativePixmapHandle() {} | 26 NativePixmapHandle::NativePixmapHandle() {} |
| 25 NativePixmapHandle::NativePixmapHandle(const NativePixmapHandle& other) = | 27 NativePixmapHandle::NativePixmapHandle(const NativePixmapHandle& other) = |
| 26 default; | 28 default; |
| 27 | 29 |
| 28 NativePixmapHandle::~NativePixmapHandle() {} | 30 NativePixmapHandle::~NativePixmapHandle() {} |
| 29 | 31 |
| 32 #if defined(USE_OZONE) |
| 33 NativePixmapHandle CloneHandleForIPC(const NativePixmapHandle& handle) { |
| 34 NativePixmapHandle clone; |
| 35 std::vector<base::ScopedFD> scoped_fds; |
| 36 for (auto& fd : handle.fds) { |
| 37 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(fd.fd))); |
| 38 if (!scoped_fd.is_valid()) { |
| 39 PLOG(ERROR) << "dup"; |
| 40 return NativePixmapHandle(); |
| 41 } |
| 42 scoped_fds.emplace_back(std::move(scoped_fd)); |
| 43 } |
| 44 for (auto& scoped_fd : scoped_fds) |
| 45 clone.fds.emplace_back(scoped_fd.release(), true /* auto_close */); |
| 46 clone.planes = handle.planes; |
| 47 return clone; |
| 48 } |
| 49 #endif // defined(USE_OZONE) |
| 50 |
| 30 } // namespace gfx | 51 } // namespace gfx |
| OLD | NEW |