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

#include <qpixmapdata_x11gl_p.h>

Inheritance diagram for QX11GLPixmapData:
QX11PixmapData QGLPaintDevice QPixmapData QPaintDevice

Public Functions

void beginPaint ()
 
QGLContextcontext () const
 
void copy (const QPixmapData *data, const QRect &rect)
 
void fill (const QColor &color)
 
QPaintEnginepaintEngine () const
 
 QX11GLPixmapData ()
 
bool scroll (int dx, int dy, const QRect &rect)
 
QSize size () const
 
virtual ~QX11GLPixmapData ()
 
- Public Functions inherited from QX11PixmapData
QPixmap alphaChannel () const
 
void convertToARGB32 (bool preserveContents=true)
 
QPixmapDatacreateCompatiblePixmapData () const
 
void fromImage (const QImage &image, Qt::ImageConversionFlags flags)
 
Qt::HANDLE handle () const
 
bool hasAlphaChannel () const
 
QBitmap mask () const
 
 QX11PixmapData (PixelType type)
 
void resize (int width, int height)
 
void setAlphaChannel (const QPixmap &alphaChannel)
 
void setMask (const QBitmap &mask)
 Sets a mask bitmap. More...
 
QImage toImage () const
 Converts the pixmap to a QImage. More...
 
QImage toImage (const QRect &rect) const
 
QPixmap transformed (const QTransform &transform, Qt::TransformationMode mode) const
 Returns a copy of the pixmap that is transformed using the given transformation matrix and transformation mode. More...
 
Qt::HANDLE x11ConvertToDefaultDepth ()
 
 ~QX11PixmapData ()
 
- Public Functions inherited from QPixmapData
virtual QImagebuffer ()
 
qint64 cacheKey () const
 
ClassId classId () const
 
int colorCount () const
 
int depth () const
 
virtual bool fromData (const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
 
virtual bool fromFile (const QString &filename, const char *format, Qt::ImageConversionFlags flags)
 
virtual void fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags)
 
int height () const
 
bool isNull () const
 
QT_DEPRECATED int numColors () const
 
PixelType pixelType () const
 
 QPixmapData (PixelType pixelType, int classId)
 
virtual QPixmapDataruntimeData () const
 
int serialNumber () const
 
int width () const
 
virtual ~QPixmapData ()
 
- Public Functions inherited from QGLPaintDevice
virtual bool alphaRequested () const
 
int devType () const
 
virtual void endPaint ()
 
virtual void ensureActiveTarget ()
 
virtual QGLFormat format () const
 
virtual bool isFlipped () const
 
 QGLPaintDevice ()
 
virtual ~QGLPaintDevice ()
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
virtual HDC getDC () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
virtual void releaseDC (HDC hdc) const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Static Public Functions

static QGLFormat glFormat ()
 
static bool hasX11GLPixmaps ()
 
static QX11GLSharedContextssharedContexts ()
 
- Static Public Functions inherited from QX11PixmapData
static Qt::HANDLE createBitmapFromImage (const QImage &image)
 
- Static Public Functions inherited from QPixmapData
static QPixmapDatacreate (int w, int h, PixelType type)
 
- Static Public Functions inherited from QGLPaintDevice
static QGLPaintDevicegetDevice (QPaintDevice *)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 

Properties

QGLContextctx
 

Additional Inherited Members

- Public Types inherited from QPixmapData
enum  ClassId {
  RasterClass, X11Class, MacClass, DirectFBClass,
  OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
  CustomClass = 1024
}
 
enum  PixelType { PixmapType, BitmapType }
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 
- Public Variables inherited from QX11PixmapData
void * gl_surface
 
- Protected Functions inherited from QX11PixmapData
int metric (QPaintDevice::PaintDeviceMetric metric) const
 
- Protected Functions inherited from QPixmapData
void setSerialNumber (int serNo)
 
- Protected Functions inherited from QGLPaintDevice
int metric (QPaintDevice::PaintDeviceMetric metric) const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 
- Protected Variables inherited from QPixmapData
int d
 
int h
 
bool is_null
 
int w
 
- Protected Variables inherited from QGLPaintDevice
GLuint m_previousFBO
 
GLuint m_thisFBO
 
- Protected Variables inherited from QPaintDevice
ushort painters
 

Detailed Description

Definition at line 70 of file qpixmapdata_x11gl_p.h.

Constructors and Destructors

◆ QX11GLPixmapData()

QX11GLPixmapData::QX11GLPixmapData ( )

Definition at line 234 of file qpixmapdata_x11gl_egl.cpp.

236  ctx(0)
237 {
238 }
QX11PixmapData(PixelType type)

◆ ~QX11GLPixmapData()

QX11GLPixmapData::~QX11GLPixmapData ( )
virtual

Definition at line 240 of file qpixmapdata_x11gl_egl.cpp.

241 {
242  if (ctx)
243  delete ctx;
244 }

Functions

◆ beginPaint()

void QX11GLPixmapData::beginPaint ( )
virtual

Reimplemented from QGLPaintDevice.

Definition at line 365 of file qpixmapdata_x11gl_egl.cpp.

366 {
367 // qDebug("QX11GLPixmapData::beginPaint()");
368  // TODO: Check to see if the surface is renderable
369  if ((EGLSurface)gl_surface == EGL_NO_SURFACE) {
370  QPixmap tmpPixmap(this);
371  EGLConfig cfg = ctx->d_func()->eglContext->config();
372  Q_ASSERT(cfg != QEGL_NO_CONFIG);
373 
374 // qDebug("QX11GLPixmapData - using EGL Config ID %d", ctx->d_func()->eglContext->configAttrib(EGL_CONFIG_ID));
375  EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg);
376  if (surface == EGL_NO_SURFACE) {
377  qWarning() << "Error creating EGL surface for pixmap:" << QEgl::errorString();
378  return;
379  }
380  gl_surface = (void*)surface;
381  ctx->d_func()->eglSurface = surface;
382  ctx->d_func()->valid = true;
383  }
385 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
Q_CORE_EXPORT void qWarning(const char *,...)
#define QEGL_NO_CONFIG
Definition: qegl_p.h:129
Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs=0)
Definition: qegl_x11.cpp:333
virtual void beginPaint()
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ context()

QGLContext * QX11GLPixmapData::context ( ) const
virtual

Implements QGLPaintDevice.

Definition at line 387 of file qpixmapdata_x11gl_egl.cpp.

388 {
389  return ctx;
390 }

◆ copy()

void QX11GLPixmapData::copy ( const QPixmapData data,
const QRect rect 
)
virtual

Reimplemented from QX11PixmapData.

Definition at line 264 of file qpixmapdata_x11gl_egl.cpp.

265 {
266  if (ctx) {
267  ctx->makeCurrent();
268  glFinish();
269  eglWaitClient();
270  }
271 
272  QX11PixmapData::copy(data, rect);
273  XSync(X11->display, False);
274 
275  if (ctx) {
276  ctx->makeCurrent();
277  eglWaitNative(EGL_CORE_NATIVE_ENGINE);
278  }
279 }
#define X11
Definition: qt_x11_p.h:724
void copy(const QPixmapData *data, const QRect &rect)
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
Definition: qgl_egl.cpp:213

◆ fill()

void QX11GLPixmapData::fill ( const QColor color)
virtual

Reimplemented from QX11PixmapData.

Definition at line 247 of file qpixmapdata_x11gl_egl.cpp.

248 {
249  if (ctx) {
250  ctx->makeCurrent();
251  glFinish();
252  eglWaitClient();
253  }
254 
255  QX11PixmapData::fill(color);
256  XSync(X11->display, False);
257 
258  if (ctx) {
259  ctx->makeCurrent();
260  eglWaitNative(EGL_CORE_NATIVE_ENGINE);
261  }
262 }
#define X11
Definition: qt_x11_p.h:724
void fill(const QColor &color)
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
Definition: qgl_egl.cpp:213

◆ glFormat()

QGLFormat QX11GLPixmapData::glFormat ( )
static

Definition at line 398 of file qpixmapdata_x11gl_egl.cpp.

Referenced by paintEngine(), and QX11GLSharedContexts::QX11GLSharedContexts().

399 {
400  return QGLFormat::defaultFormat(); //###
401 }
static QGLFormat defaultFormat()
Definition: qgl.cpp:1518

◆ hasX11GLPixmaps()

bool QX11GLPixmapData::hasX11GLPixmaps ( )
static

Definition at line 220 of file qpixmapdata_x11gl_egl.cpp.

Referenced by QGLGraphicsSystem::createWindowSurface().

221 {
222  static bool checkedForX11GLPixmaps = false;
223  static bool haveX11GLPixmaps = false;
224 
225  if (checkedForX11GLPixmaps)
226  return haveX11GLPixmaps;
227 
228  haveX11GLPixmaps = qt_x11gl_share_contexts()->isValid();
229  checkedForX11GLPixmaps = true;
230 
231  return haveX11GLPixmaps;
232 }

◆ paintEngine()

QPaintEngine * QX11GLPixmapData::paintEngine ( ) const
virtual

Reimplemented from QX11PixmapData.

Definition at line 309 of file qpixmapdata_x11gl_egl.cpp.

310 {
311  // We need to create the context before beginPaint - do it here:
312  if (!ctx) {
313  ctx = new QGLContext(glFormat());
314  Q_ASSERT(ctx->d_func()->eglContext == 0);
315  ctx->d_func()->eglContext = hasAlphaChannel() ? sharedContexts()->argbContext : sharedContexts()->rgbContext;
316 
317  // While we use a separate QGLContext for each pixmap, the underlying QEglContext is
318  // the same. So we must use a "fake" QGLContext and fool the texture cache into thinking
319  // each pixmap's QGLContext is sharing with this central one. The only place this is
320  // going to fail is where we the underlying EGL RGB and ARGB contexts aren't sharing.
321  ctx->d_func()->sharing = true;
322  QGLContextGroup::addShare(ctx, sharedContexts()->sharedQGLContext);
323 
324  // Update the glFormat for the QGLContext:
325  qt_glformat_from_eglconfig(ctx->d_func()->glFormat, ctx->d_func()->eglContext->config());
326  }
327 
328  QPaintEngine* engine;
329 
330 #if defined(QT_OPENGL_ES_1)
331  engine = qt_gl_pixmap_engine();
332 #elif defined(QT_OPENGL_ES_2)
333  engine = qt_gl_pixmap_2_engine();
334 #else
335  if (qt_gl_preferGL2Engine())
336  engine = qt_gl_pixmap_2_engine();
337  else
338  engine = qt_gl_pixmap_engine();
339 #endif
340 
341 
342 
343  // Support multiple painters on multiple pixmaps simultaniously
344  if (engine->isActive()) {
345  qWarning("Pixmap paint engine already active");
346 
347 #if defined(QT_OPENGL_ES_1)
348  engine = new QOpenGLPaintEngine;
349 #elif defined(QT_OPENGL_ES_2)
350  engine = new QGL2PaintEngineEx;
351 #else
352  if (qt_gl_preferGL2Engine())
353  engine = new QGL2PaintEngineEx;
354  else
355  engine = new QOpenGLPaintEngine;
356 #endif
357 
358  engine->setAutoDestruct(true);
359  return engine;
360  }
361 
362  return engine;
363 }
void qt_glformat_from_eglconfig(QGLFormat &format, const EGLConfig config)
Definition: qgl_egl.cpp:145
static void addShare(const QGLContext *context, const QGLContext *share)
Definition: qgl.cpp:5846
static QGLFormat glFormat()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qWarning(const char *,...)
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
bool qt_gl_preferGL2Engine()
Definition: qgl.cpp:218
friend class QGLContext
bool hasAlphaChannel() const
static QX11GLSharedContexts * sharedContexts()

◆ scroll()

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

Reimplemented from QX11PixmapData.

Definition at line 281 of file qpixmapdata_x11gl_egl.cpp.

282 {
283  if (ctx) {
284  ctx->makeCurrent();
285  glFinish();
286  eglWaitClient();
287  }
288 
289  bool success = QX11PixmapData::scroll(dx, dy, rect);
290  XSync(X11->display, False);
291 
292  if (ctx) {
293  ctx->makeCurrent();
294  eglWaitNative(EGL_CORE_NATIVE_ENGINE);
295  }
296 
297  return success;
298 }
#define X11
Definition: qt_x11_p.h:724
bool scroll(int dx, int dy, const QRect &rect)
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
Definition: qgl_egl.cpp:213

◆ sharedContexts()

QX11GLSharedContexts * QX11GLPixmapData::sharedContexts ( )
static

Definition at line 215 of file qpixmapdata_x11gl_egl.cpp.

Referenced by paintEngine().

216 {
217  return qt_x11gl_share_contexts();
218 }

◆ size()

QSize QX11GLPixmapData::size ( ) const
virtual

Implements QGLPaintDevice.

Definition at line 392 of file qpixmapdata_x11gl_egl.cpp.

393 {
394  return QSize(w, h);
395 }
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

Properties

◆ ctx

QGLContext* QX11GLPixmapData::ctx
mutableprivate

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