| 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_base.h" | 5 #include "ui/ozone/platform/dri/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/dri/dri_wrapper.h" | 10 #include "ui/ozone/platform/dri/drm_device.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Pixel configuration for the current buffer format. | 16 // Pixel configuration for the current buffer format. |
| 17 // TODO(dnicoara) These will need to change once we query the hardware for | 17 // TODO(dnicoara) These will need to change once we query the hardware for |
| 18 // supported configurations. | 18 // supported configurations. |
| 19 const uint8_t kColorDepth = 24; | 19 const uint8_t kColorDepth = 24; |
| 20 const uint8_t kPixelDepth = 32; | 20 const uint8_t kPixelDepth = 32; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 GbmBufferBase::GbmBufferBase(const scoped_refptr<DriWrapper>& dri, | 24 GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm, |
| 25 gbm_bo* bo, | 25 gbm_bo* bo, |
| 26 bool scanout) | 26 bool scanout) |
| 27 : dri_(dri), bo_(bo), framebuffer_(0) { | 27 : drm_(drm), bo_(bo), framebuffer_(0) { |
| 28 if (scanout && !dri_->AddFramebuffer(gbm_bo_get_width(bo), | 28 if (scanout && |
| 29 gbm_bo_get_height(bo), | 29 !drm_->AddFramebuffer(gbm_bo_get_width(bo), gbm_bo_get_height(bo), |
| 30 kColorDepth, | 30 kColorDepth, kPixelDepth, gbm_bo_get_stride(bo), |
| 31 kPixelDepth, | 31 gbm_bo_get_handle(bo).u32, &framebuffer_)) |
| 32 gbm_bo_get_stride(bo), | |
| 33 gbm_bo_get_handle(bo).u32, | |
| 34 &framebuffer_)) | |
| 35 LOG(ERROR) << "Failed to register buffer"; | 32 LOG(ERROR) << "Failed to register buffer"; |
| 36 } | 33 } |
| 37 | 34 |
| 38 GbmBufferBase::~GbmBufferBase() { | 35 GbmBufferBase::~GbmBufferBase() { |
| 39 if (framebuffer_) | 36 if (framebuffer_) |
| 40 dri_->RemoveFramebuffer(framebuffer_); | 37 drm_->RemoveFramebuffer(framebuffer_); |
| 41 } | 38 } |
| 42 | 39 |
| 43 uint32_t GbmBufferBase::GetFramebufferId() const { | 40 uint32_t GbmBufferBase::GetFramebufferId() const { |
| 44 return framebuffer_; | 41 return framebuffer_; |
| 45 } | 42 } |
| 46 | 43 |
| 47 uint32_t GbmBufferBase::GetHandle() const { | 44 uint32_t GbmBufferBase::GetHandle() const { |
| 48 return gbm_bo_get_handle(bo_).u32; | 45 return gbm_bo_get_handle(bo_).u32; |
| 49 } | 46 } |
| 50 | 47 |
| 51 gfx::Size GbmBufferBase::GetSize() const { | 48 gfx::Size GbmBufferBase::GetSize() const { |
| 52 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_)); | 49 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_)); |
| 53 } | 50 } |
| 54 | 51 |
| 55 } // namespace ui | 52 } // namespace ui |
| OLD | NEW |