| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 scoped_refptr<GbmBuffer> buffer = | 105 scoped_refptr<GbmBuffer> buffer = |
| 106 drm_thread_->CreateBuffer(widget, size, format, usage); | 106 drm_thread_->CreateBuffer(widget, size, format, usage); |
| 107 if (!buffer.get()) | 107 if (!buffer.get()) |
| 108 return nullptr; | 108 return nullptr; |
| 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::AcceleratedWidget widget, |
| 114 gfx::Size size, | 115 gfx::Size size, |
| 115 gfx::BufferFormat format, | 116 gfx::BufferFormat format, |
| 116 const gfx::NativePixmapHandle& handle) { | 117 const gfx::NativePixmapHandle& handle) { |
| 117 size_t planes = gfx::NumberOfPlanesForBufferFormat(format); | 118 size_t planes = gfx::NumberOfPlanesForBufferFormat(format); |
| 118 if (handle.strides_and_offsets.size() != planes || | 119 if (handle.strides_and_offsets.size() != planes || |
| 119 (handle.fds.size() != 1 && handle.fds.size() != planes)) { | 120 (handle.fds.size() != 1 && handle.fds.size() != planes)) { |
| 120 return nullptr; | 121 return nullptr; |
| 121 } | 122 } |
| 122 std::vector<base::ScopedFD> scoped_fds; | 123 std::vector<base::ScopedFD> scoped_fds; |
| 123 for (auto& fd : handle.fds) { | 124 for (auto& fd : handle.fds) { |
| 124 scoped_fds.emplace_back(fd.fd); | 125 scoped_fds.emplace_back(fd.fd); |
| 125 } | 126 } |
| 126 | 127 |
| 127 std::vector<int> strides; | 128 std::vector<int> strides; |
| 128 std::vector<int> offsets; | 129 std::vector<int> offsets; |
| 129 | 130 |
| 130 for (const auto& stride_and_offset : handle.strides_and_offsets) { | 131 for (const auto& stride_and_offset : handle.strides_and_offsets) { |
| 131 strides.push_back(stride_and_offset.first); | 132 strides.push_back(stride_and_offset.first); |
| 132 offsets.push_back(stride_and_offset.second); | 133 offsets.push_back(stride_and_offset.second); |
| 133 } | 134 } |
| 134 | 135 |
| 135 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( | 136 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( |
| 136 size, format, std::move(scoped_fds), strides, offsets); | 137 widget, size, format, std::move(scoped_fds), strides, offsets); |
| 137 if (!buffer) | 138 if (!buffer) |
| 138 return nullptr; | 139 return nullptr; |
| 139 return make_scoped_refptr(new GbmPixmap(this, buffer)); | 140 return make_scoped_refptr(new GbmPixmap(this, buffer)); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace ui | 143 } // namespace ui |
| OLD | NEW |