2020-07-22 17:29:23 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
2020-07-22 17:29:23 +00:00
|
|
|
|
|
|
|
#include "dmabuftexture.h"
|
|
|
|
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
2022-05-13 09:06:17 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2020-08-21 10:32:04 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2020-07-22 17:29:23 +00:00
|
|
|
|
2022-05-17 10:36:34 +00:00
|
|
|
DmaBufTexture::DmaBufTexture(std::shared_ptr<GLTexture> texture, const DmaBufAttributes &attributes)
|
2020-07-22 17:29:23 +00:00
|
|
|
: m_texture(texture)
|
2022-05-17 10:36:34 +00:00
|
|
|
, m_framebuffer(std::make_unique<GLFramebuffer>(texture.get()))
|
2022-05-13 09:06:17 +00:00
|
|
|
, m_attributes(attributes)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DmaBufTexture::~DmaBufTexture()
|
2020-07-22 17:29:23 +00:00
|
|
|
{
|
2022-05-13 09:06:17 +00:00
|
|
|
for (int i = 0; i < m_attributes.planeCount; ++i) {
|
|
|
|
::close(m_attributes.fd[i]);
|
|
|
|
}
|
2020-07-22 17:29:23 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 09:06:17 +00:00
|
|
|
DmaBufAttributes DmaBufTexture::attributes() const
|
|
|
|
{
|
|
|
|
return m_attributes;
|
|
|
|
}
|
2020-07-22 17:29:23 +00:00
|
|
|
|
2021-11-14 13:43:53 +00:00
|
|
|
KWin::GLTexture *DmaBufTexture::texture() const
|
|
|
|
{
|
2022-05-17 10:36:34 +00:00
|
|
|
return m_texture.get();
|
2021-11-14 13:43:53 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 16:46:10 +00:00
|
|
|
KWin::GLFramebuffer *DmaBufTexture::framebuffer() const
|
2020-07-22 17:29:23 +00:00
|
|
|
{
|
2022-05-17 10:36:34 +00:00
|
|
|
return m_framebuffer.get();
|
2020-07-22 17:29:23 +00:00
|
|
|
}
|
|
|
|
|
2020-08-21 10:32:04 +00:00
|
|
|
} // namespace KWin
|