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/gfx/linux/native_pixmap_dmabuf.cc

Issue 2705213005: Add NativePixmapDmabufStub to finalize glCreateImageCHROMIUM on Linux. (Closed)
Patch Set: Go back to previous solution (Patch Set 13) make the helper a parent instead of member 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(const gfx::Size& size,
68 gfx::BufferFormat format,
69 const gfx::NativePixmapHandle& handle)
70 : size_(size),
71 format_(format),
72 holder_(new NativePixmapDmabufHelper(handle)),
73 helper_(*holder_) {}
74
75 NativePixmapDmaBuf::NativePixmapDmaBuf(const gfx::Size& size,
76 gfx::BufferFormat format,
77 const NativePixmapDmabufHelper& helper)
78 : size_(size), format_(format), helper_(helper) {}
79
80 NativePixmapDmaBuf::~NativePixmapDmaBuf() {}
81
82 void* NativePixmapDmaBuf::GetEGLClientBuffer() const {
83 return nullptr;
84 }
85
86 bool NativePixmapDmaBuf::AreDmaBufFdsValid() const {
87 return helper_.AreFdsValid();
88 }
89
90 size_t NativePixmapDmaBuf::GetDmaBufFdCount() const {
91 return helper_.GetFdCount();
92 }
93
94 int NativePixmapDmaBuf::GetDmaBufFd(size_t plane) const {
95 return helper_.GetFd(plane);
96 }
97
98 int NativePixmapDmaBuf::GetDmaBufPitch(size_t plane) const {
99 return helper_.GetStride(plane);
100 }
101
102 int NativePixmapDmaBuf::GetDmaBufOffset(size_t plane) const {
103 return helper_.GetOffset(plane);
104 }
105
106 uint64_t NativePixmapDmaBuf::GetDmaBufModifier(size_t plane) const {
107 return helper_.GetFormatModifier(plane);
108 }
109
110 gfx::BufferFormat NativePixmapDmaBuf::GetBufferFormat() const {
111 return format_;
112 }
113
114 gfx::Size NativePixmapDmaBuf::GetBufferSize() const {
115 return size_;
116 }
117
118 bool NativePixmapDmaBuf::ScheduleOverlayPlane(
119 gfx::AcceleratedWidget widget,
120 int plane_z_order,
121 gfx::OverlayTransform plane_transform,
122 const gfx::Rect& display_bounds,
123 const gfx::RectF& crop_rect) {
124 return false;
125 }
126
127 void NativePixmapDmaBuf::SetProcessingCallback(
128 const ProcessingCallback& processing_callback) {}
129
130 gfx::NativePixmapHandle NativePixmapDmaBuf::ExportHandle() {
131 return gfx::NativePixmapHandle();
132 }
133
134 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698