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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // static | 45 // static |
46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( | 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( |
47 const scoped_refptr<GbmDevice>& 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("drm", "GbmBuffer::CreateBuffer", "device", | 51 TRACE_EVENT2("drm", "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 // SCANOUT allocates continuous memory, so better for performance even if |
55 flags |= GBM_BO_USE_SCANOUT; | 55 // |scanout| is false. |
| 56 flags |= GBM_BO_USE_SCANOUT; |
56 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), | 57 gbm_bo* bo = gbm_bo_create(gbm->device(), size.width(), size.height(), |
57 GetGbmFormatFromBufferFormat(format), flags); | 58 GetGbmFormatFromBufferFormat(format), flags); |
58 if (!bo) | 59 if (!bo) |
59 return NULL; | 60 return NULL; |
60 | 61 |
61 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); | 62 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); |
62 if (scanout && !buffer->GetFramebufferId()) | 63 if (scanout && !buffer->GetFramebufferId()) |
63 return NULL; | 64 return NULL; |
64 | 65 |
65 return buffer; | 66 return buffer; |
(...skipping 24 matching lines...) Expand all Loading... |
90 } | 91 } |
91 | 92 |
92 int GbmPixmap::GetDmaBufFd() { | 93 int GbmPixmap::GetDmaBufFd() { |
93 return dma_buf_; | 94 return dma_buf_; |
94 } | 95 } |
95 | 96 |
96 int GbmPixmap::GetDmaBufPitch() { | 97 int GbmPixmap::GetDmaBufPitch() { |
97 return gbm_bo_get_stride(buffer_->bo()); | 98 return gbm_bo_get_stride(buffer_->bo()); |
98 } | 99 } |
99 | 100 |
| 101 NativePixmap::BufferUsage GbmPixmap::GetBufferUsage() const { |
| 102 return buffer_->GetFramebufferId() ? SCANOUT : MAP; |
| 103 } |
| 104 |
| 105 void* GbmPixmap::Map() { |
| 106 NOTREACHED(); |
| 107 return nullptr; |
| 108 } |
| 109 |
| 110 void GbmPixmap::Unmap() { |
| 111 NOTREACHED(); |
| 112 } |
| 113 |
100 } // namespace ui | 114 } // namespace ui |
OLD | NEW |