KWin
Loading...
Searching...
No Matches
gltexture.h
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: 2006-2007 Rivo Laks <rivolaks@hot.ee>
6 SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "core/output.h"
14
15#include <QExplicitlySharedDataPointer>
16#include <QMatrix4x4>
17#include <QRegion>
18#include <QSize>
19
20#include <epoxy/gl.h>
21
22class QImage;
23class QPixmap;
24
28namespace KWin
29{
30
31class GLVertexBuffer;
32class GLTexturePrivate;
33
38
39class KWIN_EXPORT GLTexture
40{
41public:
42 explicit GLTexture(GLenum target);
43
49 bool create();
50 virtual ~GLTexture();
51
52 bool isNull() const;
53 QSize size() const;
54 void setSize(const QSize &size);
55 int width() const;
56 int height() const;
57
61 void setContentTransform(OutputTransform transform);
62
66 OutputTransform contentTransform() const;
67
77 void setSwizzle(GLenum red, GLenum green, GLenum blue, GLenum alpha);
78
85 QMatrix4x4 matrix(TextureCoordinateType type) const;
86
87 void update(const QImage &image, const QPoint &offset = QPoint(0, 0), const QRect &src = QRect());
88 void bind();
89 void unbind();
90 void render(const QSizeF &size);
91 void render(const QRegion &region, const QSizeF &size, bool hardwareClipping = false);
92 void render(const QRectF &source, const QRegion &region, const QSizeF &targetSize, bool hardwareClipping = false);
93
94 GLuint texture() const;
95 GLenum target() const;
96 GLenum filter() const;
97 GLenum internalFormat() const;
98
99 QImage toImage();
100
104 void clear();
108 void setDirty();
109 bool isDirty() const;
110 void setFilter(GLenum filter);
111 void setWrapMode(GLenum mode);
112
113 void generateMipmaps();
114
115 static bool framebufferObjectSupported();
116
124 static bool supportsSwizzle();
125
133 static bool supportsFormatRG();
134
135 static std::unique_ptr<GLTexture> createNonOwningWrapper(GLuint textureId, GLenum internalFormat, const QSize &size);
136 static std::unique_ptr<GLTexture> allocate(GLenum internalFormat, const QSize &size, int levels = 1);
137 static std::unique_ptr<GLTexture> upload(const QImage &image);
138 static std::unique_ptr<GLTexture> upload(const QPixmap &pixmap);
139
140protected:
141 explicit GLTexture(GLenum target, GLuint textureId, GLenum internalFormat, const QSize &size, int levels, bool owning, OutputTransform transform);
142
143 const std::unique_ptr<GLTexturePrivate> d;
144
145 virtual void onDamage();
146};
147
148} // namespace
149
const std::unique_ptr< GLTexturePrivate > d
Definition gltexture.h:143
Session::Type type
Definition session.cpp:17
GLenum internalFormat
Definition gltexture.cpp:48
TextureCoordinateType
Definition gltexture.h:34
@ NormalizedCoordinates
Definition gltexture.h:35
@ UnnormalizedCoordinates
Definition gltexture.h:36