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 NeedsPremultipliedAlphaBlending = 0x04
86 };
87 Q_DECLARE_FLAGS(Flags, Flag)
88
89 explicit QPlatformTextureList(QObject *parent = nullptr);
90 ~QPlatformTextureList();
91
92 int count() const;
93 bool isEmpty() const { return count() == 0; }
94 GLuint textureId(int index) const;
95 QRect geometry(int index) const;
96 QRect clipRect(int index) const;
97 void *source(int index);
98 Flags flags(int index) const;
99 void lock(bool on);
100 bool isLocked() const;
101
102 void appendTexture(void *source, GLuint textureId, const QRect &geometry,
103 const QRect &clipRect = QRect(), Flags flags = { });
104 void clear();
105
106 Q_SIGNALS:
107 void locked(bool);
108};
109Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags)
110#endif
111
112class Q_GUI_EXPORT QPlatformBackingStore
113{
114public:
115 explicit QPlatformBackingStore(QWindow *window);
116 virtual ~QPlatformBackingStore();
117
118 QWindow *window() const;
119 QBackingStore *backingStore() const;
120
121 virtual QPaintDevice *paintDevice() = 0;
122
123 virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
124#ifndef QT_NO_OPENGL
125 virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
126 QPlatformTextureList *textures,
127 bool translucentBackground);
128#endif
129 virtual QImage toImage() const;
130#ifndef QT_NO_OPENGL
131 enum TextureFlag {
132 TextureSwizzle = 0x01,
133 TextureFlip = 0x02,
134 TexturePremultiplied = 0x04,
135 };
136 Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
137 virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
138#endif
139
140 virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
141
142 virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
143
144 virtual bool scroll(const QRegion &area, int dx, int dy);
145
146 virtual void beginPaint(const QRegion &);
147 virtual void endPaint();
148
149private:
150 QPlatformBackingStorePrivate *d_ptr;
151
152 void setBackingStore(QBackingStore *);
153 friend class QBackingStore;
154};
155
156#ifndef QT_NO_OPENGL
157Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
158#endif
159
160QT_END_NAMESPACE
161
162#endif // QPLATFORMBACKINGSTORE_H
163

source code of qtbase/src/gui/painting/qplatformbackingstore.h