| 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/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 int GbmBuffer::GetOffset(size_t index) const { | 76 int GbmBuffer::GetOffset(size_t index) const { |
| 77 DCHECK_LT(index, planes_.size()); | 77 DCHECK_LT(index, planes_.size()); |
| 78 return planes_[index].offset; | 78 return planes_[index].offset; |
| 79 } | 79 } |
| 80 | 80 |
| 81 size_t GbmBuffer::GetSize(size_t index) const { | 81 size_t GbmBuffer::GetSize(size_t index) const { |
| 82 DCHECK_LT(index, planes_.size()); | 82 DCHECK_LT(index, planes_.size()); |
| 83 return planes_[index].size; | 83 return planes_[index].size; |
| 84 } | 84 } |
| 85 | 85 |
| 86 uint64_t GbmBuffer::GetFormatModifier(size_t index) const { | |
| 87 DCHECK_LT(index, planes_.size()); | |
| 88 return planes_[index].modifier; | |
| 89 } | |
| 90 | |
| 91 // TODO(reveman): This should not be needed once crbug.com/597932 is fixed, | 86 // TODO(reveman): This should not be needed once crbug.com/597932 is fixed, |
| 92 // as the size would be queried directly from the underlying bo. | 87 // as the size would be queried directly from the underlying bo. |
| 93 gfx::Size GbmBuffer::GetSize() const { | 88 gfx::Size GbmBuffer::GetSize() const { |
| 94 return size_; | 89 return size_; |
| 95 } | 90 } |
| 96 | 91 |
| 97 scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO( | 92 scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO( |
| 98 const scoped_refptr<GbmDevice>& gbm, | 93 const scoped_refptr<GbmDevice>& gbm, |
| 99 gbm_bo* bo, | 94 gbm_bo* bo, |
| 100 uint32_t format, | 95 uint32_t format, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); | 238 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(buffer_->GetFd(i)))); |
| 244 if (!scoped_fd.is_valid()) { | 239 if (!scoped_fd.is_valid()) { |
| 245 PLOG(ERROR) << "dup"; | 240 PLOG(ERROR) << "dup"; |
| 246 return gfx::NativePixmapHandle(); | 241 return gfx::NativePixmapHandle(); |
| 247 } | 242 } |
| 248 handle.fds.emplace_back( | 243 handle.fds.emplace_back( |
| 249 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); | 244 base::FileDescriptor(scoped_fd.release(), true /* auto_close */)); |
| 250 } | 245 } |
| 251 handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i), | 246 handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i), |
| 252 buffer_->GetSize(i), | 247 buffer_->GetSize(i), |
| 253 buffer_->GetFormatModifier(i)); | 248 buffer_->GetFormatModifier()); |
| 254 } | 249 } |
| 255 return handle; | 250 return handle; |
| 256 } | 251 } |
| 257 | 252 |
| 258 GbmPixmap::~GbmPixmap() { | 253 GbmPixmap::~GbmPixmap() { |
| 259 } | 254 } |
| 260 | 255 |
| 261 void* GbmPixmap::GetEGLClientBuffer() const { | 256 void* GbmPixmap::GetEGLClientBuffer() const { |
| 262 return nullptr; | 257 return nullptr; |
| 263 } | 258 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 276 | 271 |
| 277 int GbmPixmap::GetDmaBufPitch(size_t plane) const { | 272 int GbmPixmap::GetDmaBufPitch(size_t plane) const { |
| 278 return buffer_->GetStride(plane); | 273 return buffer_->GetStride(plane); |
| 279 } | 274 } |
| 280 | 275 |
| 281 int GbmPixmap::GetDmaBufOffset(size_t plane) const { | 276 int GbmPixmap::GetDmaBufOffset(size_t plane) const { |
| 282 return buffer_->GetOffset(plane); | 277 return buffer_->GetOffset(plane); |
| 283 } | 278 } |
| 284 | 279 |
| 285 uint64_t GbmPixmap::GetDmaBufModifier(size_t plane) const { | 280 uint64_t GbmPixmap::GetDmaBufModifier(size_t plane) const { |
| 286 return buffer_->GetFormatModifier(plane); | 281 return buffer_->GetFormatModifier(); |
| 287 } | 282 } |
| 288 | 283 |
| 289 gfx::BufferFormat GbmPixmap::GetBufferFormat() const { | 284 gfx::BufferFormat GbmPixmap::GetBufferFormat() const { |
| 290 return ui::GetBufferFormatFromFourCCFormat(buffer_->GetFormat()); | 285 return ui::GetBufferFormatFromFourCCFormat(buffer_->GetFormat()); |
| 291 } | 286 } |
| 292 | 287 |
| 293 gfx::Size GbmPixmap::GetBufferSize() const { | 288 gfx::Size GbmPixmap::GetBufferSize() const { |
| 294 return buffer_->GetSize(); | 289 return buffer_->GetSize(); |
| 295 } | 290 } |
| 296 | 291 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 DCHECK(!processing_callback_.is_null()); | 329 DCHECK(!processing_callback_.is_null()); |
| 335 if (!processing_callback_.Run(this, processed_pixmap_)) { | 330 if (!processing_callback_.Run(this, processed_pixmap_)) { |
| 336 LOG(ERROR) << "Failed processing NativePixmap"; | 331 LOG(ERROR) << "Failed processing NativePixmap"; |
| 337 return nullptr; | 332 return nullptr; |
| 338 } | 333 } |
| 339 | 334 |
| 340 return processed_pixmap_->buffer(); | 335 return processed_pixmap_->buffer(); |
| 341 } | 336 } |
| 342 | 337 |
| 343 } // namespace ui | 338 } // namespace ui |
| OLD | NEW |