diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-02-12 15:53:40 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-02-12 15:56:24 (GMT) |
commit | 040151b51780084f3a2b764bab7e2359677eb0b1 (patch) | |
tree | c251bb56b21d1a42f0a41dbed4694ff06b6f084b /src/opengl | |
parent | e5ee4c3c8a621c24117f004f4c137f8a531d7ea4 (diff) | |
download | Qt-040151b51780084f3a2b764bab7e2359677eb0b1.zip Qt-040151b51780084f3a2b764bab7e2359677eb0b1.tar.gz Qt-040151b51780084f3a2b764bab7e2359677eb0b1.tar.bz2 |
Moved 'hasAlpha' property from GL2 engine to GL paint device.
Got rid of an ugly switch statement.
Reviewed-by: Tom
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 23 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 7 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice.cpp | 5 | ||||
-rw-r--r-- | src/opengl/qglpaintdevice_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 5 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_gl_p.h | 1 |
8 files changed, 23 insertions, 24 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 143b2e9..8235a5c 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1233,7 +1233,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->deviceHasAlpha || txtype > QTransform::TxTranslate + if (d->device->alphaRequested() || txtype > QTransform::TxTranslate || (state()->composition_mode != QPainter::CompositionMode_Source && state()->composition_mode != QPainter::CompositionMode_SourceOver)) { @@ -1529,27 +1529,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); d->stencilClean = true; - switch (pdev->devType()) { - case QInternal::Pixmap: - d->deviceHasAlpha = static_cast<QPixmap *>(pdev)->hasAlphaChannel(); - break; - case QInternal::FramebufferObject: - { - GLenum f = static_cast<QGLFramebufferObject *>(pdev)->format().internalTextureFormat(); - d->deviceHasAlpha = (f != GL_RGB -#ifndef QT_OPENGL_ES - && f != GL_RGB5 && f != GL_RGB8 -#endif - ); - } - break; - default: - // widget, pbuffer - d->deviceHasAlpha = d->ctx->d_func()->reqFormat.alpha(); - break; - } - - // Calling begin paint should make the correct context current. So, any // code which calls into GL or otherwise needs a current context *must* // go after beginPaint: diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index fe577be..8fa0eff 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -278,7 +278,6 @@ public: bool needsSync; bool multisamplingAlwaysEnabled; - bool deviceHasAlpha; GLfloat depthRange[2]; diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index ce80796..dd6a3d5 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -329,6 +329,13 @@ void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, } else if (attachment == QGLFramebufferObject::Depth) { fboFormat.setDepth(true); } + + GLenum format = f->format().internalTextureFormat(); + reqAlpha = (format != GL_RGB +#ifndef QT_OPENGL_ES + && format != GL_RGB5 && format != GL_RGB8 +#endif + ); } QGLContext *QGLFBOGLPaintDevice::context() const diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index d7f96a5..d8ff012 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -111,14 +111,16 @@ public: virtual QSize size() const {return fbo->size();} virtual QGLContext* context() const; virtual QGLFormat format() const {return fboFormat;} + virtual bool alphaRequested() const { return reqAlpha; } void setFBO(QGLFramebufferObject* f, QGLFramebufferObject::Attachment attachment); private: - bool wasBound; QGLFramebufferObject* fbo; QGLFormat fboFormat; + bool wasBound; + bool reqAlpha; }; class QGLFramebufferObjectPrivate diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 7697570..8ba0108 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -128,6 +128,11 @@ QGLFormat QGLPaintDevice::format() const return context()->format(); } +bool QGLPaintDevice::alphaRequested() const +{ + return context()->d_func()->reqFormat.alpha(); +} + diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index 9815467..3d669da 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -75,6 +75,7 @@ public: virtual QGLContext* context() const = 0; virtual QGLFormat format() const; virtual QSize size() const = 0; + virtual bool alphaRequested() const; // returns the QGLPaintDevice for the given QPaintDevice static QGLPaintDevice* getDevice(QPaintDevice*); diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index aa80664..653e805 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -234,6 +234,11 @@ QSize QGLPixmapGLPaintDevice::size() const return data->size(); } +bool QGLPixmapGLPaintDevice::alphaRequested() const +{ + return data->m_hasAlpha; +} + void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d) { data = d; diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index e3ba5f8..c239bcb 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -88,6 +88,7 @@ public: void endPaint(); QGLContext* context() const; QSize size() const; + bool alphaRequested() const; void setPixmapData(QGLPixmapData*); private: |