| Index: ui/ozone/platform/dri/gbm_buffer.cc
|
| diff --git a/ui/ozone/platform/dri/gbm_buffer.cc b/ui/ozone/platform/dri/gbm_buffer.cc
|
| index 53c0f25e3b93aa6783637ebb26254515c3bf2184..79e8b3b53968c7c9740726082b51883c30080e8e 100644
|
| --- a/ui/ozone/platform/dri/gbm_buffer.cc
|
| +++ b/ui/ozone/platform/dri/gbm_buffer.cc
|
| @@ -7,16 +7,10 @@
|
| #include <gbm.h>
|
|
|
| #include "base/logging.h"
|
| -#include "ui/ozone/platform/dri/dri_wrapper.h"
|
| -#include "ui/ozone/platform/dri/hardware_display_controller.h"
|
|
|
| namespace ui {
|
| +
|
| namespace {
|
| -// Pixel configuration for the current buffer format.
|
| -// TODO(dnicoara) These will need to change once we query the hardware for
|
| -// supported configurations.
|
| -const uint8_t kColorDepth = 24;
|
| -const uint8_t kPixelDepth = 32;
|
|
|
| int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
|
| switch (fmt) {
|
| @@ -32,87 +26,55 @@ int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
|
| }
|
| return 0;
|
| }
|
| -}
|
|
|
| -GbmBuffer::GbmBuffer(gbm_device* device, DriWrapper* dri, const gfx::Size& size)
|
| - : gbm_device_(device),
|
| - bo_(NULL),
|
| - handle_(0),
|
| - framebuffer_(0),
|
| - dri_(dri),
|
| - size_(size) {
|
| +} // namespace
|
| +
|
| +GbmBuffer::GbmBuffer(DriWrapper* dri, gbm_bo* bo, bool scanout)
|
| + : GbmBufferBase(dri, bo, scanout) {
|
| }
|
|
|
| GbmBuffer::~GbmBuffer() {
|
| - if (framebuffer_)
|
| - dri_->RemoveFramebuffer(framebuffer_);
|
| - if (bo_)
|
| - gbm_bo_destroy(bo_);
|
| + if (bo())
|
| + gbm_bo_destroy(bo());
|
| }
|
|
|
| -bool GbmBuffer::InitializeBuffer(SurfaceFactoryOzone::BufferFormat format,
|
| - bool scanout) {
|
| +// static
|
| +scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
|
| + DriWrapper* dri,
|
| + gbm_device* device,
|
| + SurfaceFactoryOzone::BufferFormat format,
|
| + const gfx::Size& size,
|
| + bool scanout) {
|
| unsigned flags = GBM_BO_USE_RENDERING;
|
| if (scanout)
|
| flags |= GBM_BO_USE_SCANOUT;
|
| - bo_ = gbm_bo_create(gbm_device_,
|
| - size_.width(),
|
| - size_.height(),
|
| - GetGbmFormatFromBufferFormat(format),
|
| - flags);
|
| - if (!bo_)
|
| - return false;
|
| -
|
| - gbm_bo_set_user_data(bo_, this, NULL);
|
| - handle_ = gbm_bo_get_handle(bo_).u32;
|
| -
|
| - if (scanout &&
|
| - !dri_->AddFramebuffer(size_.width(),
|
| - size_.height(),
|
| - kColorDepth,
|
| - kPixelDepth,
|
| - gbm_bo_get_stride(bo_),
|
| - handle_,
|
| - &framebuffer_)) {
|
| - return false;
|
| - }
|
| - return true;
|
| -}
|
| -
|
| -bool GbmBuffer::Initialize() {
|
| - return bo_ != NULL;
|
| -}
|
| -
|
| -uint32_t GbmBuffer::GetFramebufferId() const {
|
| - return framebuffer_;
|
| -}
|
| -
|
| -uint32_t GbmBuffer::GetHandle() const {
|
| - return handle_;
|
| -}
|
| -
|
| -gfx::Size GbmBuffer::Size() const {
|
| - return size_;
|
| -}
|
| -
|
| -void GbmBuffer::PreSwapBuffers() {
|
| -}
|
| -
|
| -void GbmBuffer::SwapBuffers() {
|
| + gbm_bo* bo = gbm_bo_create(device,
|
| + size.width(),
|
| + size.height(),
|
| + GetGbmFormatFromBufferFormat(format),
|
| + flags);
|
| + if (!bo)
|
| + return NULL;
|
| +
|
| + scoped_refptr<GbmBuffer> buffer(new GbmBuffer(dri, bo, scanout));
|
| + if (scanout && !buffer->GetFramebufferId())
|
| + return NULL;
|
| +
|
| + return buffer;
|
| }
|
|
|
| -GbmPixmap::GbmPixmap(gbm_device* device, DriWrapper* dri, const gfx::Size& size)
|
| - : buffer_(device, dri, size) {
|
| +GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) : buffer_(buffer) {
|
| }
|
|
|
| GbmPixmap::~GbmPixmap() {
|
| }
|
|
|
| void* GbmPixmap::GetEGLClientBuffer() {
|
| - return buffer_.bo();
|
| + return buffer_->bo();
|
| }
|
|
|
| int GbmPixmap::GetDmaBufFd() {
|
| + NOTIMPLEMENTED();
|
| return -1;
|
| }
|
|
|
|
|