| 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 "ui/gfx/native_pixmap_handle.h" | 5 #include "ui/gfx/native_pixmap_handle.h" |
| 6 | 6 |
| 7 #if defined(USE_OZONE) | 7 #if defined(OS_LINUX) |
| 8 #include "base/posix/eintr_wrapper.h" | 8 #include "base/posix/eintr_wrapper.h" |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 namespace gfx { | 11 namespace gfx { |
| 12 | 12 |
| 13 NativePixmapPlane::NativePixmapPlane() | 13 NativePixmapPlane::NativePixmapPlane() |
| 14 : stride(0), offset(0), size(0), modifier(0) {} | 14 : stride(0), offset(0), size(0), modifier(0) {} |
| 15 | 15 |
| 16 NativePixmapPlane::NativePixmapPlane(int stride, | 16 NativePixmapPlane::NativePixmapPlane(int stride, |
| 17 int offset, | 17 int offset, |
| 18 uint64_t size, | 18 uint64_t size, |
| 19 uint64_t modifier) | 19 uint64_t modifier) |
| 20 : stride(stride), offset(offset), size(size), modifier(modifier) {} | 20 : stride(stride), offset(offset), size(size), modifier(modifier) {} |
| 21 | 21 |
| 22 NativePixmapPlane::NativePixmapPlane(const NativePixmapPlane& other) = default; | 22 NativePixmapPlane::NativePixmapPlane(const NativePixmapPlane& other) = default; |
| 23 | 23 |
| 24 NativePixmapPlane::~NativePixmapPlane() {} | 24 NativePixmapPlane::~NativePixmapPlane() {} |
| 25 | 25 |
| 26 NativePixmapHandle::NativePixmapHandle() {} | 26 NativePixmapHandle::NativePixmapHandle() {} |
| 27 NativePixmapHandle::NativePixmapHandle(const NativePixmapHandle& other) = | 27 NativePixmapHandle::NativePixmapHandle(const NativePixmapHandle& other) = |
| 28 default; | 28 default; |
| 29 | 29 |
| 30 NativePixmapHandle::~NativePixmapHandle() {} | 30 NativePixmapHandle::~NativePixmapHandle() {} |
| 31 | 31 |
| 32 #if defined(USE_OZONE) | 32 #if defined(OS_LINUX) |
| 33 NativePixmapHandle CloneHandleForIPC(const NativePixmapHandle& handle) { | 33 NativePixmapHandle CloneHandleForIPC(const NativePixmapHandle& handle) { |
| 34 NativePixmapHandle clone; | 34 NativePixmapHandle clone; |
| 35 std::vector<base::ScopedFD> scoped_fds; | 35 std::vector<base::ScopedFD> scoped_fds; |
| 36 for (auto& fd : handle.fds) { | 36 for (auto& fd : handle.fds) { |
| 37 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(fd.fd))); | 37 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(fd.fd))); |
| 38 if (!scoped_fd.is_valid()) { | 38 if (!scoped_fd.is_valid()) { |
| 39 PLOG(ERROR) << "dup"; | 39 PLOG(ERROR) << "dup"; |
| 40 return NativePixmapHandle(); | 40 return NativePixmapHandle(); |
| 41 } | 41 } |
| 42 scoped_fds.emplace_back(std::move(scoped_fd)); | 42 scoped_fds.emplace_back(std::move(scoped_fd)); |
| 43 } | 43 } |
| 44 for (auto& scoped_fd : scoped_fds) | 44 for (auto& scoped_fd : scoped_fds) |
| 45 clone.fds.emplace_back(scoped_fd.release(), true /* auto_close */); | 45 clone.fds.emplace_back(scoped_fd.release(), true /* auto_close */); |
| 46 clone.planes = handle.planes; | 46 clone.planes = handle.planes; |
| 47 return clone; | 47 return clone; |
| 48 } | 48 } |
| 49 #endif // defined(USE_OZONE) | 49 #endif // defined(OS_LINUX) |
| 50 | 50 |
| 51 } // namespace gfx | 51 } // namespace gfx |
| OLD | NEW |