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 "ui/ozone/platform/dri/gbm_wrapper.h" | 14 #include "ui/ozone/platform/dri/gbm_wrapper.h" |
14 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { | 20 int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) { |
20 switch (fmt) { | 21 switch (fmt) { |
21 case SurfaceFactoryOzone::RGBA_8888: | 22 case SurfaceFactoryOzone::RGBA_8888: |
22 return GBM_BO_FORMAT_ARGB8888; | 23 return GBM_BO_FORMAT_ARGB8888; |
(...skipping 17 matching lines...) Expand all Loading... |
40 if (bo()) | 41 if (bo()) |
41 gbm_bo_destroy(bo()); | 42 gbm_bo_destroy(bo()); |
42 } | 43 } |
43 | 44 |
44 // static | 45 // static |
45 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( | 46 scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( |
46 const scoped_refptr<GbmWrapper>& gbm, | 47 const scoped_refptr<GbmWrapper>& gbm, |
47 SurfaceFactoryOzone::BufferFormat format, | 48 SurfaceFactoryOzone::BufferFormat format, |
48 const gfx::Size& size, | 49 const gfx::Size& size, |
49 bool scanout) { | 50 bool scanout) { |
| 51 TRACE_EVENT2("dri", "GbmBuffer::CreateBuffer", "device", |
| 52 gbm->device_path().value(), "size", size.ToString()); |
50 unsigned flags = GBM_BO_USE_RENDERING; | 53 unsigned flags = GBM_BO_USE_RENDERING; |
51 if (scanout) | 54 if (scanout) |
52 flags |= GBM_BO_USE_SCANOUT; | 55 flags |= GBM_BO_USE_SCANOUT; |
53 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(), |
54 GetGbmFormatFromBufferFormat(format), flags); | 57 GetGbmFormatFromBufferFormat(format), flags); |
55 if (!bo) | 58 if (!bo) |
56 return NULL; | 59 return NULL; |
57 | 60 |
58 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); | 61 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, scanout)); |
59 if (scanout && !buffer->GetFramebufferId()) | 62 if (scanout && !buffer->GetFramebufferId()) |
(...skipping 29 matching lines...) Expand all Loading... |
89 | 92 |
90 int GbmPixmap::GetDmaBufFd() { | 93 int GbmPixmap::GetDmaBufFd() { |
91 return dma_buf_; | 94 return dma_buf_; |
92 } | 95 } |
93 | 96 |
94 int GbmPixmap::GetDmaBufPitch() { | 97 int GbmPixmap::GetDmaBufPitch() { |
95 return gbm_bo_get_stride(buffer_->bo()); | 98 return gbm_bo_get_stride(buffer_->bo()); |
96 } | 99 } |
97 | 100 |
98 } // namespace ui | 101 } // namespace ui |
OLD | NEW |