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

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: ToT rebase Created 4 years, 11 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..1586a17a011e5e72828dfdcc38d2b189c7dba008
--- /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), data_(nullptr) {
spang 2016/03/21 23:24:20 You don't need to initialize data_ here and in the
vignatti (out of this project) 2016/03/22 20:24:29 Done.
+ TRACE_EVENT0("nativepixmap", "ClientNativePixmapDmaBuf");
spang 2016/03/21 23:24:20 Please use the "drm" category.
vignatti (out of this project) 2016/03/22 20:24:29 Done.
+ size_t map_size = stride_ * size_.height();
+ data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
+ dmabuf_fd, 0);
+ DCHECK_NE(data_, MAP_FAILED);
+}
+
+ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
+ TRACE_EVENT0("nativepixmap", "~ClientNativePixmapDmaBuf");
spang 2016/03/21 23:24:20 Also here
vignatti (out of this project) 2016/03/22 20:24:29 Done.
+ size_t size = stride_ * size_.height();
+ int ret = munmap(data_, size);
+ DCHECK(!ret) << "fail to munmap a dmabuf.";
spang 2016/03/21 23:24:20 DPCHECK(!ret); Don't really need a message for DC
vignatti (out of this project) 2016/03/22 20:24:29 Done.
+}
+
+void* ClientNativePixmapDmaBuf::Map() {
+ return data_;
+}
+
+void ClientNativePixmapDmaBuf::Unmap() {}
+
+void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
+ *stride = stride_;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698