Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RasterPixmapData until we fix QEglGLPixmapData properly #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions src/opengl/qpixmapdata_egl_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,60 @@ bool QEglGLPixmapData::hasAlphaChannel() const
return m_hasAlpha;
}

extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha);
extern QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);

QImage QEglGLPixmapData::toImage() const
{
TRACE();
// We should not do so many toImage calls alltogether. This is what is slowing us down right now.
// QWK should keep a cache of transformed images instead of re-doing it every frame.
// FIXME make QWebKit not do so many QPixmap(QImage(pixmap.toImage).transform()) style transformations.
if (!isValid())
return QImage();

if (m_fbo) {
// copyBackFromRenderFbo(true);
} else if (!m_source.isNull()) {
if (!m_source.isNull()) {
return m_source;
} else if (m_dirty || m_hasFillColor) {
return fillImage(m_fillColor);
m_source = fillImage(m_fillColor);
return m_source;
} else {
ensureCreated();
}
// read the image from the FBO to memory
if(m_fbo) {
// we read the data back from the fbo
m_ctx->makeCurrent();
QGLShareContextScope ctx(qt_gl_share_widget()->context());
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
// this does glReadPixels - not very fast!
QImage temp=qt_gl_read_framebuffer(QSize(w, h), true, true);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
m_source=temp;
m_ctx->doneCurrent();
return temp;
}
else if (m_texture.id) {
// we read back from the texture by binding its id as a framebuffer
// is this in the OpenGL standard? It seems to work
m_ctx->makeCurrent();
QGLShareContextScope ctx(qt_gl_share_widget()->context());
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_texture.id);
// this does glReadPixels - not very fast
QImage temp=qt_gl_read_framebuffer(QSize(w, h), true, true);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
// should we cache the fetched image locally to speed up future access?
// m_source=temp;
m_ctx->doneCurrent();
return temp;
}
else {
QImage temp(w,h, QImage::Format_ARGB32_Premultiplied);
// FIXME indicating something went wrong, neither of above cases worked - look out for yellow images
temp.fill(Qt::yellow);
m_source=temp;
return temp;
}

QGLShareContextScope ctx(qt_gl_share_widget()->context());
glBindTexture(GL_TEXTURE_2D, m_texture.id);
return qt_gl_read_texture(QSize(w, h), true, true);
}

QPaintEngine* QEglGLPixmapData::paintEngine() const
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/platforms/palm/qeglfsintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <EGL/egl.h>
#include <QDebug>

#include "QtOpenGL/private/qpixmapdata_gl_p.h"
QT_BEGIN_NAMESPACE

QPlatformClipboard* QEglFSIntegration::clipboard() const {
Expand Down Expand Up @@ -101,7 +102,12 @@ QPixmapData *QEglFSIntegration::createPixmapData(QPixmapData::PixelType type) co
if(soft)
return new QRasterPixmapData(type);
else
return new QEglGLPixmapData(type);
// We have to think about either improving on the performance of EglGLPixmapData
// or having QWebKit not copy around so many images at all. For now Raster gives
// us *just* about enough speed.
// FIXME make QEglGLPixmapData faster and re-enable here.
// return new QEglGLPixmapData(type);
return new QRasterPixmapData(type);
}

QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWidget *widget, WId winId) const
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/platforms/webos/qwebosintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ QPixmapData *QWebOSIntegration::createPixmapData(QPixmapData::PixelType type) co
if(m_offscreen)
return new QRasterPixmapData(type);
else
return new QEglGLPixmapData(type);
// We have to think about either improving on the performance of EglGLPixmapData
// or having QWebKit not copy around so many images at all. For now Raster gives
// us *just* about enough speed.
// FIXME make QEglGLPixmapData faster and re-enable here.
// return new QEglGLPixmapData(type);
return new QRasterPixmapData(type);
}

QPlatformWindow *QWebOSIntegration::createPlatformWindow(QWidget *widget, WId winId) const
Expand Down