| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return nullptr; | 130 return nullptr; |
| 131 } | 131 } |
| 132 | 132 |
| 133 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats( | 133 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats( |
| 134 gfx::AcceleratedWidget widget) { | 134 gfx::AcceleratedWidget widget) { |
| 135 std::vector<gfx::BufferFormat> scanout_formats; | 135 std::vector<gfx::BufferFormat> scanout_formats; |
| 136 drm_thread_proxy_->GetScanoutFormats(widget, &scanout_formats); | 136 drm_thread_proxy_->GetScanoutFormats(widget, &scanout_formats); |
| 137 return scanout_formats; | 137 return scanout_formats; |
| 138 } | 138 } |
| 139 | 139 |
| 140 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 140 scoped_refptr<gfx::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
| 141 gfx::AcceleratedWidget widget, | 141 gfx::AcceleratedWidget widget, |
| 142 gfx::Size size, | 142 gfx::Size size, |
| 143 gfx::BufferFormat format, | 143 gfx::BufferFormat format, |
| 144 gfx::BufferUsage usage) { | 144 gfx::BufferUsage usage) { |
| 145 #if !defined(OS_CHROMEOS) | 145 #if !defined(OS_CHROMEOS) |
| 146 // Support for memory mapping accelerated buffers requires some | 146 // Support for memory mapping accelerated buffers requires some |
| 147 // CrOS-specific patches (using dma-buf mmap API). | 147 // CrOS-specific patches (using dma-buf mmap API). |
| 148 DCHECK(gfx::BufferUsage::SCANOUT == usage); | 148 DCHECK(gfx::BufferUsage::SCANOUT == usage); |
| 149 #endif | 149 #endif |
| 150 | 150 |
| 151 scoped_refptr<GbmBuffer> buffer = | 151 scoped_refptr<GbmBuffer> buffer = |
| 152 drm_thread_proxy_->CreateBuffer(widget, size, format, usage); | 152 drm_thread_proxy_->CreateBuffer(widget, size, format, usage); |
| 153 if (!buffer.get()) | 153 if (!buffer.get()) |
| 154 return nullptr; | 154 return nullptr; |
| 155 | 155 |
| 156 return make_scoped_refptr(new GbmPixmap(this, buffer)); | 156 return make_scoped_refptr(new GbmPixmap(this, buffer)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( | 159 scoped_refptr<gfx::NativePixmap> |
| 160 GbmSurfaceFactory::CreateNativePixmapFromHandle( |
| 160 gfx::AcceleratedWidget widget, | 161 gfx::AcceleratedWidget widget, |
| 161 gfx::Size size, | 162 gfx::Size size, |
| 162 gfx::BufferFormat format, | 163 gfx::BufferFormat format, |
| 163 const gfx::NativePixmapHandle& handle) { | 164 const gfx::NativePixmapHandle& handle) { |
| 164 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); | 165 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); |
| 165 if (handle.planes.size() != num_planes || | 166 if (handle.planes.size() != num_planes || |
| 166 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) { | 167 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) { |
| 167 return nullptr; | 168 return nullptr; |
| 168 } | 169 } |
| 169 std::vector<base::ScopedFD> scoped_fds; | 170 std::vector<base::ScopedFD> scoped_fds; |
| 170 for (auto& fd : handle.fds) { | 171 for (auto& fd : handle.fds) { |
| 171 scoped_fds.emplace_back(fd.fd); | 172 scoped_fds.emplace_back(fd.fd); |
| 172 } | 173 } |
| 173 | 174 |
| 174 std::vector<gfx::NativePixmapPlane> planes; | 175 std::vector<gfx::NativePixmapPlane> planes; |
| 175 | 176 |
| 176 for (const auto& plane : handle.planes) { | 177 for (const auto& plane : handle.planes) { |
| 177 planes.push_back(plane); | 178 planes.push_back(plane); |
| 178 } | 179 } |
| 179 | 180 |
| 180 scoped_refptr<GbmBuffer> buffer = drm_thread_proxy_->CreateBufferFromFds( | 181 scoped_refptr<GbmBuffer> buffer = drm_thread_proxy_->CreateBufferFromFds( |
| 181 widget, size, format, std::move(scoped_fds), planes); | 182 widget, size, format, std::move(scoped_fds), planes); |
| 182 if (!buffer) | 183 if (!buffer) |
| 183 return nullptr; | 184 return nullptr; |
| 184 return make_scoped_refptr(new GbmPixmap(this, buffer)); | 185 return make_scoped_refptr(new GbmPixmap(this, buffer)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace ui | 188 } // namespace ui |
| OLD | NEW |