Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: ui/ozone/platform/dri/gbm_buffer.cc

Issue 667293002: [Ozone-GBM] Use dma_buf with surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 030dc3b341b09047a2141ec250a09ee8254b0b00..8eaccbf0edb5bf0cc8e732ec0678281464ae4b5f 100644
--- a/ui/ozone/platform/dri/gbm_buffer.cc
+++ b/ui/ozone/platform/dri/gbm_buffer.cc
@@ -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
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698