| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); | 123 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
| 124 DCHECK(gbm); | 124 DCHECK(gbm); |
| 125 | 125 |
| 126 scoped_refptr<GbmBuffer> buffer = | 126 scoped_refptr<GbmBuffer> buffer = |
| 127 GbmBuffer::CreateBuffer(gbm, format, size, usage); | 127 GbmBuffer::CreateBuffer(gbm, format, size, usage); |
| 128 if (!buffer.get()) | 128 if (!buffer.get()) |
| 129 return nullptr; | 129 return nullptr; |
| 130 | 130 |
| 131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this)); | 131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
| 132 if (!pixmap->Initialize()) | 132 if (!pixmap->InitializeFromBuffer(buffer)) |
| 133 return nullptr; | 133 return nullptr; |
| 134 | 134 |
| 135 return pixmap; | 135 return pixmap; |
| 136 } | 136 } |
| 137 | 137 |
| 138 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( |
| 139 const gfx::NativePixmapHandle& handle) { |
| 140 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
| 141 pixmap->Initialize(base::ScopedFD(handle.fd.fd), handle.stride); |
| 142 return pixmap; |
| 143 } |
| 144 |
| 138 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 145 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
| 139 gfx::AcceleratedWidget widget) { | 146 gfx::AcceleratedWidget widget) { |
| 140 return static_cast<GbmDevice*>( | 147 return static_cast<GbmDevice*>( |
| 141 drm_device_manager_->GetDrmDevice(widget).get()); | 148 drm_device_manager_->GetDrmDevice(widget).get()); |
| 142 } | 149 } |
| 143 | 150 |
| 144 } // namespace ui | 151 } // namespace ui |
| OLD | NEW |