Commit cbaf51be authored by dnicoara's avatar dnicoara Committed by Commit bot

[Ozone-GBM] Use dma_buf with surfaceless

BUG=none
NOTRY=true

Review URL: https://codereview.chromium.org/667293002

Cr-Commit-Position: refs/heads/master@{#300679}
parent 4fc8dad0
......@@ -4,9 +4,13 @@
#include "ui/ozone/platform/dri/gbm_buffer.h"
#include <drm.h>
#include <fcntl.h>
#include <gbm.h>
#include <xf86drm.h>
#include "base/logging.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
namespace ui {
......@@ -60,22 +64,37 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
return buffer;
}
GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) : buffer_(buffer) {
GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer)
: buffer_(buffer), dma_buf_(-1) {
}
bool GbmPixmap::Initialize(DriWrapper* dri) {
if (drmPrimeHandleToFD(dri->get_fd(),
buffer_->GetHandle(),
DRM_CLOEXEC,
&dma_buf_)) {
LOG(ERROR) << "Failed to export buffer to dma_buf";
return false;
}
return true;
}
GbmPixmap::~GbmPixmap() {
if (dma_buf_ > 0)
close(dma_buf_);
}
void* GbmPixmap::GetEGLClientBuffer() {
return buffer_->bo();
return NULL;
}
int GbmPixmap::GetDmaBufFd() {
return -1;
return dma_buf_;
}
int GbmPixmap::GetDmaBufPitch() {
return -1;
return gbm_bo_get_stride(buffer_->bo());
}
} // namespace ui
......@@ -38,6 +38,7 @@ class GbmBuffer : public GbmBufferBase {
class GbmPixmap : public NativePixmap {
public:
GbmPixmap(scoped_refptr<GbmBuffer> buffer);
bool Initialize(DriWrapper* dri);
// NativePixmap:
virtual void* GetEGLClientBuffer() override;
......@@ -50,6 +51,7 @@ class GbmPixmap : public NativePixmap {
virtual ~GbmPixmap();
scoped_refptr<GbmBuffer> buffer_;
int dma_buf_;
DISALLOW_COPY_AND_ASSIGN(GbmPixmap);
};
......
......@@ -176,7 +176,11 @@ scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
if (!buffer.get())
return NULL;
return scoped_refptr<GbmPixmap>(new GbmPixmap(buffer));
scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer));
if (!pixmap->Initialize(drm_))
return NULL;
return pixmap;
}
OverlayCandidatesOzone* GbmSurfaceFactory::GetOverlayCandidates(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment