| 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/dri/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
| 6 | 6 |
| 7 #include <gbm.h> | 7 #include <gbm.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
| 12 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
| 13 #include "ui/ozone/platform/dri/dri_window_manager.h" |
| 12 #include "ui/ozone/platform/dri/gbm_buffer.h" | 14 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 13 #include "ui/ozone/platform/dri/gbm_surface.h" | 15 #include "ui/ozone/platform/dri/gbm_surface.h" |
| 14 #include "ui/ozone/platform/dri/gbm_surfaceless.h" | 16 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
| 15 #include "ui/ozone/platform/dri/screen_manager.h" | 17 #include "ui/ozone/platform/dri/screen_manager.h" |
| 16 #include "ui/ozone/public/native_pixmap.h" | 18 #include "ui/ozone/public/native_pixmap.h" |
| 17 #include "ui/ozone/public/overlay_candidates_ozone.h" | 19 #include "ui/ozone/public/overlay_candidates_ozone.h" |
| 18 #include "ui/ozone/public/ozone_switches.h" | 20 #include "ui/ozone/public/ozone_switches.h" |
| 19 #include "ui/ozone/public/surface_ozone_egl.h" | 21 #include "ui/ozone/public/surface_ozone_egl.h" |
| 20 | 22 |
| 21 namespace ui { | 23 namespace ui { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return false; | 59 return false; |
| 58 } | 60 } |
| 59 } | 61 } |
| 60 | 62 |
| 61 DISALLOW_COPY_AND_ASSIGN(SingleOverlay); | 63 DISALLOW_COPY_AND_ASSIGN(SingleOverlay); |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace | 66 } // namespace |
| 65 | 67 |
| 66 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) | 68 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) |
| 67 : DriSurfaceFactory(NULL, NULL), | 69 : DriSurfaceFactory(NULL, NULL, NULL), |
| 68 device_(NULL), | 70 device_(NULL), |
| 69 allow_surfaceless_(allow_surfaceless) { | 71 allow_surfaceless_(allow_surfaceless) { |
| 70 } | 72 } |
| 71 | 73 |
| 72 GbmSurfaceFactory::~GbmSurfaceFactory() {} | 74 GbmSurfaceFactory::~GbmSurfaceFactory() {} |
| 73 | 75 |
| 74 void GbmSurfaceFactory::InitializeGpu( | 76 void GbmSurfaceFactory::InitializeGpu(DriWrapper* dri, |
| 75 DriWrapper* dri, gbm_device* device, ScreenManager* screen_manager) { | 77 gbm_device* device, |
| 78 ScreenManager* screen_manager, |
| 79 DriWindowManager* window_manager) { |
| 76 drm_ = dri; | 80 drm_ = dri; |
| 77 device_ = device; | 81 device_ = device; |
| 78 screen_manager_ = screen_manager; | 82 screen_manager_ = screen_manager; |
| 83 window_manager_ = window_manager; |
| 79 } | 84 } |
| 80 | 85 |
| 81 intptr_t GbmSurfaceFactory::GetNativeDisplay() { | 86 intptr_t GbmSurfaceFactory::GetNativeDisplay() { |
| 82 DCHECK(state_ == INITIALIZED); | 87 DCHECK(state_ == INITIALIZED); |
| 83 return reinterpret_cast<intptr_t>(device_); | 88 return reinterpret_cast<intptr_t>(device_); |
| 84 } | 89 } |
| 85 | 90 |
| 86 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( | 91 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( |
| 87 const int32* desired_list) { | 92 const int32* desired_list) { |
| 88 static const int32 kConfigAttribs[] = { | 93 static const int32 kConfigAttribs[] = { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 set_gl_get_proc_address.Run(get_proc_address); | 139 set_gl_get_proc_address.Run(get_proc_address); |
| 135 add_gl_library.Run(egl_library); | 140 add_gl_library.Run(egl_library); |
| 136 add_gl_library.Run(gles_library); | 141 add_gl_library.Run(gles_library); |
| 137 | 142 |
| 138 return true; | 143 return true; |
| 139 } | 144 } |
| 140 | 145 |
| 141 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( | 146 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
| 142 gfx::AcceleratedWidget widget) { | 147 gfx::AcceleratedWidget widget) { |
| 143 DCHECK(state_ == INITIALIZED); | 148 DCHECK(state_ == INITIALIZED); |
| 149 |
| 150 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); |
| 151 |
| 144 ResetCursor(widget); | 152 ResetCursor(widget); |
| 145 | 153 |
| 146 scoped_ptr<GbmSurface> surface(new GbmSurface( | 154 scoped_ptr<GbmSurface> surface(new GbmSurface(delegate, device_, drm_)); |
| 147 screen_manager_->GetDisplayController(widget), device_, drm_)); | |
| 148 if (!surface->Initialize()) | 155 if (!surface->Initialize()) |
| 149 return scoped_ptr<SurfaceOzoneEGL>(); | 156 return scoped_ptr<SurfaceOzoneEGL>(); |
| 150 | 157 |
| 151 return surface.PassAs<SurfaceOzoneEGL>(); | 158 return surface.PassAs<SurfaceOzoneEGL>(); |
| 152 } | 159 } |
| 153 | 160 |
| 154 scoped_ptr<SurfaceOzoneEGL> | 161 scoped_ptr<SurfaceOzoneEGL> |
| 155 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( | 162 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
| 156 gfx::AcceleratedWidget widget) { | 163 gfx::AcceleratedWidget widget) { |
| 157 if (!allow_surfaceless_) | 164 if (!allow_surfaceless_) |
| 158 return scoped_ptr<SurfaceOzoneEGL>(); | 165 return scoped_ptr<SurfaceOzoneEGL>(); |
| 159 return scoped_ptr<SurfaceOzoneEGL>( | 166 |
| 160 new GbmSurfaceless(screen_manager_->GetDisplayController(widget))); | 167 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); |
| 168 return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate)); |
| 161 } | 169 } |
| 162 | 170 |
| 163 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 171 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
| 164 gfx::Size size, | 172 gfx::Size size, |
| 165 BufferFormat format) { | 173 BufferFormat format) { |
| 166 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer( | 174 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer( |
| 167 drm_, device_, format, size, true); | 175 drm_, device_, format, size, true); |
| 168 if (!buffer) | 176 if (!buffer) |
| 169 return NULL; | 177 return NULL; |
| 170 | 178 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 184 int plane_z_order, | 192 int plane_z_order, |
| 185 gfx::OverlayTransform plane_transform, | 193 gfx::OverlayTransform plane_transform, |
| 186 scoped_refptr<NativePixmap> buffer, | 194 scoped_refptr<NativePixmap> buffer, |
| 187 const gfx::Rect& display_bounds, | 195 const gfx::Rect& display_bounds, |
| 188 const gfx::RectF& crop_rect) { | 196 const gfx::RectF& crop_rect) { |
| 189 scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get()); | 197 scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get()); |
| 190 if (!pixmap) { | 198 if (!pixmap) { |
| 191 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer."; | 199 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer."; |
| 192 return false; | 200 return false; |
| 193 } | 201 } |
| 194 base::WeakPtr<HardwareDisplayController> hdc = | 202 HardwareDisplayController* hdc = |
| 195 screen_manager_->GetDisplayController(widget); | 203 window_manager_->GetWindowDelegate(widget)->GetController(); |
| 196 if (!hdc) | 204 if (!hdc) |
| 197 return true; | 205 return true; |
| 206 |
| 198 hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(), | 207 hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(), |
| 199 plane_z_order, | 208 plane_z_order, |
| 200 plane_transform, | 209 plane_transform, |
| 201 display_bounds, | 210 display_bounds, |
| 202 crop_rect)); | 211 crop_rect)); |
| 203 return true; | 212 return true; |
| 204 } | 213 } |
| 205 | 214 |
| 206 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { | 215 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { |
| 207 return allow_surfaceless_; | 216 return allow_surfaceless_; |
| 208 } | 217 } |
| 209 | 218 |
| 219 DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate( |
| 220 gfx::AcceleratedWidget widget) { |
| 221 if (!window_manager_->HasWindowDelegate(widget)) { |
| 222 scoped_ptr<DriWindowDelegate> delegate( |
| 223 new DriWindowDelegateImpl(widget, screen_manager_)); |
| 224 delegate->Initialize(); |
| 225 window_manager_->AddWindowDelegate(widget, delegate.Pass()); |
| 226 } |
| 227 |
| 228 return window_manager_->GetWindowDelegate(widget); |
| 229 } |
| 230 |
| 210 } // namespace ui | 231 } // namespace ui |
| OLD | NEW |