summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-06-05 13:19:02 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-05 14:09:26 +0200
commit9e99dad77b3e885e5c5a1622ba12fbc947984250 (patch)
tree324adf758f31c121edc593a28cb2e5cd9506d961
parent29dd87ecc570ebc51890e0587e73e7a144d892aa (diff)
downloadqtwebkit-9e99dad77b3e885e5c5a1622ba12fbc947984250.tar.gz
Avoid deep copy when updating BitmapTextureGL
Since we use a ImageBuffer to paint into a BitmapTextureGL, and ImageBuffer's always have an active painter, the convertion from QPixmap to QImage causes a deep copy of the content before it is uploaded to OpenGL. This copy is unnecessary and can be avoided by temporarily redirecting the QPaintDevice. Change-Id: I0106c0f6dfb9cc3fbbee943411fc8f6853df4f98 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
index 55c0b6aca..4469fde58 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
@@ -38,6 +38,7 @@
#include <wtf/TemporaryChange.h>
#if PLATFORM(QT)
+#include <QPaintEngine>
#include "NativeImageQt.h"
#endif
@@ -908,7 +909,17 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
const char* imageData;
#if PLATFORM(QT)
- QImage qImage = frameImage->toImage();
+ QImage qImage;
+ QPaintEngine* paintEngine = frameImage->paintEngine();
+ if (paintEngine && paintEngine->type() == QPaintEngine::Raster) {
+ // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it.
+ // For performance reasons, we don't want that here, so we temporarily redirect the paint engine.
+ QPaintDevice* currentPaintDevice = paintEngine->paintDevice();
+ paintEngine->setPaintDevice(0);
+ qImage = frameImage->toImage();
+ paintEngine->setPaintDevice(currentPaintDevice);
+ } else
+ qImage = frameImage->toImage();
imageData = reinterpret_cast<const char*>(qImage.constBits());
bytesPerLine = qImage.bytesPerLine();
#elif USE(CAIRO)