1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPENGLTEXTUREBLITTER_H
5#define QOPENGLTEXTUREBLITTER_H
6
7#include <QtOpenGL/qtopenglglobal.h>
8
9#include <QtGui/qopengl.h>
10#include <QtGui/QMatrix3x3>
11#include <QtGui/QMatrix4x4>
12
13QT_BEGIN_NAMESPACE
14
15class QOpenGLTextureBlitterPrivate;
16
17class Q_OPENGL_EXPORT QOpenGLTextureBlitter
18{
19public:
20 QOpenGLTextureBlitter();
21 ~QOpenGLTextureBlitter();
22
23 enum Origin {
24 OriginBottomLeft,
25 OriginTopLeft
26 };
27
28 bool create();
29 bool isCreated() const;
30 void destroy();
31
32 bool supportsExternalOESTarget() const;
33 bool supportsRectangleTarget() const;
34
35 void bind(GLenum target = GL_TEXTURE_2D);
36 void release();
37
38 void setRedBlueSwizzle(bool swizzle);
39 void setOpacity(float opacity);
40
41 void blit(GLuint texture, const QMatrix4x4 &targetTransform, Origin sourceOrigin);
42 void blit(GLuint texture, const QMatrix4x4 &targetTransform, const QMatrix3x3 &sourceTransform);
43
44 static QMatrix4x4 targetTransform(const QRectF &target, const QRect &viewport);
45 static QMatrix3x3 sourceTransform(const QRectF &subTexture, const QSize &textureSize, Origin origin);
46
47private:
48 Q_DISABLE_COPY(QOpenGLTextureBlitter)
49 Q_DECLARE_PRIVATE(QOpenGLTextureBlitter)
50 QScopedPointer<QOpenGLTextureBlitterPrivate> d_ptr;
51};
52
53QT_END_NAMESPACE
54
55#endif //QOPENGLTEXTUREBLITTER_H
56

source code of qtbase/src/opengl/qopengltextureblitter.h