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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/drm/gpu/drm_dmabuf_pixmap.h"
6
7 #include <i915_drm.h>
8 #include "base/logging.h"
9 #include "ui/ozone/platform/drm/gpu/drm_device.h"
10 #include "ui/ozone/platform/drm/gpu/drm_window.h"
11
12 namespace ui {
13
14 namespace {
15 void EmptyPageFlipCallback(gfx::SwapResult result) {}
16 } // namespace
17
18 DrmDmabufPixmap::DrmDmabufPixmap(const scoped_refptr<DrmDevice>& drm)
19 : drm_(drm) {}
20
21 DrmDmabufPixmap::~DrmDmabufPixmap() {
22 // TODO: finish
23 if (framebuffer_ && !drm_->RemoveFramebuffer(framebuffer_))
24 PLOG(ERROR) << "SharedBuffer: RemoveFramebuffer: fb " << framebuffer_;
25 }
26
27 bool DrmDmabufPixmap::Initialize(base::ScopedFD dma_buf,
28 int width,
29 int height,
30 uint32_t pitch) {
31 int fd = dma_buf.get();
32 if (!drm_->BufferFdToHandle(fd, &handle_)) {
33 PLOG(ERROR) << "SharedBuffer: Initialize: couldn't get handle from fd "
34 << fd;
35 return false;
36 }
37
38 // For scanout
39 if (!drm_->BufferHandleSetTiling(handle_, pitch, I915_TILING_X))
40 return false;
41
42 dma_buf_ = dma_buf.Pass();
43 dma_buf_pitch_ = pitch;
44
45 width_ = width;
46 height_ = height;
47
48 if (!drm_->AddFramebuffer(width_, height_, 24, 32, dma_buf_pitch_, handle_,
49 &framebuffer_)) {
50 PLOG(ERROR) << "SharedBuffer: AddFramebuffer: handle " << handle_;
51 return false;
52 }
53
54 return true;
55 }
56
57 uint32_t DrmDmabufPixmap::GetHandle() const {
58 return handle_;
59 }
60
61 gfx::Size DrmDmabufPixmap::GetSize() const {
62 return gfx::Size(width_, height_);
63 }
64
65 uint32_t DrmDmabufPixmap::GetFramebufferId() const {
66 return framebuffer_;
67 }
68
69 int DrmDmabufPixmap::GetDmaBufFd() const {
70 return dma_buf_.get();
71 }
72
73 int DrmDmabufPixmap::GetDmaBufPitch() const {
74 return dma_buf_pitch_;
75 }
76
77 DrmDmabufPixmapWrapper::DrmDmabufPixmapWrapper(
78 ScreenManager* screen_manager,
79 const scoped_refptr<DrmDmabufPixmap>& pixmap)
80 : pixmap_(pixmap), screen_manager_(screen_manager) {}
81
82 DrmDmabufPixmapWrapper::~DrmDmabufPixmapWrapper() {}
83
84 bool DrmDmabufPixmapWrapper::ScheduleOverlayPlane(
85 gfx::AcceleratedWidget widget,
86 int plane_z_order,
87 gfx::OverlayTransform plane_transform,
88 const gfx::Rect& display_bounds,
89 const gfx::RectF& crop_rect) {
90 screen_manager_->GetWindow(widget)->QueueOverlayPlane(OverlayPlane(pixmap_));
91 // TODO(cstout): for the multi-overlay case, SchedulePageFlip should be called
92 // once after all overlay planes are scheduled. Tracking issue mojo #540.
93 screen_manager_->GetWindow(widget)->SchedulePageFlip(
94 true /* is_sync */, base::Bind(&EmptyPageFlipCallback));
95 return true;
96 }
97
98 int DrmDmabufPixmapWrapper::GetDmaBufFd() {
99 return pixmap_->GetDmaBufFd();
100 }
101
102 int DrmDmabufPixmapWrapper::GetDmaBufPitch() {
103 return pixmap_->GetDmaBufPitch();
104 }
105
106 void* DrmDmabufPixmapWrapper::GetEGLClientBuffer() {
107 return nullptr;
108 }
109
110 } // namespace ui
OLDNEW
« 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