| 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 "third_party/khronos/EGL/egl.h" | 10 #include "third_party/khronos/EGL/egl.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 105 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
| 106 gfx::AcceleratedWidget widget, | 106 gfx::AcceleratedWidget widget, |
| 107 gfx::Size size, | 107 gfx::Size size, |
| 108 gfx::BufferFormat format, | 108 gfx::BufferFormat format, |
| 109 gfx::BufferUsage usage) { | 109 gfx::BufferUsage usage) { |
| 110 #if !defined(OS_CHROMEOS) | 110 #if !defined(OS_CHROMEOS) |
| 111 // Support for memory mapping accelerated buffers requires some | 111 // Support for memory mapping accelerated buffers requires some |
| 112 // CrOS-specific patches (using vgem). | 112 // CrOS-specific patches (using vgem). |
| 113 DCHECK(gfx::BufferUsage::GPU_READ == usage || | 113 DCHECK(gfx::BufferUsage::SCANOUT == usage); |
| 114 gfx::BufferUsage::GPU_READ_WRITE == usage); | |
| 115 #endif | 114 #endif |
| 116 | 115 |
| 117 scoped_refptr<GbmBuffer> buffer = | 116 scoped_refptr<GbmBuffer> buffer = |
| 118 drm_thread_->CreateBuffer(widget, size, format, usage); | 117 drm_thread_->CreateBuffer(widget, size, format, usage); |
| 119 if (!buffer.get()) | 118 if (!buffer.get()) |
| 120 return nullptr; | 119 return nullptr; |
| 121 | 120 |
| 122 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); | 121 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
| 123 if (!pixmap->InitializeFromBuffer(buffer)) | 122 if (!pixmap->InitializeFromBuffer(buffer)) |
| 124 return nullptr; | 123 return nullptr; |
| 125 | 124 |
| 126 return pixmap; | 125 return pixmap; |
| 127 } | 126 } |
| 128 | 127 |
| 129 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( | 128 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( |
| 130 const gfx::NativePixmapHandle& handle) { | 129 const gfx::NativePixmapHandle& handle) { |
| 131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); | 130 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
| 132 pixmap->Initialize(base::ScopedFD(handle.fd.fd), handle.stride); | 131 pixmap->Initialize(base::ScopedFD(handle.fd.fd), handle.stride); |
| 133 return pixmap; | 132 return pixmap; |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace ui | 135 } // namespace ui |
| OLD | NEW |