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

Unified Diff: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc

Issue 1262043002: Implement DRM Native Pixmap using prime buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-master
Patch Set: remove drm header Created 4 years, 9 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
Index: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
new file mode 100644
index 0000000000000000000000000000000000000000..26d123a2a452209637a928aa78f7b07d1d1dd3a9
--- /dev/null
+++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <sys/mman.h>
+#include <xf86drm.h>
+
+#include "base/process/memory.h"
+#include "base/trace_event/trace_event.h"
+
+namespace ui {
+
+// static
+scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
+ int dmabuf_fd,
+ const gfx::Size& size,
+ int stride) {
+ DCHECK_GE(dmabuf_fd, 0);
+ return make_scoped_ptr(new ClientNativePixmapDmaBuf(dmabuf_fd, size, stride));
+}
+
+ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
+ const gfx::Size& size,
+ int stride)
+ : size_(size), stride_(stride) {
+ TRACE_EVENT0("drm", "ClientNativePixmapDmaBuf");
+ size_t map_size = stride_ * size_.height();
+ data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
+ dmabuf_fd, 0);
+ CHECK_NE(data_, MAP_FAILED);
+}
+
+ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
+ TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf");
+ size_t size = stride_ * size_.height();
+ int ret = munmap(data_, size);
+ DCHECK(!ret);
+}
+
+void* ClientNativePixmapDmaBuf::Map() {
+ return data_;
+}
+
+void ClientNativePixmapDmaBuf::Unmap() {}
+
+void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
+ *stride = stride_;
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h ('k') | ui/ozone/platform/drm/common/client_native_pixmap_vgem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698