Chromium Code Reviews| 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/posix/eintr_wrapper.h" | |
| 10 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
| 11 #include "ui/ozone/common/egl_util.h" | 12 #include "ui/ozone/common/egl_util.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 13 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
| 15 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 16 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
| 16 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
| 17 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
| 18 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 19 #include "ui/ozone/public/native_pixmap.h" | 20 #include "ui/ozone/public/native_pixmap.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 #endif | 122 #endif |
| 122 | 123 |
| 123 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); | 124 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
| 124 DCHECK(gbm); | 125 DCHECK(gbm); |
| 125 | 126 |
| 126 scoped_refptr<GbmBuffer> buffer = | 127 scoped_refptr<GbmBuffer> buffer = |
| 127 GbmBuffer::CreateBuffer(gbm, format, size, usage); | 128 GbmBuffer::CreateBuffer(gbm, format, size, usage); |
| 128 if (!buffer.get()) | 129 if (!buffer.get()) |
| 129 return nullptr; | 130 return nullptr; |
| 130 | 131 |
| 131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this)); | 132 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); |
| 132 if (!pixmap->Initialize()) | 133 if (!pixmap->InitializeFromBuffer(buffer)) |
| 133 return nullptr; | 134 return nullptr; |
| 134 | 135 |
| 135 return pixmap; | 136 return pixmap; |
| 136 } | 137 } |
| 137 | 138 |
| 139 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( | |
| 140 const gfx::NativePixmapHandle& handle) { | |
| 141 int dmabuf_fd = HANDLE_EINTR(dup(handle.fd.fd)); | |
|
piman
2015/10/08 23:24:36
Why do we need to dup here, and if so, where is th
reveman
2015/10/09 12:47:02
Good call. We shouldn't dup it here. This just hap
| |
| 142 if (dmabuf_fd < 0) { | |
| 143 PLOG(ERROR) << "dup"; | |
| 144 return nullptr; | |
| 145 } | |
| 146 | |
| 147 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(this)); | |
| 148 pixmap->Initialize(dmabuf_fd, handle.stride); | |
| 149 return pixmap; | |
| 150 } | |
| 151 | |
| 138 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 152 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
| 139 gfx::AcceleratedWidget widget) { | 153 gfx::AcceleratedWidget widget) { |
| 140 return static_cast<GbmDevice*>( | 154 return static_cast<GbmDevice*>( |
| 141 drm_device_manager_->GetDrmDevice(widget).get()); | 155 drm_device_manager_->GetDrmDevice(widget).get()); |
| 142 } | 156 } |
| 143 | 157 |
| 144 } // namespace ui | 158 } // namespace ui |
| OLD | NEW |