| 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/dri/gbm_buffer.h" | 5 #include "ui/ozone/platform/dri/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/ozone/platform/dri/gbm_wrapper.h" | 14 #include "ui/ozone/platform/dri/gbm_device.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { | 20 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { |
| 21 switch (fmt) { | 21 switch (fmt) { |
| 22 case SurfaceFactoryOzone::RGBA_8888: | 22 case SurfaceFactoryOzone::RGBA_8888: |
| 23 return GBM_BO_FORMAT_ARGB8888; | 23 return GBM_BO_FORMAT_ARGB8888; |
| 24 case SurfaceFactoryOzone::RGBX_8888: | 24 case SurfaceFactoryOzone::RGBX_8888: |
| 25 return GBM_BO_FORMAT_XRGB8888; | 25 return GBM_BO_FORMAT_XRGB8888; |
| 26 default: | 26 default: |
| 27 NOTREACHED(); | 27 NOTREACHED(); |
| 28 return 0; | 28 return 0; |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 GbmBuffer::GbmBuffer(const scoped_refptr<GbmWrapper>& gbm, | 34 GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, |
| 35 gbm_bo* bo, | 35 gbm_bo* bo, |
| 36 bool scanout) | 36 bool scanout) |
| 37 : GbmBufferBase(gbm, bo, scanout) { | 37 : GbmBufferBase(gbm, bo, scanout) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 GbmBuffer::~GbmBuffer() { | 40 GbmBuffer::~GbmBuffer() { |
| 41 if (bo()) | 41 if (bo()) |
| 42 gbm_bo_destroy(bo()); | 42 gbm_bo_destroy(bo()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( | 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( |
| 47 const scoped_refptr<GbmWrapper>& gbm, | 47 const scoped_refptr<GbmDevice>& gbm, |
| 48 SurfaceFactoryOzone::BufferFormat format, | 48 SurfaceFactoryOzone::BufferFormat format, |
| 49 const gfx::Size& size, | 49 const gfx::Size& size, |
| 50 bool scanout) { | 50 bool scanout) { |
| 51 TRACE_EVENT2("dri", "GbmBuffer::CreateBuffer", "device", | 51 TRACE_EVENT2("dri", "GbmBuffer::CreateBuffer", "device", |
| 52 gbm->device_path().value(), "size", size.ToString()); | 52 gbm->device_path().value(), "size", size.ToString()); |
| 53 unsigned flags = GBM_BO_USE_RENDERING; | 53 unsigned flags = GBM_BO_USE_RENDERING; |
| 54 if (scanout) | 54 if (scanout) |
| 55 flags |= GBM_BO_USE_SCANOUT; | 55 flags |= GBM_BO_USE_SCANOUT; |
| 56 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), | 56 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), |
| 57 GetGbmFormatFromBufferFormat(format), flags); | 57 GetGbmFormatFromBufferFormat(format), flags); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |