diff options
author | David Boddie <david.boddie@nokia.com> | 2010-12-07 13:57:38 (GMT) |
---|---|---|
committer | David Boddie <david.boddie@nokia.com> | 2010-12-07 13:57:38 (GMT) |
commit | d8fb8ca3a378743eebb8464f7910a5e6d1870c01 (patch) | |
tree | 9c31a017163a532946f10107b8d9f4405ed1c9db /src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp | |
parent | b5915ef3a6d0417440ad82e9369d6679505b953e (diff) | |
parent | 076bba6c901e292b61fffb7a91020075dcd84919 (diff) | |
download | Qt-d8fb8ca3a378743eebb8464f7910a5e6d1870c01.zip Qt-d8fb8ca3a378743eebb8464f7910a5e6d1870c01.tar.gz Qt-d8fb8ca3a378743eebb8464f7910a5e6d1870c01.tar.bz2 |
Merge branch 'qdoc-simplified' into mimir-simplified
Conflicts:
doc/src/platforms/compiler-notes.qdoc
tools/qdoc3/ditaxmlgenerator.cpp
tools/qdoc3/ditaxmlgenerator.h
tools/qdoc3/htmlgenerator.cpp
tools/qdoc3/htmlgenerator.h
tools/qdoc3/node.cpp
tools/qdoc3/pagegenerator.h
Diffstat (limited to 'src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp')
-rw-r--r-- | src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp index 84fc593..eb63692 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -41,12 +41,18 @@ #include "qmeegopixmapdata.h" #include "qmeegoextensions.h" +#include "qmeegorasterpixmapdata.h" #include <private/qimage_p.h> #include <private/qwindowsurface_gl_p.h> #include <private/qeglcontext_p.h> #include <private/qapplication_p.h> #include <private/qgraphicssystem_runtime_p.h> +// from dithering.cpp +extern unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride); +extern unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride); +extern unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride); + static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap; @@ -87,36 +93,6 @@ void QMeeGoPixmapData::fromImage(const QImage &image, } } -void QMeeGoPixmapData::fromEGLImage(Qt::HANDLE handle) -{ - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - QMeeGoExtensions::ensureInitialized(); - - bool textureIsBound = false; - GLuint newTextureId; - GLint newWidth, newHeight; - - glGenTextures(1, &newTextureId); - glBindTexture(GL_TEXTURE_2D, newTextureId); - - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) handle); - GLint err = glGetError(); - if (err == GL_NO_ERROR) - textureIsBound = true; - - QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_WIDTH, &newWidth); - QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_HEIGHT, &newHeight); - - if (textureIsBound) { - // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix - // for QGLPixmapData. - fromTexture(newTextureId, newWidth, newHeight, true); - } else { - qWarning("Failed to create a texture from an egl image!"); - glDeleteTextures(1, &newTextureId); - } -} - void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) { if (si.isNull()) @@ -133,12 +109,10 @@ void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) glGenTextures(1, &newTextureId); glBindTexture(GL_TEXTURE_2D, newTextureId); - glFinish(); EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK, (EGLClientBuffer)handle, preserved_image_attribs); if (image != EGL_NO_IMAGE_KHR) { - glFinish(); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); GLint err = glGetError(); if (err == GL_NO_ERROR) @@ -148,14 +122,12 @@ void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); QEgl::eglDestroyImageKHR(QEgl::display(), image); - glFinish(); } if (textureIsBound) { - // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix - // for QGLPixmapData. fromTexture(newTextureId, newWidth, newHeight, (si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels())); + texture()->options &= ~QGLContext::InvertedYBindOption; softImage = si; QMeeGoPixmapData::registerSharedImage(handle, softImage); } else { @@ -170,22 +142,32 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image) QMeeGoExtensions::ensureInitialized(); - glFinish(); - QGLPixmapData pixmapData(QPixmapData::PixmapType); - pixmapData.fromImage(image, 0); - GLuint textureId = pixmapData.bind(); + GLuint textureId; + + glGenTextures(1, &textureId); + glBindTexture(GL_TEXTURE_2D, textureId); + if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) { + void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted); + free(converted); + } else { + void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, converted); + free(converted); + } - glFinish(); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + glBindTexture(GL_TEXTURE_2D, textureId); EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(), EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer) textureId, preserved_image_attribs); - glFinish(); - + glDeleteTextures(1, &textureId); if (eglimage) { EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); - glFinish(); return (Qt::HANDLE) handle; } else { qWarning("Failed to create shared image from pixmap/texture!"); @@ -195,6 +177,7 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image) void QMeeGoPixmapData::updateFromSoftImage() { + // FIXME That's broken with recent 16bit textures changes. m_dirty = true; m_source = softImage; ensureCreated(); @@ -234,3 +217,8 @@ void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different"); } } + +QPixmapData *QMeeGoPixmapData::createCompatiblePixmapData() const +{ + return new QMeeGoRasterPixmapData(pixelType()); +} |