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

Unified Diff: ui/ozone/platform/drm/common/client_native_pixmap_vgem.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
« no previous file with comments | « ui/ozone/platform/drm/common/client_native_pixmap_vgem.h ('k') | ui/ozone/platform/drm/gbm.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/common/client_native_pixmap_vgem.cc
diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_vgem.cc b/ui/ozone/platform/drm/common/client_native_pixmap_vgem.cc
deleted file mode 100644
index 25632ecb0de1f877e665d5cb6fc41640106a0394..0000000000000000000000000000000000000000
--- a/ui/ozone/platform/drm/common/client_native_pixmap_vgem.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2015 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_vgem.h"
-
-#include <fcntl.h>
-#include <libdrm/vgem_drm.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> ClientNativePixmapVgem::ImportFromDmabuf(
- int vgem_fd,
- int dmabuf_fd,
- const gfx::Size& size,
- int stride) {
- DCHECK_GE(vgem_fd, 0);
- DCHECK_GE(dmabuf_fd, 0);
- uint32_t vgem_bo_handle = 0;
- int ret = drmPrimeFDToHandle(vgem_fd, dmabuf_fd, &vgem_bo_handle);
- DCHECK(!ret) << "drmPrimeFDToHandle failed.";
- return make_scoped_ptr(
- new ClientNativePixmapVgem(vgem_fd, vgem_bo_handle, size, stride));
-}
-
-ClientNativePixmapVgem::ClientNativePixmapVgem(int vgem_fd,
- uint32_t vgem_bo_handle,
- const gfx::Size& size,
- int stride)
- : vgem_fd_(vgem_fd),
- vgem_bo_handle_(vgem_bo_handle),
- size_(size),
- stride_(stride),
- data_(nullptr) {
- DCHECK(vgem_bo_handle_);
- struct drm_mode_map_dumb mmap_arg = {0};
- mmap_arg.handle = vgem_bo_handle_;
- size_t map_size = stride_ * size_.height();
- int ret = drmIoctl(vgem_fd_, DRM_IOCTL_VGEM_MODE_MAP_DUMB, &mmap_arg);
- if (ret) {
- PLOG(ERROR) << "fail to map a vgem buffer.";
- base::TerminateBecauseOutOfMemory(map_size);
- }
- DCHECK(mmap_arg.offset);
-
- data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
- vgem_fd_, mmap_arg.offset);
- DCHECK_NE(data_, MAP_FAILED);
-}
-
-ClientNativePixmapVgem::~ClientNativePixmapVgem() {
- size_t size = stride_ * size_.height();
- int ret = munmap(data_, size);
- DCHECK(!ret) << "fail to munmap a vgem buffer.";
-
- struct drm_gem_close close = {0};
- close.handle = vgem_bo_handle_;
- ret = drmIoctl(vgem_fd_, DRM_IOCTL_GEM_CLOSE, &close);
- DCHECK(!ret) << "fail to free a vgem buffer.";
-}
-
-void* ClientNativePixmapVgem::Map() {
- return data_;
-}
-
-void ClientNativePixmapVgem::Unmap() {}
-
-void ClientNativePixmapVgem::GetStride(int* stride) const {
- *stride = stride_;
-}
-
-} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/common/client_native_pixmap_vgem.h ('k') | ui/ozone/platform/drm/gbm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698