summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Rødal <srodal@gmail.com>2014-10-30 12:38:49 +0100
committerSamuel Rødal <srodal@gmail.com>2014-11-04 15:18:15 +0100
commitf301054d60a6d7828af33a8f8ec66a78cbf4b9b3 (patch)
tree320002cc97dc6cd1f6847f46358b16f136cffce1
parentcab992ea0898676ba83ca5eb95d346bfa185421e (diff)
downloadqtwebkit-f301054d60a6d7828af33a8f8ec66a78cbf4b9b3.tar.gz
Fixed upside down drawing of accelerated 2d canvas
The convention used by the Qt OpenGL paint engine's internal drawTexture() function didn't match the texture layout of the accelerated 2D canvas. We need to adjust the coordinates according to whether flipped painting is in effect. Task-number: QTBUG-42376 Change-Id: I787a2deb5f26df532f2e7c475754f0fd2189132c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
index a7e60d090..dac6f1bc2 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
@@ -204,6 +204,11 @@ void ImageBufferDataPrivateAccelerated::draw(GraphicsContext* destContext, Color
QRect rect(QPoint(), m_paintDevice->size());
+ // drawTexture's rendering is flipped relative to QtWebKit's convention, so we need to compensate
+ FloatRect srcRectFlipped = m_paintDevice->paintFlipped()
+ ? FloatRect(srcRect.x(), srcRect.maxY(), srcRect.width(), -srcRect.height())
+ : FloatRect(srcRect.x(), rect.height() - srcRect.maxY(), srcRect.width(), srcRect.height());
+
// Using the same texture as source and target of a rendering operation is undefined in OpenGL,
// so if that's the case we need to use a temporary intermediate buffer.
if (m_paintDevice == targetPaintDevice) {
@@ -211,14 +216,17 @@ void ImageBufferDataPrivateAccelerated::draw(GraphicsContext* destContext, Color
QFramebufferPaintDevice device(rect.size(), QOpenGLFramebufferObject::NoAttachment, false);
+ // We disable flipping in order to do a pure blit into the intermediate buffer
+ device.setPaintFlipped(false);
+
QPainter painter(&device);
QOpenGL2PaintEngineEx* pe = static_cast<QOpenGL2PaintEngineEx*>(painter.paintEngine());
pe->drawTexture(rect, m_paintDevice->texture(), rect.size(), rect);
painter.end();
- acceleratedPaintEngine->drawTexture(destRect, device.texture(), rect.size(), srcRect);
+ acceleratedPaintEngine->drawTexture(destRect, device.texture(), rect.size(), srcRectFlipped);
} else {
- acceleratedPaintEngine->drawTexture(destRect, m_paintDevice->texture(), rect.size(), srcRect);
+ acceleratedPaintEngine->drawTexture(destRect, m_paintDevice->texture(), rect.size(), srcRectFlipped);
}
return;