Qt 4.8
Public Functions | Properties | List of all members
QBBBuffer Class Reference

#include <qbbbuffer.h>

Public Functions

const QImageimage () const
 
QImageimage ()
 
void invalidateInCache ()
 
screen_buffer_t nativeBuffer () const
 
 QBBBuffer ()
 
 QBBBuffer (screen_buffer_t buffer)
 
 QBBBuffer (const QBBBuffer &other)
 
QRect rect () const
 
virtual ~QBBBuffer ()
 

Properties

screen_buffer_t mBuffer
 
QImage mImage
 

Detailed Description

Definition at line 51 of file qbbbuffer.h.

Constructors and Destructors

◆ QBBBuffer() [1/3]

QBBBuffer::QBBBuffer ( )

Definition at line 54 of file qbbbuffer.cpp.

55  : mBuffer(NULL)
56 {
57 #if defined(QBBBUFFER_DEBUG)
58  qDebug() << "QBBBuffer::QBBBuffer - empty";
59 #endif
60 }
Q_CORE_EXPORT void qDebug(const char *,...)
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68

◆ QBBBuffer() [2/3]

QBBBuffer::QBBBuffer ( screen_buffer_t  buffer)

Definition at line 62 of file qbbbuffer.cpp.

63  : mBuffer(buffer)
64 {
65 #if defined(QBBBUFFER_DEBUG)
66  qDebug() << "QBBBuffer::QBBBuffer - normal";
67 #endif
68 
69  // get size of buffer
70  errno = 0;
71  int size[2];
72  int result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size);
73  if (result != 0) {
74  qFatal("QBB: failed to query buffer size, errno=%d", errno);
75  }
76 
77  // get stride of buffer
78  errno = 0;
79  int stride;
80  result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
81  if (result != 0) {
82  qFatal("QBB: failed to query buffer stride, errno=%d", errno);
83  }
84 
85  // get access to buffer's data
86  errno = 0;
87  uchar* dataPtr = NULL;
88  result = screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr);
89  if (result != 0) {
90  qFatal("QBB: failed to query buffer pointer, errno=%d", errno);
91  }
92  if (dataPtr == NULL) {
93  qFatal("QBB: buffer pointer is NULL, errno=%d", errno);
94  }
95 
96  // get format of buffer
97  errno = 0;
98  int screenFormat;
99  result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat);
100  if (result != 0) {
101  qFatal("QBB: failed to query buffer format, errno=%d", errno);
102  }
103 
104  // convert screen format to QImage format
106  switch (screenFormat) {
107  case SCREEN_FORMAT_RGBX4444:
108  imageFormat = QImage::Format_RGB444;
109  break;
110  case SCREEN_FORMAT_RGBA4444:
112  break;
113  case SCREEN_FORMAT_RGBX5551:
114  imageFormat = QImage::Format_RGB555;
115  break;
116  case SCREEN_FORMAT_RGB565:
117  imageFormat = QImage::Format_RGB16;
118  break;
119  case SCREEN_FORMAT_RGBX8888:
120  imageFormat = QImage::Format_RGB32;
121  break;
122  case SCREEN_FORMAT_RGBA8888:
124  break;
125  default:
126  qFatal("QBB: unsupported buffer format, format=%d", screenFormat);
127  }
128 
129  // wrap buffer in an image
130  mImage = QImage(dataPtr, size[0], size[1], stride, imageFormat);
131 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
QImage mImage
Definition: qbbbuffer.h:69
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68
Q_CORE_EXPORT void qFatal(const char *,...)
int errno

◆ QBBBuffer() [3/3]

QBBBuffer::QBBBuffer ( const QBBBuffer other)

Definition at line 133 of file qbbbuffer.cpp.

134  : mBuffer(other.mBuffer),
135  mImage(other.mImage)
136 {
137 #if defined(QBBBUFFER_DEBUG)
138  qDebug() << "QBBBuffer::QBBBuffer - copy";
139 #endif
140 }
Q_CORE_EXPORT void qDebug(const char *,...)
QImage mImage
Definition: qbbbuffer.h:69
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68

◆ ~QBBBuffer()

QBBBuffer::~QBBBuffer ( )
virtual

Definition at line 142 of file qbbbuffer.cpp.

143 {
144 #if defined(QBBBUFFER_DEBUG)
145  qDebug() << "QBBBuffer::~QBBBuffer";
146 #endif
147 }
Q_CORE_EXPORT void qDebug(const char *,...)

Functions

◆ image() [1/2]

const QImage* QBBBuffer::image ( ) const
inline

Definition at line 60 of file qbbbuffer.h.

Referenced by QBBRasterWindowSurface::paintDevice().

60 { return (mBuffer != NULL) ? &mImage : NULL; }
QImage mImage
Definition: qbbbuffer.h:69
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68

◆ image() [2/2]

QImage* QBBBuffer::image ( )
inline

Definition at line 61 of file qbbbuffer.h.

61 { return (mBuffer != NULL) ? &mImage : NULL; }
QImage mImage
Definition: qbbbuffer.h:69
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68

◆ invalidateInCache()

void QBBBuffer::invalidateInCache ( )

Definition at line 149 of file qbbbuffer.cpp.

Referenced by QBBWindow::copyBack(), and rect().

150 {
151 #if defined(QBBBUFFER_DEBUG)
152  qDebug() << "QBBBuffer::invalidateInCache";
153 #endif
154 
155  // verify native buffer exists
156  if (mBuffer == NULL) {
157  qFatal("QBB: can't invalidate cache for null buffer");
158  }
159 
160  // evict buffer's data from cache
161  errno = 0;
162  int result = msync(mImage.bits(), mImage.height() * mImage.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY);
163  if (result != 0) {
164  qFatal("QBB: failed to invalidate cache, errno=%d", errno);
165  }
166 }
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Q_CORE_EXPORT void qDebug(const char *,...)
QImage mImage
Definition: qbbbuffer.h:69
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
Q_CORE_EXPORT void qFatal(const char *,...)
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int errno

◆ nativeBuffer()

screen_buffer_t QBBBuffer::nativeBuffer ( ) const
inline

Definition at line 59 of file qbbbuffer.h.

Referenced by QBBWindow::copyBack(), and QBBWindow::post().

59 { return mBuffer; }
screen_buffer_t mBuffer
Definition: qbbbuffer.h:68

◆ rect()

QRect QBBBuffer::rect ( ) const
inline

Definition at line 63 of file qbbbuffer.h.

Referenced by QBBWindow::copyBack().

63 { return mImage.rect(); }
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
Definition: qimage.cpp:1603
QImage mImage
Definition: qbbbuffer.h:69

Properties

◆ mBuffer

screen_buffer_t QBBBuffer::mBuffer
private

Definition at line 68 of file qbbbuffer.h.

Referenced by image(), invalidateInCache(), and nativeBuffer().

◆ mImage

QImage QBBBuffer::mImage
private

Definition at line 69 of file qbbbuffer.h.

Referenced by image(), invalidateInCache(), QBBBuffer(), and rect().


The documentation for this class was generated from the following files: