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

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

Issue 2717963002: ui: Add gfx::BufferUsage::SCANOUT_CPU_READ_WRITE. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/gfx/mojo/buffer_types_struct_traits.h ('k') | ui/ozone/platform/drm/gpu/drm_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 case gfx::BufferUsage::GPU_READ: 50 case gfx::BufferUsage::GPU_READ:
51 return format == gfx::BufferFormat::BGR_565 || 51 return format == gfx::BufferFormat::BGR_565 ||
52 format == gfx::BufferFormat::RGBA_8888 || 52 format == gfx::BufferFormat::RGBA_8888 ||
53 format == gfx::BufferFormat::RGBX_8888 || 53 format == gfx::BufferFormat::RGBX_8888 ||
54 format == gfx::BufferFormat::BGRA_8888 || 54 format == gfx::BufferFormat::BGRA_8888 ||
55 format == gfx::BufferFormat::BGRX_8888 || 55 format == gfx::BufferFormat::BGRX_8888 ||
56 format == gfx::BufferFormat::YVU_420; 56 format == gfx::BufferFormat::YVU_420;
57 case gfx::BufferUsage::SCANOUT: 57 case gfx::BufferUsage::SCANOUT:
58 return format == gfx::BufferFormat::BGRX_8888 || 58 return format == gfx::BufferFormat::BGRX_8888 ||
59 format == gfx::BufferFormat::RGBX_8888; 59 format == gfx::BufferFormat::RGBX_8888;
60 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE:
61 return format == gfx::BufferFormat::BGRX_8888 ||
62 format == gfx::BufferFormat::BGRA_8888 ||
63 format == gfx::BufferFormat::RGBX_8888 ||
64 format == gfx::BufferFormat::RGBA_8888;
60 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: 65 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
61 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: { 66 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: {
62 #if defined(OS_CHROMEOS) 67 #if defined(OS_CHROMEOS)
63 return 68 return
64 #if defined(ARCH_CPU_X86_FAMILY) 69 #if defined(ARCH_CPU_X86_FAMILY)
65 // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8 70 // Currently only Intel driver (i.e. minigbm and Mesa) supports R_8
66 // and RG_88. crbug.com/356871 71 // and RG_88. crbug.com/356871
67 format == gfx::BufferFormat::R_8 || 72 format == gfx::BufferFormat::R_8 ||
68 format == gfx::BufferFormat::RG_88 || 73 format == gfx::BufferFormat::RG_88 ||
69 #endif 74 #endif
70 format == gfx::BufferFormat::BGRA_8888; 75 format == gfx::BufferFormat::BGRA_8888;
71 #else 76 #else
72 return false; 77 return false;
73 #endif 78 #endif
74 } 79 }
75 } 80 }
76 NOTREACHED(); 81 NOTREACHED();
77 return false; 82 return false;
78 } 83 }
79 std::unique_ptr<ClientNativePixmap> ImportFromHandle( 84 std::unique_ptr<ClientNativePixmap> ImportFromHandle(
80 const gfx::NativePixmapHandle& handle, 85 const gfx::NativePixmapHandle& handle,
81 const gfx::Size& size, 86 const gfx::Size& size,
82 gfx::BufferUsage usage) override { 87 gfx::BufferUsage usage) override {
83 DCHECK(!handle.fds.empty()); 88 DCHECK(!handle.fds.empty());
84 switch (usage) { 89 switch (usage) {
90 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE:
dcheng 2017/02/27 23:14:56 Quick question: are these only supposed to be used
reveman 2017/02/27 23:47:23 They can be used on other platforms too. The scano
85 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: 91 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
86 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: 92 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
87 #if defined(OS_CHROMEOS) 93 #if defined(OS_CHROMEOS)
88 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size); 94 return ClientNativePixmapDmaBuf::ImportFromDmabuf(handle, size);
89 #else 95 #else
90 NOTREACHED(); 96 NOTREACHED();
91 return nullptr; 97 return nullptr;
92 #endif 98 #endif
93 case gfx::BufferUsage::GPU_READ: 99 case gfx::BufferUsage::GPU_READ:
94 case gfx::BufferUsage::SCANOUT: 100 case gfx::BufferUsage::SCANOUT:
95 // Close all the fds. 101 // Close all the fds.
96 for (const auto& fd : handle.fds) 102 for (const auto& fd : handle.fds)
97 base::ScopedFD scoped_fd(fd.fd); 103 base::ScopedFD scoped_fd(fd.fd);
98 return base::WrapUnique(new ClientNativePixmapGbm); 104 return base::WrapUnique(new ClientNativePixmapGbm);
99 } 105 }
100 NOTREACHED(); 106 NOTREACHED();
101 return nullptr; 107 return nullptr;
102 } 108 }
103 109
104 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm); 110 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactoryGbm);
105 }; 111 };
106 112
107 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() { 113 ClientNativePixmapFactory* CreateClientNativePixmapFactoryGbm() {
108 return new ClientNativePixmapFactoryGbm(); 114 return new ClientNativePixmapFactoryGbm();
109 } 115 }
110 116
111 } // namespace ui 117 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/mojo/buffer_types_struct_traits.h ('k') | ui/ozone/platform/drm/gpu/drm_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698