Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: ui/ozone/platform/dri/gbm_surface_factory.cc

Issue 469343003: [Ozone-GBM] Pumb DriWindowDelegate throughout the platform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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/platform/dri/dri_window_delegate_impl.h"
12 #include "ui/ozone/platform/dri/dri_window_manager.h"
11 #include "ui/ozone/platform/dri/gbm_buffer.h" 13 #include "ui/ozone/platform/dri/gbm_buffer.h"
12 #include "ui/ozone/platform/dri/gbm_surface.h" 14 #include "ui/ozone/platform/dri/gbm_surface.h"
13 #include "ui/ozone/platform/dri/gbm_surfaceless.h" 15 #include "ui/ozone/platform/dri/gbm_surfaceless.h"
14 #include "ui/ozone/platform/dri/screen_manager.h" 16 #include "ui/ozone/platform/dri/screen_manager.h"
15 #include "ui/ozone/public/native_pixmap.h" 17 #include "ui/ozone/public/native_pixmap.h"
16 #include "ui/ozone/public/surface_ozone_egl.h" 18 #include "ui/ozone/public/surface_ozone_egl.h"
17 19
18 namespace ui { 20 namespace ui {
19 21
20 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) 22 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless)
21 : DriSurfaceFactory(NULL, NULL), 23 : DriSurfaceFactory(NULL, NULL, NULL),
22 device_(NULL), 24 device_(NULL),
23 allow_surfaceless_(allow_surfaceless) { 25 allow_surfaceless_(allow_surfaceless) {
24 } 26 }
25 27
26 GbmSurfaceFactory::~GbmSurfaceFactory() {} 28 GbmSurfaceFactory::~GbmSurfaceFactory() {}
27 29
28 void GbmSurfaceFactory::InitializeGpu( 30 void GbmSurfaceFactory::InitializeGpu(DriWrapper* dri,
29 DriWrapper* dri, gbm_device* device, ScreenManager* screen_manager) { 31 gbm_device* device,
32 ScreenManager* screen_manager,
33 DriWindowManager* window_manager) {
30 drm_ = dri; 34 drm_ = dri;
31 device_ = device; 35 device_ = device;
32 screen_manager_ = screen_manager; 36 screen_manager_ = screen_manager;
37 window_manager_ = window_manager;
33 } 38 }
34 39
35 intptr_t GbmSurfaceFactory::GetNativeDisplay() { 40 intptr_t GbmSurfaceFactory::GetNativeDisplay() {
36 DCHECK(state_ == INITIALIZED); 41 DCHECK(state_ == INITIALIZED);
37 return reinterpret_cast<intptr_t>(device_); 42 return reinterpret_cast<intptr_t>(device_);
38 } 43 }
39 44
40 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( 45 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
41 const int32* desired_list) { 46 const int32* desired_list) {
42 static const int32 kConfigAttribs[] = { 47 static const int32 kConfigAttribs[] = {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 set_gl_get_proc_address.Run(get_proc_address); 93 set_gl_get_proc_address.Run(get_proc_address);
89 add_gl_library.Run(egl_library); 94 add_gl_library.Run(egl_library);
90 add_gl_library.Run(gles_library); 95 add_gl_library.Run(gles_library);
91 96
92 return true; 97 return true;
93 } 98 }
94 99
95 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( 100 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
96 gfx::AcceleratedWidget widget) { 101 gfx::AcceleratedWidget widget) {
97 DCHECK(state_ == INITIALIZED); 102 DCHECK(state_ == INITIALIZED);
103
104 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget);
105
98 ResetCursor(widget); 106 ResetCursor(widget);
99 107
100 scoped_ptr<GbmSurface> surface(new GbmSurface( 108 scoped_ptr<GbmSurface> surface(new GbmSurface(delegate, device_, drm_));
101 screen_manager_->GetDisplayController(widget), device_, drm_));
102 if (!surface->Initialize()) 109 if (!surface->Initialize())
103 return scoped_ptr<SurfaceOzoneEGL>(); 110 return scoped_ptr<SurfaceOzoneEGL>();
104 111
105 return surface.PassAs<SurfaceOzoneEGL>(); 112 return surface.PassAs<SurfaceOzoneEGL>();
106 } 113 }
107 114
108 scoped_ptr<SurfaceOzoneEGL> 115 scoped_ptr<SurfaceOzoneEGL>
109 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( 116 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
110 gfx::AcceleratedWidget widget) { 117 gfx::AcceleratedWidget widget) {
111 if (!allow_surfaceless_) 118 if (!allow_surfaceless_)
112 return scoped_ptr<SurfaceOzoneEGL>(); 119 return scoped_ptr<SurfaceOzoneEGL>();
113 return scoped_ptr<SurfaceOzoneEGL>( 120
114 new GbmSurfaceless(screen_manager_->GetDisplayController(widget))); 121 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
122 return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate));
115 } 123 }
116 124
117 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 125 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
118 gfx::Size size, 126 gfx::Size size,
119 BufferFormat format) { 127 BufferFormat format) {
120 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer( 128 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer(
121 drm_, device_, format, size, true); 129 drm_, device_, format, size, true);
122 if (!buffer) 130 if (!buffer)
123 return NULL; 131 return NULL;
124 132
125 return scoped_refptr<GbmPixmap>(new GbmPixmap(buffer)); 133 return scoped_refptr<GbmPixmap>(new GbmPixmap(buffer));
126 } 134 }
127 135
128 bool GbmSurfaceFactory::ScheduleOverlayPlane( 136 bool GbmSurfaceFactory::ScheduleOverlayPlane(
129 gfx::AcceleratedWidget widget, 137 gfx::AcceleratedWidget widget,
130 int plane_z_order, 138 int plane_z_order,
131 gfx::OverlayTransform plane_transform, 139 gfx::OverlayTransform plane_transform,
132 scoped_refptr<NativePixmap> buffer, 140 scoped_refptr<NativePixmap> buffer,
133 const gfx::Rect& display_bounds, 141 const gfx::Rect& display_bounds,
134 const gfx::RectF& crop_rect) { 142 const gfx::RectF& crop_rect) {
135 scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get()); 143 scoped_refptr<GbmPixmap> pixmap = static_cast<GbmPixmap*>(buffer.get());
136 if (!pixmap) { 144 if (!pixmap) {
137 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer."; 145 LOG(ERROR) << "ScheduleOverlayPlane passed NULL buffer.";
138 return false; 146 return false;
139 } 147 }
140 base::WeakPtr<HardwareDisplayController> hdc = 148 HardwareDisplayController* hdc =
141 screen_manager_->GetDisplayController(widget); 149 window_manager_->GetWindowDelegate(widget)->GetController();
142 if (!hdc) 150 if (!hdc)
143 return true; 151 return true;
152
144 hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(), 153 hdc->QueueOverlayPlane(OverlayPlane(pixmap->buffer(),
145 plane_z_order, 154 plane_z_order,
146 plane_transform, 155 plane_transform,
147 display_bounds, 156 display_bounds,
148 crop_rect)); 157 crop_rect));
149 return true; 158 return true;
150 } 159 }
151 160
152 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { 161 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
153 return allow_surfaceless_; 162 return allow_surfaceless_;
154 } 163 }
155 164
165 DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate(
166 gfx::AcceleratedWidget widget) {
167 if (!window_manager_->HasWindowDelegate(widget)) {
168 DriWindowDelegateImpl* delegate =
169 new DriWindowDelegateImpl(widget, screen_manager_);
170 window_manager_->AddWindowDelegate(widget, delegate);
171 delegate->Initialize();
172 return delegate;
173 }
174
175 return window_manager_->GetWindowDelegate(widget);
176 }
177
156 } // namespace ui 178 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698