Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / ui / ozone / platform / dri / gbm_buffer_base.cc
blobf5c057af381d6d9fc3f5a5ddf7ed11c2af068295
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.
5 #include "ui/ozone/platform/dri/gbm_buffer_base.h"
7 #include <gbm.h>
9 #include "base/logging.h"
10 #include "ui/ozone/platform/dri/dri_wrapper.h"
12 namespace ui {
14 namespace {
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;
22 } // namespace
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";
36 GbmBufferBase::~GbmBufferBase() {
37 if (framebuffer_)
38 dri_->RemoveFramebuffer(framebuffer_);
41 uint32_t GbmBufferBase::GetFramebufferId() const {
42 return framebuffer_;
45 uint32_t GbmBufferBase::GetHandle() const {
46 return gbm_bo_get_handle(bo_).u32;
49 gfx::Size GbmBufferBase::GetSize() const {
50 return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_));
53 } // namespace ui