Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqnxbuffer.cpp
Go to the documentation of this file.
1// Copyright (C) 2011 - 2012 Research In Motion
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qqnxglobal.h"
5
6#include "qqnxbuffer.h"
7
8#include <QtCore/QDebug>
9
10#include <errno.h>
11#include <sys/mman.h>
12
14
15Q_LOGGING_CATEGORY(lcQpaScreenBuffer, "qt.qpa.screen.buffer");
16
18 : m_buffer(0)
19{
20 qCDebug(lcQpaScreenBuffer) << Q_FUNC_INFO << "Empty";
21}
22
24 : m_buffer(buffer)
25{
26 qCDebug(lcQpaScreenBuffer) << Q_FUNC_INFO << "Normal";
27
28 // Get size of buffer
29 int size[2];
30 Q_SCREEN_CRITICALERROR(screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size),
31 "Failed to query buffer size");
32
33 // Get stride of buffer
34 int stride;
35 Q_SCREEN_CHECKERROR(screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride),
36 "Failed to query buffer stride");
37
38 // Get access to buffer's data
39 errno = 0;
40 uchar *dataPtr = nullptr;
42 screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr),
43 "Failed to query buffer pointer");
44
45 if (Q_UNLIKELY(!dataPtr))
46 qFatal("QQNX: buffer pointer is NULL, errno=%d", errno);
47
48 // Get format of buffer
49 int screenFormat;
51 screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat),
52 "Failed to query buffer format");
53
54 // Convert screen format to QImage format
56 switch (screenFormat) {
57 case SCREEN_FORMAT_RGBX4444:
58 imageFormat = QImage::Format_RGB444;
59 break;
60 case SCREEN_FORMAT_RGBA4444:
62 break;
63 case SCREEN_FORMAT_RGBX5551:
64 imageFormat = QImage::Format_RGB555;
65 break;
66 case SCREEN_FORMAT_RGB565:
67 imageFormat = QImage::Format_RGB16;
68 break;
69 case SCREEN_FORMAT_RGBX8888:
70 imageFormat = QImage::Format_RGB32;
71 break;
72 case SCREEN_FORMAT_RGBA8888:
74 break;
75 default:
76 qFatal(lcQpaScreenBuffer, "QQNX: unsupported buffer format, format=%d", screenFormat);
77 }
78
79 // wrap buffer in an image
80 m_image = QImage(dataPtr, size[0], size[1], stride, imageFormat);
81}
82
84 : m_buffer(other.m_buffer),
85 m_image(other.m_image)
86{
87 qCDebug(lcQpaScreenBuffer) << Q_FUNC_INFO << "Copy";
88}
89
91{
92 qCDebug(lcQpaScreenBuffer) << Q_FUNC_INFO;
93}
94
96{
97 qCDebug(lcQpaScreenBuffer) << Q_FUNC_INFO;
98
99 // Verify native buffer exists
100 if (Q_UNLIKELY(!m_buffer))
101 qFatal(lcQpaScreenBuffer, "QQNX: can't invalidate cache for null buffer");
102
103 // Evict buffer's data from cache
104 errno = 0;
105 int result = msync(m_image.bits(), m_image.height() * m_image.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY);
106 if (Q_UNLIKELY(result != 0))
107 qFatal(lcQpaScreenBuffer, "QQNX: failed to invalidate cache, errno=%d", errno);
108}
109
\inmodule QtGui
Definition qimage.h:37
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
Definition qimage.cpp:1560
uchar * bits()
Returns a pointer to the first pixel data.
Definition qimage.cpp:1698
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB32
Definition qimage.h:46
@ Format_Invalid
Definition qimage.h:42
@ Format_RGB444
Definition qimage.h:56
@ Format_RGB555
Definition qimage.h:53
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_ARGB4444_Premultiplied
Definition qimage.h:57
@ Format_RGB16
Definition qimage.h:49
virtual ~QQnxBuffer()
void invalidateInCache()
Combined button and popup list for selecting options.
#define Q_UNLIKELY(x)
#define Q_FUNC_INFO
#define qFatal
Definition qlogging.h:168
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
const void GLsizei GLsizei stride
GLenum GLuint buffer
GLuint64EXT * result
[6]
#define Q_SCREEN_CRITICALERROR(x, message)
Definition qqnxglobal.h:16
#define Q_SCREEN_CHECKERROR(x, message)
Definition qqnxglobal.h:13
unsigned char uchar
Definition qtypes.h:32
QSharedPointer< T > other(t)
[5]