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

Side by Side Diff: ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc

Issue 1262043002: Implement DRM Native Pixmap using prime buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-master
Patch Set: ToT rebase Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/drm/client_native_pixmap_factory_gbm.h" 5 #include "ui/ozone/platform/drm/client_native_pixmap_factory_gbm.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "ui/gfx/native_pixmap_handle_ozone.h" 11 #include "ui/gfx/native_pixmap_handle_ozone.h"
12 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
11 #include "ui/ozone/public/client_native_pixmap_factory.h" // nogncheck 13 #include "ui/ozone/public/client_native_pixmap_factory.h" // nogncheck
14 #include "ui/ozone/public/ozone_switches.h"
12 15
13 #if defined(USE_VGEM_MAP) 16 #if defined(USE_VGEM_MAP)
14 #include "ui/ozone/platform/drm/common/client_native_pixmap_vgem.h" 17 #include "ui/ozone/platform/drm/common/client_native_pixmap_vgem.h"
15 #endif 18 #endif
16 19
17 namespace ui { 20 namespace ui {
18 21
19 namespace { 22 namespace {
20 23
21 class ClientNativePixmapGbm : public ClientNativePixmap { 24 class ClientNativePixmapGbm : public ClientNativePixmap {
(...skipping 29 matching lines...) Expand all
51 gfx::BufferUsage usage) const override { 54 gfx::BufferUsage usage) const override {
52 switch (usage) { 55 switch (usage) {
53 case gfx::BufferUsage::GPU_READ: 56 case gfx::BufferUsage::GPU_READ:
54 case gfx::BufferUsage::SCANOUT: 57 case gfx::BufferUsage::SCANOUT:
55 return format == gfx::BufferFormat::RGBA_8888 || 58 return format == gfx::BufferFormat::RGBA_8888 ||
56 format == gfx::BufferFormat::RGBX_8888 || 59 format == gfx::BufferFormat::RGBX_8888 ||
57 format == gfx::BufferFormat::BGRA_8888 || 60 format == gfx::BufferFormat::BGRA_8888 ||
58 format == gfx::BufferFormat::BGRX_8888; 61 format == gfx::BufferFormat::BGRX_8888;
59 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: 62 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
60 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: { 63 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: {
64 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
65 switches::kOzoneUseDmaBufMmap))
spang 2016/03/21 23:24:20 Check the command line in the constructor or Initi
vignatti (out of this project) 2016/03/22 20:24:29 I was actually thinking about removing the cmd lin
66 return format == gfx::BufferFormat::BGRA_8888;
61 #if defined(USE_VGEM_MAP) 67 #if defined(USE_VGEM_MAP)
62 return vgem_fd_.is_valid() && format == gfx::BufferFormat::BGRA_8888; 68 return vgem_fd_.is_valid() && format == gfx::BufferFormat::BGRA_8888;
63 #else 69 #else
64 return false; 70 return false;
65 #endif 71 #endif
66 } 72 }
67 } 73 }
68 NOTREACHED(); 74 NOTREACHED();
69 return false; 75 return false;
70 } 76 }
71 scoped_ptr<ClientNativePixmap> ImportFromHandle( 77 scoped_ptr<ClientNativePixmap> ImportFromHandle(
72 const gfx::NativePixmapHandle& handle, 78 const gfx::NativePixmapHandle& handle,
73 const gfx::Size& size, 79 const gfx::Size& size,
74 gfx::BufferUsage usage) override { 80 gfx::BufferUsage usage) override {
75 base::ScopedFD scoped_fd(handle.fd.fd); 81 base::ScopedFD scoped_fd(handle.fd.fd);
76 82
77 switch (usage) { 83 switch (usage) {
78 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: 84 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
79 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: 85 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
86 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
87 switches::kOzoneUseDmaBufMmap))
88 return ClientNativePixmapDmaBuf::ImportFromDmabuf(
89 scoped_fd.get(), size, handle.stride);
80 #if defined(USE_VGEM_MAP) 90 #if defined(USE_VGEM_MAP)
81 // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is 91 // A valid |vgem_fd_| is required to acquire a VGEM bo. |vgem_fd_| is
82 // set before a widget is created. 92 // set before a widget is created.
83 DCHECK_GE(vgem_fd_.get(), 0); 93 DCHECK_GE(vgem_fd_.get(), 0);
84 return ClientNativePixmapVgem::ImportFromDmabuf( 94 return ClientNativePixmapVgem::ImportFromDmabuf(
85 vgem_fd_.get(), scoped_fd.get(), size, handle.stride); 95 vgem_fd_.get(), scoped_fd.get(), size, handle.stride);
86 #endif 96 #endif
87 NOTREACHED(); 97 NOTREACHED();
88 return nullptr; 98 return nullptr;
89 case gfx::BufferUsage::GPU_READ: 99 case gfx::BufferUsage::GPU_READ:
(...skipping 11 matching lines...) Expand all
101 #endif 111 #endif
102 112
103 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 113 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
104 }; 114 };
105 115
106 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 116 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
107 return new ClientNativePixmapFactoryGbm(); 117 return new ClientNativePixmapFactoryGbm();
108 } 118 }
109 119
110 } // namespace ui 120 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698