src/opengl/qpaintengine_opengl.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   108 #define DEBUG_ONCE_STR(str) DEBUG_ONCE qDebug() << (str);
   108 #define DEBUG_ONCE_STR(str) DEBUG_ONCE qDebug() << (str);
   109 #endif
   109 #endif
   110 
   110 
   111 static inline void qt_glColor4ubv(unsigned char *col)
   111 static inline void qt_glColor4ubv(unsigned char *col)
   112 {
   112 {
   113 #ifdef QT_OPENGL_ES
   113     glColor4f(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, col[3]/255.0f);
   114         glColor4f(col[0]/255.0, col[1]/255.0, col[2]/255.0, col[3]/255.0);
       
   115 #else
       
   116         glColor4ubv(col);
       
   117 #endif
       
   118 }
   114 }
   119 
   115 
   120 struct QT_PointF {
   116 struct QT_PointF {
   121     qreal x;
   117     qreal x;
   122     qreal y;
   118     qreal y;
   246           mask_dim(0),
   242           mask_dim(0),
   247           activated(false),
   243           activated(false),
   248           bound(false)
   244           bound(false)
   249     {
   245     {
   250         connect(QGLSignalProxy::instance(),
   246         connect(QGLSignalProxy::instance(),
   251                 SIGNAL(aboutToDestroyContext(const QGLContext *)),
   247                 SIGNAL(aboutToDestroyContext(const QGLContext*)),
   252                 SLOT(cleanupGLContextRefs(const QGLContext *)));
   248                 SLOT(cleanupGLContextRefs(const QGLContext*)));
   253     }
   249     }
   254 
   250 
   255     inline void setDevice(QPaintDevice *pdev);
   251     inline void setDevice(QPaintDevice *pdev);
   256 
   252 
   257     void begin();
   253     void begin();
   523     Q_OBJECT
   519     Q_OBJECT
   524 public:
   520 public:
   525     QGLProgramCache() {
   521     QGLProgramCache() {
   526         // we have to know when a context is deleted so we can free
   522         // we have to know when a context is deleted so we can free
   527         // any program handles it holds
   523         // any program handles it holds
   528         connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext *)),
   524         connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)),
   529                 SLOT(cleanupPrograms(const QGLContext *)));
   525                 SLOT(cleanupPrograms(const QGLContext*)));
   530 
   526 
   531     }
   527     }
   532     ~QGLProgramCache() {
   528     ~QGLProgramCache() {
   533         // at this point the cache should contain 0 elements
   529         // at this point the cache should contain 0 elements
   534         // Q_ASSERT(program.size() == 0);
   530         // Q_ASSERT(program.size() == 0);
   637 public:
   633 public:
   638     QGLPrivateCleanup(QOpenGLPaintEnginePrivate *priv)
   634     QGLPrivateCleanup(QOpenGLPaintEnginePrivate *priv)
   639         : p(priv)
   635         : p(priv)
   640     {
   636     {
   641         connect(QGLSignalProxy::instance(),
   637         connect(QGLSignalProxy::instance(),
   642                 SIGNAL(aboutToDestroyContext(const QGLContext *)),
   638                 SIGNAL(aboutToDestroyContext(const QGLContext*)),
   643                 SLOT(cleanupGLContextRefs(const QGLContext *)));
   639                 SLOT(cleanupGLContextRefs(const QGLContext*)));
   644     }
   640     }
   645 
   641 
   646 public Q_SLOTS:
   642 public Q_SLOTS:
   647     void cleanupGLContextRefs(const QGLContext *context);
   643     void cleanupGLContextRefs(const QGLContext *context);
   648 
   644 
  1008 
  1004 
  1009 public:
  1005 public:
  1010     QGLGradientCache() : QObject(), buffer_ctx(0)
  1006     QGLGradientCache() : QObject(), buffer_ctx(0)
  1011     {
  1007     {
  1012         connect(QGLSignalProxy::instance(),
  1008         connect(QGLSignalProxy::instance(),
  1013                 SIGNAL(aboutToDestroyContext(const QGLContext *)),
  1009                 SIGNAL(aboutToDestroyContext(const QGLContext*)),
  1014                 SLOT(cleanupGLContextRefs(const QGLContext *)));
  1010                 SLOT(cleanupGLContextRefs(const QGLContext*)));
  1015     }
  1011     }
  1016 
  1012 
  1017     inline GLuint getBuffer(const QGradient &gradient, qreal opacity, QGLContext *ctx) {
  1013     inline GLuint getBuffer(const QGradient &gradient, qreal opacity, QGLContext *ctx) {
  1018         if (buffer_ctx && !QGLContext::areSharing(buffer_ctx, ctx))
  1014         if (buffer_ctx && !QGLContext::areSharing(buffer_ctx, ctx))
  1019             cleanCache();
  1015             cleanCache();
  4710         qt_context_cache.insert(context, font_cache);
  4706         qt_context_cache.insert(context, font_cache);
  4711         if (context->isValid() && context->device()->devType() == QInternal::Widget) {
  4707         if (context->isValid() && context->device()->devType() == QInternal::Widget) {
  4712             QWidget *widget = static_cast<QWidget *>(context->device());
  4708             QWidget *widget = static_cast<QWidget *>(context->device());
  4713             connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
  4709             connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*)));
  4714             connect(QGLSignalProxy::instance(),
  4710             connect(QGLSignalProxy::instance(),
  4715                     SIGNAL(aboutToDestroyContext(const QGLContext *)),
  4711                     SIGNAL(aboutToDestroyContext(const QGLContext*)),
  4716                     SLOT(cleanupContext(const QGLContext *)));
  4712                     SLOT(cleanupContext(const QGLContext*)));
  4717         }
  4713         }
  4718     } else {
  4714     } else {
  4719         font_cache = dev_it.value();
  4715         font_cache = dev_it.value();
  4720     }
  4716     }
  4721     Q_ASSERT(font_cache != 0);
  4717     Q_ASSERT(font_cache != 0);