Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QMeeGoLivePixmapData Class Reference

#include <qmeegolivepixmapdata.h>

Inheritance diagram for QMeeGoLivePixmapData:
QGLPixmapData QPixmapData

Public Functions

QPixmapDatacreateCompatiblePixmapData () const
 
void destroySurfaceForPixmapData (QPixmapData *pmd)
 
EGLSurface getSurfaceForBackingPixmap ()
 
Qt::HANDLE handle ()
 
void initializeThroughEGLImage ()
 
QImagelock (EGLSyncKHR fenceSync)
 
 QMeeGoLivePixmapData (int w, int h, QImage::Format format)
 
 QMeeGoLivePixmapData (Qt::HANDLE h)
 
bool release (QImage *img)
 
bool scroll (int dx, int dy, const QRect &rect)
 
 ~QMeeGoLivePixmapData ()
 
- Public Functions inherited from QGLPixmapData
GLuint bind (bool copyBack=true) const
 
void copy (const QPixmapData *data, const QRect &rect)
 
void fill (const QColor &color)
 
bool fromData (const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
 
bool fromFile (const QString &filename, const char *format, Qt::ImageConversionFlags flags)
 
void fromImage (const QImage &image, Qt::ImageConversionFlags flags)
 
void fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags)
 
QGLPaintDeviceglDevice () const
 
bool hasAlphaChannel () const
 
bool isValidContext (const QGLContext *ctx) const
 
int metric (QPaintDevice::PaintDeviceMetric metric) const
 
QPaintEnginepaintEngine () const
 
 QGLPixmapData (PixelType type)
 
void resize (int width, int height)
 
QGLTexturetexture () const
 
QImage toImage () const
 
 ~QGLPixmapData ()
 
- Public Functions inherited from QPixmapData
virtual QPixmap alphaChannel () const
 
virtual QImagebuffer ()
 
qint64 cacheKey () const
 
ClassId classId () const
 
int colorCount () const
 
int depth () const
 
int height () const
 
bool isNull () const
 
virtual QBitmap mask () const
 
QT_DEPRECATED int numColors () const
 
PixelType pixelType () const
 
 QPixmapData (PixelType pixelType, int classId)
 
virtual QPixmapDataruntimeData () const
 
int serialNumber () const
 
virtual void setAlphaChannel (const QPixmap &alphaChannel)
 
virtual void setMask (const QBitmap &mask)
 
virtual QImage toImage (const QRect &rect) const
 
virtual QPixmap transformed (const QTransform &matrix, Qt::TransformationMode mode) const
 
int width () const
 
virtual ~QPixmapData ()
 

Static Public Functions

static void invalidateSurfaces ()
 
- Static Public Functions inherited from QPixmapData
static QPixmapDatacreate (int w, int h, PixelType type)
 

Public Variables

QPixmapbackingX11Pixmap
 
QImage lockedImage
 
QMeeGoLivePixmapDataList::Iterator pos
 

Additional Inherited Members

- Public Types inherited from QPixmapData
enum  ClassId {
  RasterClass, X11Class, MacClass, DirectFBClass,
  OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
  CustomClass = 1024
}
 
enum  PixelType { PixmapType, BitmapType }
 
- Protected Functions inherited from QPixmapData
void setSerialNumber (int serNo)
 
- Protected Variables inherited from QPixmapData
int d
 
int h
 
bool is_null
 
int w
 

Detailed Description

Definition at line 52 of file qmeegolivepixmapdata.h.

Constructors and Destructors

◆ QMeeGoLivePixmapData() [1/2]

QMeeGoLivePixmapData::QMeeGoLivePixmapData ( int  w,
int  h,
QImage::Format  format 
)

Definition at line 115 of file qmeegolivepixmapdata.cpp.

116 {
117  QImage image(w, h, format);
119  pmd->fromImage(image, Qt::NoOpaqueDetection);
120  backingX11Pixmap = new QPixmap(pmd);
121 
123 
125 }
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class QPixmap
void fromImage(const QImage &image, Qt::ImageConversionFlags flags)
QMeeGoLivePixmapDataList::Iterator pos
QGLPixmapData(PixelType type)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
friend class QX11PixmapData
static QMeeGoLivePixmapDataList all_live_pixmaps
iterator insert(iterator before, const T &t)
Inserts value in front of the item pointed to by the iterator before.
Definition: qlinkedlist.h:447

◆ QMeeGoLivePixmapData() [2/2]

QMeeGoLivePixmapData::QMeeGoLivePixmapData ( Qt::HANDLE  h)

Definition at line 127 of file qmeegolivepixmapdata.cpp.

128 {
129  backingX11Pixmap = new QPixmap(QPixmap::fromX11Pixmap(h));
131 
133 }
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class QPixmap
QMeeGoLivePixmapDataList::Iterator pos
QGLPixmapData(PixelType type)
static QMeeGoLivePixmapDataList all_live_pixmaps
iterator insert(iterator before, const T &t)
Inserts value in front of the item pointed to by the iterator before.
Definition: qlinkedlist.h:447

◆ ~QMeeGoLivePixmapData()

QMeeGoLivePixmapData::~QMeeGoLivePixmapData ( )

Definition at line 135 of file qmeegolivepixmapdata.cpp.

136 {
137  delete backingX11Pixmap;
139 }
iterator erase(iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next it...
Definition: qlinkedlist.h:470
QMeeGoLivePixmapDataList::Iterator pos
static QMeeGoLivePixmapDataList all_live_pixmaps

Functions

◆ createCompatiblePixmapData()

QPixmapData * QMeeGoLivePixmapData::createCompatiblePixmapData ( ) const
virtual

Reimplemented from QGLPixmapData.

Definition at line 177 of file qmeegolivepixmapdata.cpp.

178 {
179  qWarning("Create compatible called on live pixmap! Expect fail soon...");
180  return new QMeeGoRasterPixmapData(pixelType());
181 }
PixelType pixelType() const
Q_CORE_EXPORT void qWarning(const char *,...)

◆ destroySurfaceForPixmapData()

void QMeeGoLivePixmapData::destroySurfaceForPixmapData ( QPixmapData pmd)

Definition at line 306 of file qmeegolivepixmapdata.cpp.

Referenced by getSurfaceForBackingPixmap().

307 {
309  QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
310  if (pixmapData->gl_surface) {
311  eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
312  pixmapData->gl_surface = 0;
313  }
314 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
ClassId classId() const

◆ getSurfaceForBackingPixmap()

EGLSurface QMeeGoLivePixmapData::getSurfaceForBackingPixmap ( )

Definition at line 266 of file qmeegolivepixmapdata.cpp.

Referenced by lock(), and release().

267 {
269 
270  // This code is a crative remix of the stuff that can be found in the
271  // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap
272  QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(backingX11Pixmap->data_ptr().data());
273  Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
274  bool hasAlpha = pixmapData->hasAlphaChannel();
275 
276  if (pixmapData->gl_surface &&
277  hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
278  return pixmapData->gl_surface;
279 
280  // Check to see if the surface is still valid
281  if (pixmapData->gl_surface &&
282  hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) {
283  // Surface is invalid!
284  destroySurfaceForPixmapData(pixmapData);
285  }
286 
287  if (pixmapData->gl_surface == 0) {
288  EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
289  QEgl::OpenGL,
290  hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
291 
292  pixmapData->gl_surface = (void*)QEgl::createSurface(backingX11Pixmap, config);
293 
294  if (hasAlpha)
296  else
297  pixmapData->flags &= ~QX11PixmapData::GlSurfaceCreatedWithAlpha;
298 
299  if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
300  return NULL;
301  }
302 
303  return pixmapData->gl_surface;
304 }
DataPtr & data_ptr()
Definition: qpixmap.h:297
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void destroySurfaceForPixmapData(QPixmapData *pmd)
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
ClassId classId() const
Q_GUI_EXPORT EGLConfig defaultConfig(int devType, API api, ConfigOptions options)
Definition: qegl.cpp:126
Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs=0)
Definition: qegl_x11.cpp:333
bool hasAlphaChannel() const

◆ handle()

Qt::HANDLE QMeeGoLivePixmapData::handle ( )

Definition at line 250 of file qmeegolivepixmapdata.cpp.

Referenced by QMeeGoGraphicsSystem::getLiveTextureHandle().

251 {
252  return backingX11Pixmap->handle();
253 }
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299

◆ initializeThroughEGLImage()

void QMeeGoLivePixmapData::initializeThroughEGLImage ( )

Definition at line 141 of file qmeegolivepixmapdata.cpp.

Referenced by getSurfaceForBackingPixmap(), and QMeeGoLivePixmapData().

142 {
143  if (texture()->id != 0)
144  return;
145 
148 
149  EGLImageKHR eglImage = EGL_NO_IMAGE_KHR;
150  GLuint newTextureId = 0;
151 
152  eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
154 
155  if (eglImage == EGL_NO_IMAGE_KHR) {
156  qWarning("eglCreateImageKHR failed (live texture)!");
157  return;
158  }
159 
160  glGenTextures(1, &newTextureId);
161  glBindTexture(GL_TEXTURE_2D, newTextureId);
162 
164  if (glGetError() == GL_NO_ERROR) {
166  texture()->id = newTextureId;
167  texture()->options &= ~QGLContext::InvertedYBindOption;
169  } else {
170  qWarning("Failed to create a texture from an egl image (live texture)!");
171  glDeleteTextures(1, &newTextureId);
172  }
173 
175 }
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
static EGLint preserved_attribs[]
#define EGL_NO_IMAGE_KHR
Definition: qegl_p.h:169
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
QGLContext::BindOptions options
Definition: qgl_p.h:611
#define GL_TEXTURE_2D
QGLTexture * texture() const
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
Definition: qegl.cpp:638
GLuint id
Definition: qgl_p.h:608
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
void resize(int width, int height)
#define EGL_NATIVE_PIXMAP_KHR
Definition: qegl_p.h:180
Q_CORE_EXPORT void qWarning(const char *,...)
void * EGLClientBuffer
Definition: qegl_p.h:70
void * EGLImageKHR
Definition: qegl_p.h:165
static void ensureInitialized()
#define ctx
Definition: qgl.cpp:6094
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
Definition: qegl.cpp:625
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
Definition: qpixmap.cpp:1965
#define GL_NO_ERROR
#define glEGLImageTargetTexture2DOES

◆ invalidateSurfaces()

void QMeeGoLivePixmapData::invalidateSurfaces ( )
static

Definition at line 316 of file qmeegolivepixmapdata.cpp.

Referenced by qt_meego_invalidate_live_surfaces(), and QMeeGoGraphicsSystem::switchToRaster().

317 {
319  QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(data->backingX11Pixmap->data_ptr().data());
320  *data->texture() = QGLTexture();
321  pixmapData->gl_surface = 0;
322  }
323 }
DataPtr & data_ptr()
Definition: qpixmap.h:297
QGLTexture * texture() const
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
static const char * data(const QByteArray &arr)
static QMeeGoLivePixmapDataList all_live_pixmaps

◆ lock()

QImage * QMeeGoLivePixmapData::lock ( EGLSyncKHR  fenceSync)

Definition at line 183 of file qmeegolivepixmapdata.cpp.

Referenced by QMeeGoGraphicsSystem::lockLiveTexture(), and scroll().

184 {
187 
188  if (fenceSync) {
190  fenceSync,
193  }
194 
195  void *data = 0;
196  int pitch = 0;
197  int surfaceWidth = 0;
198  int surfaceHeight = 0;
199  EGLSurface surface = 0;
201  lockedImage = QImage();
202 
203  surface = getSurfaceForBackingPixmap();
205  qWarning("Failed to lock surface (live texture)!");
206  return &lockedImage;
207  }
208 
209  eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) &data);
210  eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) &pitch);
211  eglQuerySurface(QEgl::display(), surface, EGL_WIDTH, (EGLint*) &surfaceWidth);
212  eglQuerySurface(QEgl::display(), surface, EGL_HEIGHT, (EGLint*) &surfaceHeight);
213 
214  // Ok, here we know we just support those two formats. Real solution would be:
215  // query also the format.
216  if (backingX11Pixmap->depth() > 16)
218  else
219  format = QImage::Format_RGB16;
220 
221  if (data == NULL || pitch == 0) {
222  qWarning("Failed to query the live texture!");
223  return &lockedImage;
224  }
225 
226  if (width() != surfaceWidth || height() != surfaceHeight) {
227  qWarning("Live texture dimensions don't match!");
229  return &lockedImage;
230  }
231 
232  lockedImage = QImage((uchar *) data, width(), height(), pitch, format);
233  return &lockedImage;
234 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
int width() const
#define EGL_FOREVER_KHR
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR
static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
#define EGL_BITMAP_POINTER_KHR
unsigned char uchar
Definition: qglobal.h:994
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
EGLSurface getSurfaceForBackingPixmap()
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
static EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
static void ensureInitialized()
#define ctx
Definition: qgl.cpp:6094
int height() const
static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
static EGLint lock_attribs[]
#define EGL_BITMAP_PITCH_KHR

◆ release()

bool QMeeGoLivePixmapData::release ( QImage img)

Definition at line 236 of file qmeegolivepixmapdata.cpp.

Referenced by QMeeGoGraphicsSystem::releaseLiveTexture(), and scroll().

237 {
240 
242  lockedImage = QImage();
243  return true;
244  } else {
245  lockedImage = QImage();
246  return false;
247  }
248 }
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
EGLSurface getSurfaceForBackingPixmap()
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static void ensureInitialized()
#define ctx
Definition: qgl.cpp:6094

◆ scroll()

bool QMeeGoLivePixmapData::scroll ( int  dx,
int  dy,
const QRect rect 
)
virtual

Reimplemented from QGLPixmapData.

Definition at line 255 of file qmeegolivepixmapdata.cpp.

256 {
257  lock(NULL);
258 
259  if (!lockedImage.isNull())
260  qt_scrollRectInImage(lockedImage, rect, QPoint(dx, dy));
261 
263  return true;
264 }
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QImage * lock(EGLSyncKHR fenceSync)
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

Properties

◆ backingX11Pixmap

QPixmap* QMeeGoLivePixmapData::backingX11Pixmap

◆ lockedImage

QImage QMeeGoLivePixmapData::lockedImage

Definition at line 72 of file qmeegolivepixmapdata.h.

Referenced by lock(), release(), and scroll().

◆ pos

QMeeGoLivePixmapDataList::Iterator QMeeGoLivePixmapData::pos

Definition at line 73 of file qmeegolivepixmapdata.h.

Referenced by QMeeGoLivePixmapData(), and ~QMeeGoLivePixmapData().


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