| Index: ui/gfx/linux/native_pixmap_dmabuf.cc
|
| diff --git a/ui/gfx/linux/native_pixmap_dmabuf.cc b/ui/gfx/linux/native_pixmap_dmabuf.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f3ba5140b528ceacaa00f37c3429ac21ffd1ae1b
|
| --- /dev/null
|
| +++ b/ui/gfx/linux/native_pixmap_dmabuf.cc
|
| @@ -0,0 +1,134 @@
|
| +// Copyright 2017 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/gfx/linux/native_pixmap_dmabuf.h"
|
| +
|
| +namespace gfx {
|
| +
|
| +NativePixmapDmabufHelper::NativePixmapDmabufHelper(
|
| + const gfx::NativePixmapHandle& handle) {
|
| + for (auto& fd : handle.fds) {
|
| + fds_.emplace_back(fd.fd);
|
| + }
|
| +
|
| + for (const auto& plane : handle.planes) {
|
| + planes_.push_back(plane);
|
| + }
|
| +}
|
| +
|
| +NativePixmapDmabufHelper::NativePixmapDmabufHelper(
|
| + std::vector<base::ScopedFD>&& fds,
|
| + const std::vector<gfx::NativePixmapPlane>&& planes)
|
| + : fds_(std::move(fds)), planes_(std::move(planes)) {}
|
| +
|
| +NativePixmapDmabufHelper::~NativePixmapDmabufHelper() {}
|
| +
|
| +bool NativePixmapDmabufHelper::AreFdsValid() const {
|
| + if (fds_.empty())
|
| + return false;
|
| +
|
| + for (const auto& fd : fds_) {
|
| + if (fd.get() == -1)
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +size_t NativePixmapDmabufHelper::GetFdCount() const {
|
| + return fds_.size();
|
| +}
|
| +
|
| +int NativePixmapDmabufHelper::GetFd(size_t index) const {
|
| + DCHECK_LT(index, fds_.size());
|
| + return fds_[index].get();
|
| +}
|
| +
|
| +int NativePixmapDmabufHelper::GetStride(size_t index) const {
|
| + DCHECK_LT(index, planes_.size());
|
| + return planes_[index].stride;
|
| +}
|
| +
|
| +int NativePixmapDmabufHelper::GetOffset(size_t index) const {
|
| + DCHECK_LT(index, planes_.size());
|
| + return planes_[index].offset;
|
| +}
|
| +
|
| +size_t NativePixmapDmabufHelper::GetSize(size_t index) const {
|
| + DCHECK_LT(index, planes_.size());
|
| + return planes_[index].size;
|
| +}
|
| +
|
| +uint64_t NativePixmapDmabufHelper::GetFormatModifier(size_t index) const {
|
| + DCHECK_LT(index, planes_.size());
|
| + return planes_[index].modifier;
|
| +}
|
| +
|
| +NativePixmapDmaBuf::NativePixmapDmaBuf(const gfx::Size& size,
|
| + gfx::BufferFormat format,
|
| + const gfx::NativePixmapHandle& handle)
|
| + : size_(size),
|
| + format_(format),
|
| + holder_(new NativePixmapDmabufHelper(handle)),
|
| + helper_(*holder_) {}
|
| +
|
| +NativePixmapDmaBuf::NativePixmapDmaBuf(const gfx::Size& size,
|
| + gfx::BufferFormat format,
|
| + const NativePixmapDmabufHelper& helper)
|
| + : size_(size), format_(format), helper_(helper) {}
|
| +
|
| +NativePixmapDmaBuf::~NativePixmapDmaBuf() {}
|
| +
|
| +void* NativePixmapDmaBuf::GetEGLClientBuffer() const {
|
| + return nullptr;
|
| +}
|
| +
|
| +bool NativePixmapDmaBuf::AreDmaBufFdsValid() const {
|
| + return helper_.AreFdsValid();
|
| +}
|
| +
|
| +size_t NativePixmapDmaBuf::GetDmaBufFdCount() const {
|
| + return helper_.GetFdCount();
|
| +}
|
| +
|
| +int NativePixmapDmaBuf::GetDmaBufFd(size_t plane) const {
|
| + return helper_.GetFd(plane);
|
| +}
|
| +
|
| +int NativePixmapDmaBuf::GetDmaBufPitch(size_t plane) const {
|
| + return helper_.GetStride(plane);
|
| +}
|
| +
|
| +int NativePixmapDmaBuf::GetDmaBufOffset(size_t plane) const {
|
| + return helper_.GetOffset(plane);
|
| +}
|
| +
|
| +uint64_t NativePixmapDmaBuf::GetDmaBufModifier(size_t plane) const {
|
| + return helper_.GetFormatModifier(plane);
|
| +}
|
| +
|
| +gfx::BufferFormat NativePixmapDmaBuf::GetBufferFormat() const {
|
| + return format_;
|
| +}
|
| +
|
| +gfx::Size NativePixmapDmaBuf::GetBufferSize() const {
|
| + return size_;
|
| +}
|
| +
|
| +bool NativePixmapDmaBuf::ScheduleOverlayPlane(
|
| + gfx::AcceleratedWidget widget,
|
| + int plane_z_order,
|
| + gfx::OverlayTransform plane_transform,
|
| + const gfx::Rect& display_bounds,
|
| + const gfx::RectF& crop_rect) {
|
| + return false;
|
| +}
|
| +
|
| +void NativePixmapDmaBuf::SetProcessingCallback(
|
| + const ProcessingCallback& processing_callback) {}
|
| +
|
| +gfx::NativePixmapHandle NativePixmapDmaBuf::ExportHandle() {
|
| + return gfx::NativePixmapHandle();
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|