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

#include <qmeegopixmapdata.h>

Inheritance diagram for QMeeGoPixmapData:
QGLPixmapData QPixmapData

Public Functions

QPixmapDatacreateCompatiblePixmapData () const
 
virtual void fromEGLSharedImage (Qt::HANDLE handle, const QImage &softImage)
 
virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags)
 
void fromTexture (GLuint textureId, int w, int h, bool alpha)
 
 QMeeGoPixmapData ()
 
virtual QImage toImage () const
 
virtual void updateFromSoftImage ()
 
- 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 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)
 
bool scroll (int dx, int dy, const QRect &rect)
 
QGLTexturetexture () 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 bool destroyEGLSharedImage (Qt::HANDLE h)
 
static Qt::HANDLE imageToEGLSharedImage (const QImage &image)
 
static void registerSharedImage (Qt::HANDLE handle, const QImage &si)
 
- Static Public Functions inherited from QPixmapData
static QPixmapDatacreate (int w, int h, PixelType type)
 

Public Variables

QImage softImage
 

Static Public Variables

static QHash< void *, QMeeGoImageInfo * > sharedImagesMap
 

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 53 of file qmeegopixmapdata.h.

Constructors and Destructors

◆ QMeeGoPixmapData()

QMeeGoPixmapData::QMeeGoPixmapData ( )

Definition at line 62 of file qmeegopixmapdata.cpp.

Functions

◆ createCompatiblePixmapData()

QPixmapData * QMeeGoPixmapData::createCompatiblePixmapData ( ) const
virtual

Reimplemented from QGLPixmapData.

Definition at line 223 of file qmeegopixmapdata.cpp.

224 {
225  return new QMeeGoRasterPixmapData(pixelType());
226 }
PixelType pixelType() const

◆ destroyEGLSharedImage()

bool QMeeGoPixmapData::destroyEGLSharedImage ( Qt::HANDLE  h)
static

Definition at line 191 of file qmeegopixmapdata.cpp.

Referenced by qt_meego_destroy_egl_shared_image().

192 {
195 
196  QMutableHashIterator <void*, QMeeGoImageInfo*> i(sharedImagesMap);
197  while (i.hasNext()) {
198  i.next();
199  if (i.value()->handle == h)
200  i.remove();
201  }
202 
204 }
static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
void * EGLNativeSharedImageTypeNOK
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static QHash< void *, QMeeGoImageInfo * > sharedImagesMap
static void ensureInitialized()
#define ctx
Definition: qgl.cpp:6094

◆ fromEGLSharedImage()

void QMeeGoPixmapData::fromEGLSharedImage ( Qt::HANDLE  handle,
const QImage softImage 
)
virtual

Definition at line 96 of file qmeegopixmapdata.cpp.

Referenced by fromImage(), and QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage().

97 {
98  if (si.isNull())
99  qFatal("Trying to build pixmap with an empty/null softimage!");
100 
102 
104 
105  bool textureIsBound = false;
106  GLuint newTextureId;
107  GLint newWidth, newHeight;
108 
109  glGenTextures(1, &newTextureId);
110  glBindTexture(GL_TEXTURE_2D, newTextureId);
111 
114 
115  if (image != EGL_NO_IMAGE_KHR) {
117  GLint err = glGetError();
118  if (err == GL_NO_ERROR)
119  textureIsBound = true;
120 
121  QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth);
122  QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight);
123 
125  }
126 
127  if (textureIsBound) {
128  fromTexture(newTextureId, newWidth, newHeight,
129  (si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels()));
130  texture()->options &= ~QGLContext::InvertedYBindOption;
131  softImage = si;
132  QMeeGoPixmapData::registerSharedImage(handle, softImage);
133  } else {
134  qWarning("Failed to create a texture from a shared image!");
135  glDeleteTextures(1, &newTextureId);
136  }
137 }
static void registerSharedImage(Qt::HANDLE handle, const QImage &si)
static EGLint preserved_image_attribs[]
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
#define EGL_NO_IMAGE_KHR
Definition: qegl_p.h:169
void fromTexture(GLuint textureId, int w, int h, bool alpha)
QGLContext::BindOptions options
Definition: qgl_p.h:611
#define GL_TEXTURE_2D
QGLTexture * texture() const
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
Definition: qegl.cpp:638
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
Q_CORE_EXPORT void qWarning(const char *,...)
void * EGLClientBuffer
Definition: qegl_p.h:70
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void * EGLImageKHR
Definition: qegl_p.h:165
Q_CORE_EXPORT void qFatal(const char *,...)
static void ensureInitialized()
void * data_ptr(const QTransform &t)
Definition: qpainter_p.h:81
#define ctx
Definition: qgl.cpp:6094
typedef GLint
Definition: glfunctions.h:67
Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
Definition: qegl.cpp:625
#define EGL_SHARED_IMAGE_NOK
#define GL_NO_ERROR
#define glEGLImageTargetTexture2DOES

◆ fromImage()

void QMeeGoPixmapData::fromImage ( const QImage image,
Qt::ImageConversionFlags  flags 
)
virtual

Reimplemented from QGLPixmapData.

Definition at line 79 of file qmeegopixmapdata.cpp.

81 {
82  void *rawResource = static_cast <void *> (((QImage &) image).data_ptr()->data);
83 
84  if (sharedImagesMap.contains(rawResource)) {
85  QMeeGoImageInfo *info = sharedImagesMap.value(rawResource);
86  fromEGLSharedImage(info->handle, image);
87  } else {
88  // This should *never* happen since the graphics system should never
89  // create a QMeeGoPixmapData for an origin that doesn't contain a raster
90  // image we know about. But...
91  qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back...");
92  QGLPixmapData::fromImage(image, flags);
93  }
94 }
static mach_timebase_info_data_t info
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 QHash< void *, QMeeGoImageInfo * > sharedImagesMap
virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
void fromImage(const QImage &image, Qt::ImageConversionFlags flags)

◆ fromTexture()

void QMeeGoPixmapData::fromTexture ( GLuint  textureId,
int  w,
int  h,
bool  alpha 
)

Definition at line 66 of file qmeegopixmapdata.cpp.

Referenced by fromEGLSharedImage().

67 {
68  resize(w, h);
69  texture()->id = textureId;
70  m_hasAlpha = alpha;
71  softImage = QImage();
72 }
QGLTexture * texture() const
GLuint id
Definition: qgl_p.h:608
void resize(int width, int height)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87

◆ imageToEGLSharedImage()

Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage ( const QImage image)
static

Definition at line 139 of file qmeegopixmapdata.cpp.

Referenced by qt_meego_image_to_egl_shared_image().

140 {
142 
144 
145  GLuint textureId;
146 
147  glGenTextures(1, &textureId);
148  glBindTexture(GL_TEXTURE_2D, textureId);
149  if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) {
150  void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine());
151  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted);
152  free(converted);
153  } else {
154  void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine());
155  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, converted);
156  free(converted);
157  }
158 
161 
164 
167  (EGLClientBuffer) textureId,
169  glDeleteTextures(1, &textureId);
170  if (eglimage) {
173  return (Qt::HANDLE) handle;
174  } else {
175  qWarning("Failed to create shared image from pixmap/texture!");
176  return 0;
177  }
178 }
#define GL_RGB
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
#define GL_TEXTURE_MIN_FILTER
static EGLint preserved_image_attribs[]
Q_OPENGL_EXPORT QGLWidget * qt_gl_share_widget()
unsigned short * convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride)
Definition: dithering.cpp:84
#define GL_TEXTURE_WRAP_S
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
#define GL_TEXTURE_2D
void * EGLNativeSharedImageTypeNOK
#define GL_UNSIGNED_SHORT_5_6_5
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
Definition: qegl.cpp:638
Q_CORE_EXPORT void qWarning(const char *,...)
void * EGLClientBuffer
Definition: qegl_p.h:70
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void * HANDLE
Definition: qnamespace.h:1671
unsigned char * convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride)
Definition: dithering.cpp:250
void * EGLImageKHR
Definition: qegl_p.h:165
#define GL_TEXTURE_WRAP_T
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
static QEglContext * currentContext(QEgl::API api)
Definition: qegl.cpp:799
static void ensureInitialized()
#define GL_UNSIGNED_BYTE
void * data_ptr(const QTransform &t)
Definition: qpainter_p.h:81
#define ctx
Definition: qgl.cpp:6094
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
#define GL_RGBA
Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
Definition: qegl.cpp:625
#define GL_TEXTURE_MAG_FILTER
static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props)
#define EGL_GL_TEXTURE_2D_KHR
#define GL_NEAREST

◆ registerSharedImage()

void QMeeGoPixmapData::registerSharedImage ( Qt::HANDLE  handle,
const QImage si 
)
static

Definition at line 206 of file qmeegopixmapdata.cpp.

Referenced by fromEGLSharedImage(), and QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage().

207 {
208  void *raw = static_cast <void *> (((QImage) si).data_ptr()->data);
210 
211  if (! sharedImagesMap.contains(raw)) {
212  info = new QMeeGoImageInfo;
213  info->handle = handle;
214  info->rawFormat = si.format();
215  sharedImagesMap.insert(raw, info);
216  } else {
217  info = sharedImagesMap.value(raw);
218  if (info->handle != handle || info->rawFormat != si.format())
219  qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different");
220  }
221 }
static mach_timebase_info_data_t info
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
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 QHash< void *, QMeeGoImageInfo * > sharedImagesMap

◆ toImage()

QImage QMeeGoPixmapData::toImage ( ) const
virtual

Reimplemented from QGLPixmapData.

Definition at line 74 of file qmeegopixmapdata.cpp.

75 {
76  return softImage;
77 }

◆ updateFromSoftImage()

void QMeeGoPixmapData::updateFromSoftImage ( )
virtual

Definition at line 180 of file qmeegopixmapdata.cpp.

Referenced by QMeeGoGraphicsSystem::updateEGLSharedImagePixmap().

181 {
182  // FIXME That's broken with recent 16bit textures changes.
183  m_dirty = true;
185  ensureCreated();
186 
187  if (softImage.width() != w || softImage.height() != h)
188  qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!");
189 }
void ensureCreated() const
Q_CORE_EXPORT void qWarning(const char *,...)
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

Properties

◆ sharedImagesMap

QHash< void *, QMeeGoImageInfo * > QMeeGoPixmapData::sharedImagesMap
static

◆ softImage

QImage QMeeGoPixmapData::softImage

Definition at line 65 of file qmeegopixmapdata.h.

Referenced by fromEGLSharedImage(), fromTexture(), toImage(), and updateFromSoftImage().


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