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