KWin
Loading...
Searching...
No Matches
eglimagetexture.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "eglimagetexture.h"
11#include "egldisplay.h"
12#include "opengl/gltexture_p.h"
13
14#include <QDebug>
15#include <epoxy/egl.h>
16
17namespace KWin
18{
19
20EGLImageTexture::EGLImageTexture(EglDisplay *display, EGLImage image, uint textureId, int internalFormat, const QSize &size, uint32_t target)
21 : GLTexture(target, textureId, internalFormat, size, 1, true, OutputTransform::FlipY)
22 , m_image(image)
23 , m_display(display)
24{
25}
26
28{
29 eglDestroyImageKHR(m_display->handle(), m_image);
30}
31
32std::shared_ptr<EGLImageTexture> EGLImageTexture::create(EglDisplay *display, EGLImageKHR image, int internalFormat, const QSize &size, bool externalOnly)
33{
34 if (image == EGL_NO_IMAGE) {
35 return nullptr;
36 }
37 GLuint texture = 0;
38 glGenTextures(1, &texture);
39 if (!texture) {
40 return nullptr;
41 }
42 const uint32_t target = externalOnly ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
43 glBindTexture(target, texture);
44 glEGLImageTargetTexture2DOES(target, image);
45 glBindTexture(target, 0);
46 return std::make_shared<EGLImageTexture>(display, image, texture, internalFormat, size, target);
47}
48
49} // namespace KWin
EGLImageTexture(EglDisplay *display, EGLImageKHR image, uint textureId, int internalFormat, const QSize &size, uint32_t target)
EglDisplay *const m_display
::EGLDisplay handle() const
QSize size() const
GLuint texture() const
GLenum internalFormat() const
GLenum target() const
void * EGLImageKHR
GLenum internalFormat
Definition gltexture.cpp:48