1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QPLATFORMBACKINGSTORE_H
41#define QPLATFORMBACKINGSTORE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is part of the QPA API and is not meant to be used
48// in applications. Usage of this API may make your code
49// source and binary incompatible with future versions of Qt.
50//
51
52#include <QtGui/qtguiglobal.h>
53#include <QtCore/qloggingcategory.h>
54#include <QtCore/qrect.h>
55#include <QtCore/qobject.h>
56
57#include <QtGui/qwindow.h>
58#include <QtGui/qregion.h>
59#include <QtGui/qopengl.h>
60
61QT_BEGIN_NAMESPACE
62
63Q_GUI_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStore)
64
65class QRegion;
66class QRect;
67class QPoint;
68class QImage;
69class QPlatformBackingStorePrivate;
70class QPlatformWindow;
71class QPlatformTextureList;
72class QPlatformTextureListPrivate;
73class QOpenGLContext;
74class QPlatformGraphicsBuffer;
75
76#ifndef QT_NO_OPENGL
77class Q_GUI_EXPORT QPlatformTextureList : public QObject
78{
79 Q_OBJECT
80 Q_DECLARE_PRIVATE(QPlatformTextureList)
81public:
82 enum Flag {
83 StacksOnTop = 0x01,
84 TextureIsSrgb = 0x02
85 };
86 Q_DECLARE_FLAGS(Flags, Flag)
87
88 explicit QPlatformTextureList(QObject *parent = nullptr);
89 ~QPlatformTextureList();
90
91 int count() const;
92 bool isEmpty() const { return count() == 0; }
93 GLuint textureId(int index) const;
94 QRect geometry(int index) const;
95 QRect clipRect(int index) const;
96 void *source(int index);
97 Flags flags(int index) const;
98 void lock(bool on);
99 bool isLocked() const;
100
101 void appendTexture(void *source, GLuint textureId, const QRect &geometry,
102 const QRect &clipRect = QRect(), Flags flags = nullptr);
103 void clear();
104
105 Q_SIGNALS:
106 void locked(bool);
107};
108Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags)
109#endif
110
111class Q_GUI_EXPORT QPlatformBackingStore
112{
113public:
114 explicit QPlatformBackingStore(QWindow *window);
115 virtual ~QPlatformBackingStore();
116
117 QWindow *window() const;
118 QBackingStore *backingStore() const;
119
120 virtual QPaintDevice *paintDevice() = 0;
121
122 virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
123#ifndef QT_NO_OPENGL
124 virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
125 QPlatformTextureList *textures,
126 bool translucentBackground);
127#endif
128 virtual QImage toImage() const;
129#ifndef QT_NO_OPENGL
130 enum TextureFlag {
131 TextureSwizzle = 0x01,
132 TextureFlip = 0x02,
133 TexturePremultiplied = 0x04,
134 };
135 Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
136 virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
137#endif
138
139 virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
140
141 virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
142
143 virtual bool scroll(const QRegion &area, int dx, int dy);
144
145 virtual void beginPaint(const QRegion &);
146 virtual void endPaint();
147
148private:
149 QPlatformBackingStorePrivate *d_ptr;
150
151 void setBackingStore(QBackingStore *);
152 friend class QBackingStore;
153};
154
155#ifndef QT_NO_OPENGL
156Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
157#endif
158
159QT_END_NAMESPACE
160
161#endif // QPLATFORMBACKINGSTORE_H
162