Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "ui/gfx/gpu_memory_buffer.h" | |
|
reveman
2015/05/14 13:22:03
This code should not know about GpuMemoryBuffers.
| |
| 14 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 15 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { | 21 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { |
| 21 switch (fmt) { | 22 switch (fmt) { |
| 22 case SurfaceFactoryOzone::BGRA_8888: | 23 case SurfaceFactoryOzone::BGRA_8888: |
| 23 return GBM_BO_FORMAT_ARGB8888; | 24 return GBM_BO_FORMAT_ARGB8888; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 44 | 45 |
| 45 // static | 46 // static |
| 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( | 47 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( |
| 47 const scoped_refptr<GbmDevice>& gbm, | 48 const scoped_refptr<GbmDevice>& gbm, |
| 48 SurfaceFactoryOzone::BufferFormat format, | 49 SurfaceFactoryOzone::BufferFormat format, |
| 49 const gfx::Size& size, | 50 const gfx::Size& size, |
| 50 bool scanout) { | 51 bool scanout) { |
| 51 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", | 52 TRACE_EVENT2("drm", "GbmBuffer::CreateBuffer", "device", |
| 52 gbm->device_path().value(), "size", size.ToString()); | 53 gbm->device_path().value(), "size", size.ToString()); |
| 53 unsigned flags = GBM_BO_USE_RENDERING; | 54 unsigned flags = GBM_BO_USE_RENDERING; |
| 54 if (scanout) | 55 // SCANOUT allocates continuous memory, so better for performance even if |
| 55 flags |= GBM_BO_USE_SCANOUT; | 56 // |scanout| is false. |
| 57 flags |= GBM_BO_USE_SCANOUT; | |
| 56 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), | 58 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), |
| 57 GetGbmFormatFromBufferFormat(format), flags); | 59 GetGbmFormatFromBufferFormat(format), flags); |
| 58 if (!bo) | 60 if (!bo) |
| 59 return NULL; | 61 return NULL; |
| 60 | 62 |
| 61 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); | 63 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); |
| 62 if (scanout && !buffer->GetFramebufferId()) | 64 if (scanout && !buffer->GetFramebufferId()) |
| 63 return NULL; | 65 return NULL; |
| 64 | 66 |
| 65 return buffer; | 67 return buffer; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 91 } | 93 } |
| 92 | 94 |
| 93 int GbmPixmap::GetDmaBufFd() { | 95 int GbmPixmap::GetDmaBufFd() { |
| 94 return dma_buf_; | 96 return dma_buf_; |
| 95 } | 97 } |
| 96 | 98 |
| 97 int GbmPixmap::GetDmaBufPitch() { | 99 int GbmPixmap::GetDmaBufPitch() { |
| 98 return gbm_bo_get_stride(buffer_->bo()); | 100 return gbm_bo_get_stride(buffer_->bo()); |
| 99 } | 101 } |
| 100 | 102 |
| 103 NativePixmap::BufferUsage GbmPixmap::GetBufferUsage() const { | |
| 104 return buffer_->GetFramebufferId() ? SCANOUT : MAP; | |
| 105 } | |
| 106 | |
| 101 } // namespace ui | 107 } // namespace ui |
| OLD | NEW |