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

Unified Diff: ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.cc

Issue 1582613004: Ozone support for multiprocess graphics. (Closed) Base URL: https://github.com/domokit/mojo.git@submit-1
Patch Set: rebase Created 4 years, 10 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/gpu/drm_dmabuf_pixmap.h ('k') | ui/ozone/platform/drm/gpu/gbm_surface_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.cc
diff --git a/ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.cc b/ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.cc
new file mode 100644
index 0000000000000000000000000000000000000000..338e75a2adab472c0a2419afba2289495c84d7e9
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.cc
@@ -0,0 +1,110 @@
+// 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/gpu/drm_dmabuf_pixmap.h"
+
+#include <i915_drm.h>
+#include "base/logging.h"
+#include "ui/ozone/platform/drm/gpu/drm_device.h"
+#include "ui/ozone/platform/drm/gpu/drm_window.h"
+
+namespace ui {
+
+namespace {
+void EmptyPageFlipCallback(gfx::SwapResult result) {}
+} // namespace
+
+DrmDmabufPixmap::DrmDmabufPixmap(const scoped_refptr<DrmDevice>& drm)
+ : drm_(drm) {}
+
+DrmDmabufPixmap::~DrmDmabufPixmap() {
+ // TODO: finish
+ if (framebuffer_ && !drm_->RemoveFramebuffer(framebuffer_))
+ PLOG(ERROR) << "SharedBuffer: RemoveFramebuffer: fb " << framebuffer_;
+}
+
+bool DrmDmabufPixmap::Initialize(base::ScopedFD dma_buf,
+ int width,
+ int height,
+ uint32_t pitch) {
+ int fd = dma_buf.get();
+ if (!drm_->BufferFdToHandle(fd, &handle_)) {
+ PLOG(ERROR) << "SharedBuffer: Initialize: couldn't get handle from fd "
+ << fd;
+ return false;
+ }
+
+ // For scanout
+ if (!drm_->BufferHandleSetTiling(handle_, pitch, I915_TILING_X))
+ return false;
+
+ dma_buf_ = dma_buf.Pass();
+ dma_buf_pitch_ = pitch;
+
+ width_ = width;
+ height_ = height;
+
+ if (!drm_->AddFramebuffer(width_, height_, 24, 32, dma_buf_pitch_, handle_,
+ &framebuffer_)) {
+ PLOG(ERROR) << "SharedBuffer: AddFramebuffer: handle " << handle_;
+ return false;
+ }
+
+ return true;
+}
+
+uint32_t DrmDmabufPixmap::GetHandle() const {
+ return handle_;
+}
+
+gfx::Size DrmDmabufPixmap::GetSize() const {
+ return gfx::Size(width_, height_);
+}
+
+uint32_t DrmDmabufPixmap::GetFramebufferId() const {
+ return framebuffer_;
+}
+
+int DrmDmabufPixmap::GetDmaBufFd() const {
+ return dma_buf_.get();
+}
+
+int DrmDmabufPixmap::GetDmaBufPitch() const {
+ return dma_buf_pitch_;
+}
+
+DrmDmabufPixmapWrapper::DrmDmabufPixmapWrapper(
+ ScreenManager* screen_manager,
+ const scoped_refptr<DrmDmabufPixmap>& pixmap)
+ : pixmap_(pixmap), screen_manager_(screen_manager) {}
+
+DrmDmabufPixmapWrapper::~DrmDmabufPixmapWrapper() {}
+
+bool DrmDmabufPixmapWrapper::ScheduleOverlayPlane(
+ gfx::AcceleratedWidget widget,
+ int plane_z_order,
+ gfx::OverlayTransform plane_transform,
+ const gfx::Rect& display_bounds,
+ const gfx::RectF& crop_rect) {
+ screen_manager_->GetWindow(widget)->QueueOverlayPlane(OverlayPlane(pixmap_));
+ // TODO(cstout): for the multi-overlay case, SchedulePageFlip should be called
+ // once after all overlay planes are scheduled. Tracking issue mojo #540.
+ screen_manager_->GetWindow(widget)->SchedulePageFlip(
+ true /* is_sync */, base::Bind(&EmptyPageFlipCallback));
+ return true;
+}
+
+int DrmDmabufPixmapWrapper::GetDmaBufFd() {
+ return pixmap_->GetDmaBufFd();
+}
+
+int DrmDmabufPixmapWrapper::GetDmaBufPitch() {
+ return pixmap_->GetDmaBufPitch();
+}
+
+void* DrmDmabufPixmapWrapper::GetEGLClientBuffer() {
+ return nullptr;
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.h ('k') | ui/ozone/platform/drm/gpu/gbm_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698