qplatformgraphicsbuffer.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformgraphicsbuffer.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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#include "qplatformgraphicsbuffer.h"-
41#include <QtGui/QOpenGLContext>-
42#include <QtGui/QOpenGLFunctions>-
43#include <QtGui/qopengl.h>-
44#include <QtCore/QDebug>-
45-
46QT_BEGIN_NAMESPACE-
47/*!-
48 \class QPlatformGraphicsBuffer-
49 \inmodule QtGui-
50 \since 5.5-
51 \brief The QPlatformGraphicsBuffer is a windowsystem abstraction for native graphics buffers-
52-
53 Different platforms have different ways of representing graphics buffers. On-
54 some platforms, it is possible to create one graphics buffer that you can bind-
55 to a texture and also get main memory access to the image bits. On the-
56 other hand, on some platforms all graphics buffer abstraction is completely-
57 hidden.-
58-
59 QPlatformGraphicsBuffer is an abstraction of a single Graphics Buffer.-
60-
61 There is no public constructor nor any public factory function.-
62-
63 QPlatformGraphicsBuffer is intended to be created by using platform specific-
64 APIs available from QtPlatformHeaders, or there might be accessor functions-
65 similar to the accessor function that QPlatformBackingstore has.-
66*/-
67-
68/*!-
69 \enum QPlatformGraphicsBuffer::AccessType-
70-
71 This enum describes the access that is desired or granted for the graphics-
72 buffer.-
73-
74 \value None-
75 \value SWReadAccess-
76 \value SWWriteAccess-
77 \value TextureAccess-
78 \value HWCompositor-
79*/-
80-
81/*!-
82 \enum QPlatformGraphicsBuffer::Origin-
83-
84 This enum describes the origin of the content of the buffer.-
85-
86 \value OriginTopLeft-
87 \value OriginBottomLeft-
88*/-
89-
90/*!-
91 Protected constructor to initialize the private members.-
92-
93 \a size is the size of the buffer.-
94 \a format is the format of the buffer.-
95-
96 \sa size() format()-
97*/-
98QPlatformGraphicsBuffer::QPlatformGraphicsBuffer(const QSize &size, const QPixelFormat &format)-
99 : m_size(size)-
100 , m_format(format)-
101{-
102}
never executed: end of block
0
103-
104-
105/*!-
106 Virtual destructor.-
107*/-
108QPlatformGraphicsBuffer::~QPlatformGraphicsBuffer()-
109{-
110}-
111-
112/*!-
113 Binds the content of this graphics buffer into the currently bound texture.-
114-
115 This function should fail for buffers not capable of locking to TextureAccess.-
116-
117 \a rect is the subrect which is desired to be bounded to the texture. This-
118 argument has a no less than semantic, meaning more (if not all) of the buffer-
119 can be bounded to the texture. An empty QRect is interpreted as entire buffer-
120 should be bound.-
121-
122 This function only supports binding buffers to the GL_TEXTURE_2D texture-
123 target.-
124-
125 Returns true on success, otherwise false.-
126*/-
127bool QPlatformGraphicsBuffer::bindToTexture(const QRect &rect) const-
128{-
129 Q_UNUSED(rect);-
130 return false;
never executed: return false;
0
131}-
132-
133/*!-
134 \fn QPlatformGraphicsBuffer::AccessTypes QPlatformGraphicsBuffer::isLocked() const-
135 Function to check if the buffer is locked.-
136-
137 \sa lock()-
138*/-
139-
140/*!-
141 Before the data can be retrieved or before a buffer can be bound to a-
142 texture it needs to be locked. This is a separate function call since this-
143 operation might be time consuming, and it would not be satisfactory to do-
144 it per function call.-
145-
146 \a access is the access type wanted.-
147-
148 \a rect is the subrect which is desired to be locked. This-
149 argument has a no less than semantic, meaning more (if not all) of the buffer-
150 can be locked. An empty QRect is interpreted as entire buffer should be locked.-
151-
152 Return true on successfully locking all AccessTypes specified \a access-
153 otherwise returns false and no locks have been granted.-
154*/-
155bool QPlatformGraphicsBuffer::lock(AccessTypes access, const QRect &rect)-
156{-
157 bool locked = doLock(access, rect);-
158 if (locked)
lockedDescription
TRUEnever evaluated
FALSEnever evaluated
0
159 m_lock_access |= access;
never executed: m_lock_access |= access;
0
160-
161 return locked;
never executed: return locked;
0
162}-
163-
164/*!-
165 Unlocks the current buffer lock.-
166-
167 This function calls doUnlock, and then emits the unlocked signal with the-
168 AccessTypes from before doUnlock was called.-
169*/-
170void QPlatformGraphicsBuffer::unlock()-
171{-
172 if (m_lock_access == None)
m_lock_access == NoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 return;
never executed: return;
0
174 AccessTypes previous = m_lock_access;-
175 doUnlock();-
176 m_lock_access = None;-
177 emit unlocked(previous);-
178}
never executed: end of block
0
179-
180-
181/*!-
182 \fn QPlatformGraphicsBuffer::doLock(AccessTypes access, const QRect &rect = QRect())-
183-
184 This function should be reimplemented by subclasses. If one of the \a-
185 access types specified can not be locked, then all should fail and this-
186 function should return false.-
187-
188 \a rect is the subrect which is desired to be locked. This-
189 argument has a no less than semantic, meaning more (if not all) of the-
190 buffer can be locked. An empty QRect should be interpreted as the entire buffer-
191 should be locked.-
192-
193 It is safe to call isLocked() to verify the current lock state.-
194*/-
195-
196/*!-
197 \fn QPlatformGraphicsBuffer::doUnlock()-
198-
199 This function should remove all locks set on the buffer.-
200-
201 It is safe to call isLocked() to verify the current lock state.-
202*/-
203-
204/*!-
205 \fn QPlatformGraphicsBuffer::unlocked(AccessTypes previousAccessTypes)-
206-
207 Signal that is emitted after unlocked has been called.-
208-
209 \a previousAccessTypes is the access types locked before unlock was called.-
210*/-
211-
212/*!-
213 Accessor for the bytes of the buffer. This function needs to be called on a-
214 buffer with SWReadAccess access lock. Behavior is undefined for modifying-
215 the memory returned when not having a SWWriteAccess.-
216*/-
217const uchar *QPlatformGraphicsBuffer::data() const-
218{
never executed: return nullptr;
return Q_NULLPTR; }
never executed: return nullptr;
0
219-
220/*!-
221 Accessor for the bytes of the buffer. This function needs to be called on a-
222 buffer with SWReadAccess access lock. Behavior is undefined for modifying-
223 the memory returned when not having a SWWriteAccess.-
224*/-
225uchar *QPlatformGraphicsBuffer::data()-
226{-
227 return Q_NULLPTR;
never executed: return nullptr;
0
228}-
229-
230/*!-
231 Accessor for the length of the data buffer. This function is a convenience-
232 function multiplying height of buffer with bytesPerLine().-
233-
234 \sa data() bytesPerLine() size()-
235*/-
236int QPlatformGraphicsBuffer::byteCount() const-
237{-
238 Q_ASSERT(isLocked() & SWReadAccess);-
239 return size().height() * bytesPerLine();
never executed: return size().height() * bytesPerLine();
0
240}-
241-
242/*!-
243 Accessor for bytes per line in the graphics buffer.-
244*/-
245int QPlatformGraphicsBuffer::bytesPerLine() const-
246{-
247 return 0;
never executed: return 0;
0
248}-
249-
250-
251/*!-
252 In origin of the content of the graphics buffer.-
253-
254 Default implementation is OriginTopLeft, as this is the coordinate-
255 system default for Qt. However, for most regular OpenGL textures-
256 this will be OriginBottomLeft.-
257*/-
258QPlatformGraphicsBuffer::Origin QPlatformGraphicsBuffer::origin() const-
259{-
260 return OriginTopLeft;
never executed: return OriginTopLeft;
0
261}-
262-
263/*!-
264 \fn QPlatformGraphicsBuffer::size() const-
265-
266 Accessor for content size.-
267*/-
268-
269/*!-
270 \fn QPlatformGraphicsBuffer::format() const-
271-
272 Accessor for the pixel format of the buffer.-
273*/-
274-
275QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9