| 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" |
| 11 #include "ui/ozone/common/egl_util.h" | 11 #include "ui/ozone/common/egl_util.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 13 #include "ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.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_surface.h" | 17 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" |
| 17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 18 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
| 18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 19 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
| 19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 20 #include "ui/ozone/public/native_pixmap.h" | 21 #include "ui/ozone/public/native_pixmap.h" |
| 21 #include "ui/ozone/public/surface_ozone_canvas.h" | 22 #include "ui/ozone/public/surface_ozone_canvas.h" |
| 22 #include "ui/ozone/public/surface_ozone_egl.h" | 23 #include "ui/ozone/public/surface_ozone_egl.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (!buffer.get()) | 124 if (!buffer.get()) |
| 124 return nullptr; | 125 return nullptr; |
| 125 | 126 |
| 126 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); | 127 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); |
| 127 if (!pixmap->Initialize()) | 128 if (!pixmap->Initialize()) |
| 128 return nullptr; | 129 return nullptr; |
| 129 | 130 |
| 130 return pixmap; | 131 return pixmap; |
| 131 } | 132 } |
| 132 | 133 |
| 134 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( |
| 135 gfx::AcceleratedWidget widget, |
| 136 gfx::Size size, |
| 137 const gfx::NativePixmapHandle& handle) { |
| 138 scoped_refptr<DrmDevice> drm = |
| 139 drm_device_manager_->GetDrmDevice(widget).get(); |
| 140 DCHECK(drm); |
| 141 |
| 142 scoped_refptr<VgemPixmap> pixmap(new VgemPixmap(drm)); |
| 143 pixmap->Initialize(base::ScopedFD(handle.fd.fd), size.width(), size.height(), |
| 144 handle.stride); |
| 145 |
| 146 return scoped_refptr<VgemPixmapWrapper>( |
| 147 new VgemPixmapWrapper(screen_manager_, pixmap)); |
| 148 } |
| 149 |
| 133 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { | 150 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { |
| 134 DCHECK(thread_checker_.CalledOnValidThread()); | 151 DCHECK(thread_checker_.CalledOnValidThread()); |
| 135 return allow_surfaceless_; | 152 return allow_surfaceless_; |
| 136 } | 153 } |
| 137 | 154 |
| 138 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { | 155 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { |
| 139 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
| 140 switch (usage) { | 157 switch (usage) { |
| 141 case MAP: | 158 case MAP: |
| 142 return false; | 159 return false; |
| 143 case PERSISTENT_MAP: | 160 case PERSISTENT_MAP: |
| 144 return false; | 161 return false; |
| 145 case SCANOUT: | 162 case SCANOUT: |
| 146 return true; | 163 return true; |
| 147 } | 164 } |
| 148 NOTREACHED(); | 165 NOTREACHED(); |
| 149 return false; | 166 return false; |
| 150 } | 167 } |
| 151 | 168 |
| 152 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 169 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
| 153 gfx::AcceleratedWidget widget) { | 170 gfx::AcceleratedWidget widget) { |
| 154 return static_cast<GbmDevice*>( | 171 return static_cast<GbmDevice*>( |
| 155 drm_device_manager_->GetDrmDevice(widget).get()); | 172 drm_device_manager_->GetDrmDevice(widget).get()); |
| 156 } | 173 } |
| 157 | 174 |
| 158 } // namespace ui | 175 } // namespace ui |
| OLD | NEW |