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_base.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer_base.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/ozone/platform/drm/common/drm_util.h" | 10 #include "ui/ozone/platform/drm/common/drm_util.h" |
11 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 11 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 GbmBufferBase::GbmBufferBase(const scoped_refptr<GbmDevice>& drm, | 15 GbmBufferBase::GbmBufferBase(const scoped_refptr<GbmDevice>& drm, |
16 gbm_bo* bo, | 16 gbm_bo* bo, |
17 gfx::BufferFormat format, | 17 uint32_t format, |
18 gfx::BufferUsage usage) | 18 uint32_t flags) |
19 : drm_(drm), bo_(bo) { | 19 : drm_(drm), bo_(bo) { |
20 if (usage == gfx::BufferUsage::SCANOUT) { | 20 if (flags & GBM_BO_USE_SCANOUT) { |
21 framebuffer_pixel_format_ = GetFourCCFormatForFramebuffer(format); | 21 DCHECK(bo_); |
| 22 framebuffer_pixel_format_ = format; |
22 | 23 |
| 24 // TODO(dcastagna): Add multi-planar support. |
23 uint32_t handles[4] = {0}; | 25 uint32_t handles[4] = {0}; |
24 handles[0] = gbm_bo_get_handle(bo).u32; | 26 handles[0] = gbm_bo_get_handle(bo).u32; |
25 uint32_t strides[4] = {0}; | 27 uint32_t strides[4] = {0}; |
26 strides[0] = gbm_bo_get_stride(bo); | 28 strides[0] = gbm_bo_get_stride(bo); |
27 uint32_t offsets[4] = {0}; | 29 uint32_t offsets[4] = {0}; |
28 | 30 |
29 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), | 31 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), |
30 framebuffer_pixel_format_, handles, strides, | 32 framebuffer_pixel_format_, handles, strides, |
31 offsets, &framebuffer_, 0)) { | 33 offsets, &framebuffer_, 0)) { |
32 PLOG(ERROR) << "Failed to register buffer"; | 34 PLOG(ERROR) << "Failed to register buffer"; |
(...skipping 26 matching lines...) Expand all Loading... |
59 | 61 |
60 const DrmDevice* GbmBufferBase::GetDrmDevice() const { | 62 const DrmDevice* GbmBufferBase::GetDrmDevice() const { |
61 return drm_.get(); | 63 return drm_.get(); |
62 } | 64 } |
63 | 65 |
64 bool GbmBufferBase::RequiresGlFinish() const { | 66 bool GbmBufferBase::RequiresGlFinish() const { |
65 return !drm_->is_primary_device(); | 67 return !drm_->is_primary_device(); |
66 } | 68 } |
67 | 69 |
68 } // namespace ui | 70 } // namespace ui |
OLD | NEW |