2011-06-22 10:55:04 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006-2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
Copyright (C) 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_GLTEXTURE_H
|
|
|
|
#define KWIN_GLTEXTURE_H
|
|
|
|
|
|
|
|
#include "kwinglobals.h"
|
|
|
|
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QSize>
|
2013-02-26 07:02:27 +00:00
|
|
|
#include <QRegion>
|
2011-07-18 15:55:39 +00:00
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QExplicitlySharedDataPointer>
|
2012-09-27 19:22:05 +00:00
|
|
|
#include <QtGui/QMatrix4x4>
|
2011-06-22 10:55:04 +00:00
|
|
|
|
|
|
|
class QImage;
|
|
|
|
class QPixmap;
|
|
|
|
|
|
|
|
/** @addtogroup kwineffects */
|
|
|
|
/** @{ */
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class GLVertexBuffer;
|
2011-07-18 15:55:39 +00:00
|
|
|
class GLTexturePrivate;
|
2011-06-22 10:55:04 +00:00
|
|
|
|
2012-09-27 19:22:05 +00:00
|
|
|
enum TextureCoordinateType {
|
|
|
|
NormalizedCoordinates = 0,
|
|
|
|
UnnormalizedCoordinates
|
|
|
|
};
|
|
|
|
|
2011-06-22 10:55:04 +00:00
|
|
|
class KWIN_EXPORT GLTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLTexture();
|
2011-07-18 15:55:39 +00:00
|
|
|
GLTexture(const GLTexture& tex);
|
2011-06-22 10:55:04 +00:00
|
|
|
explicit GLTexture(const QImage& image, GLenum target = GL_TEXTURE_2D);
|
|
|
|
explicit GLTexture(const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D);
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit GLTexture(const QString& fileName);
|
2011-06-22 10:55:04 +00:00
|
|
|
GLTexture(int width, int height);
|
|
|
|
virtual ~GLTexture();
|
|
|
|
|
2011-07-18 15:55:39 +00:00
|
|
|
GLTexture & operator = (const GLTexture& tex);
|
|
|
|
|
2011-06-22 10:55:04 +00:00
|
|
|
bool isNull() const;
|
|
|
|
QSize size() const;
|
2011-07-18 15:55:39 +00:00
|
|
|
int width() const;
|
|
|
|
int height() const;
|
2011-07-03 07:30:38 +00:00
|
|
|
/**
|
|
|
|
* @since 4.7
|
|
|
|
**/
|
|
|
|
bool isYInverted() const;
|
2011-07-18 15:55:39 +00:00
|
|
|
/**
|
|
|
|
* @since 4.8
|
|
|
|
**/
|
|
|
|
void setYInverted(bool inverted);
|
2011-06-22 10:55:04 +00:00
|
|
|
|
2012-09-27 19:22:05 +00:00
|
|
|
/**
|
|
|
|
* Returns a matrix that transforms texture coordinates of the given type,
|
|
|
|
* taking the texture target and the y-inversion flag into account.
|
|
|
|
*
|
|
|
|
* @since 4.11
|
|
|
|
*/
|
|
|
|
QMatrix4x4 matrix(TextureCoordinateType type) const;
|
|
|
|
|
2011-06-22 10:55:04 +00:00
|
|
|
virtual bool load(const QImage& image, GLenum target = GL_TEXTURE_2D);
|
|
|
|
virtual bool load(const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D);
|
|
|
|
virtual bool load(const QString& fileName);
|
2013-02-22 09:13:46 +00:00
|
|
|
void update(const QImage& image, const QPoint &offset = QPoint(0, 0), const QRect &src = QRect());
|
2011-06-22 10:55:04 +00:00
|
|
|
virtual void discard();
|
2011-07-18 15:55:39 +00:00
|
|
|
void bind();
|
|
|
|
void unbind();
|
2012-02-12 15:42:09 +00:00
|
|
|
void render(QRegion region, const QRect& rect, bool hardwareClipping = false);
|
2011-06-22 10:55:04 +00:00
|
|
|
|
|
|
|
GLuint texture() const;
|
|
|
|
GLenum target() const;
|
|
|
|
GLenum filter() const;
|
2013-09-05 19:10:13 +00:00
|
|
|
/** @short
|
|
|
|
* Make the texture fully transparent
|
|
|
|
* Warning: this clobbers the current framebuffer binding except on fglrx
|
|
|
|
*/
|
|
|
|
void clear();
|
2012-01-07 21:26:50 +00:00
|
|
|
bool isDirty() const;
|
2011-06-22 10:55:04 +00:00
|
|
|
void setFilter(GLenum filter);
|
|
|
|
void setWrapMode(GLenum mode);
|
2012-01-07 21:26:50 +00:00
|
|
|
void setDirty();
|
2011-06-22 10:55:04 +00:00
|
|
|
|
2011-07-18 15:55:39 +00:00
|
|
|
static bool NPOTTextureSupported();
|
|
|
|
static bool framebufferObjectSupported();
|
|
|
|
static bool saturationSupported();
|
2011-06-22 10:55:04 +00:00
|
|
|
|
|
|
|
protected:
|
2011-07-18 15:55:39 +00:00
|
|
|
QExplicitlySharedDataPointer<GLTexturePrivate> d_ptr;
|
|
|
|
GLTexture(GLTexturePrivate& dd);
|
2011-06-22 10:55:04 +00:00
|
|
|
|
|
|
|
private:
|
2011-08-27 07:31:38 +00:00
|
|
|
Q_DECLARE_PRIVATE(GLTexture)
|
2011-06-22 10:55:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#endif
|