48 #if !defined(QT_NO_EGL) 53 #if !defined(EGL_RENDER_BUFFER) || !defined(EGL_SINGLE_BUFFER) 54 #if defined(QVG_DIRECT_TO_WINDOW) 55 #undef QVG_DIRECT_TO_WINDOW 60 #if !defined(EGL_SWAP_BEHAVIOR) || !defined(EGL_BUFFER_PRESERVED) 61 #if !defined(QVG_NO_PRESERVED_SWAP) 62 #define QVG_NO_PRESERVED_SWAP 1 79 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT 81 if ((type & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0)
88 if (red == 8 && green == 8 && blue == 8 && alpha == 8)
90 else if (red == 8 && green == 8 && blue == 8 && alpha == 0)
92 else if (red == 5 && green == 6 && blue == 5 && alpha == 0)
94 else if (red == 4 && green == 4 && blue == 4 && alpha == 4)
100 #if !defined(QVG_NO_SINGLE_CONTEXT) 204 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT 208 return context->
configAttrib(EGL_SURFACE_TYPE) & EGL_VG_ALPHA_FORMAT_PRE_BIT;
228 #ifdef EGL_RENDERABLE_TYPE 232 EGLint cfgId = configId.
toInt();
234 EGL_CONFIG_ID, cfgId,
250 if (cfgId ==
id && (type & EGL_OPENVG_BIT) != 0) {
258 qWarning(
"QT_VG_EGL_CONFIG: %d is not a valid OpenVG configuration",
int(cfgId));
267 int redSize = configProps.
value(EGL_RED_SIZE);
268 if (redSize == EGL_DONT_CARE || redSize == 0)
270 configProps.
setValue(EGL_ALPHA_MASK_SIZE, 1);
271 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT 272 configProps.
setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT
273 | EGL_SWAP_BEHAVIOR_PRESERVED_BIT
274 | EGL_VG_ALPHA_FORMAT_PRE_BIT);
278 configProps.
setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
285 configProps.
setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
302 #if !defined(QVG_NO_SINGLE_CONTEXT) 325 if (shared->
surface != EGL_NO_SURFACE) {
327 shared->
surface = EGL_NO_SURFACE;
364 if (shared->
context != context) {
387 if (shared->
surface == EGL_NO_SURFACE) {
389 attribs[0] = EGL_WIDTH;
391 attribs[2] = EGL_HEIGHT;
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;
401 attribs[4] = EGL_NONE;
403 shared->
surface = eglCreatePbufferSurface
425 return EGL_NO_SURFACE;
439 destroyPaintEngine();
451 return VG_INVALID_HANDLE;
466 QRect rect = winSurface->geometry();
469 #if defined(Q_WS_QWS) 481 #if defined(QVG_VGIMAGE_BACKBUFFERS) 483 QVGEGLWindowSurfaceVGImage::QVGEGLWindowSurfaceVGImage(
QWindowSurface *win)
486 , backBuffer(VG_INVALID_HANDLE)
487 , backBufferSurface(EGL_NO_SURFACE)
488 , recreateBackBuffer(
false)
489 , isPaintingActive(
false)
490 , windowSurface(EGL_NO_SURFACE)
494 QVGEGLWindowSurfaceVGImage::~QVGEGLWindowSurfaceVGImage()
496 destroyPaintEngine();
498 if (backBufferSurface != EGL_NO_SURFACE) {
504 vgDestroyImage(backBuffer);
507 if (windowSurface != EGL_NO_SURFACE)
515 QSize newSize = windowSurfaceSize(widget);
516 if (context && size != newSize) {
520 if (isPaintingActive)
522 isPaintingActive =
false;
523 recreateBackBuffer =
true;
531 isPaintingActive =
false;
536 void QVGEGLWindowSurfaceVGImage::beginPaint(
QWidget *widget)
540 if (recreateBackBuffer || backBufferSurface == EGL_NO_SURFACE) {
545 recreateBackBuffer =
false;
546 if (backBufferSurface != EGL_NO_SURFACE) {
548 backBufferSurface = EGL_NO_SURFACE;
550 if (backBuffer != VG_INVALID_HANDLE) {
551 vgDestroyImage(backBuffer);
554 backBuffer = vgCreateImage
555 (format, size.width(), size.height(),
556 VG_IMAGE_QUALITY_FASTER);
557 if (backBuffer != VG_INVALID_HANDLE) {
559 backBufferSurface = eglCreatePbufferFromClientBuffer
563 if (backBufferSurface == EGL_NO_SURFACE) {
564 vgDestroyImage(backBuffer);
565 backBuffer = VG_INVALID_HANDLE;
569 if (backBufferSurface != EGL_NO_SURFACE)
573 isPaintingActive =
true;
577 void QVGEGLWindowSurfaceVGImage::endPaint
584 if (backBufferSurface != EGL_NO_SURFACE) {
585 if (isPaintingActive)
589 isPaintingActive =
false;
593 VGImage QVGEGLWindowSurfaceVGImage::surfaceImage()
const 598 EGLSurface QVGEGLWindowSurfaceVGImage::mainSurface()
const 600 if (windowSurface != EGL_NO_SURFACE)
601 return windowSurface;
606 #endif // QVG_VGIMAGE_BACKBUFFERS 611 , isPaintingActive(false)
613 , windowSurface(EGL_NO_SURFACE)
632 #if defined(QVG_RECREATE_ON_SIZE_CHANGE) 633 #if !defined(QVG_NO_SINGLE_CONTEXT) 634 if (context &&
size != newSize) {
641 #if defined(EGL_VG_ALPHA_FORMAT_PRE_BIT) 642 if (isPremultipliedContext(context)) {
644 (EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE);
654 if (context &&
size != newSize) {
676 #if defined(QVG_DIRECT_TO_WINDOW) 677 surfaceProps.
setValue(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
679 #if defined(EGL_VG_ALPHA_FORMAT_PRE_BIT) 680 if (isPremultipliedContext(context)) {
682 (EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE);
687 EGLSurface surface = context->
createSurface(widget, &surfaceProps);
688 if (surface == EGL_NO_SURFACE) {
696 #if defined(QVG_DIRECT_TO_WINDOW) 700 EGL_RENDER_BUFFER, &buffer) &&
701 buffer == EGL_SINGLE_BUFFER) {
709 #if !defined(QVG_NO_PRESERVED_SWAP) 713 EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
714 if (!succeeded && eglGetError() != EGL_SUCCESS) {
715 qWarning(
"QVG: could not enable preserved swap");
753 #if defined(QVG_BUFFER_SCROLLING) && !defined(QVG_NO_PRESERVED_SWAP) 762 #ifdef QVG_BUFFER_SCROLLING 767 int sx = scrollRect.
x();
769 vgSeti(VG_SCISSORING, VG_FALSE);
770 vgCopyPixels(sx + dx, sy - dy, sx, sy, scrollRect.
width(), scrollRect.
height());
Format
The following image formats are available in Qt.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties=0)
#define QT_END_NAMESPACE
This macro expands to.
bool createContext(QEglContext *shareContext=0, const QEglProperties *properties=0)
QPointer< QWidget > widget
void qt_vg_hibernate_pixmaps(QVGSharedContext *shared)
QVGPaintEngine * qt_vg_create_paint_engine(void)
bool removeValue(int name)
virtual ~QVGEGLWindowSurfaceDirect()
QVGEGLWindowSurfacePrivate(QWindowSurface *win)
The QByteArray class provides an array of bytes.
EGLSurface qt_vg_shared_surface(void)
void qt_vg_destroy_paint_engine(QVGPaintEngine *engine)
int value(int name) const
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
int width() const
Returns the width of the rectangle.
bool chooseConfig(const QEglProperties &properties, QEgl::PixelFormatMatch match=QEgl::ExactPixelFormat)
QRect boundingRect() const
Returns the bounding rectangle of this region.
int height() const
Returns the height of the rectangle.
void setValue(int name, int value)
bool swapBuffers(EGLSurface surface)
QImage::Format qt_vg_config_to_image_format(QEglContext *context)
QVGPixmapData * firstPixmap
QEglContext * qt_vg_create_context(QPaintDevice *device, int devType)
EGLContext context() const
QVGPaintEngine * paintEngine()
void setApi(QEgl::API api)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
void destroyPaintEngine()
void endPaint(QWidget *widget, const QRegion ®ion, QImage *image)
void setRenderableType(QEgl::API api)
Q_GLOBAL_STATIC(QVGSharedContext, sharedContext)
virtual ~QVGEGLWindowSurfacePrivate()
virtual VGImage surfaceImage() const
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
QSize size() const
Returns the size of the rectangle.
void qt_vg_destroy_context(QEglContext *context, int devType)
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
static void qt_vg_destroy_shared_context(QVGSharedContext *shared)
static QEglContext * createContext(QPaintDevice *device)
The QRegion class specifies a clip region for a painter.
QSize windowSurfaceSize(QWidget *widget) const
QVGEGLWindowSurfaceDirect(QWindowSurface *win)
The QWindowSurface class provides the drawing area for top-level windows.
int configAttrib(int name) const
QEglContext * ensureContext(QWidget *widget)
static QVGImagePool * instance()
int y() const
Returns the y-coordinate of the rectangle's top edge.
bool makeCurrent(EGLSurface surface)
VGImageFormat qt_vg_config_to_vg_format(QEglContext *context)
int x() const
Returns the x-coordinate of the rectangle's left edge.
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
void destroySurface(EGLSurface surface)
void setConfig(EGLConfig config)
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
void setPaintDeviceFormat(QPaintDevice *dev)
static const QCssKnownValue properties[NumProperties - 1]
void setPixelFormat(QImage::Format pixelFormat)
void beginPaint(QWidget *widget)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
void qt_vg_unregister_pixmap(QVGPixmapData *pd)
virtual bool supportsStaticContents() const
void qt_vg_register_pixmap(QVGPixmapData *pd)
bool supportsStaticContents() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool scroll(QWidget *widget, const QRegion &area, int dx, int dy)
static int area(const QSize &s)
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.