Chromium Code Reviews| Index: ui/ozone/platform/dri/gbm_surface_factory.cc |
| diff --git a/ui/ozone/platform/dri/gbm_surface_factory.cc b/ui/ozone/platform/dri/gbm_surface_factory.cc |
| index 6e354b8b8a21c25e4808dc4e9a38ea13d4ab24bb..ab2997ad60581836ab67adf298315a2fdaf87073 100644 |
| --- a/ui/ozone/platform/dri/gbm_surface_factory.cc |
| +++ b/ui/ozone/platform/dri/gbm_surface_factory.cc |
| @@ -8,6 +8,8 @@ |
| #include "base/files/file_path.h" |
| #include "third_party/khronos/EGL/egl.h" |
| +#include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
| +#include "ui/ozone/platform/dri/dri_window_manager.h" |
| #include "ui/ozone/platform/dri/gbm_buffer.h" |
| #include "ui/ozone/platform/dri/gbm_surface.h" |
| #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
| @@ -18,18 +20,21 @@ |
| namespace ui { |
| GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) |
| - : DriSurfaceFactory(NULL, NULL), |
| + : DriSurfaceFactory(NULL, NULL, NULL), |
| device_(NULL), |
| allow_surfaceless_(allow_surfaceless) { |
| } |
| GbmSurfaceFactory::~GbmSurfaceFactory() {} |
| -void GbmSurfaceFactory::InitializeGpu( |
| - DriWrapper* dri, gbm_device* device, ScreenManager* screen_manager) { |
| +void GbmSurfaceFactory::InitializeGpu(DriWrapper* dri, |
| + gbm_device* device, |
| + ScreenManager* screen_manager, |
| + DriWindowManager* window_manager) { |
| drm_ = dri; |
| device_ = device; |
| screen_manager_ = screen_manager; |
| + window_manager_ = window_manager; |
| } |
| intptr_t GbmSurfaceFactory::GetNativeDisplay() { |
| @@ -95,10 +100,12 @@ bool GbmSurfaceFactory::LoadEGLGLES2Bindings( |
| scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
| gfx::AcceleratedWidget widget) { |
| DCHECK(state_ == INITIALIZED); |
| + |
| + DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); |
| + |
| ResetCursor(widget); |
| - scoped_ptr<GbmSurface> surface(new GbmSurface( |
| - screen_manager_->GetDisplayController(widget), device_, drm_)); |
| + scoped_ptr<GbmSurface> surface(new GbmSurface(delegate, device_, drm_)); |
| if (!surface->Initialize()) |
| return scoped_ptr<SurfaceOzoneEGL>(); |
| @@ -110,8 +117,9 @@ GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
| gfx::AcceleratedWidget widget) { |
| if (!allow_surfaceless_) |
| return scoped_ptr<SurfaceOzoneEGL>(); |
| - return scoped_ptr<SurfaceOzoneEGL>( |
| - new GbmSurfaceless(screen_manager_->GetDisplayController(widget))); |
| + |
| + DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); |
|
alexst (slow to review)
2014/08/20 21:51:09
I think this leaks. As far as I can tell looking t
dnicoara
2014/08/21 20:54:17
Arr, yes, I forgot about this through all the refa
|
| + return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate)); |
| } |
| scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
| @@ -137,10 +145,11 @@ bool GbmSurfaceFactory::ScheduleOverlayPlane( |
| LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer."; |
| return false; |
| } |
| - base::WeakPtr<HardwareDisplayController> hdc = |
| - screen_manager_->GetDisplayController(widget); |
| + HardwareDisplayController* hdc = |
| + window_manager_->GetWindowDelegate(widget)->GetController(); |
| if (!hdc) |
| return true; |
| + |
| hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(), |
| plane_z_order, |
| plane_transform, |
| @@ -153,4 +162,17 @@ bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { |
| return allow_surfaceless_; |
| } |
| +DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate( |
| + gfx::AcceleratedWidget widget) { |
| + if (!window_manager_->HasWindowDelegate(widget)) { |
| + DriWindowDelegateImpl* delegate = |
| + new DriWindowDelegateImpl(widget, screen_manager_); |
| + window_manager_->AddWindowDelegate(widget, delegate); |
| + delegate->Initialize(); |
| + return delegate; |
| + } |
| + |
| + return window_manager_->GetWindowDelegate(widget); |
| +} |
| + |
| } // namespace ui |