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

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_buffer.cc

Issue 2272153002: Add ClientNativePixmap multi-planar support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-native-pixmap-dmabug-multiple-planes
Patch Set: ifdef USE_OZONE for unused variables. Created 4 years, 2 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/ozone/platform/drm/gpu/gbm_buffer.h ('k') | ui/ozone/public/client_native_pixmap.h » ('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 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/drm/gpu/gbm_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <gbm.h> 9 #include <gbm.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 int GbmBuffer::GetStride(size_t index) const { 68 int GbmBuffer::GetStride(size_t index) const {
69 DCHECK_LT(index, planes_.size()); 69 DCHECK_LT(index, planes_.size());
70 return planes_[index].stride; 70 return planes_[index].stride;
71 } 71 }
72 72
73 int GbmBuffer::GetOffset(size_t index) const { 73 int GbmBuffer::GetOffset(size_t index) const {
74 DCHECK_LT(index, planes_.size()); 74 DCHECK_LT(index, planes_.size());
75 return planes_[index].offset; 75 return planes_[index].offset;
76 } 76 }
77 77
78 size_t GbmBuffer::GetSize(size_t index) const {
79 DCHECK_LT(index, planes_.size());
80 return planes_[index].size;
81 }
82
78 uint64_t GbmBuffer::GetFormatModifier(size_t index) const { 83 uint64_t GbmBuffer::GetFormatModifier(size_t index) const {
79 DCHECK_LT(index, planes_.size()); 84 DCHECK_LT(index, planes_.size());
80 return planes_[index].modifier; 85 return planes_[index].modifier;
81 } 86 }
82 87
83 // TODO(reveman): This should not be needed once crbug.com/597932 is fixed, 88 // TODO(reveman): This should not be needed once crbug.com/597932 is fixed,
84 // as the size would be queried directly from the underlying bo. 89 // as the size would be queried directly from the underlying bo.
85 gfx::Size GbmBuffer::GetSize() const { 90 gfx::Size GbmBuffer::GetSize() const {
86 return size_; 91 return size_;
87 } 92 }
(...skipping 28 matching lines...) Expand all
116 std::vector<base::ScopedFD> fds; 121 std::vector<base::ScopedFD> fds;
117 std::vector<gfx::NativePixmapPlane> planes; 122 std::vector<gfx::NativePixmapPlane> planes;
118 123
119 DCHECK_EQ(gbm_bo_get_num_planes(bo), 124 DCHECK_EQ(gbm_bo_get_num_planes(bo),
120 gfx::NumberOfPlanesForBufferFormat(format)); 125 gfx::NumberOfPlanesForBufferFormat(format));
121 for (size_t i = 0; i < gfx::NumberOfPlanesForBufferFormat(format); ++i) { 126 for (size_t i = 0; i < gfx::NumberOfPlanesForBufferFormat(format); ++i) {
122 // The fd returned by gbm_bo_get_fd is not ref-counted and need to be 127 // The fd returned by gbm_bo_get_fd is not ref-counted and need to be
123 // kept open for the lifetime of the buffer. 128 // kept open for the lifetime of the buffer.
124 base::ScopedFD fd(gbm_bo_get_plane_fd(bo, i)); 129 base::ScopedFD fd(gbm_bo_get_plane_fd(bo, i));
125 130
126 if (!fd.is_valid()) { 131 // TODO(dcastagna): support multiple fds.
127 PLOG(ERROR) << "Failed to export buffer to dma_buf"; 132 // crbug.com/642410
128 gbm_bo_destroy(bo); 133 if (!i) {
129 return nullptr; 134 if (!fd.is_valid()) {
135 PLOG(ERROR) << "Failed to export buffer to dma_buf";
136 gbm_bo_destroy(bo);
137 return nullptr;
138 }
139 fds.emplace_back(std::move(fd));
130 } 140 }
131 fds.emplace_back(std::move(fd));
132 141
133 planes.emplace_back(gbm_bo_get_plane_stride(bo, i), 142 planes.emplace_back(
134 gbm_bo_get_plane_offset(bo, i), 143 gbm_bo_get_plane_stride(bo, i), gbm_bo_get_plane_offset(bo, i),
135 gbm_bo_get_plane_format_modifier(bo, i)); 144 gbm_bo_get_plane_size(bo, i), gbm_bo_get_plane_format_modifier(bo, i));
136 } 145 }
137 scoped_refptr<GbmBuffer> buffer(new GbmBuffer( 146 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
138 gbm, bo, format, usage, std::move(fds), size, std::move(planes))); 147 gbm, bo, format, usage, std::move(fds), size, std::move(planes)));
139 if (usage == gfx::BufferUsage::SCANOUT && !buffer->GetFramebufferId()) 148 if (usage == gfx::BufferUsage::SCANOUT && !buffer->GetFramebufferId())
140 return nullptr; 149 return nullptr;
141 150
142 return buffer; 151 return buffer;
143 } 152 }
144 153
145 // static 154 // static
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (i < buffer_->GetFdCount()) { 218 if (i < buffer_->GetFdCount()) {
210 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); 219 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i))));
211 if (!scoped_fd.is_valid()) { 220 if (!scoped_fd.is_valid()) {
212 PLOG(ERROR) << "dup"; 221 PLOG(ERROR) << "dup";
213 return gfx::NativePixmapHandle(); 222 return gfx::NativePixmapHandle();
214 } 223 }
215 handle.fds.emplace_back( 224 handle.fds.emplace_back(
216 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); 225 base::FileDescriptor(scoped_fd.release(), true /* auto_close */));
217 } 226 }
218 handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i), 227 handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i),
228 buffer_->GetSize(i),
219 buffer_->GetFormatModifier(i)); 229 buffer_->GetFormatModifier(i));
220 } 230 }
221 return handle; 231 return handle;
222 } 232 }
223 233
224 GbmPixmap::~GbmPixmap() { 234 GbmPixmap::~GbmPixmap() {
225 } 235 }
226 236
227 void* GbmPixmap::GetEGLClientBuffer() const { 237 void* GbmPixmap::GetEGLClientBuffer() const {
228 return nullptr; 238 return nullptr;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 DCHECK(!processing_callback_.is_null()); 312 DCHECK(!processing_callback_.is_null());
303 if (!processing_callback_.Run(this, processed_pixmap_)) { 313 if (!processing_callback_.Run(this, processed_pixmap_)) {
304 LOG(ERROR) << "Failed processing NativePixmap"; 314 LOG(ERROR) << "Failed processing NativePixmap";
305 return nullptr; 315 return nullptr;
306 } 316 }
307 317
308 return processed_pixmap_->buffer(); 318 return processed_pixmap_->buffer();
309 } 319 }
310 320
311 } // namespace ui 321 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer.h ('k') | ui/ozone/public/client_native_pixmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698