| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 GbmPixmap::GbmPixmap(const scoped_refptr<GbmBuffer>& buffer) | 68 GbmPixmap::GbmPixmap(const scoped_refptr<GbmBuffer>& buffer) |
| 69 : buffer_(buffer), dma_buf_(-1) { | 69 : buffer_(buffer), dma_buf_(-1) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool GbmPixmap::Initialize() { | 72 bool GbmPixmap::Initialize() { |
| 73 // We want to use the GBM API because it's going to call into libdrm | 73 // We want to use the GBM API because it's going to call into libdrm |
| 74 // which might do some optimizations on buffer allocation, | 74 // which might do some optimizations on buffer allocation, |
| 75 // especially when sharing buffers via DMABUF. | 75 // especially when sharing buffers via DMABUF. |
| 76 dma_buf_ = gbm_bo_get_fd(buffer_->bo()); | 76 dma_buf_ = gbm_bo_get_fd(buffer_->bo()); |
| 77 if (dma_buf_ < 0) { | 77 if (dma_buf_ < 0) { |
| 78 LOG(ERROR) << "Failed to export buffer to dma_buf"; | 78 PLOG(ERROR) << "Failed to export buffer to dma_buf"; |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 GbmPixmap::~GbmPixmap() { | 84 GbmPixmap::~GbmPixmap() { |
| 85 if (dma_buf_ > 0) | 85 if (dma_buf_ > 0) |
| 86 close(dma_buf_); | 86 close(dma_buf_); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void* GbmPixmap::GetEGLClientBuffer() { | 89 void* GbmPixmap::GetEGLClientBuffer() { |
| 90 return nullptr; | 90 return nullptr; |
| 91 } | 91 } |
| 92 | 92 |
| 93 int GbmPixmap::GetDmaBufFd() { | 93 int GbmPixmap::GetDmaBufFd() { |
| 94 return dma_buf_; | 94 return dma_buf_; |
| 95 } | 95 } |
| 96 | 96 |
| 97 int GbmPixmap::GetDmaBufPitch() { | 97 int GbmPixmap::GetDmaBufPitch() { |
| 98 return gbm_bo_get_stride(buffer_->bo()); | 98 return gbm_bo_get_stride(buffer_->bo()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace ui | 101 } // namespace ui |
| OLD | NEW |