src/opengl/qpixmapdata_x11gl_egl.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 0 1918ee327afb
child 8 3f74d0d4af4c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     8 **
     8 **
    37 **
    37 **
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
       
    42 #include <QDebug>
       
    43 
    42 #include <private/qgl_p.h>
    44 #include <private/qgl_p.h>
    43 #include <private/qegl_p.h>
    45 #include <private/qegl_p.h>
    44 #include <private/qeglproperties_p.h>
    46 #include <private/qeglproperties_p.h>
       
    47 
       
    48 #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
    45 #include <private/qpaintengineex_opengl2_p.h>
    49 #include <private/qpaintengineex_opengl2_p.h>
       
    50 #endif
       
    51 
       
    52 #ifndef QT_OPENGL_ES_2
       
    53 #include <private/qpaintengine_opengl_p.h>
       
    54 #endif
    46 
    55 
    47 #include "qpixmapdata_x11gl_p.h"
    56 #include "qpixmapdata_x11gl_p.h"
    48 
    57 
    49 QT_BEGIN_NAMESPACE
    58 QT_BEGIN_NAMESPACE
    50 
    59 
   185 
   194 
   186 QX11GLPixmapData::~QX11GLPixmapData()
   195 QX11GLPixmapData::~QX11GLPixmapData()
   187 {
   196 {
   188 }
   197 }
   189 
   198 
   190 static QGL2PaintEngineEx* qt_gl2_engine_for_pixmaps = 0;
   199 #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
       
   200 Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_pixmap_2_engine)
       
   201 #endif
       
   202 
       
   203 #ifndef QT_OPENGL_ES_2
       
   204 Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_pixmap_engine)
       
   205 #endif
       
   206 
   191 
   207 
   192 QPaintEngine* QX11GLPixmapData::paintEngine() const
   208 QPaintEngine* QX11GLPixmapData::paintEngine() const
   193 {
   209 {
   194     // We need to create the context before beginPaint - do it here:
   210     // We need to create the context before beginPaint - do it here:
   195     if (!ctx) {
   211     if (!ctx) {
   200         ctx->d_func()->eglContext->setApi(QEgl::OpenGL);
   216         ctx->d_func()->eglContext->setApi(QEgl::OpenGL);
   201         ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext
   217         ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext
   202                                                                 : qPixmapRGBSharedEglContext);
   218                                                                 : qPixmapRGBSharedEglContext);
   203     }
   219     }
   204 
   220 
   205     if (!qt_gl2_engine_for_pixmaps)
   221     QPaintEngine* engine;
   206         qt_gl2_engine_for_pixmaps = new QGL2PaintEngineEx();
   222 
       
   223 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
       
   224     engine = qt_gl_pixmap_engine();
       
   225 #elif defined(QT_OPENGL_ES_2)
       
   226     engine = qt_gl_pixmap_2_engine();
       
   227 #else
       
   228     if (qt_gl_preferGL2Engine())
       
   229         engine = qt_gl_pixmap_2_engine();
       
   230     else
       
   231         engine = qt_gl_pixmap_engine();
       
   232 #endif
       
   233 
       
   234 
   207 
   235 
   208     // Support multiple painters on multiple pixmaps simultaniously
   236     // Support multiple painters on multiple pixmaps simultaniously
   209     if (qt_gl2_engine_for_pixmaps->isActive()) {
   237     if (engine->isActive()) {
   210         qWarning("Pixmap paint engine already active");
   238         qWarning("Pixmap paint engine already active");
   211         QPaintEngine* engine = new QGL2PaintEngineEx();
   239 
       
   240 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
       
   241         engine = new QOpenGLPaintEngine;
       
   242 #elif defined(QT_OPENGL_ES_2)
       
   243         engine = new QGL2PaintEngineEx;
       
   244 #else
       
   245         if (qt_gl_preferGL2Engine())
       
   246             engine = new QGL2PaintEngineEx;
       
   247         else
       
   248             engine = new QOpenGLPaintEngine;
       
   249 #endif
       
   250 
   212         engine->setAutoDestruct(true);
   251         engine->setAutoDestruct(true);
   213         return engine;
   252         return engine;
   214     }
   253     }
   215 
   254 
   216     return qt_gl2_engine_for_pixmaps;
   255     return engine;
   217 }
   256 }
   218 
   257 
   219 void QX11GLPixmapData::beginPaint()
   258 void QX11GLPixmapData::beginPaint()
   220 {
   259 {
   221 //    qDebug("QX11GLPixmapData::beginPaint()");
   260 //    qDebug("QX11GLPixmapData::beginPaint()");