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 <EGL/egl.h> | 7 #include <EGL/egl.h> |
8 #include <gbm.h> | |
8 | 9 |
9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
10 #include "ui/gfx/ozone/surface_ozone_egl.h" | 11 #include "ui/gfx/ozone/surface_ozone_egl.h" |
12 #include "ui/ozone/platform/dri/buffer_data.h" | |
11 #include "ui/ozone/platform/dri/dri_vsync_provider.h" | 13 #include "ui/ozone/platform/dri/dri_vsync_provider.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/hardware_display_controller.h" | 15 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
14 #include "ui/ozone/platform/dri/scanout_surface.h" | 16 #include "ui/ozone/platform/dri/scanout_surface.h" |
15 #include "ui/ozone/platform/dri/screen_manager.h" | 17 #include "ui/ozone/platform/dri/screen_manager.h" |
16 | 18 |
17 namespace ui { | 19 namespace ui { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 145 |
144 scoped_ptr<gfx::SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( | 146 scoped_ptr<gfx::SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
145 gfx::AcceleratedWidget w) { | 147 gfx::AcceleratedWidget w) { |
146 CHECK(state_ == INITIALIZED); | 148 CHECK(state_ == INITIALIZED); |
147 ResetCursor(w); | 149 ResetCursor(w); |
148 | 150 |
149 return scoped_ptr<gfx::SurfaceOzoneEGL>( | 151 return scoped_ptr<gfx::SurfaceOzoneEGL>( |
150 new GbmSurfaceAdapter(screen_manager_->GetDisplayController(w))); | 152 new GbmSurfaceAdapter(screen_manager_->GetDisplayController(w))); |
151 } | 153 } |
152 | 154 |
155 gfx::NativeBufferOzone GbmSurfaceFactory::CreateNativeBuffer( | |
156 gfx::Size size, | |
157 BufferFormat format) { | |
158 uint32_t gbm_format = 0; | |
159 switch (format) { | |
dnicoara
2014/06/17 18:16:43
Should we have XRGB8888 in here for 32 bpp support
| |
160 case SurfaceFactoryOzone::UNKNOWN: | |
161 return 0; | |
162 case SurfaceFactoryOzone::RGBA_8888: | |
163 gbm_format = GBM_FORMAT_ARGB8888; | |
164 break; | |
165 case SurfaceFactoryOzone::RGB_888: | |
166 gbm_format = GBM_FORMAT_RGB888; | |
167 break; | |
168 } | |
169 gbm_bo* buffer_object = | |
170 gbm_bo_create(device_, | |
171 size.width(), | |
172 size.height(), | |
173 gbm_format, | |
174 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING | 0); | |
dnicoara
2014/06/17 18:16:43
nit: Don't need "| 0" at the end.
| |
175 if (!buffer_object) | |
176 return 0; | |
177 | |
178 BufferData* data = BufferData::CreateData(drm_, buffer_object); | |
179 DCHECK(data) << "Failed to associate the buffer with the controller"; | |
180 | |
181 return reinterpret_cast<gfx::NativeBufferOzone>(buffer_object); | |
182 } | |
183 | |
153 } // namespace ui | 184 } // namespace ui |
OLD | NEW |