| 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, |
| 20 uint32_t addfb_flags) |
| 19 : drm_(drm), bo_(bo) { | 21 : drm_(drm), bo_(bo) { |
| 20 if (flags & GBM_BO_USE_SCANOUT) { | 22 if (flags & GBM_BO_USE_SCANOUT) { |
| 21 DCHECK(bo_); | 23 DCHECK(bo_); |
| 22 // The framebuffer format might be different than the format: | 24 // The framebuffer format might be different than the format: |
| 23 // drm supports 24 bit color depth and formats with alpha will | 25 // drm supports 24 bit color depth and formats with alpha will |
| 24 // be converted to one without it. | 26 // be converted to one without it. |
| 25 framebuffer_pixel_format_ = | 27 framebuffer_pixel_format_ = |
| 26 GetFourCCFormatForFramebuffer(GetBufferFormatFromFourCCFormat(format)); | 28 GetFourCCFormatForFramebuffer(GetBufferFormatFromFourCCFormat(format)); |
| 27 | 29 |
| 28 // TODO(dcastagna): Add multi-planar support. | 30 // TODO(dcastagna): Add multi-planar support. |
| 29 uint32_t handles[4] = {0}; | 31 uint32_t handles[4] = {0}; |
| 30 handles[0] = gbm_bo_get_handle(bo).u32; | 32 handles[0] = gbm_bo_get_handle(bo).u32; |
| 31 uint32_t strides[4] = {0}; | 33 uint32_t strides[4] = {0}; |
| 32 strides[0] = gbm_bo_get_stride(bo); | 34 strides[0] = gbm_bo_get_stride(bo); |
| 33 uint32_t offsets[4] = {0}; | 35 uint32_t offsets[4] = {0}; |
| 36 uint64_t modifiers[4] = {0}; |
| 37 modifiers[0] = modifier; |
| 34 | 38 |
| 39 // AddFramebuffer2 only considers the modifiers if addfb_flags has |
| 40 // DRM_MODE_FB_MODIFIERS set. We only set that when we've created |
| 41 // a bo with modifiers, otherwise, we rely on the "no modifiers" |
| 42 // behavior doing the right thing. |
| 35 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), | 43 if (!drm_->AddFramebuffer2(gbm_bo_get_width(bo), gbm_bo_get_height(bo), |
| 36 framebuffer_pixel_format_, handles, strides, | 44 framebuffer_pixel_format_, handles, strides, |
| 37 offsets, &framebuffer_, 0)) { | 45 offsets, modifiers, &framebuffer_, |
| 46 addfb_flags)) { |
| 38 PLOG(ERROR) << "Failed to register buffer"; | 47 PLOG(ERROR) << "Failed to register buffer"; |
| 39 return; | 48 return; |
| 40 } | 49 } |
| 41 } | 50 } |
| 42 } | 51 } |
| 43 | 52 |
| 44 GbmBufferBase::~GbmBufferBase() { | 53 GbmBufferBase::~GbmBufferBase() { |
| 45 if (framebuffer_) | 54 if (framebuffer_) |
| 46 drm_->RemoveFramebuffer(framebuffer_); | 55 drm_->RemoveFramebuffer(framebuffer_); |
| 47 } | 56 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 65 | 74 |
| 66 const DrmDevice* GbmBufferBase::GetDrmDevice() const { | 75 const DrmDevice* GbmBufferBase::GetDrmDevice() const { |
| 67 return drm_.get(); | 76 return drm_.get(); |
| 68 } | 77 } |
| 69 | 78 |
| 70 bool GbmBufferBase::RequiresGlFinish() const { | 79 bool GbmBufferBase::RequiresGlFinish() const { |
| 71 return !drm_->is_primary_device(); | 80 return !drm_->is_primary_device(); |
| 72 } | 81 } |
| 73 | 82 |
| 74 } // namespace ui | 83 } // namespace ui |
| OLD | NEW |