| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/platform/drm/gpu/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
| 6 | 6 |
| 7 #include <gbm.h> | 7 #include <gbm.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 return make_scoped_refptr(new GbmPixmap(this, buffer)); | 110 return make_scoped_refptr(new GbmPixmap(this, buffer)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( | 113 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( |
| 114 gfx::Size size, | 114 gfx::Size size, |
| 115 gfx::BufferFormat format, | 115 gfx::BufferFormat format, |
| 116 const gfx::NativePixmapHandle& handle) { | 116 const gfx::NativePixmapHandle& handle) { |
| 117 size_t planes = gfx::NumberOfPlanesForBufferFormat(format); | 117 size_t planes = gfx::NumberOfPlanesForBufferFormat(format); |
| 118 if (handle.strides_and_offsets.size() != planes || | 118 if (handle.strides_and_offsets.size() != planes || |
| 119 handle.fds.size() != planes) { // This constraint could be relaxed. | 119 (handle.fds.size() != 1 && handle.fds.size() != planes)) { |
| 120 return nullptr; | 120 return nullptr; |
| 121 } | 121 } |
| 122 std::vector<base::ScopedFD> scoped_fds; | 122 std::vector<base::ScopedFD> scoped_fds; |
| 123 for (auto& fd : handle.fds) { | 123 for (auto& fd : handle.fds) { |
| 124 scoped_fds.emplace_back(fd.fd); | 124 scoped_fds.emplace_back(fd.fd); |
| 125 } | 125 } |
| 126 | 126 |
| 127 std::vector<int> strides; | 127 std::vector<int> strides; |
| 128 std::vector<int> offsets; | 128 std::vector<int> offsets; |
| 129 | 129 |
| 130 for (const auto& stride_and_offset : handle.strides_and_offsets) { | 130 for (const auto& stride_and_offset : handle.strides_and_offsets) { |
| 131 strides.push_back(stride_and_offset.first); | 131 strides.push_back(stride_and_offset.first); |
| 132 offsets.push_back(stride_and_offset.second); | 132 offsets.push_back(stride_and_offset.second); |
| 133 } | 133 } |
| 134 | 134 |
| 135 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( | 135 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( |
| 136 size, format, std::move(scoped_fds), strides, offsets); | 136 size, format, std::move(scoped_fds), strides, offsets); |
| 137 if (!buffer) | 137 if (!buffer) |
| 138 return nullptr; | 138 return nullptr; |
| 139 return make_scoped_refptr(new GbmPixmap(this, buffer)); | 139 return make_scoped_refptr(new GbmPixmap(this, buffer)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace ui | 142 } // namespace ui |
| OLD | NEW |