| 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 <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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |