summaryrefslogtreecommitdiffstats
path: root/src/opengl/qpixmapdata_gl.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-15 14:42:10 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-15 15:15:20 (GMT)
commitb5106b1b99a749653c58719c333411b9ce374b67 (patch)
tree86327ee5e8c6b8ed632981b791a06a2a578e65e4 /src/opengl/qpixmapdata_gl.cpp
parent08554b7e8e58c685879881b17bdf65c5f4594c3c (diff)
downloadQt-b5106b1b99a749653c58719c333411b9ce374b67.zip
Qt-b5106b1b99a749653c58719c333411b9ce374b67.tar.gz
Qt-b5106b1b99a749653c58719c333411b9ce374b67.tar.bz2
Optimized QPixmap::fill for GL backend when pixmap is used as is.
When QGLPixmapData is bound after a fill(), without being painted on in the mean-time, it's cheaper to directly generate a source image than to go through convertToGLFormat(), since all the pixels in the image will have the same value. Reviewed-by: Trond
Diffstat (limited to 'src/opengl/qpixmapdata_gl.cpp')
-rw-r--r--src/opengl/qpixmapdata_gl.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index ba4663f..83ebece 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -568,6 +568,7 @@ QPaintEngine* QGLPixmapData::paintEngine() const
return m_source.paintEngine();
}
+extern QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format);
// If copyBack is true, bind will copy the contents of the render
// FBO to the texture (which is not bound to the texture, as it's
@@ -577,17 +578,26 @@ GLuint QGLPixmapData::bind(bool copyBack) const
if (m_renderFbo && copyBack) {
copyBackFromRenderFbo(true);
} else {
- if (m_hasFillColor) {
- m_dirty = true;
- m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
- m_source.fill(PREMUL(m_fillColor.rgba()));
- m_hasFillColor = false;
- }
ensureCreated();
}
GLuint id = m_texture.id;
glBindTexture(GL_TEXTURE_2D, id);
+
+ if (m_hasFillColor) {
+ if (!useFramebufferObjects()) {
+ m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
+ m_source.fill(PREMUL(m_fillColor.rgba()));
+ }
+
+ m_hasFillColor = false;
+
+ GLenum format = qt_gl_preferredTextureFormat();
+ QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
+ tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.bits());
+ }
+
return id;
}