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

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

Issue 706273002: Add ability to query and allocate zero copy buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 <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"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 gfx::AcceleratedWidget widget) { 163 gfx::AcceleratedWidget widget) {
164 if (!allow_surfaceless_) 164 if (!allow_surfaceless_)
165 return scoped_ptr<SurfaceOzoneEGL>(); 165 return scoped_ptr<SurfaceOzoneEGL>();
166 166
167 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); 167 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget);
168 return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate)); 168 return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate));
169 } 169 }
170 170
171 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 171 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
172 gfx::Size size, 172 gfx::Size size,
173 BufferFormat format) { 173 BufferFormat format,
174 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer( 174 BufferUsage usage) {
175 drm_, device_, format, size, true); 175 if (usage == MAP)
176 return NULL;
177
178 scoped_refptr<GbmBuffer> buffer =
179 GbmBuffer::CreateBuffer(drm_, device_, format, size, true);
176 if (!buffer.get()) 180 if (!buffer.get())
177 return NULL; 181 return NULL;
178 182
179 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); 183 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer));
180 if (!pixmap->Initialize(drm_)) 184 if (!pixmap->Initialize(drm_))
181 return NULL; 185 return NULL;
182 186
183 return pixmap; 187 return pixmap;
184 } 188 }
185 189
(...skipping 27 matching lines...) Expand all
213 plane_transform, 217 plane_transform,
214 display_bounds, 218 display_bounds,
215 crop_rect)); 219 crop_rect));
216 return true; 220 return true;
217 } 221 }
218 222
219 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { 223 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
220 return allow_surfaceless_; 224 return allow_surfaceless_;
221 } 225 }
222 226
227 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) {
228 switch (usage) {
229 case MAP:
230 return false;
231 case SCANOUT:
232 return true;
233 }
234 NOTREACHED();
235 return false;
236 }
237
223 DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate( 238 DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate(
224 gfx::AcceleratedWidget widget) { 239 gfx::AcceleratedWidget widget) {
225 if (!window_manager_->HasWindowDelegate(widget)) { 240 if (!window_manager_->HasWindowDelegate(widget)) {
226 scoped_ptr<DriWindowDelegate> delegate( 241 scoped_ptr<DriWindowDelegate> delegate(
227 new DriWindowDelegateImpl(widget, screen_manager_)); 242 new DriWindowDelegateImpl(widget, screen_manager_));
228 delegate->Initialize(); 243 delegate->Initialize();
229 window_manager_->AddWindowDelegate(widget, delegate.Pass()); 244 window_manager_->AddWindowDelegate(widget, delegate.Pass());
230 } 245 }
231 246
232 return window_manager_->GetWindowDelegate(widget); 247 return window_manager_->GetWindowDelegate(widget);
233 } 248 }
234 249
235 } // namespace ui 250 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698