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 } }
property string imagefile:"../contents/qt-logo.png"
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
Component.onCompleted:loadImage(canvas.imagefile);
onAlphaChanged:requestPaint();
PropertyChanges { target: pressed; opacity: 1 }
}
]
-}
+}
\ No newline at end of file
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();
property real rotate : rotateCtrl.value
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
onLineWidthChanged:requestPaint();
onFillChanged:requestPaint();
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);
}
}
height:360
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
property int radius: rCtrl.value
property int rectx: rxCtrl.value
height:360
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
property string strokeStyle:"green"
property string fillStyle:"yellow"
height:360
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
property string strokeStyle:"blue"
property string fillStyle:"steelblue"
anchors.bottom : view.top
width:container.width;
opacity:0
- threadRendering:false
+ renderInThread:false
renderTarget: Canvas.Image
property bool running:false
property int frames:first
drawKLine(ctx, first, last, points, highestPrice);
}
}
-}
+}
\ No newline at end of file
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
property real rotate : rotateCtrl.value
property int frame:0
- onLineWidthChanged: requestPaint();
onFillChanged: requestPaint();
onStrokeChanged: requestPaint();
onAlphaChanged: requestPaint();
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);
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"}
anchors.bottom : parent.bottom
smooth:true
renderTarget:Canvas.Image
- threadRendering:false
+ renderInThread:false
property bool layoutChanged:true
property string twitterName:""
}
}
}
-
QSize tileSize;
QRectF canvasWindow;
QRectF dirtyRect;
- uint threadRendering : 1;
+ uint renderInThread : 1;
uint hasCanvasSize :1;
uint hasTileSize :1;
uint hasCanvasWindow :1;
, texture(0)
, canvasSize(1, 1)
, tileSize(1, 1)
- , threadRendering(true)
+ , renderInThread(false)
, hasCanvasSize(false)
, hasTileSize(false)
, hasCanvasWindow(false)
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
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();
}
}
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()
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();
}
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);
the Canvas is actually rendered.
*/
-QT_END_NAMESPACE
+QT_END_NAMESPACE
\ No newline at end of file
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 {
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);
void painted();
void canvasSizeChanged();
void tileSizeChanged();
- void threadRenderingChanged();
+ void renderInThreadChanged();
void textureChanged();
void canvasWindowChanged();
void renderTargetChanged();
QT_END_HEADER
-#endif //QSGCANVASITEM_P_H
+#endif //QSGCANVASITEM_P_H
\ No newline at end of file