From: Charles Yin Date: Fri, 16 Sep 2011 01:55:01 +0000 (+1000) Subject: rename threadRendering to renderInThread X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3277b6f803b0f82c72ca2dc26a90cafb18067971;p=konrad%2Fqtdeclarative.git rename threadRendering to renderInThread Change-Id: I21d2492288adc84d3ef99633752e78a3ea232a4a Reviewed-on: http://codereview.qt-project.org/5042 Reviewed-by: Charles Yin --- diff --git a/examples/declarative/canvas/bezierCurve/bezierCurve.qml b/examples/declarative/canvas/bezierCurve/bezierCurve.qml index bce3777..4d30c4d 100644 --- a/examples/declarative/canvas/bezierCurve/bezierCurve.qml +++ b/examples/declarative/canvas/bezierCurve/bezierCurve.qml @@ -65,7 +65,7 @@ Item { property real rotate : rotateCtrl.value smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } diff --git a/examples/declarative/canvas/clip/clip.qml b/examples/declarative/canvas/clip/clip.qml index 58925e6..f2397c6 100644 --- a/examples/declarative/canvas/clip/clip.qml +++ b/examples/declarative/canvas/clip/clip.qml @@ -66,7 +66,7 @@ Item { property string imagefile:"../contents/qt-logo.png" smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false Component.onCompleted:loadImage(canvas.imagefile); onAlphaChanged:requestPaint(); diff --git a/examples/declarative/canvas/contents/Button.qml b/examples/declarative/canvas/contents/Button.qml index 410c742..3c41a19 100644 --- a/examples/declarative/canvas/contents/Button.qml +++ b/examples/declarative/canvas/contents/Button.qml @@ -84,4 +84,4 @@ Item { PropertyChanges { target: pressed; opacity: 1 } } ] -} +} \ No newline at end of file diff --git a/examples/declarative/canvas/pixels/pixels.qml b/examples/declarative/canvas/pixels/pixels.qml index 97af746..8047bb1 100644 --- a/examples/declarative/canvas/pixels/pixels.qml +++ b/examples/declarative/canvas/pixels/pixels.qml @@ -55,8 +55,8 @@ Item { width:360 height:360 smooth:true - renderTarget:Canvas.Image - threadRendering:false + renderTarget:Canvas.FramebufferObject + renderInThread:false property string image :"../contents/qt-logo.png" Component.onCompleted:loadImage(image); onImageLoaded:requestPaint(); diff --git a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml index 76b09d8..00d9e9d 100644 --- a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml +++ b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml @@ -65,7 +65,7 @@ Item { property real rotate : rotateCtrl.value smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false onLineWidthChanged:requestPaint(); onFillChanged:requestPaint(); @@ -106,8 +106,7 @@ Item { ctx.fillStyle="green"; ctx.font = "Bold 15px"; - // ctx.fillText("QML酷毙了", 30, 60); //BUG(in Linux):can't show multiple Chinese characters correctly. - ctx.fillText("QML酷 毙 了 !", 35, 65); + ctx.fillText("QML酷毙了", 30, 60); } } diff --git a/examples/declarative/canvas/roundedrect/roundedrect.qml b/examples/declarative/canvas/roundedrect/roundedrect.qml index bed4098..50c07ea 100644 --- a/examples/declarative/canvas/roundedrect/roundedrect.qml +++ b/examples/declarative/canvas/roundedrect/roundedrect.qml @@ -55,7 +55,7 @@ Item { height:360 smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false property int radius: rCtrl.value property int rectx: rxCtrl.value diff --git a/examples/declarative/canvas/smile/smile.qml b/examples/declarative/canvas/smile/smile.qml index 9a75707..3a7fbe7 100644 --- a/examples/declarative/canvas/smile/smile.qml +++ b/examples/declarative/canvas/smile/smile.qml @@ -56,7 +56,7 @@ Item { height:360 smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false property string strokeStyle:"green" property string fillStyle:"yellow" diff --git a/examples/declarative/canvas/squircle/squircle.qml b/examples/declarative/canvas/squircle/squircle.qml index 638abd9..f9845e8 100644 --- a/examples/declarative/canvas/squircle/squircle.qml +++ b/examples/declarative/canvas/squircle/squircle.qml @@ -61,7 +61,7 @@ Item { height:360 smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false property string strokeStyle:"blue" property string fillStyle:"steelblue" diff --git a/examples/declarative/canvas/stockchart/stock.qml b/examples/declarative/canvas/stockchart/stock.qml index c6fdd0e..32ffac1 100644 --- a/examples/declarative/canvas/stockchart/stock.qml +++ b/examples/declarative/canvas/stockchart/stock.qml @@ -337,7 +337,7 @@ Rectangle { anchors.bottom : view.top width:container.width; opacity:0 - threadRendering:false + renderInThread:false renderTarget: Canvas.Image property bool running:false property int frames:first @@ -722,4 +722,4 @@ Rectangle { drawKLine(ctx, first, last, points, highestPrice); } } -} +} \ No newline at end of file diff --git a/examples/declarative/canvas/tiger/tiger.qml b/examples/declarative/canvas/tiger/tiger.qml index 9adda4c..5ec9204 100644 --- a/examples/declarative/canvas/tiger/tiger.qml +++ b/examples/declarative/canvas/tiger/tiger.qml @@ -55,12 +55,11 @@ Item { id:canvas width:360 height:360 - smooth:false - renderTarget:Canvas.Image - threadRendering:false + smooth:true + renderTarget:Canvas.FramebufferObject + renderInThread:false property string strokeStyle:"steelblue" property string fillStyle:"yellow" - property int lineWidth:lineWidthCtrl.value property bool fill:true property bool stroke:true property real alpha:alphaCtrl.value @@ -69,7 +68,6 @@ Item { property real rotate : rotateCtrl.value property int frame:0 - onLineWidthChanged: requestPaint(); onFillChanged: requestPaint(); onStrokeChanged: requestPaint(); onAlphaChanged: requestPaint(); @@ -85,8 +83,7 @@ Item { onPaint: { var ctx = canvas.getContext('2d'); ctx.reset(); - ctx.fillStyle = "rgba(0,0,0,0)"; - ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.globalAlpha = canvas.alpha; ctx.scale(canvas.scaleX, canvas.scaleY); ctx.rotate(canvas.rotate); @@ -121,7 +118,6 @@ Item { height:160 Column { spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} diff --git a/examples/declarative/canvas/twitterfriends/twitter.qml b/examples/declarative/canvas/twitterfriends/twitter.qml index b852e66..685a59d 100644 --- a/examples/declarative/canvas/twitterfriends/twitter.qml +++ b/examples/declarative/canvas/twitterfriends/twitter.qml @@ -84,7 +84,7 @@ Item { anchors.bottom : parent.bottom smooth:true renderTarget:Canvas.Image - threadRendering:false + renderInThread:false property bool layoutChanged:true property string twitterName:"" @@ -124,4 +124,3 @@ Item { } } } - diff --git a/src/declarative/items/context2d/qsgcanvasitem.cpp b/src/declarative/items/context2d/qsgcanvasitem.cpp index 4a5f771..2ecd322 100644 --- a/src/declarative/items/context2d/qsgcanvasitem.cpp +++ b/src/declarative/items/context2d/qsgcanvasitem.cpp @@ -64,7 +64,7 @@ public: QSize tileSize; QRectF canvasWindow; QRectF dirtyRect; - uint threadRendering : 1; + uint renderInThread : 1; uint hasCanvasSize :1; uint hasTileSize :1; uint hasCanvasWindow :1; @@ -80,7 +80,7 @@ QSGCanvasItemPrivate::QSGCanvasItemPrivate() , texture(0) , canvasSize(1, 1) , tileSize(1, 1) - , threadRendering(true) + , renderInThread(false) , hasCanvasSize(false) , hasTileSize(false) , hasCanvasWindow(false) @@ -303,10 +303,10 @@ QSGContext2D* QSGCanvasItem::context() const The default value is false. \sa QtQuick2::Canvas::renderTarget */ -bool QSGCanvasItem::threadRendering() const +bool QSGCanvasItem::renderInThread() const { Q_D(const QSGCanvasItem); - return d->threadRendering; + return d->renderInThread; } /*! \qmlproperty bool QtQuick2::Canvas::renderTarget @@ -353,20 +353,30 @@ void QSGCanvasItem::_doPainting(const QRectF& region) d->texture->wake(); } -void QSGCanvasItem::setThreadRendering(bool threadRendering) +/*! + \qmlproperty bool QtQuick2::Canvas::renderInThread + Holds the current canvas rendering mode. + + When this property is true, all canvas painting commands + are rendered in a background rendering thread, otherwise + the rendering happens in the main GUI thread. + + The default renderInThread value is false. +*/ +void QSGCanvasItem::setRenderInThread(bool renderInThread) { Q_D(QSGCanvasItem); - if (d->threadRendering != threadRendering) { - d->threadRendering = threadRendering; + if (d->renderInThread != renderInThread) { + d->renderInThread = renderInThread; if (d->componentCompleted) createTexture(); - if (d->threadRendering) + if (d->renderInThread) connect(this, SIGNAL(painted()), SLOT(update())); else disconnect(this, SIGNAL(painted()), this, SLOT(update())); - emit threadRenderingChanged(); + emit renderInThreadChanged(); polish(); } } @@ -418,7 +428,7 @@ void QSGCanvasItem::updatePolish() QSGItem::updatePolish(); if (d->texture) { - if (!d->threadRendering && d->dirtyRect.isValid()) + if (!d->renderInThread && d->dirtyRect.isValid()) _doPainting(d->dirtyRect); d->texture->canvasChanged(d->canvasSize.toSize() @@ -447,7 +457,7 @@ void QSGCanvasItem::createTexture() Q_D(QSGCanvasItem); if (!d->texture - || d->texture->threadRendering() != d->threadRendering + || d->texture->threadRendering() != d->renderInThread || d->texture->renderTarget() != d->renderTarget) { if (d->texture) { d->texture->deleteLater(); @@ -455,18 +465,18 @@ void QSGCanvasItem::createTexture() } if (d->renderTarget == QSGCanvasItem::Image) { - d->texture = new QSGContext2DImageTexture(d->threadRendering); + d->texture = new QSGContext2DImageTexture(d->renderInThread); } else if (d->renderTarget == QSGCanvasItem::FramebufferObject) { d->texture = new QSGContext2DFBOTexture(); } - if (d->threadRendering && !d->texture->supportThreadRendering()) { + if (d->renderInThread && !d->texture->supportThreadRendering()) { qWarning("Canvas: render target does not support thread rendering, force to non-thread rendering mode."); - d->threadRendering = false; - emit threadRenderingChanged(); + d->renderInThread = false; + emit renderInThreadChanged(); } - if (d->threadRendering) + if (d->renderInThread) connect(d->texture, SIGNAL(textureChanged()), this, SLOT(update())); d->texture->setItem(this); @@ -707,4 +717,4 @@ QString QSGCanvasItem::toDataURL(const QString& mimeType) const the Canvas is actually rendered. */ -QT_END_NAMESPACE +QT_END_NAMESPACE \ No newline at end of file diff --git a/src/declarative/items/context2d/qsgcanvasitem_p.h b/src/declarative/items/context2d/qsgcanvasitem_p.h index 1dd4cea..8d6441a 100644 --- a/src/declarative/items/context2d/qsgcanvasitem_p.h +++ b/src/declarative/items/context2d/qsgcanvasitem_p.h @@ -63,7 +63,7 @@ class QSGCanvasItem : public QSGItem Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged) Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged) Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged) - Q_PROPERTY(bool threadRendering READ threadRendering WRITE setThreadRendering NOTIFY threadRenderingChanged) + Q_PROPERTY(bool renderInThread READ renderInThread WRITE setRenderInThread NOTIFY renderInThreadChanged) Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged) public: enum RenderTarget { @@ -94,8 +94,8 @@ public: QRectF canvasWindow() const; void setCanvasWindow(const QRectF& rect); - bool threadRendering() const; - void setThreadRendering(bool theadRendering); + bool renderInThread() const; + void setRenderInThread(bool renderInThread); RenderTarget renderTarget() const; void setRenderTarget(RenderTarget target); @@ -109,7 +109,7 @@ Q_SIGNALS: void painted(); void canvasSizeChanged(); void tileSizeChanged(); - void threadRenderingChanged(); + void renderInThreadChanged(); void textureChanged(); void canvasWindowChanged(); void renderTargetChanged(); @@ -147,4 +147,4 @@ QML_DECLARE_TYPE(QSGCanvasItem) QT_END_HEADER -#endif //QSGCANVASITEM_P_H +#endif //QSGCANVASITEM_P_H \ No newline at end of file