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

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

Issue 365193003: Change NativeBufferOzone to be an object and move the overlay calls to the surface object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 <EGL/egl.h> 7 #include <EGL/egl.h>
8 #include <gbm.h> 8 #include <gbm.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "ui/ozone/platform/dri/buffer_data.h" 11 #include "ui/ozone/platform/dri/buffer_data.h"
12 #include "ui/ozone/platform/dri/dri_vsync_provider.h" 12 #include "ui/ozone/platform/dri/dri_vsync_provider.h"
13 #include "ui/ozone/platform/dri/gbm_buffer.h"
13 #include "ui/ozone/platform/dri/gbm_surface.h" 14 #include "ui/ozone/platform/dri/gbm_surface.h"
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" 15 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 #include "ui/ozone/platform/dri/scanout_surface.h" 16 #include "ui/ozone/platform/dri/scanout_surface.h"
16 #include "ui/ozone/platform/dri/screen_manager.h" 17 #include "ui/ozone/platform/dri/screen_manager.h"
17 #include "ui/ozone/public/surface_ozone_egl.h" 18 #include "ui/ozone/public/surface_ozone_egl.h"
18 19
19 namespace ui { 20 namespace ui {
20 21
21 namespace { 22 namespace {
22 23
23 class GbmSurfaceAdapter : public ui::SurfaceOzoneEGL { 24 class GbmSurfaceAdapter : public ui::SurfaceOzoneEGL {
24 public: 25 public:
25 GbmSurfaceAdapter(const base::WeakPtr<HardwareDisplayController>& controller); 26 GbmSurfaceAdapter(const base::WeakPtr<HardwareDisplayController>& controller);
26 virtual ~GbmSurfaceAdapter(); 27 virtual ~GbmSurfaceAdapter();
27 28
28 // SurfaceOzoneEGL: 29 // SurfaceOzoneEGL:
29 virtual intptr_t GetNativeWindow() OVERRIDE; 30 virtual intptr_t GetNativeWindow() OVERRIDE;
30 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE; 31 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE;
31 virtual bool OnSwapBuffers() OVERRIDE; 32 virtual bool OnSwapBuffers() OVERRIDE;
32 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; 33 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE;
34 virtual bool ScheduleOverlayPlane(int plane_z_order,
35 gfx::OverlayTransform plane_transform,
36 scoped_refptr<ui::NativePixmap> buffer,
37 const gfx::Rect& display_bounds,
38 const gfx::RectF& crop_rect) OVERRIDE;
33 39
34 private: 40 private:
35 base::WeakPtr<HardwareDisplayController> controller_; 41 base::WeakPtr<HardwareDisplayController> controller_;
36 42
37 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter); 43 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceAdapter);
38 }; 44 };
39 45
40 GbmSurfaceAdapter::GbmSurfaceAdapter( 46 GbmSurfaceAdapter::GbmSurfaceAdapter(
41 const base::WeakPtr<HardwareDisplayController>& controller) 47 const base::WeakPtr<HardwareDisplayController>& controller)
42 : controller_(controller) {} 48 : controller_(controller) {}
(...skipping 19 matching lines...) Expand all
62 68
63 static_cast<GbmSurface*>(controller_->surface())->LockCurrentDrawable(); 69 static_cast<GbmSurface*>(controller_->surface())->LockCurrentDrawable();
64 if (controller_->SchedulePageFlip()) { 70 if (controller_->SchedulePageFlip()) {
65 controller_->WaitForPageFlipEvent(); 71 controller_->WaitForPageFlipEvent();
66 return true; 72 return true;
67 } 73 }
68 74
69 return false; 75 return false;
70 } 76 }
71 77
78 bool GbmSurfaceAdapter::ScheduleOverlayPlane(
79 int plane_z_order,
80 gfx::OverlayTransform plane_transform,
81 scoped_refptr<ui::NativePixmap> buffer,
82 const gfx::Rect& display_bounds,
83 const gfx::RectF& crop_rect) {
84 NOTIMPLEMENTED();
85 return false;
86 }
87
72 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() { 88 scoped_ptr<gfx::VSyncProvider> GbmSurfaceAdapter::CreateVSyncProvider() {
73 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); 89 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_));
74 } 90 }
75 91
76 } // namespace 92 } // namespace
77 93
78 GbmSurfaceFactory::GbmSurfaceFactory(DriWrapper* dri, 94 GbmSurfaceFactory::GbmSurfaceFactory(DriWrapper* dri,
79 gbm_device* device, 95 gbm_device* device,
80 ScreenManager* screen_manager) 96 ScreenManager* screen_manager)
81 : DriSurfaceFactory(dri, screen_manager), 97 : DriSurfaceFactory(dri, screen_manager),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 161
146 scoped_ptr<ui::SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( 162 scoped_ptr<ui::SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
147 gfx::AcceleratedWidget w) { 163 gfx::AcceleratedWidget w) {
148 CHECK(state_ == INITIALIZED); 164 CHECK(state_ == INITIALIZED);
149 ResetCursor(w); 165 ResetCursor(w);
150 166
151 return scoped_ptr<ui::SurfaceOzoneEGL>( 167 return scoped_ptr<ui::SurfaceOzoneEGL>(
152 new GbmSurfaceAdapter(screen_manager_->GetDisplayController(w))); 168 new GbmSurfaceAdapter(screen_manager_->GetDisplayController(w)));
153 } 169 }
154 170
155 ui::NativeBufferOzone GbmSurfaceFactory::CreateNativeBuffer( 171 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
156 gfx::Size size, 172 gfx::Size size,
157 BufferFormat format) { 173 BufferFormat format) {
158 uint32_t gbm_format = 0; 174 scoped_refptr<GbmBuffer> buf = new GbmBuffer(device_, drm_, size);
159 switch (format) { 175 if (!buf->InitializeBuffer(format, true)) {
160 case SurfaceFactoryOzone::UNKNOWN: 176 return NULL;
161 return 0;
162 // TODO(alexst): Setting this to XRGB for now to allow presentation
163 // as a primary plane but disallowing overlay transparency. Address this
164 // to allow both use cases.
165 case SurfaceFactoryOzone::RGBA_8888:
166 gbm_format = GBM_FORMAT_XRGB8888;
167 break;
168 case SurfaceFactoryOzone::RGB_888:
169 gbm_format = GBM_FORMAT_RGB888;
170 break;
171 } 177 }
172 gbm_bo* buffer_object = 178 return buf;
173 gbm_bo_create(device_,
174 size.width(),
175 size.height(),
176 gbm_format,
177 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
178 if (!buffer_object)
179 return 0;
180
181 BufferData* data = BufferData::CreateData(drm_, buffer_object);
182 DCHECK(data) << "Failed to associate the buffer with the controller";
183
184 return reinterpret_cast<ui::NativeBufferOzone>(buffer_object);
185 } 179 }
186 180
187 } // namespace ui 181 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/gbm_surface_factory.h ('k') | ui/ozone/platform/egltest/ozone_platform_egltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698