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

Side by Side Diff: ui/gfx/linux/native_pixmap_dmabuf.cc

Issue 2705213005: Add NativePixmapDmabufStub to finalize glCreateImageCHROMIUM on Linux. (Closed)
Patch Set: Forgot friend class base::RefCountedThreadSafe Created 3 years, 6 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 2017 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/gfx/linux/native_pixmap_dmabuf.h"
6
7 namespace gfx {
8
9 NativePixmapDmabufHelper::NativePixmapDmabufHelper(
10 const gfx::NativePixmapHandle& handle) {
11 for (auto& fd : handle.fds) {
12 fds_.emplace_back(fd.fd);
13 }
14
15 for (const auto& plane : handle.planes) {
16 planes_.push_back(plane);
17 }
18 }
19
20 NativePixmapDmabufHelper::NativePixmapDmabufHelper(
21 std::vector<base::ScopedFD>&& fds,
22 const std::vector<gfx::NativePixmapPlane>&& planes)
23 : fds_(std::move(fds)), planes_(std::move(planes)) {}
24
25 NativePixmapDmabufHelper::~NativePixmapDmabufHelper() {}
26
27 bool NativePixmapDmabufHelper::AreFdsValid() const {
28 if (fds_.empty())
29 return false;
30
31 for (const auto& fd : fds_) {
32 if (fd.get() == -1)
33 return false;
34 }
35 return true;
36 }
37
38 size_t NativePixmapDmabufHelper::GetFdCount() const {
39 return fds_.size();
40 }
41
42 int NativePixmapDmabufHelper::GetFd(size_t index) const {
43 DCHECK_LT(index, fds_.size());
44 return fds_[index].get();
45 }
46
47 int NativePixmapDmabufHelper::GetStride(size_t index) const {
48 DCHECK_LT(index, planes_.size());
49 return planes_[index].stride;
50 }
51
52 int NativePixmapDmabufHelper::GetOffset(size_t index) const {
53 DCHECK_LT(index, planes_.size());
54 return planes_[index].offset;
55 }
56
57 size_t NativePixmapDmabufHelper::GetSize(size_t index) const {
58 DCHECK_LT(index, planes_.size());
59 return planes_[index].size;
60 }
61
62 uint64_t NativePixmapDmabufHelper::GetFormatModifier(size_t index) const {
63 DCHECK_LT(index, planes_.size());
64 return planes_[index].modifier;
65 }
66
67 NativePixmapDmaBuf::NativePixmapDmaBuf(
68 const gfx::Size& size,
69 gfx::BufferFormat format,
70 const scoped_refptr<NativePixmapDmabufHelper>& helper)
71 : size_(size), format_(format), helper_(helper) {}
72
73 NativePixmapDmaBuf::~NativePixmapDmaBuf() {}
74
75 void* NativePixmapDmaBuf::GetEGLClientBuffer() const {
76 return nullptr;
77 }
78
79 bool NativePixmapDmaBuf::AreDmaBufFdsValid() const {
80 return helper_->AreFdsValid();
81 }
82
83 size_t NativePixmapDmaBuf::GetDmaBufFdCount() const {
84 return helper_->GetFdCount();
85 }
86
87 int NativePixmapDmaBuf::GetDmaBufFd(size_t plane) const {
88 return helper_->GetFd(plane);
89 }
90
91 int NativePixmapDmaBuf::GetDmaBufPitch(size_t plane) const {
92 return helper_->GetStride(plane);
93 }
94
95 int NativePixmapDmaBuf::GetDmaBufOffset(size_t plane) const {
96 return helper_->GetOffset(plane);
97 }
98
99 uint64_t NativePixmapDmaBuf::GetDmaBufModifier(size_t plane) const {
100 return helper_->GetFormatModifier(plane);
101 }
102
103 gfx::BufferFormat NativePixmapDmaBuf::GetBufferFormat() const {
104 return format_;
105 }
106
107 gfx::Size NativePixmapDmaBuf::GetBufferSize() const {
108 return size_;
109 }
110
111 bool NativePixmapDmaBuf::ScheduleOverlayPlane(
112 gfx::AcceleratedWidget widget,
113 int plane_z_order,
114 gfx::OverlayTransform plane_transform,
115 const gfx::Rect& display_bounds,
116 const gfx::RectF& crop_rect) {
117 return false;
118 }
119
120 void NativePixmapDmaBuf::SetProcessingCallback(
121 const ProcessingCallback& processing_callback) {}
122
123 gfx::NativePixmapHandle NativePixmapDmaBuf::ExportHandle() {
124 return gfx::NativePixmapHandle();
125 }
126
127 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698