summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-19 08:39:40 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-19 08:39:40 (GMT)
commit928f902015a0ad97279ce6e2ac4cb85e5baed684 (patch)
treec3afd6f5b72b32136ab9d40788e1cf05d7b91763 /src/opengl/gl2paintengineex
parent17d6f2a59fe2b170087cdf7074807c6a2dce1043 (diff)
parent5fb5c01bd0ac234eaca890d97053c7b0772861a3 (diff)
downloadQt-928f902015a0ad97279ce6e2ac4cb85e5baed684.zip
Qt-928f902015a0ad97279ce6e2ac4cb85e5baed684.tar.gz
Qt-928f902015a0ad97279ce6e2ac4cb85e5baed684.tar.bz2
Merge commit 'qt/master' into kinetic-graphicseffect
Conflicts: src/gui/graphicsview/qgraphicsitem_p.h
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
2 files changed, 31 insertions, 12 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index 842cac4..cf930f3 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -73,8 +73,8 @@ static const char* const qglslMainVertexShader = "\
}";
static const char* const qglslMainWithTexCoordsVertexShader = "\
- attribute lowp vec2 textureCoordArray; \
- varying lowp vec2 textureCoords; \
+ attribute mediump vec2 textureCoordArray; \
+ varying mediump vec2 textureCoords; \
uniform highp float depth;\
void setPosition();\
void main(void) \
@@ -284,7 +284,7 @@ static const char* const qglslSolidBrushSrcFragmentShader = "\
}";
static const char* const qglslImageSrcFragmentShader = "\
- varying highp vec2 textureCoords; \
+ varying mediump vec2 textureCoords; \
uniform sampler2D imageTexture; \
lowp vec4 srcPixel() { \
return texture2D(imageTexture, textureCoords); \
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index b415b13..c1e39a7 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -75,6 +75,7 @@
#include <private/qfontengine_p.h>
#include <private/qtextureglyphcache_p.h>
#include <private/qpixmapdata_gl_p.h>
+#include <private/qdatabuffer_p.h>
#include "qglgradientcache_p.h"
#include "qglengineshadermanager_p.h"
@@ -175,7 +176,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
m_height = height;
QVarLengthArray<uchar> data(width * height);
- for (int i = 0; i < width * height; ++i)
+ for (int i = 0; i < data.size(); ++i)
data[i] = 0;
if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
@@ -200,13 +201,18 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
- GLuint colorBuffer;
- glGenRenderbuffers(1, &colorBuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorBuffer);
- glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, oldWidth, oldHeight);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, colorBuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
+ GLuint tmp_texture;
+ glGenTextures(1, &tmp_texture);
+ glBindTexture(GL_TEXTURE_2D, tmp_texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, tmp_texture, 0);
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
glBindTexture(GL_TEXTURE_2D, oldTexture);
@@ -237,11 +243,24 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
glBindTexture(GL_TEXTURE_2D, m_texture);
+
+#ifdef QT_OPENGL_ES_2
+ QDataBuffer<uchar> buffer(4*oldWidth*oldHeight);
+ glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data());
+
+ // do an in-place conversion from GL_RGBA to GL_ALPHA
+ for (int i=0; i<oldWidth*oldHeight; ++i)
+ buffer.data()[i] = buffer.at(4*i + 3);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight,
+ GL_ALPHA, GL_UNSIGNED_BYTE, buffer.data());
+#else
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
+#endif
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, 0);
- glDeleteRenderbuffers(1, &colorBuffer);
+ glDeleteTextures(1, &tmp_texture);
glDeleteTextures(1, &oldTexture);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);