aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2012-05-28 10:48:37 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-05 01:59:58 +0200
commit41a9f34461e34c171ce7ecc4b3e9bc64948ffbde (patch)
tree64272e64e1fb99758810a039cee38ea7333084e5
parent3747f1972db869853a593f869154debf174c9cf2 (diff)
Fix canvas item drawImage bug with FBO render target
If canvas' render target is FramebufferObject, only the first drawImage() call was successful, it could be fixed by adding beginNativePainting() and endNativePainting(), but this could be unexpected behavior with OpenGL paint engine. task-number: QTBUG-23595 Change-Id: Iff70fc88f6d39655dd283fa5dde3365887910460 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp4
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_image.qml14
2 files changed, 17 insertions, 1 deletions
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
index f6b9a1afeb..6f20b699c9 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
@@ -409,7 +409,11 @@ void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& s
qreal shadow_dy = dy + (state.shadowOffsetX < 0? state.shadowOffsetY:0);
p->drawImage(shadow_dx, shadow_dy, shadow);
}
+
+ //Strange OpenGL painting behavior here, without beginNativePainting/endNativePainting, only the first image is painted.
+ p->beginNativePainting();
p->drawImage(dx, dy, image);
+ p->endNativePainting();
}
break;
}
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_image.qml b/tests/auto/quick/qquickcanvasitem/data/tst_image.qml
index 5853c034c4..71931acae8 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_image.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_image.qml
@@ -692,4 +692,16 @@ CanvasTestCase {
comparePixel(ctx, 50,25, 0,255,0,255, 2);
}
-}
+ function test_multiple_painting(row) {
+ var canvas = createCanvasObject(row);
+ var ctx = canvas.getContext('2d');
+ loadImages(canvas);
+
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 50, 50);
+ ctx.drawImage('red.png', 50, 0, 100, 50);
+ comparePixel(ctx, 25,25, 255,0,0,255, 2);
+ comparePixel(ctx, 75,25, 255,0,0,255, 2);
+ }
+} \ No newline at end of file