Qt 4.8
Macros | Functions
qvg_p.h File Reference
#include "qvg.h"
#include <QtGui/qimage.h>
#include <QtGui/private/qeglcontext_p.h>

Go to the source code of this file.

Macros

#define QVG_NO_DRAW_GLYPHS   1
 

Functions

Q_OPENVG_EXPORT QImage::Format qt_vg_config_to_image_format (QEglContext *context)
 
Q_OPENVG_EXPORT VGImageFormat qt_vg_config_to_vg_format (QEglContext *context)
 
Q_OPENVG_EXPORT QEglContextqt_vg_create_context (QPaintDevice *device, int devType)
 
Q_OPENVG_EXPORT QVGPaintEngineqt_vg_create_paint_engine (void)
 
Q_OPENVG_EXPORT void qt_vg_destroy_context (QEglContext *context, int devType)
 
Q_OPENVG_EXPORT void qt_vg_destroy_paint_engine (QVGPaintEngine *engine)
 
Q_OPENVG_EXPORT VGImageFormat qt_vg_image_to_vg_format (QImage::Format format)
 
Q_OPENVG_EXPORT EGLSurface qt_vg_shared_surface (void)
 

Macro Definition Documentation

◆ QVG_NO_DRAW_GLYPHS

#define QVG_NO_DRAW_GLYPHS   1

Definition at line 60 of file qvg_p.h.

Function Documentation

◆ qt_vg_config_to_image_format()

Q_OPENVG_EXPORT QImage::Format qt_vg_config_to_image_format ( QEglContext context)

Definition at line 72 of file qwindowsurface_vgegl.cpp.

Referenced by qt_vg_config_to_vg_format().

73 {
74  EGLint red = context->configAttrib(EGL_RED_SIZE);
75  EGLint green = context->configAttrib(EGL_GREEN_SIZE);
76  EGLint blue = context->configAttrib(EGL_BLUE_SIZE);
77  EGLint alpha = context->configAttrib(EGL_ALPHA_SIZE);
78  QImage::Format argbFormat;
79 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
80  EGLint type = context->configAttrib(EGL_SURFACE_TYPE);
81  if ((type & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0)
83  else
84  argbFormat = QImage::Format_ARGB32;
85 #else
86  argbFormat = QImage::Format_ARGB32;
87 #endif
88  if (red == 8 && green == 8 && blue == 8 && alpha == 8)
89  return argbFormat;
90  else if (red == 8 && green == 8 && blue == 8 && alpha == 0)
91  return QImage::Format_RGB32;
92  else if (red == 5 && green == 6 && blue == 5 && alpha == 0)
93  return QImage::Format_RGB16;
94  else if (red == 4 && green == 4 && blue == 4 && alpha == 4)
96  else
97  return argbFormat; // XXX
98 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
int type
Definition: qmetatype.cpp:239
int configAttrib(int name) const
Definition: qegl.cpp:568

◆ qt_vg_config_to_vg_format()

Q_OPENVG_EXPORT VGImageFormat qt_vg_config_to_vg_format ( QEglContext context)

Definition at line 66 of file qwindowsurface_vgegl.cpp.

Referenced by QVGEGLWindowSurfacePrivate::windowSurfaceSize().

67 {
70 }
VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
QImage::Format qt_vg_config_to_image_format(QEglContext *context)

◆ qt_vg_create_context()

Q_OPENVG_EXPORT QEglContext* qt_vg_create_context ( QPaintDevice device,
int  devType 
)

Definition at line 304 of file qwindowsurface_vgegl.cpp.

Referenced by QVGPixmapData::destroyImageAndContext(), QVGEGLWindowSurfaceDirect::ensureContext(), qt_vg_shared_surface(), QVGPixmapData::toVGImage(), and QVGEGLWindowSurfacePrivate::windowSurfaceSize().

305 {
306  QVGSharedContext *shared = sharedContext();
307  if (devType == QInternal::Widget)
308  ++(shared->widgetRefCount);
309  if (shared->context) {
310  ++(shared->refCount);
311  return shared->context;
312  } else {
313  shared->context = createContext(device);
314  shared->refCount = 1;
315  return shared->context;
316  }
317 }
static QEglContext * createContext(QPaintDevice *device)

◆ qt_vg_create_paint_engine()

Q_OPENVG_EXPORT QVGPaintEngine* qt_vg_create_paint_engine ( void  )

Definition at line 144 of file qwindowsurface_vgegl.cpp.

Referenced by QVGEGLWindowSurfacePrivate::paintEngine(), qt_vg_unregister_pixmap(), and QVGCompositionHelper::QVGCompositionHelper().

145 {
146  QVGSharedContext *shared = sharedContext();
147  if (!shared->engine)
148  shared->engine = new QVGPaintEngine();
149  return shared->engine;
150 }
QVGPaintEngine * engine

◆ qt_vg_destroy_context()

Q_OPENVG_EXPORT void qt_vg_destroy_context ( QEglContext context,
int  devType 
)

Definition at line 361 of file qwindowsurface_vgegl.cpp.

Referenced by QVGPixmapData::destroyImageAndContext(), QVGEGLWindowSurfaceDirect::ensureContext(), qt_vg_shared_surface(), QVGEGLWindowSurfacePrivate::windowSurfaceSize(), and QVGEGLWindowSurfaceDirect::~QVGEGLWindowSurfaceDirect().

362 {
363  QVGSharedContext *shared = sharedContext();
364  if (shared->context != context) {
365  // This is not the shared context. Shouldn't happen!
366  delete context;
367  return;
368  }
369  if (devType == QInternal::Widget)
370  --(shared->widgetRefCount);
371  if (--(shared->refCount) <= 0) {
373  } else if (shared->widgetRefCount <= 0 && devType == QInternal::Widget) {
374  // All of the widget window surfaces have been destroyed
375  // but we still have VG pixmaps active. Ask them to hibernate
376  // to free up GPU resources until a widget is shown again.
377  // This may eventually cause the EGLContext to be destroyed
378  // because nothing in the system needs a context, which will
379  // free up even more GPU resources.
380  qt_vg_hibernate_pixmaps(shared);
381  }
382 }
void qt_vg_hibernate_pixmaps(QVGSharedContext *shared)
static void qt_vg_destroy_shared_context(QVGSharedContext *shared)

◆ qt_vg_destroy_paint_engine()

Q_OPENVG_EXPORT void qt_vg_destroy_paint_engine ( QVGPaintEngine engine)

Definition at line 152 of file qwindowsurface_vgegl.cpp.

Referenced by QVGEGLWindowSurfacePrivate::destroyPaintEngine(), QVGEGLWindowSurfaceDirect::ensureContext(), and qt_vg_unregister_pixmap().

153 {
154  Q_UNUSED(engine);
155 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qt_vg_image_to_vg_format()

Q_OPENVG_EXPORT VGImageFormat qt_vg_image_to_vg_format ( QImage::Format  format)

Definition at line 4239 of file qpaintengine_vg.cpp.

Referenced by QVGPaintEngine::canVgWritePixels(), QVGPaintEngine::drawImage(), drawImageTiled(), QVGPixmapData::ensureReadback(), qt_vg_config_to_vg_format(), and QVGPixmapData::toVGImage().

4240 {
4241  switch (format) {
4243  return VG_BW_1;
4245  return VG_sL_8;
4247  return VG_sARGB_8888_PRE;
4248  case QImage::Format_RGB32:
4249  return VG_sXRGB_8888;
4250  case QImage::Format_ARGB32:
4251  return VG_sARGB_8888;
4252  case QImage::Format_RGB16:
4253  return VG_sRGB_565;
4255  return VG_sARGB_4444;
4256  default:
4257  break;
4258  }
4259  return VG_sARGB_8888; // XXX
4260 }

◆ qt_vg_shared_surface()

Q_OPENVG_EXPORT EGLSurface qt_vg_shared_surface ( void  )

Definition at line 384 of file qwindowsurface_vgegl.cpp.

Referenced by QVGPixmapData::destroyImageAndContext(), qt_vg_destroy_shared_context(), qt_vg_hibernate_pixmaps(), QVGEGLWindowSurfacePrivate::windowSurfaceSize(), and QVGSharedContext::~QVGSharedContext().

385 {
386  QVGSharedContext *shared = sharedContext();
387  if (shared->surface == EGL_NO_SURFACE) {
388  EGLint attribs[7];
389  attribs[0] = EGL_WIDTH;
390  attribs[1] = 16;
391  attribs[2] = EGL_HEIGHT;
392  attribs[3] = 16;
393 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
394  if (isPremultipliedContext(shared->context)) {
395  attribs[4] = EGL_VG_ALPHA_FORMAT;
396  attribs[5] = EGL_VG_ALPHA_FORMAT_PRE;
397  attribs[6] = EGL_NONE;
398  } else
399 #endif
400  {
401  attribs[4] = EGL_NONE;
402  }
403  shared->surface = eglCreatePbufferSurface
404  (QEgl::display(), shared->context->config(), attribs);
405  }
406  return shared->surface;
407 }
EGLConfig config() const
Definition: qeglcontext_p.h:96
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589