| 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 uint32_t format, | 17 uint32_t format, |
| 18 uint32_t flags, | 18 uint32_t flags, |
| 19 uint64_t modifier, | 19 uint64_t modifier, |
| 20 uint32_t addfb_flags) | 20 uint32_t addfb_flags) |
| 21 : drm_(drm), bo_(bo) { | 21 : drm_(drm), bo_(bo) { |
| 22 if (flags & GBM_BO_USE_SCANOUT) { | 22 if (flags & GBM_BO_USE_SCANOUT) { |
| 23 DCHECK(bo_); | 23 DCHECK(bo_); |
| 24 framebuffer_pixel_format_ = format; | 24 framebuffer_pixel_format_ = format; |
| 25 opaque_framebuffer_pixel_format_ = GetFourCCFormatForOpaqueFramebuffer( | 25 opaque_framebuffer_pixel_format_ = GetFourCCFormatForOpaqueFramebuffer( |
| 26 GetBufferFormatFromFourCCFormat(format)); | 26 GetBufferFormatFromFourCCFormat(format)); |
| 27 | 27 |
| 28 // TODO(dcastagna): Add multi-planar support. | |
| 29 uint32_t handles[4] = {0}; | 28 uint32_t handles[4] = {0}; |
| 30 handles[0] = gbm_bo_get_handle(bo).u32; | |
| 31 uint32_t strides[4] = {0}; | 29 uint32_t strides[4] = {0}; |
| 32 strides[0] = gbm_bo_get_stride(bo); | |
| 33 uint32_t offsets[4] = {0}; | 30 uint32_t offsets[4] = {0}; |
| 34 uint64_t modifiers[4] = {0}; | 31 uint64_t modifiers[4] = {0}; |
| 35 modifiers[0] = modifier; | 32 |
| 33 for (size_t i = 0; i < gbm_bo_get_num_planes(bo); ++i) { |
| 34 handles[i] = gbm_bo_get_plane_handle(bo, i).u32; |
| 35 strides[i] = gbm_bo_get_plane_stride(bo, i); |
| 36 offsets[i] = gbm_bo_get_plane_offset(bo, i); |
| 37 modifiers[i] = modifier; |
| 38 } |
| 36 | 39 |
| 37 // AddFramebuffer2 only considers the modifiers if addfb_flags has | 40 // AddFramebuffer2 only considers the modifiers if addfb_flags has |
| 38 // DRM_MODE_FB_MODIFIERS set. We only set that when we've created | 41 // DRM_MODE_FB_MODIFIERS set. We only set that when we've created |
| 39 // a bo with modifiers, otherwise, we rely on the "no modifiers" | 42 // a bo with modifiers, otherwise, we rely on the "no modifiers" |
| 40 // behavior doing the right thing. | 43 // behavior doing the right thing. |
| 41 drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), | 44 drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), |
| 42 framebuffer_pixel_format_, handles, strides, offsets, | 45 framebuffer_pixel_format_, handles, strides, offsets, |
| 43 modifiers, &framebuffer_, addfb_flags); | 46 modifiers, &framebuffer_, addfb_flags); |
| 44 if (opaque_framebuffer_pixel_format_ != framebuffer_pixel_format_) { | 47 if (opaque_framebuffer_pixel_format_ != framebuffer_pixel_format_) { |
| 45 drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), | 48 drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 86 |
| 84 const DrmDevice* GbmBufferBase::GetDrmDevice() const { | 87 const DrmDevice* GbmBufferBase::GetDrmDevice() const { |
| 85 return drm_.get(); | 88 return drm_.get(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 bool GbmBufferBase::RequiresGlFinish() const { | 91 bool GbmBufferBase::RequiresGlFinish() const { |
| 89 return !drm_->is_primary_device(); | 92 return !drm_->is_primary_device(); |
| 90 } | 93 } |
| 91 | 94 |
| 92 } // namespace ui | 95 } // namespace ui |
| OLD | NEW |