aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-08-09 16:44:38 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-12 17:04:03 +0200
commit82b21536e72a640699594b3e82a5a6182a95521c (patch)
treed641802de88c644e12b9cf3e2279f3aae084779b
parent6a15dae8c2f09c99bb124b4587ff8088b35a7273 (diff)
canvas item refactors
1.Supports tiled canvas with canvasSize, tileSize and canvasWindow 2.Supports different rendering targets: Canvas.Image and Canvas.FrameBufferObject by renderTarget property 3.Supports thread rendering when possible by threadRendering property. 4.Refactors QSGContext2D code, move some logic to QSGContext2DCommandBuffer,QSGContext2DTexture,QSGContext2DTile, etc 5.Updates/adds some canvas examples 6.Some improvements for context2d API 6.1 drawImage() now loads image asynchoronously and draw images automatically when they are ready 6.2 adds fillRule supports 6.3 add svg path supports 6.4 Pixel operations (getImageData/putImageData/createImageData) now have better performance by using V8 indexed array accessors 6.5 Uses QTransform instead of QMatrix 6.6 Gradients/patterns now are V8 values, not QObjects 6.7 Supports measureText and TextMetrics interface 6.8 Gives not support warnings for unimplemented functions (drawFocusRing,setCaretSelectionRect,caretBlinkRate) 6.9 Better error handling, throw standard DOM exceptions according to the HTML5 context2d spec. 6.10 Adds shear, resetTransform to matrix operations 6.11 Adds roundedRect, ellipse, text to path operations 6.12 Adds new features to CanvasImageData interface 1) adds mirror() function 2) adds filter() function, include the following filters: Threshold GrayScale Brightness Invert Blur Blend Opaque Convolute 7. Adds documentations Change-Id: Id19224260d6a3fdc589d1f9681c34a88a7e7b3e5 Reviewed-on: http://codereview.qt-project.org/3621 Reviewed-by: Charles Yin <charles.yin@nokia.com>
-rw-r--r--examples/declarative/canvas/bezierCurve/bezierCurve.qml83
-rw-r--r--examples/declarative/canvas/clip/clip.qml109
-rw-r--r--examples/declarative/canvas/contents/Button.qml (renamed from examples/declarative/canvas/stockchart/contents/Button.qml)0
-rw-r--r--examples/declarative/canvas/contents/ScrollBar.qml (renamed from examples/declarative/canvas/stockchart/contents/ScrollBar.qml)0
-rw-r--r--examples/declarative/canvas/contents/Slider.qml115
-rw-r--r--examples/declarative/canvas/contents/Stocks.qml (renamed from examples/declarative/canvas/stockchart/contents/Stocks.qml)0
-rw-r--r--examples/declarative/canvas/contents/TitleBar.qml (renamed from examples/declarative/canvas/stockchart/contents/TitleBar.qml)0
-rw-r--r--examples/declarative/canvas/contents/ToolBar.qml (renamed from examples/declarative/canvas/stockchart/contents/ToolBar.qml)0
-rw-r--r--examples/declarative/canvas/contents/images/button-pressed.png (renamed from examples/declarative/canvas/stockchart/contents/images/button-pressed.png)bin571 -> 571 bytes
-rw-r--r--examples/declarative/canvas/contents/images/button.png (renamed from examples/declarative/canvas/stockchart/contents/images/button.png)bin564 -> 564 bytes
-rw-r--r--examples/declarative/canvas/contents/images/default.svg (renamed from examples/declarative/canvas/stockchart/contents/images/default.svg)0
-rwxr-xr-xexamples/declarative/canvas/contents/images/gloss.png (renamed from examples/declarative/canvas/stockchart/contents/images/gloss.png)bin1236 -> 1236 bytes
-rwxr-xr-xexamples/declarative/canvas/contents/images/lineedit.png (renamed from examples/declarative/canvas/stockchart/contents/images/lineedit.png)bin1415 -> 1415 bytes
-rw-r--r--examples/declarative/canvas/contents/images/lineedit.sci (renamed from examples/declarative/canvas/stockchart/contents/images/lineedit.sci)0
-rwxr-xr-xexamples/declarative/canvas/contents/images/quit.png (renamed from examples/declarative/canvas/stockchart/contents/images/quit.png)bin2369 -> 2369 bytes
-rwxr-xr-xexamples/declarative/canvas/contents/images/stripes.png (renamed from examples/declarative/canvas/stockchart/contents/images/stripes.png)bin257 -> 257 bytes
-rwxr-xr-xexamples/declarative/canvas/contents/images/titlebar.png (renamed from examples/declarative/canvas/stockchart/contents/images/titlebar.png)bin1436 -> 1436 bytes
-rw-r--r--examples/declarative/canvas/contents/images/titlebar.sci (renamed from examples/declarative/canvas/stockchart/contents/images/titlebar.sci)0
-rwxr-xr-xexamples/declarative/canvas/contents/images/toolbutton.png (renamed from examples/declarative/canvas/stockchart/contents/images/toolbutton.png)bin2550 -> 2550 bytes
-rw-r--r--examples/declarative/canvas/contents/images/toolbutton.sci (renamed from examples/declarative/canvas/stockchart/contents/images/toolbutton.sci)0
-rw-r--r--examples/declarative/canvas/contents/qt-logo.pngbin0 -> 23519 bytes
-rw-r--r--examples/declarative/canvas/pixels/pixels.qml43
-rw-r--r--examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml88
-rw-r--r--examples/declarative/canvas/roundedrect/roundedrect.qml84
-rw-r--r--examples/declarative/canvas/smile/smile.qml87
-rw-r--r--examples/declarative/canvas/squircle/squircle.pngbin0 -> 771 bytes
-rw-r--r--examples/declarative/canvas/squircle/squircle.qml114
-rw-r--r--examples/declarative/canvas/stockchart/README5
-rw-r--r--examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir1
-rw-r--r--examples/declarative/canvas/stockchart/plugin.cpp (renamed from examples/declarative/canvas/stockchart/main.cpp)33
-rw-r--r--examples/declarative/canvas/stockchart/stock.qml18
-rw-r--r--examples/declarative/canvas/stockchart/stockchart.pro30
-rw-r--r--examples/declarative/canvas/stockchart/stockchart.qrc21
-rw-r--r--examples/declarative/canvas/tiger/tiger.js721
-rw-r--r--examples/declarative/canvas/tiger/tiger.qml92
-rw-r--r--examples/declarative/canvas/twitterfriends/TwitterUser.qml254
-rw-r--r--examples/declarative/canvas/twitterfriends/cache.js42
-rw-r--r--examples/declarative/canvas/twitterfriends/twitter.qml87
-rw-r--r--src/declarative/items/context2d/context2d.pri9
-rw-r--r--src/declarative/items/context2d/qsgcanvasitem.cpp529
-rw-r--r--src/declarative/items/context2d/qsgcanvasitem_p.h91
-rw-r--r--src/declarative/items/context2d/qsgcontext2d.cpp4033
-rw-r--r--src/declarative/items/context2d/qsgcontext2d_p.h335
-rw-r--r--src/declarative/items/context2d/qsgcontext2d_p_p.h238
-rw-r--r--src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp402
-rw-r--r--src/declarative/items/context2d/qsgcontext2dcommandbuffer_p.h268
-rw-r--r--src/declarative/items/context2d/qsgcontext2dnode.cpp116
-rw-r--r--src/declarative/items/context2d/qsgcontext2dnode_p.h84
-rw-r--r--src/declarative/items/context2d/qsgcontext2dtexture.cpp673
-rw-r--r--src/declarative/items/context2d/qsgcontext2dtexture_p.h200
-rw-r--r--src/declarative/items/context2d/qsgcontext2dtile.cpp146
-rw-r--r--src/declarative/items/context2d/qsgcontext2dtile_p.h104
-rw-r--r--src/declarative/items/qsgitemsmodule.cpp2
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h4
54 files changed, 6345 insertions, 2916 deletions
diff --git a/examples/declarative/canvas/bezierCurve/bezierCurve.qml b/examples/declarative/canvas/bezierCurve/bezierCurve.qml
new file mode 100644
index 0000000000..ec267c62f1
--- /dev/null
+++ b/examples/declarative/canvas/bezierCurve/bezierCurve.qml
@@ -0,0 +1,83 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"red"
+ property string fillStyle:"red"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,40);
+ ctx.bezierCurveTo(75,37,70,25,50,25);
+ ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
+ ctx.bezierCurveTo(20,80,40,102,75,120);
+ ctx.bezierCurveTo(110,102,130,80,130,62.5);
+ ctx.bezierCurveTo(130,62.5,130,25,100,25);
+ ctx.bezierCurveTo(85,25,75,37,75,40);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ 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:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/clip/clip.qml b/examples/declarative/canvas/clip/clip.qml
new file mode 100644
index 0000000000..a61c5efa64
--- /dev/null
+++ b/examples/declarative/canvas/clip/clip.qml
@@ -0,0 +1,109 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+ property string imagefile:"../contents/qt-logo.png"
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+ Component.onCompleted:loadImage(canvas.imagefile);
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+ onImageLoaded : requestPaint();
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.reset();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+ ctx.clip();
+
+ ctx.drawImage(canvas.imagefile, 0, 0);
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/declarative/canvas/stockchart/contents/Button.qml b/examples/declarative/canvas/contents/Button.qml
index 410c7421ae..410c7421ae 100644
--- a/examples/declarative/canvas/stockchart/contents/Button.qml
+++ b/examples/declarative/canvas/contents/Button.qml
diff --git a/examples/declarative/canvas/stockchart/contents/ScrollBar.qml b/examples/declarative/canvas/contents/ScrollBar.qml
index ad01b03a91..ad01b03a91 100644
--- a/examples/declarative/canvas/stockchart/contents/ScrollBar.qml
+++ b/examples/declarative/canvas/contents/ScrollBar.qml
diff --git a/examples/declarative/canvas/contents/Slider.qml b/examples/declarative/canvas/contents/Slider.qml
new file mode 100644
index 0000000000..6687d144e2
--- /dev/null
+++ b/examples/declarative/canvas/contents/Slider.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id:slider
+ property real min:0
+ property real max:1
+ property real value: min + (max - min) * (bar.x / (foo.width - bar.width))
+ property real init:min+(max-min)/2
+ property string name:"Slider"
+
+ Component.onCompleted: setValue(init)
+ function setValue(v) {
+ if (min < max)
+ bar.x = v/(max - min) * (foo.width - bar.width);
+ }
+ Rectangle {
+ id:sliderName
+ anchors.left:parent.left
+ height: childrenRect.height
+ width:childrenRect.width
+ anchors.verticalCenter:parent.verticalCenter
+ Text {
+ text:slider.name
+ font.pointSize:12
+ }
+ }
+ Item {
+ id: foo
+ height: 6
+ width: parent.width - 4 - sliderName.width
+ anchors.verticalCenter:parent.verticalCenter
+ anchors.left:sliderName.right
+ anchors.leftMargin:5
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/stockchart/contents/Stocks.qml b/examples/declarative/canvas/contents/Stocks.qml
index 063792d6a2..063792d6a2 100644
--- a/examples/declarative/canvas/stockchart/contents/Stocks.qml
+++ b/examples/declarative/canvas/contents/Stocks.qml
diff --git a/examples/declarative/canvas/stockchart/contents/TitleBar.qml b/examples/declarative/canvas/contents/TitleBar.qml
index 078895122e..078895122e 100644
--- a/examples/declarative/canvas/stockchart/contents/TitleBar.qml
+++ b/examples/declarative/canvas/contents/TitleBar.qml
diff --git a/examples/declarative/canvas/stockchart/contents/ToolBar.qml b/examples/declarative/canvas/contents/ToolBar.qml
index 83ee55c6fb..83ee55c6fb 100644
--- a/examples/declarative/canvas/stockchart/contents/ToolBar.qml
+++ b/examples/declarative/canvas/contents/ToolBar.qml
diff --git a/examples/declarative/canvas/stockchart/contents/images/button-pressed.png b/examples/declarative/canvas/contents/images/button-pressed.png
index e434d327f2..e434d327f2 100644
--- a/examples/declarative/canvas/stockchart/contents/images/button-pressed.png
+++ b/examples/declarative/canvas/contents/images/button-pressed.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/button.png b/examples/declarative/canvas/contents/images/button.png
index 56a63ce641..56a63ce641 100644
--- a/examples/declarative/canvas/stockchart/contents/images/button.png
+++ b/examples/declarative/canvas/contents/images/button.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/default.svg b/examples/declarative/canvas/contents/images/default.svg
index 248199cc4e..248199cc4e 100644
--- a/examples/declarative/canvas/stockchart/contents/images/default.svg
+++ b/examples/declarative/canvas/contents/images/default.svg
diff --git a/examples/declarative/canvas/stockchart/contents/images/gloss.png b/examples/declarative/canvas/contents/images/gloss.png
index 5d370cd93d..5d370cd93d 100755
--- a/examples/declarative/canvas/stockchart/contents/images/gloss.png
+++ b/examples/declarative/canvas/contents/images/gloss.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/lineedit.png b/examples/declarative/canvas/contents/images/lineedit.png
index 2cc38dc35b..2cc38dc35b 100755
--- a/examples/declarative/canvas/stockchart/contents/images/lineedit.png
+++ b/examples/declarative/canvas/contents/images/lineedit.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/lineedit.sci b/examples/declarative/canvas/contents/images/lineedit.sci
index 054bff78be..054bff78be 100644
--- a/examples/declarative/canvas/stockchart/contents/images/lineedit.sci
+++ b/examples/declarative/canvas/contents/images/lineedit.sci
diff --git a/examples/declarative/canvas/stockchart/contents/images/quit.png b/examples/declarative/canvas/contents/images/quit.png
index 5bda1b6e0d..5bda1b6e0d 100755
--- a/examples/declarative/canvas/stockchart/contents/images/quit.png
+++ b/examples/declarative/canvas/contents/images/quit.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/stripes.png b/examples/declarative/canvas/contents/images/stripes.png
index 9f36727ea4..9f36727ea4 100755
--- a/examples/declarative/canvas/stockchart/contents/images/stripes.png
+++ b/examples/declarative/canvas/contents/images/stripes.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/titlebar.png b/examples/declarative/canvas/contents/images/titlebar.png
index 51c90082d0..51c90082d0 100755
--- a/examples/declarative/canvas/stockchart/contents/images/titlebar.png
+++ b/examples/declarative/canvas/contents/images/titlebar.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/titlebar.sci b/examples/declarative/canvas/contents/images/titlebar.sci
index 0418d94cd6..0418d94cd6 100644
--- a/examples/declarative/canvas/stockchart/contents/images/titlebar.sci
+++ b/examples/declarative/canvas/contents/images/titlebar.sci
diff --git a/examples/declarative/canvas/stockchart/contents/images/toolbutton.png b/examples/declarative/canvas/contents/images/toolbutton.png
index 11310013ee..11310013ee 100755
--- a/examples/declarative/canvas/stockchart/contents/images/toolbutton.png
+++ b/examples/declarative/canvas/contents/images/toolbutton.png
Binary files differ
diff --git a/examples/declarative/canvas/stockchart/contents/images/toolbutton.sci b/examples/declarative/canvas/contents/images/toolbutton.sci
index 9e4f965307..9e4f965307 100644
--- a/examples/declarative/canvas/stockchart/contents/images/toolbutton.sci
+++ b/examples/declarative/canvas/contents/images/toolbutton.sci
diff --git a/examples/declarative/canvas/contents/qt-logo.png b/examples/declarative/canvas/contents/qt-logo.png
new file mode 100644
index 0000000000..5ab3a1b0c4
--- /dev/null
+++ b/examples/declarative/canvas/contents/qt-logo.png
Binary files differ
diff --git a/examples/declarative/canvas/pixels/pixels.qml b/examples/declarative/canvas/pixels/pixels.qml
new file mode 100644
index 0000000000..45f398dc5e
--- /dev/null
+++ b/examples/declarative/canvas/pixels/pixels.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Processing pixels"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+ property string image :"../contents/qt-logo.png"
+ Component.onCompleted:loadImage(image);
+ onImageLoaded:requestPaint();
+ onPaint: {
+
+ var ctx = canvas.getContext('2d');
+ if (canvas.isImageLoaded(image)) {
+ var pixels = ctx.createImageData(image);
+ //pixels.mirror();
+ pixels.filter(Canvas.GrayScale);
+ //pixels.filter(Canvas.Threshold, 100); //default 127
+ //pixels.filter(Canvas.Blur, 20); //default 10
+ //pixels.filter(Canvas.Opaque);
+ //pixels.filter(Canvas.Invert);
+ //pixels.filter(Canvas.Convolute, [0,-1,0,
+ // -1,5,-1,
+ // 0,-1,0]);
+ //ctx.putImageData(pixels, 0, 0, canvas.width, canvas.height);
+ ctx.putImageData(pixels, 0, 0);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml
new file mode 100644
index 0000000000..c804921877
--- /dev/null
+++ b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml
@@ -0,0 +1,88 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ 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 scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+
+
+ 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);
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ 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:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/roundedrect/roundedrect.qml b/examples/declarative/canvas/roundedrect/roundedrect.qml
new file mode 100644
index 0000000000..8d584ac354
--- /dev/null
+++ b/examples/declarative/canvas/roundedrect/roundedrect.qml
@@ -0,0 +1,84 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+ property int radius: rCtrl.value
+ property int rectx: rxCtrl.value
+ property int recty: ryCtrl.value
+ property int rectWidth: width - 2*rectx
+ property int rectHeight: height - 2*recty
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onRectxChanged:requestPaint();
+ onRectyChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.reset();
+ ctx.clearRect(0,0,canvas.width, canvas.height);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.lineWidth = canvas.lineWidth
+ ctx.fillStyle = canvas.fillStyle
+ ctx.globalAlpha = canvas.alpha
+ ctx.beginPath();
+ ctx.moveTo(rectx+radius,recty); // top side
+ ctx.lineTo(rectx+rectWidth-radius,recty);
+ // draw top right corner
+ ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius);
+ ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side
+ // draw bottom right corner
+ ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius);
+ ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side
+ // draw bottom left corner
+ ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius);
+ ctx.lineTo(rectx,recty+radius); // left side
+ // draw top left corner
+ ctx.arcTo(rectx,recty,rectx+radius,recty,radius);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"}
+ Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"}
+ Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/smile/smile.qml b/examples/declarative/canvas/smile/smile.qml
new file mode 100644
index 0000000000..aff7cd00aa
--- /dev/null
+++ b/examples/declarative/canvas/smile/smile.qml
@@ -0,0 +1,87 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+ property string strokeStyle:"green"
+ property string fillStyle:"yellow"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75 + 50 * Math.cos(0),
+ 75 - 50 * Math.sin(Math.PI*2));
+ ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
+ ctx.moveTo(75,70);
+ ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise)
+ ctx.moveTo(60,65);
+ ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
+ ctx.moveTo(90 + 5 * Math.cos(0),
+ 65 - 5 * Math.sin(Math.PI*2));
+ ctx.moveTo(90,65);
+ ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ 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:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/squircle/squircle.png b/examples/declarative/canvas/squircle/squircle.png
new file mode 100644
index 0000000000..86c69d945f
--- /dev/null
+++ b/examples/declarative/canvas/squircle/squircle.png
Binary files differ
diff --git a/examples/declarative/canvas/squircle/squircle.qml b/examples/declarative/canvas/squircle/squircle.qml
new file mode 100644
index 0000000000..5873e2fcd7
--- /dev/null
+++ b/examples/declarative/canvas/squircle/squircle.qml
@@ -0,0 +1,114 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter}
+ Image {
+ anchors.horizontalCenter:parent.horizontalCenter
+ source:"squircle.png"
+ width:250
+ height:25
+ }
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.reset();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+
+ ctx.fillStyle = "yellow";
+ ctx.font = "Helvetica 16px";
+ ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py);
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/stockchart/README b/examples/declarative/canvas/stockchart/README
new file mode 100644
index 0000000000..2652866ed6
--- /dev/null
+++ b/examples/declarative/canvas/stockchart/README
@@ -0,0 +1,5 @@
+To run:
+
+ make install
+ QML_IMPORT_PATH=$PWD qmlscene stock.qml
+
diff --git a/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir
new file mode 100644
index 0000000000..4c60e556d4
--- /dev/null
+++ b/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir
@@ -0,0 +1 @@
+plugin qmlstockchartexampleplugin
diff --git a/examples/declarative/canvas/stockchart/main.cpp b/examples/declarative/canvas/stockchart/plugin.cpp
index b1e7630d15..d9bf19e886 100644
--- a/examples/declarative/canvas/stockchart/main.cpp
+++ b/examples/declarative/canvas/stockchart/plugin.cpp
@@ -38,26 +38,23 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <qdeclarative.h>
-#include <QSGView>
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
+#include <qapplication.h>
#include "model.h"
-int main(int argc, char ** argv)
+class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin
{
- QApplication app(argc, argv);
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample"));
+ qmlRegisterType<StockModel>(uri, 1, 0, "StockModel");
+ qmlRegisterType<StockPrice>(uri, 1, 0, "StockPrice");
+ }
+};
- qmlRegisterType<StockModel>("StockChart", 1, 0, "StockModel");
- qmlRegisterType<StockPrice>("StockChart", 1, 0, "StockPrice");
- QSGView view;
- view.setResizeMode(QSGView::SizeViewToRootObject);
- view.setSource(QUrl("qrc:stock.qml"));
-
- view.showFullScreen();
- view.raise();
-
- QObject::connect((QObject*)view.engine(), SIGNAL(quit()), (QObject*)&app, SLOT(quit()));
-
- return app.exec();
-}
+#include "plugin.moc"
+Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin);
diff --git a/examples/declarative/canvas/stockchart/stock.qml b/examples/declarative/canvas/stockchart/stock.qml
index 5011237833..c6fdd0ecb6 100644
--- a/examples/declarative/canvas/stockchart/stock.qml
+++ b/examples/declarative/canvas/stockchart/stock.qml
@@ -38,12 +38,12 @@
**
****************************************************************************/
import QtQuick 2.0
-import StockChart 1.0
-import "contents"
+import com.nokia.StockChartExample 1.0
+import "../contents"
Rectangle {
id:container
- width: 1920; height: 1200
+ width: 360; height: 600
color: "#343434";
Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 }
@@ -259,8 +259,6 @@ Rectangle {
onViewTypeChanged : {
if (viewType == "list") {
-// container.width = 700;
-// container.height = 800;
view.orientation = ListView.Vertical;
view.delegate = listDelegate;
// view.section.property = "year";
@@ -269,12 +267,9 @@ Rectangle {
view.highlight = listHighlight;
view.opacity = 1;
canvas.opacity = 0;
- //view.height = 750;
// comment.opacity = 0;
} else if (viewType == "chart") {
-// container.width = 1600;
-// container.height = 800;
view.orientation = ListView.Horizontal;
view.delegate = chartDelegate;
//comment.opacity = 0.6;
@@ -342,6 +337,8 @@ Rectangle {
anchors.bottom : view.top
width:container.width;
opacity:0
+ threadRendering:false
+ renderTarget: Canvas.Image
property bool running:false
property int frames:first
property int mouseX:0;
@@ -661,7 +658,7 @@ Rectangle {
ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
}
}
-
+/*
onPainted : {
if (canvas.running) {
if (frames >= last) {
@@ -682,7 +679,7 @@ Rectangle {
}
}
}
-
+*/
onPaint: {
if (view.currentIndex <= 0)
first = 0;
@@ -726,4 +723,3 @@ Rectangle {
}
}
}
-
diff --git a/examples/declarative/canvas/stockchart/stockchart.pro b/examples/declarative/canvas/stockchart/stockchart.pro
index 832b2ea728..4006b5dccf 100644
--- a/examples/declarative/canvas/stockchart/stockchart.pro
+++ b/examples/declarative/canvas/stockchart/stockchart.pro
@@ -1,20 +1,20 @@
-TEMPLATE = app
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += declarative network
-QT += declarative
+DESTDIR = com/nokia/StockChartExample
+TARGET = qmlstockchartexampleplugin
-RESOURCES += stockchart.qrc
+SOURCES += model.cpp plugin.cpp
+HEADERS += model.h
+qdeclarativesources.files += \
+ com/nokia/StockChartExample/qmldir \
+ stock.qml
-HEADERS = model.h
-SOURCES = main.cpp model.cpp
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample
-macx: CONFIG -= app_bundle
-CONFIG += console
-
-OTHER_FILES += \
- stock.qml \
- contents/Stocks.qml \
- contents/ScrollBar.qml \
- contents/TitleBar.qml \
- contents/Button.qml \
- contents/ToolBar.qml
+sources.files += stockchart.pro model.h model.cpp plugin.cpp README
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample
+INSTALLS += qdeclarativesources sources target
diff --git a/examples/declarative/canvas/stockchart/stockchart.qrc b/examples/declarative/canvas/stockchart/stockchart.qrc
deleted file mode 100644
index 1793bda12d..0000000000
--- a/examples/declarative/canvas/stockchart/stockchart.qrc
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>stock.qml</file>
- <file>contents/Stocks.qml</file>
- <file>contents/TitleBar.qml</file>
- <file>contents/ToolBar.qml</file>
- <file>contents/Button.qml</file>
- <file>contents/images/button.png</file>
- <file>contents/images/button-pressed.png</file>
- <file>contents/images/gloss.png</file>
- <file>contents/images/lineedit.png</file>
- <file>contents/images/lineedit.sci</file>
- <file>contents/images/quit.png</file>
- <file>contents/images/stripes.png</file>
- <file>contents/images/titlebar.png</file>
- <file>contents/images/titlebar.sci</file>
- <file>contents/images/toolbutton.png</file>
- <file>contents/images/toolbutton.sci</file>
-</qresource>
-</RCC>
-
diff --git a/examples/declarative/canvas/tiger/tiger.js b/examples/declarative/canvas/tiger/tiger.js
new file mode 100644
index 0000000000..4be0d26c9d
--- /dev/null
+++ b/examples/declarative/canvas/tiger/tiger.js
@@ -0,0 +1,721 @@
+var tiger = [
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000",
+ "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"}
+ ,
+ {"fill": "#cc7226", "stroke":"#000000",
+ "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"}
+ ,
+ {"fill": "#e87f3a",
+ "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"}
+ ,
+ {"fill": "#ea8c4d",
+ "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"}
+ ,
+ {"fill": "#ec9961",
+ "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"}
+ ,
+ {"fill": "#eea575",
+ "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"}
+ ,
+ {"fill": "#f1b288",
+ "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"}
+ ,
+ {"fill": "#f3bf9c",
+ "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"}
+ ,
+ {"fill": "#f5ccb0",
+ "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"}
+ ,
+ {"fill": "#f8d8c4",
+ "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"}
+ ,
+ {"fill": "#fae5d7",
+ "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"}
+ ,
+ {"fill": "#fcf2eb",
+ "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"}
+ ,
+ {"fill": "#e5668c",
+ "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"}
+ ,
+ {"fill": "#b23259",
+ "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"}
+ ,
+ {"fill": "#a5264c",
+ "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"}
+ ,
+ {"fill": "#ff727f", "stroke":"#000000",
+ "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"}
+ ,
+ {"fill": "#cc3f4c",
+ "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"}
+ ,
+ {"stroke":"#a51926", "width":2,
+ "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"}
+ ,
+ {"fill": "#b2b2b2",
+ "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"}
+ ,
+ {"fill": "#ea8e51",
+ "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"}
+ ,
+ {"fill": "#efaa7c",
+ "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"}
+ ,
+ {"fill": "#f4c6a8",
+ "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"}
+ ,
+ {"fill": "#f9e2d3",
+ "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"}
+ ,
+ {"fill": "#659900",
+ "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"}
+ ,
+ {"fill": "#eb955c",
+ "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"}
+ ,
+ {"fill": "#f2b892",
+ "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"}
+ ,
+ {"fill": "#f8dcc8",
+ "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"}
+ ,
+ {"fill": "#000000",
+ "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"}
+ ,
+ {"fill": "#000000",
+ "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"}
+ ,
+ {"fill": "#323232",
+ "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"}
+ ,
+ {"fill": "#666666",
+ "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"}
+ ,
+ {"fill": "#999999",
+ "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"}
+ ,
+ {"fill": "#000000",
+ "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"}
+ ,
+ {"fill": "#000000",
+ "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"}
+ ,
+ {"fill": "#000000",
+ "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"}
+ ,
+ {"fill": "#4c0000",
+ "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"}
+ ,
+ {"fill": "#659900",
+ "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 9z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"}
+ ,
+ {"fill": "#e59999",
+ "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"}
+ ,
+ {"fill": "#b26565",
+ "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"}
+ ,
+ {"fill": "#000000",
+ "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"}
+ ,
+ {"fill": "#000000",
+ "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"}
+ ,
+ {"fill": "#000000",
+ "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"}
+ ,
+ {"fill": "#000000",
+ "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"}
+ ,
+ {"fill": "#000000",
+ "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"}
+ ,
+ {"fill": "#000000",
+ "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"}
+ ,
+ {"fill": "#000000",
+ "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"}
+ ,
+ {"fill": "#000000",
+ "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-89.25 169L-67.25 173.75"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"}
+ ,
+ {"stroke":"#000000",
+ "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"}
+]; \ No newline at end of file
diff --git a/examples/declarative/canvas/tiger/tiger.qml b/examples/declarative/canvas/tiger/tiger.qml
new file mode 100644
index 0000000000..9978ef15bb
--- /dev/null
+++ b/examples/declarative/canvas/tiger/tiger.qml
@@ -0,0 +1,92 @@
+import QtQuick 2.0
+import "../contents"
+import "tiger.js" as Tiger
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:false
+ renderTarget:Canvas.Image
+ threadRendering: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 scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ property int frame:0
+
+ onLineWidthChanged: requestPaint();
+ onFillChanged: requestPaint();
+ onStrokeChanged: requestPaint();
+ onAlphaChanged: requestPaint();
+ onScaleXChanged: requestPaint();
+ onScaleYChanged: requestPaint();
+ onRotateChanged: requestPaint();
+
+ onPainted : {
+ canvas.frame++;
+ if (canvas.frame < Tiger.tiger.length)
+ 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.globalAlpha = canvas.alpha;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.globalCompositeOperation = "source-over";
+ ctx.translate(canvas.width/2, canvas.height/2);
+ ctx.strokeStyle = Qt.rgba(.3, .3, .3,1);
+ ctx.lineWidth = 1;
+
+
+ for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) {
+ if (Tiger.tiger[i].width != undefined)
+ ctx.lineWidth = Tiger.tiger[i].width;
+
+ if (Tiger.tiger[i].path != undefined)
+ ctx.path = Tiger.tiger[i].path;
+
+ if (Tiger.tiger[i].fill != undefined) {
+ ctx.fillStyle = Tiger.tiger[i].fill;
+ ctx.fill();
+ }
+
+ if (Tiger.tiger[i].stroke != undefined) {
+ ctx.strokeStyle = Tiger.tiger[i].stroke;
+ ctx.stroke();
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:controls
+ width:360
+ 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"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/declarative/canvas/twitterfriends/TwitterUser.qml b/examples/declarative/canvas/twitterfriends/TwitterUser.qml
new file mode 100644
index 0000000000..1a83d57928
--- /dev/null
+++ b/examples/declarative/canvas/twitterfriends/TwitterUser.qml
@@ -0,0 +1,254 @@
+import QtQuick 2.0
+
+Item {
+ id:twitterUser
+ property variant friends : [];
+ property string name : "";
+ property string twitterId : "";
+ property string image : "";
+ property string url : "";
+ property string desc : "";
+ width : 0;
+ height : 0;
+ property int posX:0;
+ property int posY:0;
+ property bool hasFocus : false;
+ property variant canvas;
+ property variant manager;
+ property variant linkColor;
+ property bool selected : false;
+
+ Rectangle {
+ id:twitterStatus
+ x:twitterUser.width
+ y:twitterUser.height
+ width:250
+ height:60
+ opacity: 0
+ border.color:"steelblue"
+ border.width:3
+ Column {
+ spacing:2
+ Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere}
+ Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere}
+ }
+ }
+
+ function moved() {
+ twitterUser.posX = twitterUser.x;
+ twitterUser.posY = twitterUser.y;
+ twitterUser.canvas.requestPaint();
+ }
+
+ onXChanged: moved();
+ onYChanged: moved();
+
+ MouseArea {
+ anchors.fill:parent
+ drag.target : twitterUser
+ drag.axis : Drag.XandYAxis
+
+ onClicked: {
+ if (!twitterUser.selected) {
+ twitterUser.selected = true;
+ twitterStatus.opacity = 1;
+ twitterStatus.visible = true;
+ } else {
+ twitterUser.selected = false;
+ twitterStatus.opacity = 0;
+ }
+ }
+
+ onDoubleClicked : {
+ twitterStatus.opacity = 0;
+ twitterUser.selected = false;
+ twitterUser.hasFocus = true;
+ twitterUser.canvas.twitterName = twitterUser.name;
+ twitterUser.canvas.twitterId = twitterUser.twitterId;
+ twitterUser.canvas.loading = true;
+ twitterUser.createFriends();
+ }
+ }
+
+ function show(ctx, layoutChanged) {
+ var w = canvas.width;
+ var h = canvas.height;
+ if (twitterUser.hasFocus) {
+ twitterUser.width = 60
+ twitterUser.height = 60
+ twitterUser.posX = w/2;
+ twitterUser.posY = h/2;
+ } else {
+ twitterUser.width = 40
+ twitterUser.height = 40
+ }
+
+
+ if (twitterUser.hasFocus) {
+ if (layoutChanged)
+ twitterUser.layoutFriends();
+ twitterUser.linkFriends(ctx);
+ twitterUser.showFriends(ctx);
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 20;
+ ctx.shadowColor = "blue";
+ ctx.globalAlpha = 1;
+ } else {
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 20;
+ ctx.shadowColor = twitterUser.linkColor;
+ ctx.globalAlpha = 0.6;
+ }
+
+ if (twitterUser.canvas.isImageLoaded(twitterUser.image)) {
+ ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height);
+ }
+// ctx.font = "15px";
+// var nameSize = ctx.measureText(twitterUser.name).width;
+// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10);
+ }
+ function dump() {
+ console.log("name:" + twitterUser.name
+ + " x:" + twitterUser.posX
+ + " y:" + twitterUser.posY
+ + " width:" + twitterUser.width
+ + " height:" + twitterUser.height
+ + " id:" + twitterUser.twitterId
+ + " image:" + twitterUser.image
+ + " url:" + twitterUser.url + "\n" + twitterUser.desc);
+ }
+
+ function layoutFriends() {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend) {
+ friend.x = Math.random() *w;
+ friend.y = Math.random() *h;
+ }
+ }
+ }
+
+ function showFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ friend.hasFocus = false;
+ friend.show(ctx, false);
+ }
+ }
+ }
+
+ function linkFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ if (!friend.linkColor)
+ friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255, 0.8);
+ ctx.strokeStyle = friend.linkColor;
+ ctx.lineWidth = 8;
+ ctx.beginPath();
+ ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2);
+ ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2);
+ ctx.stroke();
+ }
+ }
+ }
+
+
+ function create(url) {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ var user = eval('(' + x.responseText +')')[0];
+ twitterUser.name = user.name;
+ twitterUser.twitterId = user.id;
+ twitterUser.image = user.profile_image_url;
+ twitterUser.canvas.loadImage(twitterUser.image);
+ twitterUser.url = user.url;
+ twitterUser.desc = user.description;
+ twitterUser.createFriends();
+ }
+ }
+ x.send();
+ }
+
+ function createByName(name) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.name = name;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createById(id) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.twitterId = id;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createFriends() {
+ if (twitterUser.friends.length === 0) {
+ var x = new XMLHttpRequest;
+ var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId;
+ x.open("GET", friendsUrl);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ twitterUser.friends = eval('(' + x.responseText +')').ids;
+ var doRequest = false;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=";
+
+ for (var i=0; i<twitterUser.friends.length && i < 100; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (!friend) {
+ userUrl += "," + twitterUser.friends[i];
+ doRequest = true;
+ }
+ }
+
+ if (!doRequest) return;
+
+ var xx = new XMLHttpRequest;
+ xx.open("GET", userUrl);
+ xx.onreadystatechange = function() {
+ if (xx.readyState == XMLHttpRequest.DONE) {
+ var friendUsers = eval('(' + xx.responseText +')');
+ for(var i=0; i<friendUsers.length; i++) {
+ var friend = manager.createTwitterUser(twitterUser.canvas);
+ friend.name = friendUsers[i].name;
+ friend.twitterId = friendUsers[i].id;
+ friend.image = friendUsers[i].profile_image_url ? friendUsers[i].profile_image_url : "";
+ friend.url = friendUsers[i].url ? friendUsers[i].url : "";
+ friend.desc = friendUsers[i].description ? friendUsers[i].description : "";
+ friend.manager = twitterUser.manager;
+ twitterUser.canvas.loadImage(friend.image);
+ }
+
+ if (twitterUser.hasFocus && twitterUser.canvas) {
+ twitterUser.canvas.layoutChanged = true;
+ twitterUser.canvas.loading = false;
+ twitterUser.canvas.requestPaint();
+ }
+ }
+ }
+ xx.send();
+ }
+ }
+ x.send();
+ }
+ }
+}
diff --git a/examples/declarative/canvas/twitterfriends/cache.js b/examples/declarative/canvas/twitterfriends/cache.js
new file mode 100644
index 0000000000..6c8a1cd71a
--- /dev/null
+++ b/examples/declarative/canvas/twitterfriends/cache.js
@@ -0,0 +1,42 @@
+var UserCache = function() {
+ this._users = [];
+}
+
+
+UserCache.prototype.getById = function(id){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.twitterId == id) {
+ return user;
+ }
+ }
+}
+UserCache.prototype.getByName = function(name){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.name == name)
+ return user;
+ }
+}
+
+UserCache.prototype.add = function(user){
+ this._users[this._users.length] = user;
+}
+
+
+var cache = new UserCache;
+
+function getById(id) {
+ return cache.getById(id);
+}
+
+function getByName(name) {
+ return cache.getByName(name);
+}
+
+function createTwitterUser(canvas) {
+ var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas);
+ user.canvas = canvas;
+ cache.add(user);
+ return user;
+}
diff --git a/examples/declarative/canvas/twitterfriends/twitter.qml b/examples/declarative/canvas/twitterfriends/twitter.qml
new file mode 100644
index 0000000000..0f456711b8
--- /dev/null
+++ b/examples/declarative/canvas/twitterfriends/twitter.qml
@@ -0,0 +1,87 @@
+import QtQuick 2.0
+import "../contents"
+import "cache.js" as TwitterUserCache
+Item {
+ width:360
+ height:600
+ QtObject {
+ id:twitterManager
+ function getById(id) {
+ return TwitterUserCache.cache.getById(id);
+ }
+
+ function getByName(name) {
+ return TwitterUserCache.cache.getByName(name);
+ }
+
+ function createTwitterUser(canvas) {
+ return TwitterUserCache.createTwitterUser(canvas);
+ }
+ }
+ Rectangle {
+ id:inputContainer
+ width:parent.width
+ height:40
+ anchors.top : parent.top
+
+ TextInput {
+ id:inputName
+ anchors.fill:parent
+ font.pointSize : 20
+ opacity:1
+ color:"steelblue"
+ width:200
+ height:40
+ text: "Input your twitter name..."
+ selectByMouse:true
+ onAccepted : {canvas.twitterName = text; canvas.requestPaint();}
+ }
+ }
+ Canvas {
+ id:canvas
+ width:parent.width
+ anchors.top :inputContainer.bottom
+ anchors.bottom : parent.bottom
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+
+ property bool layoutChanged:true
+ property string twitterName:""
+ property string twitterId:""
+ property bool loading:false
+
+ onLoadingChanged: requestPaint();
+ onWidthChanged: { layoutChanged = true; requestPaint();}
+ onHeightChanged: { layoutChanged = true; requestPaint();}
+ onTwitterNameChanged: inputName.text = twitterName;
+ onImageLoaded:requestPaint();
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.fillStyle="black";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ if (canvas.twitterName != "" || canvas.twitterId != "") {
+ var user = canvas.twitterId ? TwitterUserCache.getById(canvas.twitterId) : TwitterUserCache.getByName(canvas.twitterName);
+ if (!user) {
+ user = TwitterUserCache.createTwitterUser(canvas);
+ user.hasFocus = true;
+ user.manager = twitterManager;
+ user.createByName(canvas.twitterName);
+ canvas.loading = true;
+ }
+
+ if (canvas.loading) {
+ ctx.font = "40px";
+ ctx.fillStyle = "steelblue";
+ ctx.fillText("Loading...", canvas.width/2 - 80, canvas.height/2);
+ } else {
+ user.show(ctx, layoutChanged);
+ }
+ layoutChanged = false;
+ }
+ }
+ }
+}
+
diff --git a/src/declarative/items/context2d/context2d.pri b/src/declarative/items/context2d/context2d.pri
index a43ef7806a..60fe28dd43 100644
--- a/src/declarative/items/context2d/context2d.pri
+++ b/src/declarative/items/context2d/context2d.pri
@@ -3,9 +3,16 @@ INCLUDEPATH += $$PWD
SOURCES += \
$$PWD/qsgcanvasitem.cpp \
$$PWD/qsgcontext2d.cpp \
+ $$PWD/qsgcontext2dnode.cpp \
+ $$PWD/qsgcontext2dtile.cpp \
+ $$PWD/qsgcontext2dtexture.cpp \
+ $$PWD/qsgcontext2dcommandbuffer.cpp \
HEADERS += \
$$PWD/qsgcanvasitem_p.h \
- $$PWD/qsgcontext2d_p_p.h \
$$PWD/qsgcontext2d_p.h \
+ $$PWD/qsgcontext2dnode_p.h \
+ $$PWD/qsgcontext2dtile_p.h \
+ $$PWD/qsgcontext2dtexture_p.h \
+ $$PWD/qsgcontext2dcommandbuffer_p.h \
diff --git a/src/declarative/items/context2d/qsgcanvasitem.cpp b/src/declarative/items/context2d/qsgcanvasitem.cpp
index 0bd9a47d8d..03eab72368 100644
--- a/src/declarative/items/context2d/qsgcanvasitem.cpp
+++ b/src/declarative/items/context2d/qsgcanvasitem.cpp
@@ -39,124 +39,366 @@
**
****************************************************************************/
-#include <QtGui/qpainter.h>
-
#include "private/qsgadaptationlayer_p.h"
#include "qsgcanvasitem_p.h"
-#include "qsgpainteditem_p.h"
+#include "qsgitem_p.h"
#include "qsgcontext2d_p.h"
-#include "private/qsgpainternode_p.h"
+#include "qsgcontext2dnode_p.h"
+#include "qsgcontext2dtexture_p.h"
+#include "qdeclarativepixmapcache_p.h"
+
#include <qdeclarativeinfo.h>
#include "qdeclarativeengine_p.h"
#include <QtCore/QBuffer>
QT_BEGIN_NAMESPACE
-class QSGCanvasItemPrivate : public QSGPaintedItemPrivate
+class QSGCanvasItemPrivate : public QSGItemPrivate
{
public:
QSGCanvasItemPrivate();
~QSGCanvasItemPrivate();
QSGContext2D* context;
- QList<QRect> dirtyRegions;
- QRect unitedDirtyRegion;
- qreal canvasX;
- qreal canvasY;
+ QSGContext2DTexture* texture;
+ QSizeF canvasSize;
+ QSize tileSize;
+ QRectF canvasWindow;
+ QRectF dirtyRect;
+ uint threadRendering : 1;
+ uint hasCanvasSize :1;
+ uint hasTileSize :1;
+ uint hasCanvasWindow :1;
+ uint componentCompleted :1;
+ QSGCanvasItem::RenderTarget renderTarget;
+ QHash<QUrl, QDeclarativePixmap*> images;
+ QUrl baseUrl;
};
-
-/*!
- \internal
-*/
QSGCanvasItemPrivate::QSGCanvasItemPrivate()
- : QSGPaintedItemPrivate()
+ : QSGItemPrivate()
, context(0)
- , unitedDirtyRegion()
- , canvasX(0.)
- , canvasY(0.)
+ , texture(0)
+ , canvasSize(1, 1)
+ , tileSize(1, 1)
+ , threadRendering(true)
+ , hasCanvasSize(false)
+ , hasTileSize(false)
+ , hasCanvasWindow(false)
+ , componentCompleted(false)
+ , renderTarget(QSGCanvasItem::Image)
{
}
QSGCanvasItemPrivate::~QSGCanvasItemPrivate()
{
+ qDeleteAll(images);
+}
+
+/*!
+ \qmlclass Canvas QSGCanvasItem
+ \inqmlmodule QtQuick 2
+ \since QtQuick 2.0
+ \brief The Canvas item provides HTML5 canvas element compatible scripts with a resolution-dependent bitmap canvas.
+ \inherits Item
+ \ingroup qml-basic-visual-elements
+
+ The canvas is used to render graphs, game graphics, or other visual images on the fly.
+
+ \section1 Example Usage
+
+ \section1 Thread Rendering Mode
+
+ \section1 Tiled Canvas
+
+ \section1 Quality and Performance
+
+ By default, all of the drawing commands are rendered by a dedicated thread for better
+ performance and avoid blocking the main GUI thread. Setting the \l threadRendering property
+ to false can make the canvas rendering stay in the main GUI thread.
+
+ \sa Context2D
+*/
+
+/*!
+ Constructs a QSGCanvasItem with the given \a parent item.
+ */
+QSGCanvasItem::QSGCanvasItem(QSGItem *parent)
+ : QSGItem(*(new QSGCanvasItemPrivate), parent)
+{
+ setFlag(ItemHasContents);
+}
+
+/*!
+ Destroys the QSGCanvasItem.
+*/
+QSGCanvasItem::~QSGCanvasItem()
+{
+ Q_D(QSGCanvasItem);
+ if (d->texture) {
+ d->texture->setItem(0);
+ d->texture->deleteLater();
+ }
+ delete d->context;
+}
+
+/*!
+ \qmlproperty size QtQuick2::Canvas::canvasSize
+ Holds the logical canvas size that the context paints on.
+
+ By default, the canvas size is the same with the current canvas item size.
+ \sa tileSize canvasWindow
+*/
+QSizeF QSGCanvasItem::canvasSize() const
+{
+ Q_D(const QSGCanvasItem);
+ return d->canvasSize;
+}
+
+void QSGCanvasItem::setCanvasSize(const QSizeF & size)
+{
+ Q_D(QSGCanvasItem);
+ if (d->canvasSize != size) {
+ d->hasCanvasSize = true;
+ d->canvasSize = size;
+ emit canvasSizeChanged();
+ polish();
+ }
}
+/*!
+ \qmlproperty size QtQuick2::Canvas::tileSize
+ Holds the canvas rendering tile size.
+
+ The canvas render can improve the rendering performance
+ by rendering and caching each tiles instead of rendering
+ the whole canvas everytime.
+
+ Additionally, the canvas size could be infinitely large
+ because only those tiles within the current visible region
+ are actually rendered.
+
+ By default, the tile size is the same with the canvas size.
+ \sa canvasSize
+*/
+QSize QSGCanvasItem::tileSize() const
+{
+ Q_D(const QSGCanvasItem);
+ return d->tileSize;
+}
-void QSGCanvasItem::setCanvasX(qreal x)
+void QSGCanvasItem::setTileSize(const QSize & size)
{
Q_D(QSGCanvasItem);
- if (d->canvasX != x) {
- d->canvasX = x;
- emit canvasXChanged();
+ if (d->tileSize != size) {
+ d->hasTileSize = true;
+ d->tileSize = size;
+
+ emit tileSizeChanged();
+ polish();
}
}
-void QSGCanvasItem::setCanvasY(qreal y)
+
+/*!
+ \qmlproperty rect QtQuick2::Canvas::canvasWindow
+ Holds the current canvas visible window.
+
+ This property is read only, a canvas window can
+ be changed by changing the canvas item width, height
+ or the canvas viewport properties.
+
+ When painting on a canvas item, even the item is visible
+ and focused, only the current canvas window area is actually
+ rendered even the painting commands may paint shaps out of
+ the canvas window.
+
+ The canvas window size is already synchronized with the canvas item size.
+ \sa width height canvasSize
+*/
+QRectF QSGCanvasItem::canvasWindow() const
+{
+ Q_D(const QSGCanvasItem);
+ return d->canvasWindow;
+}
+
+void QSGCanvasItem::setCanvasWindow(const QRectF& rect)
{
Q_D(QSGCanvasItem);
- if (d->canvasY != y) {
- d->canvasY = y;
- emit canvasYChanged();
+ if (d->canvasWindow != rect) {
+ d->canvasWindow = rect;
+
+ d->hasCanvasWindow = true;
+ emit canvasWindowChanged();
+ polish();
}
}
-qreal QSGCanvasItem::canvasX() const
+
+QSGContext2D* QSGCanvasItem::context() const
{
Q_D(const QSGCanvasItem);
- return d->canvasX;
+ return d->context;
}
-qreal QSGCanvasItem::canvasY() const
+bool QSGCanvasItem::threadRendering() const
{
Q_D(const QSGCanvasItem);
- return d->canvasY;
+ return d->threadRendering;
}
-QPointF QSGCanvasItem::canvasPos() const
+
+QSGCanvasItem::RenderTarget QSGCanvasItem::renderTarget() const
{
Q_D(const QSGCanvasItem);
- return QPointF(d->canvasX, d->canvasY);
+ return d->renderTarget;
}
-/*!
- Constructs a QSGCanvasItem with the given \a parent item.
- */
-QSGCanvasItem::QSGCanvasItem(QSGItem *parent)
- : QSGPaintedItem(*(new QSGCanvasItemPrivate), parent)
+void QSGCanvasItem::setRenderTarget(RenderTarget target)
{
+ Q_D(QSGCanvasItem);
+ if (d->renderTarget != target) {
+ d->renderTarget = target;
+
+ if (d->componentCompleted)
+ createTexture();
+ emit renderTargetChanged();
+ }
+}
+
+void QSGCanvasItem::_doPainting(const QRectF& region)
+{
+ Q_D(QSGCanvasItem);
+ emit paint(QDeclarativeV8Handle::fromHandle(d->context->v8value())
+ , QSGContext2DTexture::tiledRect(region, d->tileSize));
+ if (d->texture)
+ d->texture->wake();
}
/*!
- Destroys the QSGCanvasItem.
+ \qmlproperty bool QtQuick2::Canvas::threadRendering
+ 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 threadRendering value is true.
*/
-QSGCanvasItem::~QSGCanvasItem()
+void QSGCanvasItem::setThreadRendering(bool threadRendering)
{
+ Q_D(QSGCanvasItem);
+ if (d->threadRendering != threadRendering) {
+ d->threadRendering = threadRendering;
+
+ if (d->componentCompleted)
+ createTexture();
+
+ if (d->threadRendering)
+ connect(this, SIGNAL(painted()), SLOT(update()));
+ else
+ disconnect(this, SIGNAL(painted()), this, SLOT(update()));
+ emit threadRenderingChanged();
+ polish();
+ }
}
-void QSGCanvasItem::paint(QPainter *painter)
+void QSGCanvasItem::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
{
Q_D(QSGCanvasItem);
- if (d->context && d->context->isDirty()) {
- painter->setWindow(-d->canvasX, -d->canvasY, d->width, d->height);
- painter->setViewport(0, 0, d->width, d->height);
- painter->scale(d->contentsScale, d->contentsScale);
+ QSGItem::geometryChanged(newGeometry, oldGeometry);
+
+ const qreal w = newGeometry.width();
+ const qreal h = newGeometry.height();
+
+ if (!d->hasCanvasSize) {
+ d->canvasSize = QSizeF(w, h);
+ emit canvasSizeChanged();
+ }
+
+ if (!d->hasTileSize) {
+ d->tileSize = d->canvasSize.toSize();
+ emit tileSizeChanged();
+ }
- d->context->paint(painter);
- emit painted();
+ if (!d->hasCanvasWindow) {
+ d->canvasWindow = newGeometry;
+ emit canvasWindowChanged();
}
+
+ polish();
}
void QSGCanvasItem::componentComplete()
{
- const QMetaObject *metaObject = this->metaObject();
- int propertyCount = metaObject->propertyCount();
- int requestPaintMethod = metaObject->indexOfMethod("requestPaint(const QRect&)");
- for (int ii = QSGCanvasItem::staticMetaObject.propertyCount(); ii < propertyCount; ++ii) {
- QMetaProperty p = metaObject->property(ii);
- if (p.hasNotifySignal())
- QMetaObject::connect(this, p.notifySignalIndex(), this, requestPaintMethod, 0, 0);
- }
+ Q_D(QSGCanvasItem);
createContext();
+ createTexture();
+
+ markDirty(d->canvasWindow);
+ QSGItem::componentComplete();
+
+ d->baseUrl = qmlEngine(this)->contextForObject(this)->baseUrl();
+ d->componentCompleted = true;
+}
+
+void QSGCanvasItem::updatePolish()
+{
+ Q_D(QSGCanvasItem);
+
+ QSGItem::updatePolish();
+ if (d->texture) {
+ if (!d->threadRendering && d->dirtyRect.isValid())
+ _doPainting(d->dirtyRect);
+
+ d->texture->canvasChanged(d->canvasSize.toSize()
+ , d->tileSize
+ , d->canvasWindow.toAlignedRect()
+ , d->dirtyRect.toAlignedRect()
+ , d->smooth);
+ d->dirtyRect = QRectF();
+ }
+}
+
+QSGNode *QSGCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ Q_D(QSGCanvasItem);
+ QSGContext2DNode *node = static_cast<QSGContext2DNode *>(oldNode);
+ if (!node)
+ node = new QSGContext2DNode(this);
+
+ node->setTexture(d->texture);
+ node->update();
+ return node;
+}
+
+void QSGCanvasItem::createTexture()
+{
+ Q_D(QSGCanvasItem);
- QSGPaintedItem::componentComplete();
+ if (!d->texture
+ || d->texture->threadRendering() != d->threadRendering
+ || d->texture->renderTarget() != d->renderTarget) {
+ if (d->texture) {
+ d->texture->deleteLater();
+ d->texture = 0;
+ }
+
+ if (d->renderTarget == QSGCanvasItem::Image) {
+ d->texture = new QSGContext2DImageTexture(d->threadRendering);
+ } else if (d->renderTarget == QSGCanvasItem::FramebufferObject) {
+ d->texture = new QSGContext2DFBOTexture();
+ }
+
+ if (d->threadRendering && !d->texture->supportThreadRendering()) {
+ qWarning("Canvas: render target does not support thread rendering, force to non-thread rendering mode.");
+ d->threadRendering = false;
+ emit threadRenderingChanged();
+ }
+
+ if (d->threadRendering)
+ connect(d->texture, SIGNAL(textureChanged()), this, SLOT(update()));
+
+ d->texture->setItem(this);
+ }
}
void QSGCanvasItem::createContext()
@@ -171,6 +413,13 @@ void QSGCanvasItem::createContext()
d->context->setV8Engine(e);
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Canvas::getContext(string contextId)
+
+ Currently, the canvas item only support the 2D context. If the \a contextId
+ parameter isn't provided or is "2d", then the QtQuick2::Context2D object is
+ returned, otherwise returns an invalid value.
+ */
QDeclarativeV8Handle QSGCanvasItem::getContext(const QString &contextId)
{
Q_D(QSGCanvasItem);
@@ -181,91 +430,157 @@ QDeclarativeV8Handle QSGCanvasItem::getContext(const QString &contextId)
return QDeclarativeV8Handle::fromHandle(v8::Undefined());
}
-void QSGCanvasItem::requestPaint(const QRect& r)
+/*!
+ \qmlmethod void QtQuick2::Canvas::markDirty(rect region)
+
+ Mark the given \a region as dirty, so that when this region is visible
+ the canvas render will redraw it. During the rendering stage, the
+ canvas renderer may emit the canvas' "paint" signal so the actual painting
+ scripts can be putted into the canvas's "onPaint" function.
+
+ \sa QtQuick2::Canvas::paint
+ */
+void QSGCanvasItem::markDirty(const QRectF& region)
{
Q_D(QSGCanvasItem);
+ d->dirtyRect |= region;
+ polish();
+}
- QRect region;
- if (!r.isValid())
- region = QRect(d->canvasX, d->canvasY, d->width, d->height);
- else
- region = r;
- foreach (const QRect& rect, d->dirtyRegions) {
- if (rect.contains(region))
- return;
- }
+/*!
+ \qmlmethod bool QtQuick2::Canvas::save(string filename)
- d->unitedDirtyRegion = d->unitedDirtyRegion.unite(region);
- d->dirtyRegions.append(region);
- polish();
- update(d->unitedDirtyRegion);
-}
+ Save the current canvas content into an image file \a filename.
+ The saved image format is automatically decided by the \a filename's
+ suffix.
+
+ Note: calling this method will force painting the whole canvas, not the
+ current canvas visible window.
+ \sa canvasWindow canvasSize toDataURL
+ */
bool QSGCanvasItem::save(const QString &filename) const
{
- Q_D(const QSGCanvasItem);
- QSGPainterNode* node = static_cast<QSGPainterNode*>(d->paintNode);
- if (node) {
- QImage image = node->toImage();
- image.save(filename);
+ return toImage().save(filename);
+}
+
+QImage QSGCanvasItem::loadedImage(const QUrl& url)
+{
+ Q_D(QSGCanvasItem);
+ QUrl fullPathUrl = d->baseUrl.resolved(url);
+ if (!d->images.contains(fullPathUrl)) {
+ loadImage(url);
+ }
+ QDeclarativePixmap* pix = d->images.value(fullPathUrl);
+ if (pix->isLoading() || pix->isError()) {
+ return QImage();
+ }
+ return pix->pixmap().toImage();
+}
+void QSGCanvasItem::loadImage(const QUrl& url)
+{
+ Q_D(QSGCanvasItem);
+ QUrl fullPathUrl = d->baseUrl.resolved(url);
+ if (!d->images.contains(fullPathUrl)) {
+ QDeclarativePixmap* pix = new QDeclarativePixmap();
+ d->images.insert(fullPathUrl, pix);
+
+ pix->load(qmlEngine(this)
+ , fullPathUrl
+ , QDeclarativePixmap::Cache | QDeclarativePixmap::Asynchronous);
+ pix->connectFinished(this, SIGNAL(imageLoaded()));
}
- return false;
}
-void QSGCanvasItem::updatePolish()
+void QSGCanvasItem::unloadImage(const QUrl& url)
{
Q_D(QSGCanvasItem);
- QDeclarativeV8Handle context = QDeclarativeV8Handle::fromHandle(d->context->v8value());
+ QUrl removeThis = d->baseUrl.resolved(url);
+ if (d->images.contains(removeThis)) {
+ delete d->images.value(removeThis);
+ d->images.remove(removeThis);
+ }
+}
+
+bool QSGCanvasItem::isImageError(const QUrl& url) const
+{
+ Q_D(const QSGCanvasItem);
+ QUrl fullPathUrl = d->baseUrl.resolved(url);
+ return d->images.contains(fullPathUrl)
+ && d->images.value(fullPathUrl)->isError();
+}
- d->context->setValid(true);
+bool QSGCanvasItem::isImageLoading(const QUrl& url) const
+{
+ Q_D(const QSGCanvasItem);
+ QUrl fullPathUrl = d->baseUrl.resolved(url);
+ return d->images.contains(fullPathUrl)
+ && d->images.value(fullPathUrl)->isLoading();
+}
- // d->context->setTileRect(QRectF(d->canvasX, d->canvasY, d->width, d->height).intersected(QRectF(0, 0, d->width, d->height)));
- // d->context->setTileRect(QRectF(d->canvasX, d->canvasY, d->width, d->height));
+bool QSGCanvasItem::isImageLoaded(const QUrl& url) const
+{
+ Q_D(const QSGCanvasItem);
+ QUrl fullPathUrl = d->baseUrl.resolved(url);
+ return d->images.contains(fullPathUrl)
+ && d->images.value(fullPathUrl)->isReady();
+}
- foreach (const QRect& region, d->dirtyRegions) {
- emit paint(context, region);
+QImage QSGCanvasItem::toImage(const QRectF& region) const
+{
+ Q_D(const QSGCanvasItem);
+ if (d->texture) {
+ if (region.isEmpty())
+ return d->texture->toImage(canvasWindow());
+ else
+ return d->texture->toImage(region);
}
- d->dirtyRegions.clear();
+ return QImage();
+}
- d->context->setValid(false);
+/*!
+ \qmlmethod string QtQuick2::Canvas::toDataURL(string mimeType)
- QSGPaintedItem::updatePolish();
-}
+ Returns a data: URL for the image in the canvas.
+ The default \a mimeType is "image/png".
+ Note: calling this method will force painting the whole canvas, not the
+ current canvas visible window.
+
+ \sa canvasWindow canvasSize save
+ */
QString QSGCanvasItem::toDataURL(const QString& mimeType) const
{
- Q_D(const QSGCanvasItem);
+ QImage image = toImage();
- QSGPainterNode* node = static_cast<QSGPainterNode*>(d->paintNode);
- if (node) {
- QImage image = node->toImage();
+ if (!image.isNull()) {
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
QString mime = mimeType;
QString type;
- if (mimeType == QLatin1String("image/bmp"))
- type = QLatin1String("BMP");
- else if (mimeType == QLatin1String("image/jpeg"))
- type = QLatin1String("JPEG");
- else if (mimeType == QLatin1String("image/x-portable-pixmap"))
- type = QLatin1String("PPM");
- else if (mimeType == QLatin1String("image/tiff"))
- type = QLatin1String("TIFF");
- else if (mimeType == QLatin1String("image/xbm"))
- type = QLatin1String("XBM");
- else if (mimeType == QLatin1String("image/xpm"))
- type = QLatin1String("XPM");
+ if (mimeType == QLatin1Literal("image/bmp"))
+ type = QLatin1Literal("BMP");
+ else if (mimeType == QLatin1Literal("image/jpeg"))
+ type = QLatin1Literal("JPEG");
+ else if (mimeType == QLatin1Literal("image/x-portable-pixmap"))
+ type = QLatin1Literal("PPM");
+ else if (mimeType == QLatin1Literal("image/tiff"))
+ type = QLatin1Literal("TIFF");
+ else if (mimeType == QLatin1Literal("image/xbm"))
+ type = QLatin1Literal("XBM");
+ else if (mimeType == QLatin1Literal("image/xpm"))
+ type = QLatin1Literal("XPM");
else {
- type = QLatin1String("PNG");
- mime = QLatin1String("image/png");
+ type = QLatin1Literal("PNG");
+ mime = QLatin1Literal("image/png");
}
image.save(&buffer, type.toAscii());
buffer.close();
- QString dataUrl = QLatin1String("data:%1;base64,%2");
- return dataUrl.arg(mime).arg(ba.toBase64().constData());
+ QString dataUrl = QLatin1Literal("data:%1;base64,%2");
+ return dataUrl.arg(mime).arg(QLatin1String(ba.toBase64().constData()));
}
- return QLatin1String("data:,");
+ return QLatin1Literal("data:,");
}
QT_END_NAMESPACE
diff --git a/src/declarative/items/context2d/qsgcanvasitem_p.h b/src/declarative/items/context2d/qsgcanvasitem_p.h
index 9a6ccc27ed..565b894a7c 100644
--- a/src/declarative/items/context2d/qsgcanvasitem_p.h
+++ b/src/declarative/items/context2d/qsgcanvasitem_p.h
@@ -42,14 +42,10 @@
#ifndef QSGCANVASITEM_P_H
#define QSGCANVASITEM_P_H
-#include "qsgpainteditem.h"
+#include "qsgitem.h"
#include <private/qv8engine_p.h>
-#define QSGCANVASITEM_DEBUG //enable this for just DEBUG purpose!
-#ifdef QSGCANVASITEM_DEBUG
-#include <QElapsedTimer>
-#endif
QT_BEGIN_HEADER
@@ -58,41 +54,92 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QSGContext2D;
class QSGCanvasItemPrivate;
-class QSGCanvasItem : public QSGPaintedItem
+class QSGCanvasItem : public QSGItem
{
Q_OBJECT
- Q_PROPERTY(QPointF canvasPos READ canvasPos FINAL)
- Q_PROPERTY(qreal canvasX READ canvasX WRITE setCanvasX NOTIFY canvasXChanged FINAL)
- Q_PROPERTY(qreal canvasY READ canvasY WRITE setCanvasY NOTIFY canvasYChanged FINAL)
+ Q_ENUMS(RenderTarget)
+ Q_ENUMS(ImageFilterMode)
+
+ 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(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
public:
+ enum RenderTarget {
+ Image,
+ FramebufferObject
+ };
+
+ enum ImageFilterMode {
+ Threshold,
+ GrayScale,
+ Brightness,
+ Invert,
+ Blur,
+ Opaque,
+ Convolute
+ };
+
QSGCanvasItem(QSGItem *parent = 0);
~QSGCanvasItem();
- void setCanvasX(qreal x);
- void setCanvasY(qreal y);
- qreal canvasX() const;
- qreal canvasY() const;
- QPointF canvasPos() const;
+
+ QSizeF canvasSize() const;
+ void setCanvasSize(const QSizeF &);
+
+ QSize tileSize() const;
+ void setTileSize(const QSize &);
+
+ QRectF canvasWindow() const;
+ void setCanvasWindow(const QRectF& rect);
+
+ bool threadRendering() const;
+ void setThreadRendering(bool theadRendering);
+
+ RenderTarget renderTarget() const;
+ void setRenderTarget(RenderTarget target);
+
+ QSGContext2D* context() const;
+ QImage toImage(const QRectF& region = QRectF()) const;
+
+ QImage loadedImage(const QUrl& url);
Q_SIGNALS:
- void painted();
void paint(QDeclarativeV8Handle context, const QRect &region);
- void canvasXChanged();
- void canvasYChanged();
+ void painted();
+ void canvasSizeChanged();
+ void tileSizeChanged();
+ void viewpointChanged();
+ void threadRenderingChanged();
+ void textureChanged();
+ void canvasWindowChanged();
+ void renderTargetChanged();
+ void imageLoaded();
public Q_SLOTS:
QString toDataURL(const QString& type = QLatin1String("image/png")) const;
QDeclarativeV8Handle getContext(const QString & = QLatin1String("2d"));
- void requestPaint(const QRect& region = QRect());
-
+ void markDirty(const QRectF& region);
+ void requestPaint() {markDirty(canvasWindow());}
// Save current canvas to disk
bool save(const QString& filename) const;
-
+ void loadImage(const QUrl& url);
+ void unloadImage(const QUrl& url);
+ bool isImageLoaded(const QUrl& url) const;
+ bool isImageLoading(const QUrl& url) const;
+ bool isImageError(const QUrl& url) const;
+private Q_SLOTS:
+ void _doPainting(const QRectF& region);
protected:
- void updatePolish();
- void paint(QPainter *painter);
virtual void componentComplete();
+ virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+ virtual void updatePolish();
private:
void createContext();
+ void createTexture();
Q_DECLARE_PRIVATE(QSGCanvasItem)
friend class QSGContext2D;
+ friend class QSGContext2DTexture;
};
QT_END_NAMESPACE
diff --git a/src/declarative/items/context2d/qsgcontext2d.cpp b/src/declarative/items/context2d/qsgcontext2d.cpp
index a2a57cb2ac..91bd5b5796 100644
--- a/src/declarative/items/context2d/qsgcontext2d.cpp
+++ b/src/declarative/items/context2d/qsgcontext2d.cpp
@@ -40,61 +40,43 @@
****************************************************************************/
#include "qsgcontext2d_p.h"
-#include "qsgcontext2d_p_p.h"
-#include "private/qsgadaptationlayer_p.h"
+#include "qsgcontext2dcommandbuffer_p.h"
#include "qsgcanvasitem_p.h"
-#include <QtOpenGL/qglframebufferobject.h>
+#include "qsgitem_p.h"
+#include "qsgshadereffectsource_p.h"
+
#include <QtCore/qdebug.h>
#include "private/qsgcontext_p.h"
#include "private/qdeclarativesvgparser_p.h"
+#include "private/qdeclarativepath_p.h"
+
+#include "private/qsgimage_p_p.h"
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qgraphicseffect.h>
#include <qdeclarativeinfo.h>
#include <QtCore/qmath.h>
-#include "qdeclarativepixmapcache_p.h"
-
-#include <private/qv8engine_p.h>
-#include "qvarlengtharray.h"
+#include "qv8engine_p.h"
+#include <QtOpenGL/QGLFramebufferObjectFormat>
+#include <QtOpenGL/QGLFramebufferObject>
+#include "qdeclarativeengine.h"
QT_BEGIN_NAMESPACE
-
+/*!
+ \qmlclass Context2D QSGContext2D
+ \inqmlmodule QtQuick 2
+ \since QtQuick 2.0
+ \brief The Context2D element allows you to draw 2d graphic shapes on Canvas item.
+*/
static const double Q_PI = 3.14159265358979323846; // pi
-template <class T>
-void memcpy_vector(QVector<T>* dst, const QVector<T>& src)
-{
- int pos = dst->size();
- dst->resize(pos + src.size());
- memmove(dst->data() + pos, src.constData(), sizeof(T) * src.size());
-}
-template <class T>
-void copy_vector(QVector<T>* dst, const QVector<T>& src)
-{
- int pos = dst->size();
- dst->resize(pos + src.size());
- for (int i = 0; i < src.size(); i++) {
- (*dst)[pos + i] = src[i];
- }
-}
-// Note, this is exported but in a private header as qtopengl depends on it.
-// But it really should be considered private API
-void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
-void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
#define DEGREES(t) ((t) * 180.0 / Q_PI)
#define qClamp(val, min, max) qMin(qMax(val, min), max)
-#define CHECK_CONTEXT(r) if (!r || !r->context) \
- V8THROW_ERROR("Not a Context2D object"); \
- if (!r->context->valid()) \
- V8THROW_ERROR("Context2D object is out of scope, please only access context2d APIs from onPaint method.");
+#define CHECK_CONTEXT(r) if (!r || !r->context || !r->context->buffer()) \
+ V8THROW_ERROR("Not a Context2D object");
-#define CHECK_CONTEXT_SETTER(r) if (!r || !r->context) \
- V8THROW_ERROR_SETTER("Not a Context2D object"); \
- if (!r->context->valid()) \
- V8THROW_ERROR_SETTER("Context2D object is out of scope, please only access context2d APIs from onPaint method.");
+#define CHECK_CONTEXT_SETTER(r) if (!r || !r->context || !r->context->buffer()) \
+ V8THROW_ERROR_SETTER("Not a Context2D object");
static inline int extractInt(const char **name)
{
@@ -274,7 +256,7 @@ static bool qt_get_hsl(const QString &string, QColor *color)
}
//### optimize further
-QColor colorFromString(const QString &name)
+QColor qt_color_from_string(const QString &name)
{
if (name.startsWith(QLatin1String("rgb"))) {
QRgb rgb;
@@ -289,8 +271,110 @@ QColor colorFromString(const QString &name)
return QColor(name);
}
+QFont qt_font_from_string(const QString& fontString) {
+ QFont font;
+ // ### this is simplified and incomplete
+ // ### TODO:get code from Qt webkit
+ QStringList tokens = fontString.split(QLatin1String(" "));
+ foreach (const QString &token, tokens) {
+ if (token == QLatin1String("italic"))
+ font.setItalic(true);
+ else if (token == QLatin1String("bold"))
+ font.setBold(true);
+ else if (token.endsWith(QLatin1String("px"))) {
+ QString number = token;
+ number.remove(QLatin1String("px"));
+ //font.setPointSizeF(number.trimmed().toFloat());
+ font.setPixelSize(number.trimmed().toInt());
+ } else
+ font.setFamily(token);
+ }
+
+ return font;
+}
+
-static QPainter::CompositionMode compositeOperatorFromString(const QString &compositeOperator)
+
+class QSGContext2DEngineData : public QV8Engine::Deletable
+{
+public:
+ QSGContext2DEngineData(QV8Engine *engine);
+ ~QSGContext2DEngineData();
+
+ v8::Persistent<v8::Function> constructorContext;
+ v8::Persistent<v8::Function> constructorGradient;
+ v8::Persistent<v8::Function> constructorPattern;
+ v8::Persistent<v8::Function> constructorPixelArray;
+ v8::Persistent<v8::Function> constructorImageData;
+};
+V8_DEFINE_EXTENSION(QSGContext2DEngineData, engineData);
+
+
+
+class QV8Context2DResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(Context2DType)
+public:
+ QV8Context2DResource(QV8Engine *e) : QV8ObjectResource(e) {}
+ QSGContext2D* context;
+};
+
+class QV8Context2DStyleResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(Context2DStyleType)
+public:
+ QV8Context2DStyleResource(QV8Engine *e) : QV8ObjectResource(e) {}
+ QBrush brush;
+};
+
+class QV8Context2DPixelArrayResource : public QV8ObjectResource
+{
+ V8_RESOURCE_TYPE(Context2DPixelArrayType)
+public:
+ QV8Context2DPixelArrayResource(QV8Engine *e) : QV8ObjectResource(e) {}
+
+ QImage image;
+};
+
+static QImage qt_texture_to_image(QSGTexture* texture)
+{
+ if (!texture || !texture->textureId())
+ return QImage();
+ QGLFramebufferObjectFormat format;
+ format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format.setInternalTextureFormat(GL_RGBA);
+ format.setMipmap(false);
+ QGLFramebufferObject* fbo = new QGLFramebufferObject(texture->textureSize(), format);
+ fbo->drawTexture(QPointF(0,0), texture->textureId(), GL_TEXTURE_2D);
+ return fbo->toImage();
+}
+
+static QSGTexture* qt_item_to_texture(QSGItem* item)
+{
+ if (!item)
+ return 0;
+ QSGShaderEffectTexture* texture = new QSGShaderEffectTexture(item);
+ texture->setItem(QSGItemPrivate::get(item)->itemNode());
+ texture->setLive(true);
+
+ QRectF sourceRect = QRectF(0, 0, item->width(), item->height());
+
+ texture->setRect(sourceRect);
+ QSize textureSize = QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())));
+ texture->setSize(textureSize);
+ texture->setRecursive(false);
+ texture->setFormat(GL_RGBA);
+ texture->setHasMipmaps(false);
+ texture->markDirtyTexture();
+ texture->updateTexture();
+ return texture;
+}
+
+static QImage qt_item_to_image(QSGItem* item) {
+ return qt_texture_to_image(qt_item_to_texture(item));
+}
+
+static QPainter::CompositionMode qt_composite_mode_from_string(const QString &compositeOperator)
{
if (compositeOperator == QLatin1String("source-over")) {
return QPainter::CompositionMode_SourceOver;
@@ -308,20 +392,43 @@ static QPainter::CompositionMode compositeOperatorFromString(const QString &comp
return QPainter::CompositionMode_DestinationOut;
} else if (compositeOperator == QLatin1String("destination-over")) {
return QPainter::CompositionMode_DestinationOver;
- } else if (compositeOperator == QLatin1String("darker")) {
- return QPainter::CompositionMode_SourceOver;
} else if (compositeOperator == QLatin1String("lighter")) {
- return QPainter::CompositionMode_SourceOver;
+ return QPainter::CompositionMode_Plus;
} else if (compositeOperator == QLatin1String("copy")) {
return QPainter::CompositionMode_Source;
} else if (compositeOperator == QLatin1String("xor")) {
return QPainter::CompositionMode_Xor;
+ } else if (compositeOperator == QLatin1String("qt-clear")) {
+ return QPainter::CompositionMode_Clear;
+ } else if (compositeOperator == QLatin1String("qt-destination")) {
+ return QPainter::CompositionMode_Destination;
+ } else if (compositeOperator == QLatin1String("qt-multiply")) {
+ return QPainter::CompositionMode_Multiply;
+ } else if (compositeOperator == QLatin1String("qt-screen")) {
+ return QPainter::CompositionMode_Screen;
+ } else if (compositeOperator == QLatin1String("qt-overlay")) {
+ return QPainter::CompositionMode_Overlay;
+ } else if (compositeOperator == QLatin1String("qt-darken")) {
+ return QPainter::CompositionMode_Darken;
+ } else if (compositeOperator == QLatin1String("qt-lighten")) {
+ return QPainter::CompositionMode_Lighten;
+ } else if (compositeOperator == QLatin1String("qt-color-dodge")) {
+ return QPainter::CompositionMode_ColorDodge;
+ } else if (compositeOperator == QLatin1String("qt-color-burn")) {
+ return QPainter::CompositionMode_ColorBurn;
+ } else if (compositeOperator == QLatin1String("qt-hard-light")) {
+ return QPainter::CompositionMode_HardLight;
+ } else if (compositeOperator == QLatin1String("qt-soft-light")) {
+ return QPainter::CompositionMode_SoftLight;
+ } else if (compositeOperator == QLatin1String("qt-difference")) {
+ return QPainter::CompositionMode_Difference;
+ } else if (compositeOperator == QLatin1String("qt-exclusion")) {
+ return QPainter::CompositionMode_Exclusion;
}
-
return QPainter::CompositionMode_SourceOver;
}
-static QString compositeOperatorToString(QPainter::CompositionMode op)
+static QString qt_composite_mode_to_string(QPainter::CompositionMode op)
{
switch (op) {
case QPainter::CompositionMode_SourceOver:
@@ -329,11 +436,11 @@ static QString compositeOperatorToString(QPainter::CompositionMode op)
case QPainter::CompositionMode_DestinationOver:
return QLatin1String("destination-over");
case QPainter::CompositionMode_Clear:
- return QLatin1String("clear");
+ return QLatin1String("qt-clear");
case QPainter::CompositionMode_Source:
- return QLatin1String("source");
+ return QLatin1String("copy");
case QPainter::CompositionMode_Destination:
- return QLatin1String("destination");
+ return QLatin1String("qt-destination");
case QPainter::CompositionMode_SourceIn:
return QLatin1String("source-in");
case QPainter::CompositionMode_DestinationIn:
@@ -349,56 +456,61 @@ static QString compositeOperatorToString(QPainter::CompositionMode op)
case QPainter::CompositionMode_Xor:
return QLatin1String("xor");
case QPainter::CompositionMode_Plus:
- return QLatin1String("plus");
+ return QLatin1String("lighter");
case QPainter::CompositionMode_Multiply:
- return QLatin1String("multiply");
+ return QLatin1String("qt-multiply");
case QPainter::CompositionMode_Screen:
- return QLatin1String("screen");
+ return QLatin1String("qt-screen");
case QPainter::CompositionMode_Overlay:
- return QLatin1String("overlay");
+ return QLatin1String("qt-overlay");
case QPainter::CompositionMode_Darken:
- return QLatin1String("darken");
+ return QLatin1String("qt-darken");
case QPainter::CompositionMode_Lighten:
- return QLatin1String("lighten");
+ return QLatin1String("qt-lighten");
case QPainter::CompositionMode_ColorDodge:
- return QLatin1String("color-dodge");
+ return QLatin1String("qt-color-dodge");
case QPainter::CompositionMode_ColorBurn:
- return QLatin1String("color-burn");
+ return QLatin1String("qt-color-burn");
case QPainter::CompositionMode_HardLight:
- return QLatin1String("hard-light");
+ return QLatin1String("qt-hard-light");
case QPainter::CompositionMode_SoftLight:
- return QLatin1String("soft-light");
+ return QLatin1String("qt-soft-light");
case QPainter::CompositionMode_Difference:
- return QLatin1String("difference");
+ return QLatin1String("qt-difference");
case QPainter::CompositionMode_Exclusion:
- return QLatin1String("exclusion");
+ return QLatin1String("qt-exclusion");
default:
break;
}
return QString();
}
-class QV8Context2DResource : public QV8ObjectResource
-{
- V8_RESOURCE_TYPE(Context2DType)
-public:
- QV8Context2DResource(QV8Engine *e) : QV8ObjectResource(e) {}
- QDeclarativeGuard<QSGContext2D> context;
-};
-//static script functions
-static v8::Handle<v8::Value> ctx2d_sync(const v8::Arguments &args)
+static v8::Local<v8::Object> qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image)
{
- QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
- CHECK_CONTEXT(r)
-
-
- r->context->sync();
+ QSGContext2DEngineData *ed = engineData(engine);
+ v8::Local<v8::Object> imageData = ed->constructorImageData->NewInstance();
+ QV8Context2DPixelArrayResource *r = new QV8Context2DPixelArrayResource(engine);
+ if (image.isNull()) {
+ r->image = QImage(w, h, QImage::Format_ARGB32);
+ r->image.fill(Qt::transparent);
+ } else {
+ Q_ASSERT(image.width() == w && image.height() == h);
+ r->image = image;
+ }
+ v8::Local<v8::Object> pixelData = ed->constructorPixelArray->NewInstance();
+ pixelData->SetExternalResource(r);
- return v8::Undefined();
+ imageData->SetInternalField(0, pixelData);
+ return imageData;
}
-// back-reference to the canvas, getter
+//static script functions
+
+/*!
+ \qmlproperty QtQuick2::Canvas QtQuick2::Context2D::canvas
+ Holds the canvas item that the context paints on.
+*/
static v8::Handle<v8::Value> ctx2d_canvas(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -410,65 +522,94 @@ static v8::Handle<v8::Value> ctx2d_canvas(v8::Local<v8::String>, const v8::Acces
return engine->newQObject(r->context->canvas());
}
-// state
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::restore()
+ Pops the top state on the stack, restoring the context to that state.
+*/
static v8::Handle<v8::Value> ctx2d_restore(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
-
- r->context->restore();
-
- return v8::Undefined();
+ r->context->popState();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::reset()
+ Resets the context state and properties to the default values.
+*/
static v8::Handle<v8::Value> ctx2d_reset(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
-
- r->context->reset();
-
- return v8::Undefined();
+ r->context->reset();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::save()
+ Pushes the current state onto the stack.
+*/
static v8::Handle<v8::Value> ctx2d_save(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
+ r->context->pushState();
- r->context->save();
-
- return v8::Undefined();
+ return args.This();
}
// transformations
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::rotate(real angle)
+ Changes the transformation matrix to apply a rotation transformation with the given characteristics.
+ Note: The angle is in radians.
+*/
static v8::Handle<v8::Value> ctx2d_rotate(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
- if (args.Length() == 1)
- r->context->rotate(args[0]->NumberValue());
+ if (args.Length() == 1) {
+ qreal angle = args[0]->NumberValue();
+ r->context->state.matrix.rotate(DEGREES(angle));
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
+ }
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::scale(real x, real y)
+ Changes the transformation matrix to apply a scaling transformation with the given characteristics.
+*/
static v8::Handle<v8::Value> ctx2d_scale(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
- if (args.Length() == 2)
- r->context->scale(args[0]->NumberValue(), args[1]->NumberValue());
+ if (args.Length() == 2) {
+ qreal x, y;
+ x = args[0]->NumberValue();
+ y = args[1]->NumberValue();
+ r->context->state.matrix.scale(x, y);
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
+ }
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::setTransform(real a, real b, real c, real d, real e, real f)
+ Changes the transformation matrix to the matrix given by the arguments as described below.
+
+ \sa QtQuick2::Context2D::transform()
+*/
static v8::Handle<v8::Value> ctx2d_setTransform(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -476,17 +617,24 @@ static v8::Handle<v8::Value> ctx2d_setTransform(const v8::Arguments &args)
if (args.Length() == 6) {
- r->context->setTransform(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue(),
- args[4]->NumberValue(),
- args[5]->NumberValue());
+ r->context->state.matrix = QTransform(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue(),
+ args[4]->NumberValue(),
+ args[5]->NumberValue());
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::transform(real a, real b, real c, real d, real e, real f)
+ Changes the transformation matrix to apply the matrix given by the arguments as described below.
+
+ \sa QtQuick2::Context2D::setTransform()
+*/
static v8::Handle<v8::Value> ctx2d_transform(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -494,17 +642,22 @@ static v8::Handle<v8::Value> ctx2d_transform(const v8::Arguments &args)
if (args.Length() == 6) {
- r->context->transform(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue(),
- args[4]->NumberValue(),
- args[5]->NumberValue());
+ r->context->state.matrix *= QTransform(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue(),
+ args[4]->NumberValue(),
+ args[5]->NumberValue());
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::translate(real x, real y)
+ Changes the transformation matrix to apply a translation transformation with the given characteristics.
+*/
static v8::Handle<v8::Value> ctx2d_translate(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -512,46 +665,99 @@ static v8::Handle<v8::Value> ctx2d_translate(const v8::Arguments &args)
if (args.Length() == 2) {
- r->context->translate(args[0]->NumberValue(),
- args[1]->NumberValue());
+ r->context->state.matrix.translate(args[0]->NumberValue(),
+ args[1]->NumberValue());
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
}
- return v8::Undefined();
+ return args.This();
}
-// compositing
-// float getter/setter default 1.0
-static v8::Handle<v8::Value> ctx2d_globalAlpha(v8::Local<v8::String>, const v8::AccessorInfo &info)
+
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::resetTransform()
+ Reset the transformation matrix default value.
+
+ \sa QtQuick2::Context2D::transform(), QtQuick2::Context2D::setTransform()
+*/
+static v8::Handle<v8::Value> ctx2d_resetTransform(const v8::Arguments &args)
{
- QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
+ r->context->state.matrix = QTransform();
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
- return v8::Number::New(r->context->globalAlpha());
+ return args.This();
}
-static void ctx2d_globalAlpha_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::shear(real sh, real sv )
+ Shear the transformation matrix with \a sh in horizontal direction and \a sv in vertical direction.
+*/
+static v8::Handle<v8::Value> ctx2d_shear(const v8::Arguments &args)
{
- QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
- CHECK_CONTEXT_SETTER(r)
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
+
+ r->context->state.matrix.shear(args[0]->NumberValue(),
+ args[1]->NumberValue());
+ r->context->buffer()->updateMatrix(r->context->state.matrix);
- r->context->setGlobalAlpha(value->NumberValue());
+ return args.This();
}
+// compositing
-// read only property to indicate the validation of the context object
-static v8::Handle<v8::Value> ctx2d_valid(v8::Local<v8::String>, const v8::AccessorInfo &info)
+/*!
+ \qmlproperty real QtQuick2::Context2D::globalAlpha
+ Holds the the current alpha value applied to rendering operations.
+ The value must be in the range from 0.0 (fully transparent) to 1.0 (no additional transparency).
+*/
+static v8::Handle<v8::Value> ctx2d_globalAlpha(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return v8::Boolean::New(r->context->valid());
+ return v8::Number::New(r->context->state.globalAlpha);
}
+static void ctx2d_globalAlpha_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+{
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
+ CHECK_CONTEXT_SETTER(r)
-// string getter/setter default "source-over"
+ qreal globalAlpha = value->NumberValue();
+
+ if (globalAlpha >= 0.0 && globalAlpha <= 1.0 && r->context->state.globalAlpha != globalAlpha) {
+ r->context->state.globalAlpha = globalAlpha;
+ r->context->buffer()->setGlobalAlpha(r->context->state.globalAlpha);
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::Context2D::globalCompositeOperation
+ Holds the the current the current composition operation, from the list below:
+ \list
+ \o source-atop - A atop B. Display the source image wherever both images are opaque.
+ Display the destination image wherever the destination image is opaque but the source image is transparent.
+ Display transparency elsewhere.
+ \o source-in - A in B. Display the source image wherever both the source image and destination image are opaque.
+ Display transparency elsewhere.
+ \o source-out - A out B. Display the source image wherever the source image is opaque and the destination image is transparent.
+ Display transparency elsewhere.
+ \o source-over - (default) A over B. Display the source image wherever the source image is opaque.
+ Display the destination image elsewhere.
+ \o destination-atop - B atop A. Same as source-atop but using the destination image instead of the source image and vice versa.
+ \o destination-in - B in A. Same as source-in but using the destination image instead of the source image and vice versa.
+ \o destination-out - B out A. Same as source-out but using the destination image instead of the source image and vice versa.
+ \o destination-over - B over A. Same as source-over but using the destination image instead of the source image and vice versa.
+ \o lighter - A plus B. Display the sum of the source image and destination image, with color values approaching 255 (100%) as a limit.
+ \o copy - A (B is ignored). Display the source image instead of the destination image.
+ \o xor - A xor B. Exclusive OR of the source image and destination image.
+ \endlist
+*/
static v8::Handle<v8::Value> ctx2d_globalCompositeOperation(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -560,7 +766,7 @@ static v8::Handle<v8::Value> ctx2d_globalCompositeOperation(v8::Local<v8::String
QV8Engine *engine = V8ENGINE_ACCESSOR();
- return engine->toString(r->context->globalCompositeOperation());
+ return engine->toString(qt_composite_mode_to_string(r->context->state.globalCompositeOperation));
}
static void ctx2d_globalCompositeOperation_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -570,20 +776,29 @@ static void ctx2d_globalCompositeOperation_set(v8::Local<v8::String>, v8::Local<
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setGlobalCompositeOperation(engine->toString(value));
+ QPainter::CompositionMode cm = qt_composite_mode_from_string(engine->toString(value));
+ if (cm != r->context->state.globalCompositeOperation) {
+ r->context->state.globalCompositeOperation = cm;
+ r->context->buffer()->setGlobalCompositeOperation(cm);
+ }
}
// colors and styles
-// getter/setter
+/*!
+ \qmlproperty variant QtQuick2::Context2D::fillStyle
+ Holds the current style used for filling shapes.
+ The style can be either a string containing a CSS color, or a CanvasGradient or CanvasPattern object. Invalid values are ignored.
+ \sa QtQuick2::Context2D::createLinearGradient
+ \sa QtQuick2::Context2D::createRadialGradient
+ \sa QtQuick2::Context2D::createPattern
+ \sa QtQuick2::Context2D::strokeStyle
+ */
static v8::Handle<v8::Value> ctx2d_fillStyle(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
-
- QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->fromVariant(r->context->fillStyle());
+ return r->context->m_fillStyle;
}
static void ctx2d_fillStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -593,42 +808,71 @@ static void ctx2d_fillStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> valu
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setFillStyle(engine->toVariant(value, -1));
-}
-
-// colors and styles
-// getter/setter
-static v8::Handle<v8::Value> ctx2d_fillColor(v8::Local<v8::String>, const v8::AccessorInfo &info)
+ r->context->m_fillStyle = value;
+ if (value->IsObject()) {
+ QColor color = engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
+ if (color.isValid()) {
+ r->context->state.fillStyle = color;
+ r->context->buffer()->setFillStyle(color);
+ } else {
+ QV8Context2DStyleResource *style = v8_resource_cast<QV8Context2DStyleResource>(value->ToObject());
+ if (style && style->brush != r->context->state.fillStyle) {
+ r->context->state.fillStyle = style->brush;
+ r->context->buffer()->setFillStyle(style->brush);
+ }
+ }
+ } else if (value->IsString()) {
+ QColor color = qt_color_from_string(engine->toString(value));
+ if (color.isValid() && r->context->state.fillStyle != QBrush(color)) {
+ r->context->state.fillStyle = QBrush(color);
+ r->context->buffer()->setFillStyle(r->context->state.fillStyle);
+ }
+ }
+}
+
+static v8::Handle<v8::Value> ctx2d_fillRule(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
-
-
QV8Engine *engine = V8ENGINE_ACCESSOR();
- return engine->fromVariant(r->context->fillColor());
+ return engine->fromVariant(r->context->state.fillRule);
}
-static void ctx2d_fillColor_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+static void ctx2d_fillRule_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setFillColor(engine->toVariant(value, -1).value<QColor>());
-}
-
-//getter/setter
+ if ((value->IsString() && engine->toString(value) == "WindingFill")
+ ||(value->IsNumber() && value->NumberValue() == Qt::WindingFill)) {
+ r->context->state.fillRule = Qt::WindingFill;
+ } else if ((value->IsString() && engine->toString(value) == "OddEvenFill")
+ ||(value->IsNumber() && value->NumberValue() == Qt::OddEvenFill)) {
+ r->context->state.fillRule = Qt::OddEvenFill;
+ } else {
+ //error
+ }
+ r->context->m_path.setFillRule(r->context->state.fillRule);
+}
+/*!
+ \qmlproperty variant QtQuick2::Context2D::strokeStyle
+ Holds the current color or style to use for the lines around shapes,
+ The style can be either a string containing a CSS color, or a CanvasGradient or CanvasPattern object. Invalid values are ignored.
+ \sa QtQuick2::Context2D::createLinearGradient
+ \sa QtQuick2::Context2D::createRadialGradient
+ \sa QtQuick2::Context2D::createPattern
+ \sa QtQuick2::Context2D::fillStyle
+ */
v8::Handle<v8::Value> ctx2d_strokeStyle(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->fromVariant(r->context->strokeStyle());
+ return r->context->m_strokeStyle;
}
static void ctx2d_strokeStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -638,31 +882,37 @@ static void ctx2d_strokeStyle_set(v8::Local<v8::String>, v8::Local<v8::Value> va
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setStrokeStyle(engine->toVariant(value, -1));
-}
-
-// colors and styles
-// getter/setter
-v8::Handle<v8::Value> ctx2d_strokeColor(v8::Local<v8::String>, const v8::AccessorInfo &info)
-{
- QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
- CHECK_CONTEXT(r)
-
-
- QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->fromVariant(r->context->strokeColor());
+ r->context->m_strokeStyle = value;
+ if (value->IsObject()) {
+ QColor color = engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
+ if (color.isValid()) {
+ r->context->state.fillStyle = color;
+ r->context->buffer()->setStrokeStyle(color);
+ } else {
+ QV8Context2DStyleResource *style = v8_resource_cast<QV8Context2DStyleResource>(value->ToObject());
+ if (style && style->brush != r->context->state.strokeStyle) {
+ r->context->state.strokeStyle = style->brush;
+ r->context->buffer()->setStrokeStyle(style->brush);
+ }
+ }
+ } else if (value->IsString()) {
+ QColor color = qt_color_from_string(engine->toString(value));
+ if (color.isValid() && r->context->state.strokeStyle != QBrush(color)) {
+ r->context->state.strokeStyle = QBrush(color);
+ r->context->buffer()->setStrokeStyle(r->context->state.strokeStyle);
+ }
+ }
}
-static void ctx2d_strokeColor_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
-{
- QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
- CHECK_CONTEXT_SETTER(r)
-
- QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- r->context->setStrokeColor(engine->toVariant(value, -1).value<QColor>());
-}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::createLinearGradient(real x0, real y0, real x1, real y1)
+ Returns a CanvasGradient object that represents a linear gradient that paints along the line given by the coordinates
+ represented by the start point (\a x0, \a y0) and the end point (\a x1, \a y1).
+ \sa QtQuick2::Context2D::createRadialGradient
+ \sa QtQuick2::Context2D::createPattern
+ \sa QtQuick2::Context2D::fillStyle
+ \sa QtQuick2::Context2D::strokeStyle
+ */
static v8::Handle<v8::Value> ctx2d_createLinearGradient(const v8::Arguments &args)
{
@@ -673,16 +923,32 @@ static v8::Handle<v8::Value> ctx2d_createLinearGradient(const v8::Arguments &arg
QV8Engine *engine = V8ENGINE();
if (args.Length() == 4) {
- QObject* gradient = r->context->createLinearGradient(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue());
- return engine->newQObject(gradient);
+ //TODO:infinite or NaN, the method must raise a NOT_SUPPORTED_ERR
+ QSGContext2DEngineData *ed = engineData(engine);
+ v8::Local<v8::Object> gradient = ed->constructorGradient->NewInstance();
+ QV8Context2DStyleResource *r = new QV8Context2DStyleResource(engine);
+ r->brush = QLinearGradient(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue());
+ gradient->SetExternalResource(r);
+ return gradient;
}
- return v8::Null();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1)
+ Returns a CanvasGradient object that represents a radial gradient that paints along the cone given by the start circle with
+ origin (x0, y0) and radius r0, and the end circle with origin (x1, y1) and radius r1.
+
+ \sa QtQuick2::Context2D::createLinearGradient
+ \sa QtQuick2::Context2D::createPattern
+ \sa QtQuick2::Context2D::fillStyle
+ \sa QtQuick2::Context2D::strokeStyle
+ */
+
static v8::Handle<v8::Value> ctx2d_createRadialGradient(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -692,26 +958,103 @@ static v8::Handle<v8::Value> ctx2d_createRadialGradient(const v8::Arguments &arg
QV8Engine *engine = V8ENGINE();
if (args.Length() == 6) {
- QObject* gradient = r->context->createRadialGradient(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue(),
- args[4]->NumberValue(),
- args[5]->NumberValue());
- return engine->newQObject(gradient);
+ QSGContext2DEngineData *ed = engineData(engine);
+ v8::Local<v8::Object> gradient = ed->constructorGradient->NewInstance();
+ QV8Context2DStyleResource *r = new QV8Context2DStyleResource(engine);
+
+ qreal x0 = args[0]->NumberValue();
+ qreal y0 = args[1]->NumberValue();
+ qreal r0 = args[2]->NumberValue();
+ qreal x1 = args[3]->NumberValue();
+ qreal y1 = args[4]->NumberValue();
+ qreal r1 = args[5]->NumberValue();
+ //TODO:infinite or NaN, a NOT_SUPPORTED_ERR exception must be raised.
+ //If either of r0 or r1 are negative, an INDEX_SIZE_ERR exception must be raised.
+ r->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
+ gradient->SetExternalResource(r);
+ return gradient;
}
- return v8::Null();
+ return args.This();
}
+/*!
+ \qmlmethod variant createPattern(Image image, string repetition)
+ Returns a CanvasPattern object that uses the given image and repeats in the direction(s) given by the repetition argument.
+
+ The \a image parameter must be a valid Image item, if there is no image data, throws an INVALID_STATE_ERR exception.
+
+ The allowed values for \a repetition are:
+
+ \list
+ \o "repeat" - both directions
+ \o "repeat-x - horizontal only
+ \o "repeat-y" - vertical only
+ \o "no-repeat" - neither
+ \endlist
+
+ If the repetition argument is empty or null, the value "repeat" is used.
+
+ \sa QtQuick2::Context2D::strokeStyle
+ \sa QtQuick2::Context2D::fillStyle
+ */
static v8::Handle<v8::Value> ctx2d_createPattern(const v8::Arguments &args)
{
- //TODO
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
+
+
+ QV8Engine *engine = V8ENGINE();
+
+ if (args.Length() == 2) {
+ QSGContext2DEngineData *ed = engineData(engine);
+ v8::Local<v8::Object> pattern = ed->constructorPattern->NewInstance();
+ QV8Context2DStyleResource *r = new QV8Context2DStyleResource(engine);
+
+ QImage img;
+
+ QSGItem* item = qobject_cast<QSGItem*>(engine->toQObject(args[0]));
+ if (item) {
+ img = qt_item_to_image(item);
+// if (img.isNull()) {
+// //exception: INVALID_STATE_ERR
+// }
+ } /*else {
+ //exception: TYPE_MISMATCH_ERR
+ }*/
+
+ QString repetition = engine->toString(args[1]);
+
+// if (repetition == "repeat" || repetition.isEmpty()) {
+// //TODO
+// } else if (repetition == "repeat-x") {
+// //TODO
+// } else if (repetition == "repeat-y") {
+// //TODO
+// } else if (repetition == "no-repeat") {
+// //TODO
+// } else {
+// //TODO: exception: SYNTAX_ERR
+// }
+ r->brush = img;
+ pattern->SetExternalResource(r);
+ return pattern;
+ }
return v8::Null();
}
// line styles
-// string getter/setter
+/*!
+ \qmlproperty string QtQuick2::Context2D::lineCap
+ Holds the the current line cap style.
+ The possible line cap styles are:
+ \list
+ \o butt - the end of each line has a flat edge perpendicular to the direction of the line, this is the default line cap value.
+ \o round - a semi-circle with the diameter equal to the width of the line must then be added on to the end of the line.
+ \o square - a rectangle with the length of the line width and the width of half the line width, placed flat against the edge perpendicular to the direction of the line.
+ \endlist
+ Other values are ignored.
+*/
v8::Handle<v8::Value> ctx2d_lineCap(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -719,8 +1062,17 @@ v8::Handle<v8::Value> ctx2d_lineCap(v8::Local<v8::String>, const v8::AccessorInf
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->toString(r->context->lineCap());
+ switch (r->context->state.lineCap) {
+ case Qt::RoundCap:
+ return engine->toString(QLatin1String("round"));
+ case Qt::FlatCap:
+ return engine->toString(QLatin1String("butt"));
+ case Qt::SquareCap:
+ return engine->toString(QLatin1String("square"));
+ default:
+ break;
+ }
+ return engine->toString(QLatin1String("butt"));;
}
static void ctx2d_lineCap_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -730,10 +1082,35 @@ static void ctx2d_lineCap_set(v8::Local<v8::String>, v8::Local<v8::Value> value,
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setLineCap(engine->toString(value));
-}
-
-// string getter/setter
+ QString lineCap = engine->toString(value);
+ Qt::PenCapStyle cap;
+ if (lineCap == QLatin1String("round"))
+ cap = Qt::RoundCap;
+ else if (lineCap == QLatin1String("butt"))
+ cap = Qt::FlatCap;
+ else if (lineCap == QLatin1String("square"))
+ cap = Qt::SquareCap;
+
+ if (cap != r->context->state.lineCap) {
+ r->context->state.lineCap = cap;
+ r->context->buffer()->setLineCap(cap);
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::Context2D::lineJoin
+ Holds the the current line join style. A join exists at any point in a subpath
+ shared by two consecutive lines. When a subpath is closed, then a join also exists
+ at its first point (equivalent to its last point) connecting the first and last lines in the subpath.
+
+ The possible line join styles are:
+ \list
+ \o bevel - this is all that is rendered at joins.
+ \o round - a filled arc connecting the two aforementioned corners of the join, abutting (and not overlapping) the aforementioned triangle, with the diameter equal to the line width and the origin at the point of the join, must be rendered at joins.
+ \o miter - a second filled triangle must (if it can given the miter length) be rendered at the join, this is the default line join style.
+ \endlist
+ Other values are ignored.
+*/
v8::Handle<v8::Value> ctx2d_lineJoin(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -741,8 +1118,17 @@ v8::Handle<v8::Value> ctx2d_lineJoin(v8::Local<v8::String>, const v8::AccessorIn
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->toString(r->context->lineJoin());
+ switch (r->context->state.lineJoin) {
+ case Qt::RoundJoin:
+ return engine->toString(QLatin1String("round"));
+ case Qt::BevelJoin:
+ return engine->toString(QLatin1String("bevel"));
+ case Qt::MiterJoin:
+ return engine->toString(QLatin1String("miter"));
+ default:
+ break;
+ }
+ return engine->toString(QLatin1String("miter"));
}
static void ctx2d_lineJoin_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -752,17 +1138,32 @@ static void ctx2d_lineJoin_set(v8::Local<v8::String>, v8::Local<v8::Value> value
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setLineJoin(engine->toString(value));
+ QString lineJoin = engine->toString(value);
+ Qt::PenJoinStyle join;
+ if (lineJoin == QLatin1String("round"))
+ join = Qt::RoundJoin;
+ else if (lineJoin == QLatin1String("bevel"))
+ join = Qt::BevelJoin;
+ else if (lineJoin == QLatin1String("miter"))
+ join = Qt::MiterJoin;
+
+ if (join != r->context->state.lineJoin) {
+ r->context->state.lineJoin = join;
+ r->context->buffer()->setLineJoin(join);
+ }
}
-// float getter/setter
+/*!
+ \qmlproperty real QtQuick2::Context2D::lineWidth
+ Holds the the current line width. Values that are not finite values greater than zero are ignored.
+ */
v8::Handle<v8::Value> ctx2d_lineWidth(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- return v8::Number::New(r->context->lineWidth());
+ return v8::Number::New(r->context->state.lineWidth);
}
static void ctx2d_lineWidth_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -770,17 +1171,26 @@ static void ctx2d_lineWidth_set(v8::Local<v8::String>, v8::Local<v8::Value> valu
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
- r->context->setLineWidth(value->NumberValue());
+ qreal w = value->NumberValue();
+
+ if (w > 0 && w != r->context->state.lineWidth) {
+ r->context->state.lineWidth = w;
+ r->context->buffer()->setLineWidth(w);
+ }
}
-// float getter/setter
+/*!
+ \qmlproperty real QtQuick2::Context2D::miterLimit
+ Holds the current miter limit ratio.
+ The default miter limit value is 10.0.
+ */
v8::Handle<v8::Value> ctx2d_miterLimit(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- return v8::Number::New(r->context->miterLimit());
+ return v8::Number::New(r->context->state.miterLimit);
}
static void ctx2d_miterLimit_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -788,28 +1198,44 @@ static void ctx2d_miterLimit_set(v8::Local<v8::String>, v8::Local<v8::Value> val
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
- r->context->setMiterLimit(value->NumberValue());
+ qreal ml = value->NumberValue();
+
+ if (ml > 0 && ml != r->context->state.miterLimit) {
+ r->context->state.miterLimit = ml;
+ r->context->buffer()->setMiterLimit(ml);
+ }
}
// shadows
-// float getter/setter
+/*!
+ \qmlproperty real QtQuick2::Context2D::shadowBlur
+ Holds the current level of blur applied to shadows
+ */
v8::Handle<v8::Value> ctx2d_shadowBlur(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- return v8::Number::New(r->context->shadowBlur());
+ return v8::Number::New(r->context->state.shadowBlur);
}
static void ctx2d_shadowBlur_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
+ qreal blur = value->NumberValue();
- r->context->setShadowBlur(value->NumberValue());
+ if (blur > 0 && blur != r->context->state.shadowBlur) {
+ r->context->state.shadowBlur = blur;
+ r->context->buffer()->setShadowBlur(blur);
+ }
}
+/*!
+ \qmlproperty string QtQuick2::Context2D::shadowColor
+ Holds the current shadow color.
+ */
v8::Handle<v8::Value> ctx2d_shadowColor(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -818,7 +1244,7 @@ v8::Handle<v8::Value> ctx2d_shadowColor(v8::Local<v8::String>, const v8::Accesso
QV8Engine *engine = V8ENGINE_ACCESSOR();
- return engine->toString(r->context->shadowColor());
+ return engine->toString(r->context->state.shadowColor.name());
}
static void ctx2d_shadowColor_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -828,16 +1254,28 @@ static void ctx2d_shadowColor_set(v8::Local<v8::String>, v8::Local<v8::Value> va
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setShadowColor(engine->toString(value));
+ QColor color = qt_color_from_string(engine->toString(value));
+
+ if (color.isValid() && color != r->context->state.shadowColor) {
+ r->context->state.shadowColor = color;
+ r->context->buffer()->setShadowColor(color);
+ }
}
+
+/*!
+ \qmlproperty qreal QtQuick2::Context2D::shadowOffsetX
+ Holds the current shadow offset in the positive horizontal distance.
+
+ \sa QtQuick2::Context2D::shadowOffsetY
+ */
v8::Handle<v8::Value> ctx2d_shadowOffsetX(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- return v8::Number::New(r->context->shadowOffsetX());
+ return v8::Number::New(r->context->state.shadowOffsetX);
}
static void ctx2d_shadowOffsetX_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -845,27 +1283,70 @@ static void ctx2d_shadowOffsetX_set(v8::Local<v8::String>, v8::Local<v8::Value>
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
- r->context->setShadowOffsetX(value->NumberValue());
+ //TODO: check value:infinite or NaN
+ qreal offsetX = value->NumberValue();
+ if (offsetX != r->context->state.shadowOffsetX) {
+ r->context->state.shadowOffsetX = offsetX;
+ r->context->buffer()->setShadowOffsetX(offsetX);
+ }
}
+/*!
+ \qmlproperty qreal QtQuick2::Context2D::shadowOffsetY
+ Holds the current shadow offset in the positive vertical distance.
+ \sa QtQuick2::Context2D::shadowOffsetX
+ */
v8::Handle<v8::Value> ctx2d_shadowOffsetY(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
- return v8::Number::New(r->context->shadowOffsetY());
+ return v8::Number::New(r->context->state.shadowOffsetY);
}
static void ctx2d_shadowOffsetY_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
+ //TODO: check value:infinite or NaN
+ qreal offsetY = value->NumberValue();
+ if (offsetY != r->context->state.shadowOffsetY) {
+ r->context->state.shadowOffsetY = offsetY;
+ r->context->buffer()->setShadowOffsetY(offsetY);
+ }
+}
+
+v8::Handle<v8::Value> ctx2d_path(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
+ CHECK_CONTEXT(r)
+ return r->context->m_v8path;
+}
+
+static void ctx2d_path_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+{
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
+ CHECK_CONTEXT_SETTER(r)
+ QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setShadowOffsetY(value->NumberValue());
+ r->context->beginPath();
+ if (value->IsObject()) {
+ QDeclarativePath* path = qobject_cast<QDeclarativePath*>(engine->toQObject(value));
+ if (path)
+ r->context->m_path = path->path();
+ } else {
+ QString path = engine->toString(value->ToString());
+ QDeclarativeSvgParser::parsePathDataFast(path, r->context->m_path);
+ }
+ r->context->m_v8path = value;
}
//rects
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::clearRect(real x, real y, real w, real h)
+ Clears all pixels on the canvas in the given rectangle to transparent black.
+ */
static v8::Handle<v8::Value> ctx2d_clearRect(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -873,15 +1354,20 @@ static v8::Handle<v8::Value> ctx2d_clearRect(const v8::Arguments &args)
if (args.Length() == 4) {
- r->context->clearRect(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue());
+ r->context->buffer()->clearRect(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::fillRect(real x, real y, real w, real h)
+ Paint the specified rectangular area using the fillStyle.
+ \sa QtQuick2::Context2D::fillStyle
+ */
static v8::Handle<v8::Value> ctx2d_fillRect(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -889,15 +1375,25 @@ static v8::Handle<v8::Value> ctx2d_fillRect(const v8::Arguments &args)
if (args.Length() == 4) {
- r->context->fillRect(args[0]->NumberValue(),
+ r->context->buffer()->fillRect(args[0]->NumberValue(),
args[1]->NumberValue(),
args[2]->NumberValue(),
args[3]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::fillRect(real x, real y, real w, real h)
+ Stroke the specified rectangle's path using the strokeStyle, lineWidth, lineJoin,
+ and (if appropriate) miterLimit attributes.
+
+ \sa QtQuick2::Context2D::strokeStyle
+ \sa QtQuick2::Context2D::lineWidth
+ \sa QtQuick2::Context2D::lineJoin
+ \sa QtQuick2::Context2D::miterLimit
+ */
static v8::Handle<v8::Value> ctx2d_strokeRect(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -905,34 +1401,53 @@ static v8::Handle<v8::Value> ctx2d_strokeRect(const v8::Arguments &args)
if (args.Length() == 4) {
- r->context->strokeRect(args[0]->NumberValue(),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue());
+ r->context->buffer()->strokeRect(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
// Complex shapes (paths) API
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)
+ Adds points to the subpath such that the arc described by the circumference of
+ the circle described by the arguments.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-arc for details.
+ */
static v8::Handle<v8::Value> ctx2d_arc(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
+ if (args.Length() >= 5) {
+ bool antiClockwise = false;
- if (args.Length() == 6) {
+ if (args.Length() == 6)
+ antiClockwise = args[5]->BooleanValue();
+
+ qreal radius = args[2]->NumberValue();
+ //Throws an INDEX_SIZE_ERR exception if the given radius is negative.
r->context->arc(args[0]->NumberValue(),
args[1]->NumberValue(),
- args[2]->NumberValue(),
+ radius,
args[3]->NumberValue(),
args[4]->NumberValue(),
- args[5]->NumberValue());
+ antiClockwise);
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::arcTo(real x1, real y1, real x2, real y2, real radius)
+
+ Adds an arc with the given control points and radius to the current subpath, connected to the previous point by a straight line.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto for details.
+ */
static v8::Handle<v8::Value> ctx2d_arcTo(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -947,9 +1462,14 @@ static v8::Handle<v8::Value> ctx2d_arcTo(const v8::Arguments &args)
args[4]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::beginPath()
+
+ Resets the current path.
+ */
static v8::Handle<v8::Value> ctx2d_beginPath(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -958,16 +1478,23 @@ static v8::Handle<v8::Value> ctx2d_beginPath(const v8::Arguments &args)
r->context->beginPath();
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y)
+
+ Adds the given point to the current subpath, connected to the previous one by a cubic Bézier curve with the given control points.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-beziercurveto for details.
+ */
static v8::Handle<v8::Value> ctx2d_bezierCurveTo(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
- if (args.Length() == 5) {
+ if (args.Length() == 6) {
r->context->bezierCurveTo(args[0]->NumberValue(),
args[1]->NumberValue(),
args[2]->NumberValue(),
@@ -976,20 +1503,34 @@ static v8::Handle<v8::Value> ctx2d_bezierCurveTo(const v8::Arguments &args)
args[5]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::clip()
+
+ constrains the clipping region to the given path.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-clip for details.
+ */
static v8::Handle<v8::Value> ctx2d_clip(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
-
- r->context->clip();
+ r->context->state.clipPath = r->context->m_path;
+ r->context->buffer()->clip(r->context->state.clipPath);
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::closePath()
+
+ Marks the current subpath as closed, and starts a new subpath with a point the same as the start and end of the newly closed subpath.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-closepath for details.
+ */
static v8::Handle<v8::Value> ctx2d_closePath(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -998,20 +1539,33 @@ static v8::Handle<v8::Value> ctx2d_closePath(const v8::Arguments &args)
r->context->closePath();
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::fill()
+
+ Fills the subpaths with the current fill style.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-fill for details.
+
+ \sa QtQuick2::Context2D::fillStyle
+ */
static v8::Handle<v8::Value> ctx2d_fill(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
+ r->context->buffer()->fill(r->context->m_path);
- r->context->fill();
-
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::lineTo(real x, real y)
+
+ Adds the given point to the current subpath, connected to the previous one by a straight line.
+ */
static v8::Handle<v8::Value> ctx2d_lineTo(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1023,9 +1577,14 @@ static v8::Handle<v8::Value> ctx2d_lineTo(const v8::Arguments &args)
args[1]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::moveTo(real x, real y)
+
+ Creates a new subpath with the given point.
+ */
static v8::Handle<v8::Value> ctx2d_moveTo(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1037,9 +1596,16 @@ static v8::Handle<v8::Value> ctx2d_moveTo(const v8::Arguments &args)
args[1]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y)
+
+ Adds the given point to the current subpath, connected to the previous one by a quadratic Bézier curve with the given control point.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto for details.
+ */
static v8::Handle<v8::Value> ctx2d_quadraticCurveTo(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1053,9 +1619,16 @@ static v8::Handle<v8::Value> ctx2d_quadraticCurveTo(const v8::Arguments &args)
args[3]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::rect(real x, real y, real w, real h)
+
+ Adds a new closed subpath to the path, representing the given rectangle.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-rect for details.
+ */
static v8::Handle<v8::Value> ctx2d_rect(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1069,85 +1642,145 @@ static v8::Handle<v8::Value> ctx2d_rect(const v8::Arguments &args)
args[3]->NumberValue());
}
- return v8::Undefined();
+ return args.This();
}
-static v8::Handle<v8::Value> ctx2d_stroke(const v8::Arguments &args)
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)
+
+ Adds the given rectangle rect with rounded corners to the path. The xRadius and yRadius arguments specify the radii of the
+ ellipses defining the corners of the rounded rectangle.
+ */
+static v8::Handle<v8::Value> ctx2d_roundedRect(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
- r->context->stroke();
+ if (args.Length() == 6) {
+ r->context->roundedRect(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue(),
+ args[4]->NumberValue(),
+ args[5]->NumberValue());
+ }
- return v8::Undefined();
+ return args.This();
}
-static v8::Handle<v8::Value> ctx2d_isPointInPath(const v8::Arguments &args)
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::ellipse(real x, real y, real w, real h)
+
+ Creates an ellipse within the bounding rectangle defined by its top-left corner at (\a x, \ y), width \a w and height \a h,
+ and adds it to the path as a closed subpath.
+
+ The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).
+ */
+static v8::Handle<v8::Value> ctx2d_ellipse(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
- bool pointInPath = false;
- if (args.Length() == 2) {
- pointInPath = r->context->isPointInPath(args[0]->NumberValue(),
- args[1]->NumberValue());
+ if (args.Length() == 6) {
+ r->context->ellipse(args[0]->NumberValue(),
+ args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ args[3]->NumberValue());
}
- return v8::Boolean::New(pointInPath);
+ return args.This();
}
-static v8::Handle<v8::Value> ctx2d_setPathString(const v8::Arguments &args)
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::text(string text, real x, real y)
+
+ Adds the given \a text to the path as a set of closed subpaths created from the current context font supplied.
+ The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (x, y).
+ */
+static v8::Handle<v8::Value> ctx2d_text(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
-
QV8Engine *engine = V8ENGINE();
- if (args.Length() == 1) {
- r->context->setPathString(engine->toString(args[0]));
+ if (args.Length() == 3) {
+ r->context->text(engine->toString(args[0]),
+ args[1]->NumberValue(),
+ args[2]->NumberValue());
}
- return v8::Undefined();
+
+ return args.This();
}
-static v8::Handle<v8::Value> ctx2d_path(v8::Local<v8::String>, const v8::AccessorInfo &info)
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::stroke()
+
+ Strokes the subpaths with the current stroke style.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke for details.
+
+ \sa QtQuick2::Context2D::strokeStyle
+ */
+static v8::Handle<v8::Value> ctx2d_stroke(const v8::Arguments &args)
{
-// QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
-// CHECK_CONTEXT(r)
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
-// QV8Engine *engine = V8ENGINE();
- return v8::Undefined();
+ r->context->buffer()->stroke(r->context->m_path);
+
+ return args.This();
}
-static v8::Handle<v8::Value> ctx2d_path_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::isPointInPath(real x, real y)
+
+ Returns true if the given point is in the current path.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath for details.
+ */
+static v8::Handle<v8::Value> ctx2d_isPointInPath(const v8::Arguments &args)
{
-// QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
-// CHECK_CONTEXT(r)
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
-// QV8Engine *engine = V8ENGINE();
-// if (args.Length() == 1) {
-// r->context->setPathString(engine->toString(args[0]));
-// }
- return v8::Undefined();
+ bool pointInPath = false;
+ if (args.Length() == 2) {
+ pointInPath = r->context->isPointInPath(args[0]->NumberValue(),
+ args[1]->NumberValue());
+ }
+
+ return v8::Boolean::New(pointInPath);
}
-static v8::Handle<v8::Value> ctx2d_createPath(const v8::Arguments &args)
+static v8::Handle<v8::Value> ctx2d_drawFocusRing(const v8::Arguments &args)
{
-// QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
-// CHECK_CONTEXT(r)
-
+ V8THROW_ERROR("Context2D::drawFocusRing is not supported")
+ return args.This();
+}
-// QV8Engine *engine = V8ENGINE();
-// if (args.Length() == 1) {
-// r->context->setPathString(engine->toString(args[0]));
-// }
- return v8::Undefined();
+static v8::Handle<v8::Value> ctx2d_setCaretSelectionRect(const v8::Arguments &args)
+{
+ V8THROW_ERROR("Context2D::setCaretSelectionRect is not supported")
+ return args.This();
}
+static v8::Handle<v8::Value> ctx2d_caretBlinkRate(const v8::Arguments &args)
+{
+ V8THROW_ERROR("Context2D::caretBlinkRate is not supported")
+
+ return args.This();
+}
// text
+/*!
+ \qmlproperty string QtQuick2::Context2D::font
+ Holds the current font settings, default value is "10px sans-serif".
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-font for details.
+ */
v8::Handle<v8::Value> ctx2d_font(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
@@ -1155,7 +1788,7 @@ v8::Handle<v8::Value> ctx2d_font(v8::Local<v8::String>, const v8::AccessorInfo &
QV8Engine *engine = V8ENGINE_ACCESSOR();
- return engine->toString(r->context->font());
+ return engine->toString(r->context->m_fontString);
}
static void ctx2d_font_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -1164,17 +1797,48 @@ static void ctx2d_font_set(v8::Local<v8::String>, v8::Local<v8::Value> value, co
CHECK_CONTEXT_SETTER(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- r->context->setFont(engine->toString(value));
-}
-
+ QString fs = engine->toString(value);
+ if (fs != r->context->m_fontString) {
+ r->context->m_fontString = fs;
+ QFont font = qt_font_from_string(fs);
+ r->context->state.font = font;
+ }
+}
+
+/*!
+ \qmlproperty string QtQuick2::Context2D::textAlign
+
+ Holds the current text alignment settings.
+ The possible values are:
+ \list
+ \o start
+ \o end
+ \o left
+ \o right
+ \o center
+ \endlist
+ Other values are ignored. The default is start.
+ */
v8::Handle<v8::Value> ctx2d_textAlign(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->toString(r->context->textAlign());
+ switch (r->context->state.textAlign) {
+ case QSGContext2D::Start:
+ return engine->toString(QLatin1String("start"));
+ case QSGContext2D::End:
+ return engine->toString(QLatin1String("end"));
+ case QSGContext2D::Left:
+ return engine->toString(QLatin1String("left"));
+ case QSGContext2D::Right:
+ return engine->toString(QLatin1String("right"));
+ case QSGContext2D::Center:
+ return engine->toString(QLatin1String("center"));
+ default:
+ break;
+ }
+ return engine->toString(QLatin1String("start"));
}
static void ctx2d_textAlign_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -1183,17 +1847,62 @@ static void ctx2d_textAlign_set(v8::Local<v8::String>, v8::Local<v8::Value> valu
CHECK_CONTEXT_SETTER(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
- r->context->setTextAlign(engine->toString(value));
+ QString textAlign = engine->toString(value);
+
+ QSGContext2D::TextAlignType ta;
+ if (textAlign == QLatin1String("start"))
+ ta = QSGContext2D::Start;
+ else if (textAlign == QLatin1String("end"))
+ ta = QSGContext2D::End;
+ else if (textAlign == QLatin1String("left"))
+ ta = QSGContext2D::Left;
+ else if (textAlign == QLatin1String("right"))
+ ta = QSGContext2D::Right;
+ else if (textAlign == QLatin1String("center"))
+ ta = QSGContext2D::Center;
+
+ if (ta != r->context->state.textAlign) {
+ r->context->state.textAlign = ta;
+ }
}
+/*!
+ \qmlproperty string QtQuick2::Context2D::textBaseline
+
+ Holds the current baseline alignment settings.
+ The possible values are:
+ \list
+ \o top
+ \o hanging
+ \o middle
+ \o alphabetic
+ \o ideographic
+ \o bottom
+ \endlist
+ Other values are ignored. The default value is "alphabetic".
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-textbaseline for details.
+ */
v8::Handle<v8::Value> ctx2d_textBaseline(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- return engine->toString(r->context->textBaseline());
+ switch (r->context->state.textBaseline) {
+ case QSGContext2D::Alphabetic:
+ return engine->toString(QLatin1String("alphabetic"));
+ case QSGContext2D::Hanging:
+ return engine->toString(QLatin1String("hanging"));
+ case QSGContext2D::Top:
+ return engine->toString(QLatin1String("top"));
+ case QSGContext2D::Bottom:
+ return engine->toString(QLatin1String("bottom"));
+ case QSGContext2D::Middle:
+ return engine->toString(QLatin1String("middle"));
+ default:
+ break;
+ }
+ return engine->toString(QLatin1String("alphabetic"));
}
static void ctx2d_textBaseline_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
@@ -1201,10 +1910,30 @@ static void ctx2d_textBaseline_set(v8::Local<v8::String>, v8::Local<v8::Value> v
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
CHECK_CONTEXT_SETTER(r)
QV8Engine *engine = V8ENGINE_ACCESSOR();
-
- r->context->setTextBaseline(engine->toString(value));
-}
-
+ QString textBaseline = engine->toString(value);
+
+ QSGContext2D::TextBaseLineType tb;
+ if (textBaseline == QLatin1String("alphabetic"))
+ tb = QSGContext2D::Alphabetic;
+ else if (textBaseline == QLatin1String("hanging"))
+ tb = QSGContext2D::Hanging;
+ else if (textBaseline == QLatin1String("top"))
+ tb = QSGContext2D::Top;
+ else if (textBaseline == QLatin1String("bottom"))
+ tb = QSGContext2D::Bottom;
+ else if (textBaseline == QLatin1String("middle"))
+ tb = QSGContext2D::Middle;
+
+ if (tb != r->context->state.textBaseline) {
+ r->context->state.textBaseline = tb;
+ }
+}
+
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::fillText(text, x, y)
+ Fills the given text at the given position.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-filltext for details.
+ */
static v8::Handle<v8::Value> ctx2d_fillText(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1214,14 +1943,19 @@ static v8::Handle<v8::Value> ctx2d_fillText(const v8::Arguments &args)
QV8Engine *engine = V8ENGINE();
if (args.Length() == 3) {
- r->context->fillText(engine->toString(args[0]),
- args[1]->NumberValue(),
- args[2]->NumberValue());
+ QPainterPath textPath = r->context->createTextGlyphs(args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ engine->toString(args[0]));
+ r->context->buffer()->fill(textPath);
}
- return v8::Undefined();
+ return args.This();
}
-
+/*!
+ \qmlmethod QtQuick2::Context2D QtQuick2::Context2D::strokeText(text, x, y)
+ Strokes the given text at the given position.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-stroketext for details.
+ */
static v8::Handle<v8::Value> ctx2d_strokeText(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
@@ -1231,16 +1965,39 @@ static v8::Handle<v8::Value> ctx2d_strokeText(const v8::Arguments &args)
QV8Engine *engine = V8ENGINE();
if (args.Length() == 3) {
- r->context->strokeText(engine->toString(args[0]),
- args[1]->NumberValue(),
- args[2]->NumberValue());
- }
-
- return v8::Undefined();
-}
-
-// drawing images
-static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args)
+ QPainterPath textPath = r->context->createTextGlyphs(args[1]->NumberValue(),
+ args[2]->NumberValue(),
+ engine->toString(args[0]));
+ r->context->buffer()->stroke(textPath);
+ }
+
+ return args.This();
+}
+/*!
+ \qmlclass QtQuick2::TextMetrics
+ \inqmlmodule QtQuick 2
+ \since QtQuick 2.0
+ \brief The Context2D TextMetrics interface.
+ The TextMetrics object can be created by QtQuick2::Context2D::measureText method.
+ See http://www.w3.org/TR/2dcontext/#textmetrics for more details.
+
+ \sa QtQuick2::Context2D::measureText
+ \sa QtQuick2::TextMetrics::width
+ */
+
+/*!
+ \qmlproperty int QtQuick2::TextMetrics::width
+ Holds the advance width of the text that was passed to the QtQuick2::Context2D::measureText() method.
+ This property is read only.
+ See http://www.w3.org/TR/2dcontext/#dom-textmetrics-width for more details.
+ */
+
+/*!
+ \qmlmethod variant QtQuick2::Context2D::measureText(text)
+ Returns a TextMetrics object with the metrics of the given text in the current font.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-measuretext for details.
+ */
+static v8::Handle<v8::Value> ctx2d_measureText(const v8::Arguments &args)
{
QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
CHECK_CONTEXT(r)
@@ -1248,1404 +2005,866 @@ static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args)
QV8Engine *engine = V8ENGINE();
- if (args.Length() == 3) {
- r->context->drawImage(engine->toString(args[0]),
- args[1]->NumberValue(),
- args[2]->NumberValue());
- } else if (args.Length() == 5) {
- r->context->drawImage(engine->toString(args[0]),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue(),
- args[4]->NumberValue());
- } else if (args.Length() == 9) {
- r->context->drawImage(engine->toString(args[0]),
- args[1]->NumberValue(),
- args[2]->NumberValue(),
- args[3]->NumberValue(),
- args[4]->NumberValue(),
- args[5]->NumberValue(),
- args[6]->NumberValue(),
- args[7]->NumberValue(),
- args[8]->NumberValue());
+ if (args.Length() == 1) {
+ QFontMetrics fm(r->context->state.font);
+ uint width = fm.width(engine->toString(args[0]));
+ v8::Local<v8::Object> tm = v8::Object::New();
+ tm->Set(v8::String::New("width"), v8::Number::New(width));
+ return tm;
}
return v8::Undefined();
}
-// pixel manipulation
-static v8::Handle<v8::Value> ctx2d_createImageData(const v8::Arguments &args)
-{
- //#TODO
- return v8::Undefined();
-}
-
-static v8::Handle<v8::Value> ctx2d_getImageData(const v8::Arguments &args)
-{
- //#TODO
- return v8::Undefined();
-}
-
-static v8::Handle<v8::Value> ctx2d_putImageData(const v8::Arguments &args)
+// drawing images
+/*!
+ \qmlmethod QtQuick2::Context2D::drawImage(variant image, real dx, real dy)
+ Draws the given \a image on the canvas at position (\a dx, \a dy).
+ Note:
+ The \a image type can be an Image item or a image url. When given as Image
+ type, if the image isn't fully loaded, will draw nothing. When given as url string,
+ the context loads the image asynchorously and redraw the canvas when the image is loaded.
+
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage for more details.
+ */
+/*!
+ \qmlmethod QtQuick2::Context2D::drawImage(variant image, real dx, real dy, real dw, real dh)
+ Draws the given item as \a image onto the canvas at point (\a dx, \a dy) and with width \a dw,
+ height \a dh.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage for more details.
+ */
+/*!
+ \qmlmethod QtQuick2::Context2D::drawImage(variant image, real sx, real sy, real sw, sh, real dx, real dy, real dw, dh)
+ Draws the given item as \a image from source point (\a sx, \a sy) and source width \sw, source height \sh
+ onto the canvas at point (\a dx, \a dy) and with width \a dw, height \a dh.
+ See http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage for more details.
+ */
+static v8::Handle<v8::Value> ctx2d_drawImage(const v8::Arguments &args)
{
- //#TODO
- return v8::Undefined();
-}
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
-bool QSGContext2DPrivate::hasShadow() const
-{
- return state.shadowColor.isValid()
- && state.shadowColor.alpha()
- && (state.shadowBlur || state.shadowOffsetX || state.shadowOffsetY);
-}
-void QSGContext2DPrivate::clearShadow()
-{
- state.shadowOffsetX = 0;
- state.shadowOffsetY = 0;
- state.shadowBlur = 0;
- state.shadowColor = QColor();
-}
+ QV8Engine *engine = V8ENGINE();
-QImage QSGContext2DPrivate::makeShadowImage(const QPixmap& pix)
-{
- QImage shadowImg(pix.width() + state.shadowBlur * 2 + qAbs(state.shadowOffsetX),
- pix.height() + state.shadowBlur *2 + qAbs(state.shadowOffsetY),
- QImage::Format_ARGB32);
- shadowImg.fill(0);
- QPainter tmpPainter(&shadowImg);
- tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
- qreal shadowX = state.shadowOffsetX > 0? state.shadowOffsetX : 0;
- qreal shadowY = state.shadowOffsetY > 0? state.shadowOffsetY : 0;
+ //TODO: handle exceptions
- tmpPainter.drawPixmap(shadowX, shadowY, pix);
- tmpPainter.end();
+ qreal sx, sy, sw, sh, dx, dy, dw, dh;
- // blur the alpha channel
- if (state.shadowBlur > 0) {
- QImage blurred(shadowImg.size(), QImage::Format_ARGB32);
- blurred.fill(0);
- QPainter blurPainter(&blurred);
- qt_blurImage(&blurPainter, shadowImg, state.shadowBlur, false, true);
- blurPainter.end();
- shadowImg = blurred;
+ if (args.Length() != 3 && args.Length() != 5 && args.Length() != 9) {
+ //parameter error
+ return args.This();
}
- // blacken the image with shadow color...
- tmpPainter.begin(&shadowImg);
- tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- tmpPainter.fillRect(shadowImg.rect(), state.shadowColor);
- tmpPainter.end();
- return shadowImg;
-}
-
-void QSGContext2DPrivate::fillRectShadow(QPainter* p, QRectF shadowRect)
-{
- QRectF r = shadowRect;
- r.moveTo(0, 0);
- QImage shadowImage(r.size().width() + 1, r.size().height() + 1, QImage::Format_ARGB32);
- QPainter tp;
- tp.begin(&shadowImage);
- tp.fillRect(r, p->brush());
- tp.end();
- shadowImage = makeShadowImage(QPixmap::fromImage(shadowImage));
+ QImage image;
+ if (args[0]->IsString()) {
+ image = r->context->createImage(QUrl(engine->toString(args[0]->ToString())));
+ } /*else if (args[0]->IsObject()) {
+ QSGImage* imageItem = qobject_cast<QSGImage*>(engine->toQObject(args[0]->ToObject()));
+ if (imageItem) {
+ image = imageItem->pixmap().toImage();
+ } else {
+ //wrong image type
+ return args.This();
+ }
+ }*/
+ if (args.Length() == 3) {
+ dx = args[1]->NumberValue();
+ dy = args[2]->NumberValue();
+ sx = 0;
+ sy = 0;
+ sw = image.isNull()? -1 : image.width();
+ sh = image.isNull()? -1 : image.height();
+ dw = sw;
+ dh = sh;
+ } else if (args.Length() == 5) {
+ sx = 0;
+ sy = 0;
+ sw = image.isNull()? -1 : image.width();
+ sh = image.isNull()? -1 : image.height();
+ dx = args[1]->NumberValue();
+ dy = args[2]->NumberValue();
+ dw = args[3]->NumberValue();
+ dh = args[4]->NumberValue();
+ } else if (args.Length() == 9) {
+ sx = args[1]->NumberValue();
+ sy = args[2]->NumberValue();
+ sw = args[3]->NumberValue();
+ sh = args[4]->NumberValue();
+ dx = args[5]->NumberValue();
+ dy = args[6]->NumberValue();
+ dw = args[7]->NumberValue();
+ dh = args[8]->NumberValue();
+ } else {
+ //error
+ return args.This();
+ }
- qreal dx = shadowRect.left() + (state.shadowOffsetX < 0? state.shadowOffsetX:0);
- qreal dy = shadowRect.top() + (state.shadowOffsetY < 0? state.shadowOffsetY:0);
+ r->context->buffer()->drawImage(image,sx, sy, sw, sh, dx, dy, dw, dh);
- p->drawImage(dx, dy, shadowImage);
- p->fillRect(shadowRect, p->brush());
+ return args.This();
}
-void QSGContext2DPrivate::fillShadowPath(QPainter* p, const QPainterPath& path)
-{
- QRectF r = path.boundingRect();
- QImage img(r.size().width() + r.left() + 1,
- r.size().height() + r.top() + 1,
- QImage::Format_ARGB32);
- img.fill(0);
- QPainter tp(&img);
- tp.fillPath(path.translated(0, 0), p->brush());
- tp.end();
-
- QImage shadowImage = makeShadowImage(QPixmap::fromImage(img));
- qreal dx = r.left() + (state.shadowOffsetX < 0? state.shadowOffsetX:0);
- qreal dy = r.top() + (state.shadowOffsetY < 0? state.shadowOffsetY:0);
-
- p->drawImage(dx, dy, shadowImage);
- p->fillPath(path, p->brush());
-}
+// pixel manipulation
+/*!
+ \qmlclass QtQuick2::CanvasImageData
-void QSGContext2DPrivate::strokeShadowPath(QPainter* p, const QPainterPath& path)
+ */
+/*!
+ \qmlproperty QtQuick2::CanvasImageData::width
+ Holds the actual width dimension of the data in the ImageData object, in device pixels.
+ */
+v8::Handle<v8::Value> ctx2d_imageData_width(v8::Local<v8::String>, const v8::AccessorInfo &args)
{
- QRectF r = path.boundingRect();
- QImage img(r.size().width() + r.left() + 1,
- r.size().height() + r.top() + 1,
- QImage::Format_ARGB32);
- img.fill(0);
- QPainter tp(&img);
- tp.strokePath(path, p->pen());
- tp.end();
-
- QImage shadowImage = makeShadowImage(QPixmap::fromImage(img));
- qreal dx = r.left() + (state.shadowOffsetX < 0? state.shadowOffsetX:0);
- qreal dy = r.top() + (state.shadowOffsetY < 0? state.shadowOffsetY:0);
- p->drawImage(dx, dy, shadowImage);
- p->strokePath(path, p->pen());
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This()->GetInternalField(0)->ToObject());
+ if (!r)
+ return v8::Integer::New(0);
+ return v8::Integer::New(r->image.width());
}
-void QSGContext2DPrivate::clear()
+/*!
+ \qmlproperty QtQuick2::CanvasImageData::height
+ Holds the actual height dimension of the data in the ImageData object, in device pixels.
+ */
+v8::Handle<v8::Value> ctx2d_imageData_height(v8::Local<v8::String>, const v8::AccessorInfo &args)
{
- clearRect(0, 0, size.width(), size.height());
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This()->GetInternalField(0)->ToObject());
+ if (!r)
+ return v8::Integer::New(0);
+
+ return v8::Integer::New(r->image.height());
}
-void QSGContext2DPrivate::reset()
+/*!
+ \qmlproperty QtQuick2::CanvasImageData::data
+ Holds the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255.
+ */
+v8::Handle<v8::Value> ctx2d_imageData_data(v8::Local<v8::String>, const v8::AccessorInfo &args)
{
- stateStack.clear();
- state.matrix = QMatrix();
- state.clipPath = QPainterPath();
- state.strokeStyle = Qt::black;
- state.fillStyle = Qt::black;
- state.globalAlpha = 1.0;
- state.lineWidth = 1;
- state.lineCap = Qt::FlatCap;
- state.lineJoin = Qt::MiterJoin;
- state.miterLimit = 10;
- state.shadowOffsetX = 0;
- state.shadowOffsetY = 0;
- state.shadowBlur = 0;
- state.shadowColor = qRgba(0, 0, 0, 0);
- state.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
- state.font = QFont();
- state.textAlign = QSGContext2D::Start;
- state.textBaseline = QSGContext2D::Alphabetic;
- clear();
+ return args.This()->GetInternalField(0);
}
-
-void QSGContext2DPrivate::updateMatrix(const QMatrix& m)
+static v8::Handle<v8::Value> ctx2d_imageData_mirror(const v8::Arguments &args)
{
- commands.push_back(QSGContext2D::UpdateMatrix);
- matrixes.push_back(m);
-}
+ bool horizontal = false, vertical = true;
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This()->GetInternalField(0)->ToObject());
+ if (!r) {
+ //error
+ return v8::Undefined();
+ }
+ if (args.Length() > 2) {
+ //error
+ return v8::Undefined();
+ }
+ if (args.Length() == 1) {
+ horizontal = args[0]->BooleanValue();
+ } else if (args.Length() == 2) {
+ horizontal = args[0]->BooleanValue();
+ vertical = args[1]->BooleanValue();
+ }
-void QSGContext2DPrivate::save()
-{
- stateStack.push(state);
+ r->image = r->image.mirrored(horizontal, vertical);
+ return args.This();
}
-void QSGContext2DPrivate::restore()
+
+static v8::Handle<v8::Value> ctx2d_imageData_filter(const v8::Arguments &args)
{
- if (!stateStack.isEmpty()) {
- bool update = false;
- QSGContext2D::State s = stateStack.pop();
- if (state.matrix != s.matrix) {
- updateMatrix(s.matrix);
- update = true;
- }
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This()->GetInternalField(0)->ToObject());
- if (s.pen != state.pen) {
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(s.pen);
- update = true;
- }
+ if (!r) {
+ //error
+ return v8::Undefined();
+ }
- if (s.globalAlpha != state.globalAlpha) {
- commands.push_back(QSGContext2D::GlobalAlpha);
- reals.push_back(s.globalAlpha);
- update = true;
+ if (args.Length() >= 1) {
+ int filterFlag = args[0]->IntegerValue();
+ switch(filterFlag) {
+ case QSGCanvasItem::GrayScale :
+ {
+ for (int y = 0; y < r->image.height(); ++y) {
+ QRgb *row = (QRgb*)r->image.scanLine(y);
+ for (int x = 0; x < r->image.width(); ++x) {
+ unsigned char* rgb = ((unsigned char*)&row[x]);
+ rgb[0] = rgb[1] = rgb[2] = qGray(rgb[0], rgb[1], rgb[2]);
+ }
+ }
}
-
- if (s.globalCompositeOperation != state.globalCompositeOperation) {
- commands.push_back(QSGContext2D::GlobalCompositeOperation);
- ints.push_back(s.globalCompositeOperation);
- update = true;
+ break;
+ case QSGCanvasItem::Threshold :
+ {
+ int threshold = 127;
+ if (args.Length() > 1)
+ threshold = args[1]->IntegerValue();
+
+ for (int y = 0; y < r->image.height(); ++y) {
+ QRgb *row = (QRgb*)r->image.scanLine(y);
+ for (int x = 0; x < r->image.width(); ++x) {
+ unsigned char* rgb = ((unsigned char*)&row[x]);
+ unsigned char v = qGray(rgb[0], rgb[1], rgb[2]) >= threshold ? 255 : 0;
+ rgb[0] = rgb[1] = rgb[2] = v;
+ }
+ }
}
-
- if (s.font != state.font) {
- commands.push_back(QSGContext2D::Font);
- fonts.push_back(s.font);
- update = true;
+ break;
+ case QSGCanvasItem::Brightness :
+ {
+ int adjustment = 1;
+ if (args.Length() > 1)
+ adjustment = args[1]->IntegerValue();
+
+ for (int y = 0; y < r->image.height(); ++y) {
+ QRgb *row = (QRgb*)r->image.scanLine(y);
+ for (int x = 0; x < r->image.width(); ++x) {
+ ((unsigned char*)&row[x])[0] += adjustment;
+ ((unsigned char*)&row[x])[1] += adjustment;
+ ((unsigned char*)&row[x])[2] += adjustment;
+ }
+ }
}
-
- if (s.fillStyle != state.fillStyle) {
- commands.push_back(QSGContext2D::FillStyle);
- brushes.push_back(s.fillStyle);
- update = true;
+ break;
+ case QSGCanvasItem::Invert :
+ {
+ r->image.invertPixels();
}
-
- if (s.clipPath != state.clipPath) {
- //commands.push_back(QSGContext2D::ClipPath);
- update = true;
+ break;
+ case QSGCanvasItem::Blur :
+ {
+ QImage blurred(r->image.size(), QImage::Format_ARGB32);
+ qreal blur = 10;
+ if (args.Length() > 1)
+ blur = args[1]->NumberValue();
+
+ blurred.fill(Qt::transparent);
+ QPainter blurPainter(&blurred);
+ qt_blurImage(&blurPainter, r->image, blur, true, false);
+ blurPainter.end();
+ r->image = blurred;
}
-
- if (s.textAlign != state.textAlign) {
- commands.push_back(QSGContext2D::TextAlign);
- update = true;
+ break;
+ case QSGCanvasItem::Opaque :
+ {
+ for (int y = 0; y < r->image.height(); ++y) {
+ QRgb *row = (QRgb*)r->image.scanLine(y);
+ for (int x = 0; x < r->image.width(); ++x) {
+ ((unsigned char*)&row[x])[3] = 255;
+ }
+ }
}
-
- if (s.textBaseline != state.textBaseline) {
- commands.push_back(QSGContext2D::TextBaseline);
- update = true;
+ break;
+ case QSGCanvasItem::Convolute :
+ {
+ if (args.Length() > 1 && args[1]->IsArray()) {
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
+ QVector<int> weights;
+ for (uint32_t i = 0; i < array->Length(); ++i)
+ weights.append(array->Get(i)->NumberValue());
+ int sides = qRound(qSqrt(weights.size()));
+ int half = qFloor(sides/2);
+
+ QImage image = QImage(r->image.size(), QImage::Format_ARGB32);
+ int w = r->image.width();
+ int h = r->image.height();
+ for (int y = 0; y < image.height(); ++y) {
+ QRgb *dRow = (QRgb*)image.scanLine(y);
+ for (int x = 0; x < image.width(); ++x) {
+ unsigned char* dRgb = ((unsigned char*)&dRow[x]);
+ unsigned char red=0, green=0, blue=0, alpha=0;
+ int sy = y;
+ int sx = x;
+
+ for (int cy=0; cy<sides; cy++) {
+ for (int cx=0; cx<sides; cx++) {
+ int scy = sy + cy - half;
+ int scx = sx + cx - half;
+ if (scy >= 0 && scy < w && scx >= 0 && scx < h) {
+ QRgb *sRow = (QRgb*)(r->image.scanLine(scy));
+ unsigned char* sRgb = ((unsigned char*)&sRow[scx]);
+ int wt = weights[cy*sides+cx];
+ red += sRgb[0] * wt;
+ green += sRgb[1] * wt;
+ blue += sRgb[2] * wt;
+ alpha += sRgb[3] * wt;
+ }
+ }
+ }
+ dRgb[0] = red;
+ dRgb[1] = green;
+ dRgb[2] = blue;
+ dRgb[3] = alpha;
+ }
+ }
+ r->image = image;
+ } else {
+ //error
+ }
}
-
- if (s.shadowBlur != state.shadowBlur
- || s.shadowColor != state.shadowColor
- || s.shadowOffsetX != state.shadowOffsetX
- || s.shadowOffsetY != state.shadowOffsetY) {
- update = true;
+ break;
+ default:
+ break;
}
-
- if (update)
- state = s;
}
-}
-
-void QSGContext2DPrivate::scale(qreal x, qreal y)
-{
- state.matrix.scale(x, y);
- updateMatrix(state.matrix);
-}
-
-void QSGContext2DPrivate::rotate(qreal angle)
-{
- state.matrix.rotate(DEGREES(angle));
- updateMatrix(state.matrix);
-}
-
-
-void QSGContext2DPrivate::translate(qreal x, qreal y)
-{
- state.matrix.translate(x, y);
- updateMatrix(state.matrix);
-}
-void QSGContext2DPrivate::transform(
- qreal m11, qreal m12,
- qreal m21, qreal m22,
- qreal dx, qreal dy)
-{
- QMatrix matrix(m11, m12, m21, m22, dx, dy);
- state.matrix *= matrix;
- updateMatrix(state.matrix);
+ return args.This();
}
+/*!
+ \qmlclass QtQuick2::CanvasPixelArray
+ The CanvasPixelArray object provides ordered, indexed access to the color components of each pixel of the image data.
+ See http://www.w3.org/TR/2dcontext/#canvaspixelarray for more details.
+ */
-void QSGContext2DPrivate::setTransform(
- qreal m11, qreal m12,
- qreal m21, qreal m22,
- qreal dx, qreal dy)
+/*!
+ \qmlproperty QtQuick2::CanvasPixelArray::length
+ The CanvasPixelArray object represents h×w×4 integers which w and h comes from CanvasImageData.
+ The length attribute of a CanvasPixelArray object must return this h×w×4 number value.
+ */
+v8::Handle<v8::Value> ctx2d_pixelArray_length(v8::Local<v8::String>, const v8::AccessorInfo &args)
{
- QMatrix matrix(m11, m12, m21, m22, dx, dy);
- state.matrix = matrix;
- updateMatrix(state.matrix);
-}
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This());
+ if (!r || r->image.isNull()) return v8::Undefined();
-void QSGContext2DPrivate::clearRect(qreal x, qreal y,
- qreal w, qreal h)
-{
- commands.push_back(QSGContext2D::ClearRect);
- reals.push_back(x);
- reals.push_back(y);
- reals.push_back(w);
- reals.push_back(h);
+ return v8::Integer::New(r->image.width() * r->image.height() * 4);
}
-void QSGContext2DPrivate::fillRect(qreal x, qreal y,
- qreal w, qreal h)
+v8::Handle<v8::Value> ctx2d_pixelArray_indexed(uint32_t index, const v8::AccessorInfo& args)
{
- QRectF rect;
- if (tileRect.isValid()) {
- rect = tileRect.intersect(QRect(x, y, w, h));
- } else {
- rect = QRectF(x, y, w, h);
- }
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(args.This());
- if (rect.isValid()) {
- commands.push_back(QSGContext2D::FillRect);
- reals.push_back(rect.x());
- reals.push_back(rect.y());
- reals.push_back(rect.width());
- reals.push_back(rect.height());
+ if (r && index && index < r->image.width() * r->image.height() * 4) {
+ const int w = r->image.width();
+ const int h = r->image.height();
+ const int row = (index / 4) / w;
+ const int col = (index / 4) % w;
+ const QRgb* pixel = reinterpret_cast<const QRgb*>(r->image.constScanLine(row));
+ pixel += col;
+ switch (index % 4) {
+ case 0:
+ return v8::Integer::New(qRed(*pixel));
+ case 1:
+ return v8::Integer::New(qGreen(*pixel));
+ case 2:
+ return v8::Integer::New(qBlue(*pixel));
+ case 3:
+ return v8::Integer::New(qAlpha(*pixel));
+ }
}
+ return v8::Undefined();
}
-void QSGContext2DPrivate::strokeRect(qreal x, qreal y,
- qreal w, qreal h)
+v8::Handle<v8::Value> ctx2d_pixelArray_indexed_set(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
- QPainterPath p;
- p.addRect(x, y, w, h);
+ QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(info.This());
- if (tileRect.isValid()) {
- QPainterPath tr;
- tr.addRect(tileRect);
- p = p.intersected(tr);
- }
+ const int v = value->Uint32Value();
+ if (r && index > 0 && index < r->image.width() * r->image.height() * 4 && v > 0 && v <= 255) {
+ const int w = r->image.width();
+ const int h = r->image.height();
+ const int row = (index / 4) / w;
+ const int col = (index / 4) % w;
- if (!p.isEmpty()) {
- commands.push_back(QSGContext2D::Stroke);
- pathes.push_back(p);
+ QRgb* pixel = reinterpret_cast<QRgb*>(r->image.scanLine(row));
+ pixel += col;
+ switch (index % 4) {
+ case 0:
+ *pixel = qRgba(v, qGreen(*pixel), qBlue(*pixel), qAlpha(*pixel));
+ break;
+ case 1:
+ *pixel = qRgba(qRed(*pixel), v, qBlue(*pixel), qAlpha(*pixel));
+ break;
+ case 2:
+ *pixel = qRgba(qRed(*pixel), qGreen(*pixel), v, qAlpha(*pixel));
+ break;
+ case 3:
+ *pixel = qRgba(qRed(*pixel), qGreen(*pixel), qBlue(*pixel), v);
+ break;
+ }
}
+ return v8::Undefined();
}
-
-void QSGContext2DPrivate::beginPath()
-{
- path = QPainterPath();
-}
-
-void QSGContext2DPrivate::closePath()
-{
- path.closeSubpath();
-}
-
-void QSGContext2DPrivate::moveTo( qreal x, qreal y)
-{
- path.moveTo(state.matrix.map(QPointF(x, y)));
-}
-
-void QSGContext2DPrivate::lineTo( qreal x, qreal y)
-{
- path.lineTo(state.matrix.map(QPointF(x, y)));
-}
-
-void QSGContext2DPrivate::quadraticCurveTo(qreal cpx, qreal cpy,
- qreal x, qreal y)
-{
- path.quadTo(state.matrix.map(QPointF(cpx, cpy)),
- state.matrix.map(QPointF(x, y)));
-}
-
-void QSGContext2DPrivate::bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y,
- qreal x, qreal y)
-{
- path.cubicTo(state.matrix.map(QPointF(cp1x, cp1y)),
- state.matrix.map(QPointF(cp2x, cp2y)),
- state.matrix.map(QPointF(x, y)));
-}
-
-void QSGContext2DPrivate::arcTo(qreal x1, qreal y1,
- qreal x2, qreal y2,
- qreal radius)
-{
- QPointF st = state.matrix.map(QPoint(x1, y1));
- QPointF end = state.matrix.map(QPoint(x2, y2));
-
- path.arcTo(st.x(), st.y(),
- end.x()-st.x(), end.y()-st.y(),
- radius, 90);
-}
-
-void QSGContext2DPrivate::rect(qreal x, qreal y,
- qreal w, qreal h)
-{
- QPainterPath path;
- path.addRect(QRectF(x, y, w, h));
- path.addPath(state.matrix.map(path));
-}
-
-void QSGContext2DPrivate::arc(qreal xc,
- qreal yc,
- qreal radius,
- qreal sar,
- qreal ear,
- bool antiClockWise)
+/*!
+ \qmlmethod QtQuick2::CanvasImageData createImageData(real sw, real sh)
+ Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
+ */
+/*!
+ \qmlmethod QtQuick2::CanvasImageData createImageData(QtQuick2::CanvasImageData imageData)
+ Creates a CanvasImageData object with the same dimensions as the argument.
+ */
+/*!
+ \qmlmethod QtQuick2::CanvasImageData createImageData(Url imageUrl)
+ Creates a CanvasImageData object with the given image loaded from \a imageUrl.
+ Note:The \a imageUrl must be already loaded before this function call, if not, an empty
+ CanvasImageData obect will be returned.
+
+ \sa QtQuick2::Canvas::loadImage, QtQuick2::Canvas::unloadImage, QtQuick2::Canvas::isImageLoaded
+ */
+static v8::Handle<v8::Value> ctx2d_createImageData(const v8::Arguments &args)
{
- QPainterPath p;
-
- //### HACK
-
- // In Qt we don't switch the coordinate system for degrees
- // and still use the 0,0 as bottom left for degrees so we need
- // to switch
- sar = -sar;
- ear = -ear;
- antiClockWise = !antiClockWise;
- //end hack
-
- float sa = DEGREES(sar);
- float ea = DEGREES(ear);
-
- double span = 0;
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
- double xs = xc - radius;
- double ys = yc - radius;
- double width = radius*2;
- double height = radius*2;
- if (!antiClockWise && (ea < sa)) {
- span += 360;
- } else if (antiClockWise && (sa < ea)) {
- span -= 360;
- }
+ QV8Engine *engine = V8ENGINE();
- //### this is also due to switched coordinate system
- // we would end up with a 0 span instead of 360
- if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) &&
- qFuzzyCompare(qAbs(span), 360))) {
- span += ea - sa;
+ if (args.Length() == 1) {
+ if (args[0]->IsObject()) {
+ v8::Local<v8::Object> imgData = args[0]->ToObject();
+ QV8Context2DPixelArrayResource *pa = v8_resource_cast<QV8Context2DPixelArrayResource>(imgData->GetInternalField(0)->ToObject());
+ if (pa) {
+ qreal w = imgData->Get(v8::String::New("width"))->NumberValue();
+ qreal h = imgData->Get(v8::String::New("height"))->NumberValue();
+ return qt_create_image_data(w, h, engine, QImage());
+ }
+ } else if (args[0]->IsString()) {
+ QImage image = r->context->createImage(QUrl(engine->toString(args[0]->ToString())));
+ return qt_create_image_data(image.width(), image.height(), engine, image);
+ }
+ } else if (args.Length() == 2) {
+ qreal w = args[0]->NumberValue();
+ qreal h = args[1]->NumberValue();
+ if (w > 0 && h > 0)
+ return qt_create_image_data(w, h, engine, QImage());
}
-
- p.moveTo(QPointF(xc + radius * qCos(sar),
- yc - radius * qSin(sar)));
-
- p.arcTo(xs, ys, width, height, sa, span);
-
- path.addPath(state.matrix.map(p));
+ return v8::Undefined();
}
-void QSGContext2DPrivate::fill()
+/*!
+ \qmlmethod QtQuick2::CanvasImageData getImageData(real sx, real sy, real sw, real sh)
+ Returns an CanvasImageData object containing the image data for the given rectangle of the canvas.
+ */
+static v8::Handle<v8::Value> ctx2d_getImageData(const v8::Arguments &args)
{
- QPainterPath tr;
- if (tileRect.isValid()) {
- tr.addRect(tileRect);
- tr = tr.intersected(path);
- } else {
- tr = path;
- }
-
- if (!tr.isEmpty()) {
- commands.push_back(QSGContext2D::Fill);
- pathes.push_back(tr);
- }
-}
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
-void QSGContext2DPrivate::stroke()
-{
- QPainterPath tr;
- if (tileRect.isValid()) {
- tr.addRect(tileRect);
- tr = tr.intersected(path);
- } else {
- tr = path;
- }
+ QV8Engine *engine = V8ENGINE();
+ if (args.Length() == 4) {
+ qreal x = args[0]->NumberValue();
+ qreal y = args[1]->NumberValue();
+ qreal w = args[2]->NumberValue();
+ qreal h = args[3]->NumberValue();
+ QImage image = r->context->canvas()->toImage(QRectF(x, y, w, h));
+ if (image.format() != QImage::Format_ARGB32)
+ image = image.convertToFormat(QImage::Format_ARGB32);
+ v8::Local<v8::Object> imageData = qt_create_image_data(w, h, engine, image);
- if (!tr.isEmpty()) {
- commands.push_back(QSGContext2D::Stroke);
- pathes.push_back(tr);
+ return imageData;
}
+ return v8::Null();
}
-void QSGContext2DPrivate::clip()
+/*!
+ \qmlmethod QtQuick2::Context2D putImageData(QtQuick2::CanvasImageData imageData, real dx, real dy, real dirtyX, real dirtyY, real dirtyWidth, real dirtyHeight)
+ Paints the data from the given ImageData object onto the canvas. If a dirty rectangle (\a dirtyX, \a dirtyY, \a dirtyWidth, \a dirtyHeight) is provided, only the pixels from that rectangle are painted.
+ */
+static v8::Handle<v8::Value> ctx2d_putImageData(const v8::Arguments &args)
{
- //TODO:XXX
- state.clipPath = path;
- pathes.push_back(state.clipPath);
- commands.push_back(QSGContext2D::Clip);
-}
+ QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
+ CHECK_CONTEXT(r)
+ if (args.Length() != 3 && args.Length() != 7)
+ return v8::Undefined();
+
+ if (args[0]->IsNull() || !args[0]->IsObject()) {
+ V8THROW_ERROR("Context2D::putImageData, the image data type mismatch");
+ }
+ qreal dx = args[1]->NumberValue();
+ qreal dy = args[2]->NumberValue();
+ qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight;
+
+ v8::Local<v8::Object> imageData = args[0]->ToObject();
+ QV8Context2DPixelArrayResource *pixelArray = v8_resource_cast<QV8Context2DPixelArrayResource>(imageData->Get(v8::String::New("data"))->ToObject());
+ if (pixelArray) {
+ w = imageData->Get(v8::String::New("width"))->NumberValue();
+ h = imageData->Get(v8::String::New("height"))->NumberValue();
+
+ if (args.Length() == 7) {
+ dirtyX = args[3]->NumberValue();
+ dirtyY = args[4]->NumberValue();
+ dirtyWidth = args[5]->NumberValue();
+ dirtyHeight = args[6]->NumberValue();
+ if (dirtyWidth < 0) {
+ dirtyX = dirtyX+dirtyWidth;
+ dirtyWidth = -dirtyWidth;
+ }
-void QSGContext2DPrivate::setGlobalAlpha( qreal alpha)
-{
- state.globalAlpha = alpha;
- commands.push_back(QSGContext2D::GlobalAlpha);
- reals.push_back(state.globalAlpha);
-}
+ if (dirtyHeight < 0) {
+ dirtyY = dirtyY+dirtyHeight;
+ dirtyHeight = -dirtyHeight;
+ }
-void QSGContext2DPrivate::setGlobalCompositeOperation( const QString &op)
-{
- state.globalCompositeOperation = compositeOperatorFromString(op);
- commands.push_back(QSGContext2D::GlobalCompositeOperation);
- ints.push_back(state.globalCompositeOperation);
-}
+ if (dirtyX < 0) {
+ dirtyWidth = dirtyWidth+dirtyX;
+ dirtyX = 0;
+ }
-void QSGContext2DPrivate::setStrokeStyle( const QVariant &style)
-{
- QSGCanvasGradient *gradient= qobject_cast<QSGCanvasGradient*>(style.value<QObject*>());
- QBrush b;
- if (gradient) {
- b = gradient->value();
- } else {
- b = colorFromString(style.toString());
- }
+ if (dirtyY < 0) {
+ dirtyHeight = dirtyHeight+dirtyY;
+ dirtyY = 0;
+ }
- if (state.strokeStyle != b) {
- state.strokeStyle = b;
- state.pen.setBrush(state.strokeStyle);
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(state.pen);
- }
-}
-void QSGContext2DPrivate::setStrokeColor(const QColor& color)
-{
- if (state.strokeStyle != color) {
- state.strokeStyle = color;
- commands.push_back(QSGContext2D::UpdatePen);
- QPen pen;
- pen.setBrush(state.strokeStyle);
- pens.push_back(pen);
- }
-}
+ if (dirtyX+dirtyWidth > w) {
+ dirtyWidth = w - dirtyX;
+ }
-void QSGContext2DPrivate::setFillColor(const QColor& color)
-{
- if (state.fillStyle != color) {
- state.fillStyle = color;
- commands.push_back(QSGContext2D::UpdateBrush);
- brushes.push_back(state.fillStyle);
- }
-}
+ if (dirtyY+dirtyHeight > h) {
+ dirtyHeight = h - dirtyY;
+ }
-void QSGContext2DPrivate::setFillStyle( const QVariant &style)
-{
- QSGCanvasGradient *gradient= qobject_cast<QSGCanvasGradient*>(style.value<QObject*>());
- QBrush b;
- if (gradient) {
- b = gradient->value();
- } else {
- b = colorFromString(style.toString());
- }
+ if (dirtyWidth <=0 || dirtyHeight <= 0)
+ return args.This();
+ } else {
+ dirtyX = 0;
+ dirtyY = 0;
+ dirtyWidth = w;
+ dirtyHeight = h;
+ }
- if (state.fillStyle != b) {
- state.fillStyle = b;
- commands.push_back(QSGContext2D::UpdateBrush);
- brushes.push_back(b);
+ QImage image = pixelArray->image.copy(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
+ r->context->buffer()->drawImage(image, dirtyX, dirtyY, dirtyWidth, dirtyHeight, dx, dy, dirtyWidth, dirtyHeight);
}
+ return args.This();
}
+/*!
+ \qmlclass QtQuick2::CanvasGradient
+ \inqmlmodule QtQuick 2
+ \since QtQuick 2.0
+ \brief The Context2D opaque CanvasGradient interface.
+ */
-void QSGContext2DPrivate::setLineWidth( qreal w)
-{
- if (state.lineWidth != w) {
- state.pen.setWidthF(w);
- state.lineWidth = w;
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(state.pen);
- }
-}
-
-void QSGContext2DPrivate::setLineCap( const QString& cap)
+/*!
+ \qmlmethod QtQuick2::CanvasGradient QtQuick2::CanvasGradient::addColorStop(real offsetof, string color)
+ Adds a color stop with the given color to the gradient at the given offset.
+ 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.
+ */
+static v8::Handle<v8::Value> ctx2d_gradient_addColorStop(const v8::Arguments &args)
{
- Qt::PenCapStyle style;
- if (cap == QLatin1String("round"))
- style = Qt::RoundCap;
- else if (cap == QLatin1String("square"))
- style = Qt::SquareCap;
- else //if (capString == "butt")
- style = Qt::FlatCap;
+ QV8Context2DStyleResource *style = v8_resource_cast<QV8Context2DStyleResource>(args.This());
+ if (!style)
+ V8THROW_ERROR("Not a CanvasGradient object");
+ QV8Engine *engine = V8ENGINE();
- if (state.lineCap != style) {
- state.pen.setCapStyle(style);
- state.lineCap = style;
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(state.pen);
- }
-}
+ if (args.Length() == 2) {
-void QSGContext2DPrivate::setLineJoin( const QString& join)
-{
- Qt::PenJoinStyle style;
- if (join == QLatin1String("round"))
- style = Qt::RoundJoin;
- else if (join == QLatin1String("bevel"))
- style = Qt::BevelJoin;
- else //if (joinString == "miter")
- style = Qt::MiterJoin;
- if (state.lineJoin != style) {
- state.lineJoin = style;
- state.pen.setJoinStyle(style);
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(state.pen);
- }
-}
+ if (!style->brush.gradient())
+ V8THROW_ERROR("Not a valid CanvasGradient object, can't get the gradient information");
+ QGradient gradient = *(style->brush.gradient());
+ qreal pos = args[0]->NumberValue();
+ QColor color = qt_color_from_string(engine->toString(args[1]));
+ if (pos < 0.0 || pos > 1.0) {
+ //Throws an INDEX_SIZE_ERR exception
+ V8THROW_ERROR("CanvasGradient: parameter offset out of range");
+ }
-void QSGContext2DPrivate::setMiterLimit( qreal limit)
-{
- if (state.miterLimit != limit) {
- state.pen.setMiterLimit(limit);
- state.miterLimit = limit;
- commands.push_back(QSGContext2D::UpdatePen);
- pens.push_back(state.pen);
+ if (color.isValid()) {
+ gradient.setColorAt(pos, color);
+ } else {
+ //Throws a SYNTAX_ERR exception
+ V8THROW_ERROR("CanvasGradient: parameter color is not a valid color string");
+ }
+ style->brush = gradient;
}
-}
-void QSGContext2DPrivate::setShadowOffsetX( qreal x)
-{
- if (state.shadowOffsetX != x) {
- state.shadowOffsetX = x;
- commands.push_back(QSGContext2D::ShadowOffsetX);
- reals.push_back(x);
- }
+ return args.This();
}
-void QSGContext2DPrivate::setShadowOffsetY( qreal y)
-{
- if (state.shadowOffsetY != y) {
- state.shadowOffsetY = y;
- commands.push_back(QSGContext2D::ShadowOffsetY);
- reals.push_back(y);
- }
-}
-void QSGContext2DPrivate::setShadowBlur( qreal b)
-{
- if (state.shadowBlur != b) {
- state.shadowBlur = b;
- commands.push_back(QSGContext2D::ShadowBlur);
- reals.push_back(b);
- }
-}
-
-void QSGContext2DPrivate::setShadowColor( const QString& color)
+void QSGContext2D::beginPath()
{
- QColor c = colorFromString(color);
- if (state.shadowColor != c) {
- state.shadowColor = c;
- commands.push_back(QSGContext2D::ShadowColor);
- colors.push_back(c);
- }
+ m_path = QPainterPath();
+ m_path.setFillRule(state.fillRule);
}
-void QSGContext2DPrivate::setFont( const QString& fontString)
+void QSGContext2D::closePath()
{
- QFont font;
- // ### this is simplified and incomplete
- // ### TODO:get code from Qt webkit
- QStringList tokens = fontString.split(QLatin1String(" "));
- foreach (const QString &token, tokens) {
- if (token == QLatin1String("italic"))
- font.setItalic(true);
- else if (token == QLatin1String("bold"))
- font.setBold(true);
- else if (token.endsWith(QLatin1String("px"))) {
- QString number = token;
- number.remove(QLatin1String("px"));
- font.setPointSizeF(number.trimmed().toFloat());
- } else
- font.setFamily(token);
- }
-
- if (state.font != font) {
- state.font = font;
- commands.push_back(QSGContext2D::Font);
- fonts.push_back(font);
- }
-}
+ if (m_path.isEmpty())
+ return;
-void QSGContext2DPrivate::setTextBaseline( const QString& baseline)
-{
- QSGContext2D::TextBaseLineType tbl;
- if (baseline==QLatin1String("alphabetic"))
- tbl = QSGContext2D::Alphabetic;
- else if (baseline == QLatin1String("hanging"))
- tbl = QSGContext2D::Hanging;
- else if (baseline == QLatin1String("top"))
- tbl = QSGContext2D::Top;
- else if (baseline == QLatin1String("bottom"))
- tbl = QSGContext2D::Bottom;
- else if (baseline == QLatin1String("middle"))
- tbl = QSGContext2D::Middle;
- else {
- tbl = QSGContext2D::Alphabetic;
- Q_Q(QSGContext2D);
- qmlInfo(q) << "QSGContext2D: invalid baseline:" << baseline;
- }
- if (state.textBaseline != tbl) {
- state.textBaseline = tbl;
- commands.push_back(QSGContext2D::TextBaseline);
- ints.push_back(tbl);
- }
+ QRectF boundRect = m_path.boundingRect();
+ if (boundRect.width() || boundRect.height())
+ m_path.closeSubpath();
}
-void QSGContext2DPrivate::setTextAlign(const QString& align)
+void QSGContext2D::moveTo( qreal x, qreal y)
{
- QSGContext2D::TextAlignType ta;
- if (align==QLatin1String("start"))
- ta = QSGContext2D::Start;
- else if (align == QLatin1String("end"))
- ta = QSGContext2D::End;
- else if (align == QLatin1String("left"))
- ta = QSGContext2D::Left;
- else if (align == QLatin1String("right"))
- ta = QSGContext2D::Right;
- else if (align == QLatin1String("center"))
- ta = QSGContext2D::Center;
- else {
- ta = QSGContext2D::Start;
- Q_Q(QSGContext2D);
- qmlInfo(q) << "QSGContext2D: invalid text align:" << align;
- }
- if (state.textAlign != ta) {
- state.textAlign = ta;
- commands.push_back(QSGContext2D::TextAlign);
- ints.push_back(ta);
- }
+ m_path.moveTo(state.matrix.map(QPointF(x, y)));
}
-void QSGContext2DPrivate::fillText(const QString& text, qreal x, qreal y)
+void QSGContext2D::lineTo( qreal x, qreal y)
{
- commands.push_back(QSGContext2D::FillText);
- strings.push_back(text);
- reals.push_back(x);
- reals.push_back(y);
- ints.push_back(state.textAlign);
- ints.push_back(state.textBaseline);
+ m_path.lineTo(state.matrix.map(QPointF(x, y)));
}
-
-void QSGContext2DPrivate::strokeText( const QString& text, qreal x, qreal y)
+void QSGContext2D::quadraticCurveTo(qreal cpx, qreal cpy,
+ qreal x, qreal y)
{
- commands.push_back(QSGContext2D::StrokeText);
- strings.push_back(text);
- reals.push_back(x);
- reals.push_back(y);
- ints.push_back(state.textAlign);
- ints.push_back(state.textBaseline);
+ m_path.quadTo(state.matrix.map(QPointF(cpx, cpy)),
+ state.matrix.map(QPointF(x, y)));
}
-void QSGContext2DPrivate::drawImage(const QString& url, qreal dx, qreal dy)
+void QSGContext2D::bezierCurveTo(qreal cp1x, qreal cp1y,
+ qreal cp2x, qreal cp2y,
+ qreal x, qreal y)
{
- commands.push_back(QSGContext2D::DrawImage1);
- strings.push_back(url);
- reals.push_back(dx);
- reals.push_back(dy);
+ m_path.cubicTo(state.matrix.map(QPointF(cp1x, cp1y)),
+ state.matrix.map(QPointF(cp2x, cp2y)),
+ state.matrix.map(QPointF(x, y)));
}
-void QSGContext2DPrivate::drawImage(const QString& url, qreal dx, qreal dy, qreal dw, qreal dh)
+void QSGContext2D::addArcTo(const QPointF& p1, const QPointF& p2, float radius)
{
- commands.push_back(QSGContext2D::DrawImage2);
- strings.push_back(url);
- reals.push_back(dx);
- reals.push_back(dy);
- reals.push_back(dw);
- reals.push_back(dh);
-}
+ QPointF p0(m_path.currentPosition());
-void QSGContext2DPrivate::drawImage(const QString& url, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh)
-{
- commands.push_back(QSGContext2D::DrawImage3);
- strings.push_back(url);
- reals.push_back(sx);
- reals.push_back(sy);
- reals.push_back(sw);
- reals.push_back(sh);
- reals.push_back(dx);
- reals.push_back(dy);
- reals.push_back(dw);
- reals.push_back(dh);
-}
+ QPointF p1p0((p0.x() - p1.x()), (p0.y() - p1.y()));
+ QPointF p1p2((p2.x() - p1.x()), (p2.y() - p1.y()));
+ float p1p0_length = qSqrt(p1p0.x() * p1p0.x() + p1p0.y() * p1p0.y());
+ float p1p2_length = qSqrt(p1p2.x() * p1p2.x() + p1p2.y() * p1p2.y());
-QList<int> QSGContext2DPrivate::getImageData(qreal sx, qreal sy, qreal sw, qreal sh)
-{
- Q_Q(QSGContext2D);
- waitingForPainting = true;
- commands.push_back(QSGContext2D::GetImageData);
- reals.push_back(sx);
- reals.push_back(sy);
- reals.push_back(sw);
- reals.push_back(sh);
- q->sync();
- return imageData;
-}
+ double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length);
-void QSGContext2DPrivate::putImageData(const QVariantList& imageData, qreal dx, qreal dy, qreal w, qreal h)
-{
- QImage image = cachedImage.copy(dx, dy, w, h);
- uchar* data = image.bits();
- int i = 0;
- while(i< imageData.size() && i < image.byteCount()) {
- //the stored order in QImage:BGRA
- //the stored order in Canvas:RGBA
- *(data+i) = imageData[i+2].toInt();//B
- *(data+i+1) = imageData[i+1].toInt();//G
- *(data+i+2) = imageData[i].toInt();//R
- *(data+i+3) = imageData[i+3].toInt();//A
- i+=4;
+ // The points p0, p1, and p2 are on the same straight line (HTML5, 4.8.11.1.8)
+ // We could have used areCollinear() here, but since we're reusing
+ // the variables computed above later on we keep this logic.
+ if (qFuzzyCompare(qAbs(cos_phi), 1.0)) {
+ m_path.lineTo(p1);
+ return;
}
- commands.push_back(QSGContext2D::PutImageData);
- images.push_back(image);
- reals.push_back(dx);
- reals.push_back(dy);
-}
-
-void QSGContext2D::save()
-{
- Q_D(QSGContext2D);
- d->save();
-}
-
-
-void QSGContext2D::restore()
-{
- Q_D(QSGContext2D);
- d->restore();
-}
-
-
-void QSGContext2D::scale(qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->scale(x, y);
-}
-
-
-void QSGContext2D::rotate(qreal angle)
-{
- Q_D(QSGContext2D);
- d->rotate(angle);
-}
-
-
-void QSGContext2D::translate(qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->translate(x, y);
-}
-
-void QSGContext2D::transform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
-{
- Q_D(QSGContext2D);
- d->transform(m11, m12, m21, m22, dx, dy);
-}
-
-void QSGContext2D::setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
-{
- Q_D(QSGContext2D);
- d->setTransform(m11, m12, m21, m22, dx, dy);
-}
+ float tangent = radius / tan(acos(cos_phi) / 2);
+ float factor_p1p0 = tangent / p1p0_length;
+ QPointF t_p1p0((p1.x() + factor_p1p0 * p1p0.x()), (p1.y() + factor_p1p0 * p1p0.y()));
-QString QSGContext2D::globalCompositeOperation() const
-{
- Q_D(const QSGContext2D);
- return compositeOperatorToString(d->state.globalCompositeOperation);
-}
+ QPointF orth_p1p0(p1p0.y(), -p1p0.x());
+ float orth_p1p0_length = sqrt(orth_p1p0.x() * orth_p1p0.x() + orth_p1p0.y() * orth_p1p0.y());
+ float factor_ra = radius / orth_p1p0_length;
-void QSGContext2D::setGlobalCompositeOperation(const QString &op)
-{
- Q_D(QSGContext2D);
- d->setGlobalCompositeOperation(op);
-}
+ // angle between orth_p1p0 and p1p2 to get the right vector orthographic to p1p0
+ double cos_alpha = (orth_p1p0.x() * p1p2.x() + orth_p1p0.y() * p1p2.y()) / (orth_p1p0_length * p1p2_length);
+ if (cos_alpha < 0.f)
+ orth_p1p0 = QPointF(-orth_p1p0.x(), -orth_p1p0.y());
-QVariant QSGContext2D::strokeStyle() const
-{
- Q_D(const QSGContext2D);
- return d->state.strokeStyle;
-}
+ QPointF p((t_p1p0.x() + factor_ra * orth_p1p0.x()), (t_p1p0.y() + factor_ra * orth_p1p0.y()));
-void QSGContext2D::setStrokeStyle(const QVariant &style)
-{
- Q_D(QSGContext2D);
- d->setStrokeStyle(style);
-}
+ // calculate angles for addArc
+ orth_p1p0 = QPointF(-orth_p1p0.x(), -orth_p1p0.y());
+ float sa = acos(orth_p1p0.x() / orth_p1p0_length);
+ if (orth_p1p0.y() < 0.f)
+ sa = 2 * Q_PI - sa;
-QVariant QSGContext2D::fillStyle() const
-{
- Q_D(const QSGContext2D);
- return d->state.fillStyle;
-}
+ // anticlockwise logic
+ bool anticlockwise = false;
-QColor QSGContext2D::strokeColor() const
-{
- Q_D(const QSGContext2D);
- return d->state.strokeStyle.color();
-}
+ float factor_p1p2 = tangent / p1p2_length;
+ QPointF t_p1p2((p1.x() + factor_p1p2 * p1p2.x()), (p1.y() + factor_p1p2 * p1p2.y()));
+ QPointF orth_p1p2((t_p1p2.x() - p.x()), (t_p1p2.y() - p.y()));
+ float orth_p1p2_length = sqrtf(orth_p1p2.x() * orth_p1p2.x() + orth_p1p2.y() * orth_p1p2.y());
+ float ea = acos(orth_p1p2.x() / orth_p1p2_length);
+ if (orth_p1p2.y() < 0)
+ ea = 2 * Q_PI - ea;
+ if ((sa > ea) && ((sa - ea) < Q_PI))
+ anticlockwise = true;
+ if ((sa < ea) && ((ea - sa) > Q_PI))
+ anticlockwise = true;
-QColor QSGContext2D::fillColor() const
-{
- Q_D(const QSGContext2D);
- return d->state.fillStyle.color();
+ arc(p.x(), p.y(), radius, sa, ea, anticlockwise, false);
}
-void QSGContext2D::setFillStyle(const QVariant &style)
-{
- Q_D(QSGContext2D);
- d->setFillStyle(style);
-}
-void QSGContext2D::setStrokeColor(const QColor& color)
-{
- Q_D(QSGContext2D);
- d->setStrokeColor(color);
-}
-
-void QSGContext2D::setFillColor(const QColor& color)
-{
- Q_D(QSGContext2D);
- d->setFillColor(color);
-}
-
-qreal QSGContext2D::globalAlpha() const
-{
- Q_D(const QSGContext2D);
- return d->state.globalAlpha;
-}
-
-void QSGContext2D::setGlobalAlpha(qreal alpha)
-{
- Q_D(QSGContext2D);
- d->setGlobalAlpha(alpha);
-}
-
-QSGImage *QSGContext2D::createImage(const QString &url)
-{
- Q_D(QSGContext2D);
-//### cache image
- QSGImage* img = new QSGImage(d->canvas);
- img->setSource(QUrl(url));
- return img;
-}
-
-QSGCanvasGradient *QSGContext2D::createLinearGradient(qreal x0, qreal y0,
- qreal x1, qreal y1)
-{
- QLinearGradient g(x0, y0, x1, y1);
- return new QSGCanvasGradient(g);
-}
-
-
-QSGCanvasGradient *QSGContext2D::createRadialGradient(qreal x0, qreal y0,
- qreal r0, qreal x1,
- qreal y1, qreal r1)
-{
- QRadialGradient g(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
- return new QSGCanvasGradient(g);
-}
-
-qreal QSGContext2D::lineWidth() const
-{
- Q_D(const QSGContext2D);
- return d->state.lineWidth;
-}
-
-void QSGContext2D::setLineWidth(qreal w)
-{
- Q_D(QSGContext2D);
- d->setLineWidth(w);
-}
-
-QString QSGContext2D::lineCap() const
-{
- Q_D(const QSGContext2D);
- switch(d->state.lineCap) {
- case Qt::RoundCap:
- return QLatin1String("round");
- case Qt::FlatCap:
- return QLatin1String("butt");
- case Qt::SquareCap:
- return QLatin1String("square");
- default:
- break;
- }
- return QLatin1String("");
-}
-
-void QSGContext2D::setLineCap(const QString &capString)
+void QSGContext2D::arcTo(qreal x1, qreal y1,
+ qreal x2, qreal y2,
+ qreal radius)
{
- Q_D(QSGContext2D);
- d->setLineCap(capString);
-}
+ QPointF st = state.matrix.map(QPointF(x1, y1));
+ QPointF end = state.matrix.map(QPointF(x2, y2));
-QString QSGContext2D::lineJoin() const
-{
- Q_D(const QSGContext2D);
- switch (d->state.lineJoin) {
- case Qt::RoundJoin:
- return QLatin1String("round");
- case Qt::BevelJoin:
- return QLatin1String("bevel");
- case Qt::MiterJoin:
- return QLatin1String("miter");
- default:
- break;
+ if (!m_path.elementCount()) {
+ m_path.moveTo(st);
+ } else if (st == m_path.currentPosition() || st == end || !radius) {
+ m_path.lineTo(st);
+ } else {
+ addArcTo(st, end, radius);
}
- return QLatin1String("");
}
-void QSGContext2D::setLineJoin(const QString &joinString)
-{
- Q_D(QSGContext2D);
- d->setLineJoin(joinString);
-}
-
-qreal QSGContext2D::miterLimit() const
-{
- Q_D(const QSGContext2D);
- return d->state.miterLimit;
-}
-
-void QSGContext2D::setMiterLimit(qreal m)
-{
- Q_D(QSGContext2D);
- d->setMiterLimit(m);
-}
-
-void QSGContext2D::setShadowOffsetX(qreal x)
-{
- Q_D(QSGContext2D);
- d->setShadowOffsetX(x);
-}
-
-void QSGContext2D::setShadowOffsetY(qreal y)
-{
- Q_D(QSGContext2D);
- d->setShadowOffsetY(y);
-}
-
-void QSGContext2D::setShadowBlur(qreal b)
-{
- Q_D(QSGContext2D);
- d->setShadowBlur(b);
-}
-
-void QSGContext2D::setShadowColor(const QString &str)
+void QSGContext2D::rect(qreal x, qreal y,
+ qreal w, qreal h)
{
- Q_D(QSGContext2D);
- d->setShadowColor(str);
+ m_path.addPolygon(state.matrix.map(QRectF(x, y, w, h)));
}
-QSGCanvasPath* QSGContext2D::path()
-{
- Q_D(const QSGContext2D);
- return new QSGCanvasPath(d->path, this);
-}
-void QSGContext2D::setPath(QSGCanvasPath* path)
+void QSGContext2D::roundedRect(qreal x, qreal y,
+ qreal w, qreal h,
+ qreal xr, qreal yr)
{
- Q_D(QSGContext2D);
- d->path = path->m_path;
+ QPainterPath path;
+ path.addRoundedRect(QRectF(x, y, w, h), xr, yr, Qt::AbsoluteSize);
+ m_path.addPath(state.matrix.map(path));
}
-QSGCanvasPath* QSGContext2D::createPath(const QString& pathString)
+void QSGContext2D::ellipse(qreal x, qreal y,
+ qreal w, qreal h)
{
QPainterPath path;
- if (QDeclarativeSvgParser::parsePathDataFast(pathString, path)) {
- return new QSGCanvasPath(path, this);
- }
- return 0;
+ path.addEllipse(x, y, w, h);
+ m_path.addPath(state.matrix.map(path));
}
-QString QSGContext2D::textBaseline() const
+void QSGContext2D::text(const QString& str, qreal x, qreal y)
{
- Q_D(const QSGContext2D);
- switch(d->state.textBaseline) {
- case QSGContext2D::Alphabetic:
- return QLatin1String("alphabetic");
- case QSGContext2D::Hanging:
- return QLatin1String("hanging");
- case QSGContext2D::Top:
- return QLatin1String("top");
- case QSGContext2D::Bottom:
- return QLatin1String("bottom");
- case QSGContext2D::Middle:
- return QLatin1String("middle");
- default:
- break;
- }
- return QLatin1String("alphabetic");
+ QPainterPath path;
+ path.addText(x, y, state.font, str);
+ m_path.addPath(state.matrix.map(path));
}
-void QSGContext2D::setTextBaseline(const QString &baseline)
+void QSGContext2D::arc(qreal xc,
+ qreal yc,
+ qreal radius,
+ qreal sar,
+ qreal ear,
+ bool antiClockWise,
+ bool transform)
{
- Q_D(QSGContext2D);
- d->setTextBaseline(baseline);
-}
-QString QSGContext2D::textAlign() const
-{
- Q_D(const QSGContext2D);
- switch(d->state.textAlign) {
- case QSGContext2D::Start:
- return QLatin1String("start");
- case QSGContext2D::End:
- return QLatin1String("end");
- case QSGContext2D::Left:
- return QLatin1String("left");
- case QSGContext2D::Right:
- return QLatin1String("right");
- case QSGContext2D::Center:
- return QLatin1String("center");
- default:
- break;
+ if (transform) {
+ QPointF point = state.matrix.map(QPointF(xc, yc));
+ xc = point.x();
+ yc = point.y();
}
- return QLatin1String("start");
-}
-
-void QSGContext2D::setTextAlign(const QString &align)
-{
- Q_D(QSGContext2D);
- d->setTextAlign(align);
-
- d->commands.push_back(QSGContext2D::TextAlign);
- d->ints.push_back(d->state.textAlign);
-}
-
-void QSGContext2D::setFont(const QString &fontString)
-{
- Q_D(QSGContext2D);
- d->setFont(fontString);
-}
-
-QString QSGContext2D::font() const
-{
- //### TODO
- Q_D(const QSGContext2D);
- return d->state.font.toString();
-}
-
-qreal QSGContext2D::shadowOffsetX() const
-{
- Q_D(const QSGContext2D);
- return d->state.shadowOffsetX;
-}
-
-qreal QSGContext2D::shadowOffsetY() const
-{
- Q_D(const QSGContext2D);
- return d->state.shadowOffsetY;
-}
+ //### HACK
+ // In Qt we don't switch the coordinate system for degrees
+ // and still use the 0,0 as bottom left for degrees so we need
+ // to switch
+ sar = -sar;
+ ear = -ear;
+ antiClockWise = !antiClockWise;
+ //end hack
-qreal QSGContext2D::shadowBlur() const
-{
- Q_D(const QSGContext2D);
- return d->state.shadowBlur;
-}
+ float sa = DEGREES(sar);
+ float ea = DEGREES(ear);
+ double span = 0;
-QString QSGContext2D::shadowColor() const
-{
- Q_D(const QSGContext2D);
- return d->state.shadowColor.name();
-}
+ double xs = xc - radius;
+ double ys = yc - radius;
+ double width = radius*2;
+ double height = radius*2;
+ if ((!antiClockWise && (ea - sa >= 360)) || (antiClockWise && (sa - ea >= 360)))
+ // If the anticlockwise argument is false and endAngle-startAngle is equal to or greater than 2*PI, or, if the
+ // anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2*PI, then the arc is the whole
+ // circumference of this circle.
+ span = 360;
+ else {
+ if (!antiClockWise && (ea < sa)) {
+ span += 360;
+ } else if (antiClockWise && (sa < ea)) {
+ span -= 360;
+ }
+ //### this is also due to switched coordinate system
+ // we would end up with a 0 span instead of 360
+ if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) &&
+ qFuzzyCompare(qAbs(span), 360))) {
+ span += ea - sa;
+ }
+ if (!m_path.elementCount())
+ m_path.moveTo(xs, ys);
+ }
-void QSGContext2D::clearRect(qreal x, qreal y, qreal w, qreal h)
-{
- Q_D(QSGContext2D);
- d->clearRect(x, y, w, h);
-}
+ if (transform) {
+ QPointF currentPos = m_path.currentPosition();
+ QPointF startPos = QPointF(xc + radius * qCos(sar),
+ yc - radius * qSin(sar));
+ if (currentPos != startPos)
+ m_path.lineTo(startPos);
+ }
-void QSGContext2D::fillRect(qreal x, qreal y, qreal w, qreal h)
-{
- Q_D(QSGContext2D);
- d->fillRect(x, y, w, h);
+ m_path.arcTo(xs, ys, width, height, sa, span);
}
-int QSGContext2DPrivate::baseLineOffset(QSGContext2D::TextBaseLineType value, const QFontMetrics &metrics)
+int baseLineOffset(QSGContext2D::TextBaseLineType value, const QFontMetrics &metrics)
{
int offset = 0;
switch (value) {
- case QSGContext2D::Top:
+ case QSGContext2D::QSGContext2D::Top:
break;
- case QSGContext2D::Alphabetic:
- case QSGContext2D::Middle:
- case QSGContext2D::Hanging:
+ case QSGContext2D::QSGContext2D::Alphabetic:
+ case QSGContext2D::QSGContext2D::Middle:
+ case QSGContext2D::QSGContext2D::Hanging:
offset = metrics.ascent();
break;
- case QSGContext2D::Bottom:
+ case QSGContext2D::QSGContext2D::Bottom:
offset = metrics.height();
break;
}
return offset;
}
-int QSGContext2DPrivate::textAlignOffset(QSGContext2D::TextAlignType value, const QFontMetrics &metrics, const QString &text)
+static int textAlignOffset(QSGContext2D::TextAlignType value, const QFontMetrics &metrics, const QString &text)
{
int offset = 0;
if (value == QSGContext2D::Start)
- value = qApp->layoutDirection() == Qt::LeftToRight ? QSGContext2D::Left : QSGContext2D::Right;
+ value = QApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Left : QSGContext2D::Right;
else if (value == QSGContext2D::End)
- value = qApp->layoutDirection() == Qt::LeftToRight ? QSGContext2D::Right: QSGContext2D::Left;
+ value = QApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Right: QSGContext2D::Left;
switch (value) {
- case QSGContext2D::Center:
+ case QSGContext2D::QSGContext2D::Center:
offset = metrics.width(text)/2;
break;
- case QSGContext2D::Right:
+ case QSGContext2D::QSGContext2D::Right:
offset = metrics.width(text);
- case QSGContext2D::Left:
+ case QSGContext2D::QSGContext2D::Left:
default:
break;
}
return offset;
}
-void QSGContext2D::fillText(const QString &text, qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->fillText(text, x, y);
-}
-
-void QSGContext2D::strokeText(const QString &text, qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->strokeText(text, x, y);
-}
-void QSGContext2D::strokeRect(qreal x, qreal y, qreal w, qreal h)
+QImage QSGContext2D::createImage(const QUrl& url)
{
- Q_D(QSGContext2D);
- d->strokeRect(x, y, w, h);
+ return m_canvas->loadedImage(url);
}
-void QSGContext2D::beginPath()
+QPainterPath QSGContext2D::createTextGlyphs(qreal x, qreal y, const QString& text)
{
- Q_D(QSGContext2D);
- d->beginPath();
-}
+ const QFontMetrics metrics(state.font);
+ int yoffset = baseLineOffset(static_cast<QSGContext2D::TextBaseLineType>(state.textBaseline), metrics);
+ int xoffset = textAlignOffset(static_cast<QSGContext2D::TextAlignType>(state.textAlign), metrics, text);
+ QPainterPath textPath;
-void QSGContext2D::closePath()
-{
- Q_D(QSGContext2D);
- d->closePath();
-}
-
-
-void QSGContext2D::moveTo(qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->moveTo(x, y);
-}
-
-
-void QSGContext2D::lineTo(qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->lineTo(x, y);
-}
-
-
-void QSGContext2D::quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->quadraticCurveTo(cpx, cpy, x, y);
-}
-
-
-void QSGContext2D::bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y, qreal x, qreal y)
-{
- Q_D(QSGContext2D);
- d->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
-}
-
-
-void QSGContext2D::arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius)
-{
- Q_D(QSGContext2D);
- d->arcTo(x1, y1, x2, y2, radius);
-}
-
-
-void QSGContext2D::rect(qreal x, qreal y, qreal w, qreal h)
-{
- Q_D(QSGContext2D);
- d->rect(x, y, w, h);
-}
-
-void QSGContext2D::arc(qreal xc, qreal yc, qreal radius,
- qreal sar, qreal ear,
- bool anticlockwise)
-{
- Q_D(QSGContext2D);
- d->arc(xc, yc, radius, sar, ear, anticlockwise);
-}
-
-
-void QSGContext2D::fill()
-{
- Q_D(QSGContext2D);
- d->fill();
-}
-
-
-void QSGContext2D::stroke()
-{
- Q_D(QSGContext2D);
- d->stroke();
-}
-
-
-void QSGContext2D::clip()
-{
- Q_D(QSGContext2D);
- d->clip();
+ textPath.addText(x - xoffset, y - yoffset+metrics.ascent(), state.font, text);
+ textPath = state.matrix.map(textPath);
+ return textPath;
}
bool QSGContext2D::isPointInPath(qreal x, qreal y) const
{
- Q_D(const QSGContext2D);
- return d->path.contains(QPointF(x, y));
-}
-
-void QSGContext2D::setPathString(const QString& path)
-{
- Q_D(QSGContext2D);
- d->path = QPainterPath();
- QDeclarativeSvgParser::parsePathDataFast(path, d->path);
-}
-
-QList<int> QSGContext2D::getImageData(qreal sx, qreal sy, qreal sw, qreal sh)
-{
- Q_D(QSGContext2D);
- return d->getImageData(sx, sy, sw, sh);
-}
-
-void QSGContext2D::putImageData(const QVariant& imageData, qreal x, qreal y, qreal w, qreal h)
-{
- Q_D(QSGContext2D);
- return d->putImageData(imageData.toList(), x, y, w, h);
-}
-
-QSGContext2D::QSGContext2D(QObject *parent)
- : QObject(*(new QSGContext2DPrivate()), parent)
-{
- Q_D(QSGContext2D);
- d->canvas = qobject_cast<QSGCanvasItem*>(parent);
+ return m_path.contains(QPointF(x, y));
}
-QSGContext2D::QSGContext2D(QSGContext2D *orig, QSGContext2DWorkerAgent* agentData)
- : QObject(*(new QSGContext2DPrivate()), 0)
+QSGContext2D::QSGContext2D(QSGCanvasItem* item)
+ : m_canvas(item)
+ , m_buffer(new QSGContext2DCommandBuffer)
+ , m_v8engine(0)
{
- Q_D(QSGContext2D);
- d->agent = 0;
- d->agentData = agentData;
- if (d->agentData) {
- d->agentData->orig = orig;
- }
- d->canvas = qobject_cast<QSGCanvasItem*>(orig);
+ reset();
}
-QSGCanvasItem* QSGContext2D::canvas() const
-{
- Q_D(const QSGContext2D);
- return d->canvas;
-}
QSGContext2D::~QSGContext2D()
{
- Q_D(QSGContext2D);
- if (d->agent) {
- d->agentData->syncDone.wakeAll();
- d->agent->release();
- }
-}
-
-bool QSGContext2D::isDirty() const
-{
- Q_D(const QSGContext2D);
- return !d->commands.isEmpty();
}
v8::Handle<v8::Object> QSGContext2D::v8value() const
{
- Q_D(const QSGContext2D);
- return d->v8value;
+ return m_v8value;
}
-class QSGContext2DEngineData : public QV8Engine::Deletable
-{
-public:
- QSGContext2DEngineData(QV8Engine *engine);
- ~QSGContext2DEngineData();
-
- v8::Persistent<v8::Function> constructor;
-};
-
QSGContext2DEngineData::QSGContext2DEngineData(QV8Engine *engine)
{
v8::HandleScope handle_scope;
@@ -2653,23 +2872,22 @@ QSGContext2DEngineData::QSGContext2DEngineData(QV8Engine *engine)
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->PrototypeTemplate()->Set(v8::String::New("sync"), V8FUNCTION(ctx2d_sync, engine));
ft->PrototypeTemplate()->SetAccessor(v8::String::New("canvas"), ctx2d_canvas, 0, v8::External::Wrap(engine));
ft->PrototypeTemplate()->Set(v8::String::New("restore"), V8FUNCTION(ctx2d_restore, engine));
ft->PrototypeTemplate()->Set(v8::String::New("reset"), V8FUNCTION(ctx2d_reset, engine));
ft->PrototypeTemplate()->Set(v8::String::New("save"), V8FUNCTION(ctx2d_save, engine));
ft->PrototypeTemplate()->Set(v8::String::New("rotate"), V8FUNCTION(ctx2d_rotate, engine));
ft->PrototypeTemplate()->Set(v8::String::New("scale"), V8FUNCTION(ctx2d_scale, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("resetTransform"), V8FUNCTION(ctx2d_resetTransform, engine));
ft->PrototypeTemplate()->Set(v8::String::New("setTransform"), V8FUNCTION(ctx2d_setTransform, engine));
ft->PrototypeTemplate()->Set(v8::String::New("transform"), V8FUNCTION(ctx2d_transform, engine));
ft->PrototypeTemplate()->Set(v8::String::New("translate"), V8FUNCTION(ctx2d_translate, engine));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("valid"), ctx2d_valid, 0, v8::External::Wrap(engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("shear"), V8FUNCTION(ctx2d_shear, engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("globalAlpha"), ctx2d_globalAlpha, ctx2d_globalAlpha_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("globalCompositeOperation"), ctx2d_globalCompositeOperation, ctx2d_globalCompositeOperation_set, v8::External::Wrap(engine));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("fillRule"), ctx2d_fillRule, ctx2d_fillRule_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("fillStyle"), ctx2d_fillStyle, ctx2d_fillStyle_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("strokeStyle"), ctx2d_strokeStyle, ctx2d_strokeStyle_set, v8::External::Wrap(engine));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("fillColor"), ctx2d_fillColor, ctx2d_fillColor_set, v8::External::Wrap(engine));
- ft->InstanceTemplate()->SetAccessor(v8::String::New("strokeColor"), ctx2d_strokeColor, ctx2d_strokeColor_set, v8::External::Wrap(engine));
ft->PrototypeTemplate()->Set(v8::String::New("createLinearGradient"), V8FUNCTION(ctx2d_createLinearGradient, engine));
ft->PrototypeTemplate()->Set(v8::String::New("createRadialGradient"), V8FUNCTION(ctx2d_createRadialGradient, engine));
ft->PrototypeTemplate()->Set(v8::String::New("createPattern"), V8FUNCTION(ctx2d_createPattern, engine));
@@ -2681,6 +2899,7 @@ QSGContext2DEngineData::QSGContext2DEngineData(QV8Engine *engine)
ft->InstanceTemplate()->SetAccessor(v8::String::New("shadowColor"), ctx2d_shadowColor, ctx2d_shadowColor_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("shadowOffsetX"), ctx2d_shadowOffsetX, ctx2d_shadowOffsetX_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("shadowOffsetY"), ctx2d_shadowOffsetY, ctx2d_shadowOffsetY_set, v8::External::Wrap(engine));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("path"), ctx2d_path, ctx2d_path_set, v8::External::Wrap(engine));
ft->PrototypeTemplate()->Set(v8::String::New("clearRect"), V8FUNCTION(ctx2d_clearRect, engine));
ft->PrototypeTemplate()->Set(v8::String::New("fillRect"), V8FUNCTION(ctx2d_fillRect, engine));
ft->PrototypeTemplate()->Set(v8::String::New("strokeRect"), V8FUNCTION(ctx2d_strokeRect, engine));
@@ -2695,761 +2914,169 @@ QSGContext2DEngineData::QSGContext2DEngineData(QV8Engine *engine)
ft->PrototypeTemplate()->Set(v8::String::New("moveTo"), V8FUNCTION(ctx2d_moveTo, engine));
ft->PrototypeTemplate()->Set(v8::String::New("quadraticCurveTo"), V8FUNCTION(ctx2d_quadraticCurveTo, engine));
ft->PrototypeTemplate()->Set(v8::String::New("rect"), V8FUNCTION(ctx2d_rect, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("roundedRect "), V8FUNCTION(ctx2d_roundedRect, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("text"), V8FUNCTION(ctx2d_text, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("ellipse"), V8FUNCTION(ctx2d_ellipse, engine));
ft->PrototypeTemplate()->Set(v8::String::New("stroke"), V8FUNCTION(ctx2d_stroke, engine));
ft->PrototypeTemplate()->Set(v8::String::New("isPointInPath"), V8FUNCTION(ctx2d_isPointInPath, engine));
- ft->PrototypeTemplate()->Set(v8::String::New("setPathString"), V8FUNCTION(ctx2d_setPathString, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("drawFocusRing"), V8FUNCTION(ctx2d_drawFocusRing, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("caretBlinkRate"), V8FUNCTION(ctx2d_caretBlinkRate, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("setCaretSelectionRect"), V8FUNCTION(ctx2d_setCaretSelectionRect, engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("font"), ctx2d_font, ctx2d_font_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("textAlign"), ctx2d_textAlign, ctx2d_textAlign_set, v8::External::Wrap(engine));
ft->InstanceTemplate()->SetAccessor(v8::String::New("textBaseline"), ctx2d_textBaseline, ctx2d_textBaseline_set, v8::External::Wrap(engine));
ft->PrototypeTemplate()->Set(v8::String::New("fillText"), V8FUNCTION(ctx2d_fillText, engine));
- // ft->PrototypeTemplate()->Set(v8::String::New("measureText"), V8FUNCTION(ctx2d_measureText, engine));
+ ft->PrototypeTemplate()->Set(v8::String::New("measureText"), V8FUNCTION(ctx2d_measureText, engine));
ft->PrototypeTemplate()->Set(v8::String::New("strokeText"), V8FUNCTION(ctx2d_strokeText, engine));
ft->PrototypeTemplate()->Set(v8::String::New("drawImage"), V8FUNCTION(ctx2d_drawImage, engine));
ft->PrototypeTemplate()->Set(v8::String::New("createImageData"), V8FUNCTION(ctx2d_createImageData, engine));
ft->PrototypeTemplate()->Set(v8::String::New("getImageData"), V8FUNCTION(ctx2d_getImageData, engine));
ft->PrototypeTemplate()->Set(v8::String::New("putImageData"), V8FUNCTION(ctx2d_putImageData, engine));
- constructor = qPersistentNew(ft->GetFunction());
-}
-
-QSGContext2DEngineData::~QSGContext2DEngineData()
-{
- qPersistentDispose(constructor);
-}
-
-V8_DEFINE_EXTENSION(QSGContext2DEngineData, engineData);
-
-QV8Engine* QSGContext2D::v8Engine() const
-{
- Q_D(const QSGContext2D);
- return d->v8engine;
-}
-
-void QSGContext2D::setV8Engine(QV8Engine *engine)
-{
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- Q_D(QSGContext2D);
- if (d->v8engine != engine) {
- d->v8engine = engine;
+ constructorContext = qPersistentNew(ft->GetFunction());
- qPersistentDispose(d->v8value);
+ v8::Local<v8::FunctionTemplate> ftGradient = v8::FunctionTemplate::New();
+ ftGradient->InstanceTemplate()->SetHasExternalResource(true);
+ ftGradient->PrototypeTemplate()->Set(v8::String::New("addColorStop"), V8FUNCTION(ctx2d_gradient_addColorStop, engine));
+ constructorGradient = qPersistentNew(ftGradient->GetFunction());
- if (d->v8engine == 0)
- return;
+ v8::Local<v8::FunctionTemplate> ftPattern = v8::FunctionTemplate::New();
+ ftPattern->InstanceTemplate()->SetHasExternalResource(true);
+ constructorPattern = qPersistentNew(ftPattern->GetFunction());
- QSGContext2DEngineData *ed = engineData(engine);
- d->v8value = qPersistentNew(ed->constructor->NewInstance());
- QV8Context2DResource *r = new QV8Context2DResource(engine);
- r->context = this;
- d->v8value->SetExternalResource(r);
- }
-}
+ v8::Local<v8::FunctionTemplate> ftPixelArray = v8::FunctionTemplate::New();
+ ftPixelArray->InstanceTemplate()->SetHasExternalResource(true);
+ ftPixelArray->InstanceTemplate()->SetAccessor(v8::String::New("length"), ctx2d_pixelArray_length, 0, v8::External::Wrap(engine));
+ ftPixelArray->InstanceTemplate()->SetIndexedPropertyHandler(ctx2d_pixelArray_indexed, ctx2d_pixelArray_indexed_set, 0, 0, 0, v8::External::Wrap(engine));
+ constructorPixelArray = qPersistentNew(ftPixelArray->GetFunction());
-bool QSGContext2D::valid() const
-{
- Q_D(const QSGContext2D);
- return d->valid;
+ v8::Local<v8::FunctionTemplate> ftImageData = v8::FunctionTemplate::New();
+ ftImageData->InstanceTemplate()->SetAccessor(v8::String::New("width"), ctx2d_imageData_width, 0, v8::External::Wrap(engine));
+ ftImageData->InstanceTemplate()->SetAccessor(v8::String::New("height"), ctx2d_imageData_height, 0, v8::External::Wrap(engine));
+ ftImageData->InstanceTemplate()->SetAccessor(v8::String::New("data"), ctx2d_imageData_data, 0, v8::External::Wrap(engine));
+ ftImageData->PrototypeTemplate()->Set(v8::String::New("mirror"), V8FUNCTION(ctx2d_imageData_mirror, engine));
+ ftImageData->PrototypeTemplate()->Set(v8::String::New("filter"), V8FUNCTION(ctx2d_imageData_filter, engine));
+ ftImageData->InstanceTemplate()->SetInternalFieldCount(1);
+ constructorImageData = qPersistentNew(ftImageData->GetFunction());
}
-void QSGContext2D::setValid(bool valid)
-{
- Q_D(QSGContext2D);
- d->valid = valid;
-}
-void QSGContext2D::setTileRect(const QRectF& rect)
-{
- Q_D(QSGContext2D);
- if (d->tileRect != rect)
- d->tileRect = rect;
-}
-void QSGContext2D::addref()
+QSGContext2DEngineData::~QSGContext2DEngineData()
{
- Q_D(QSGContext2D);
- Q_ASSERT(d->agentData);
- d->agentData->ref.ref();
+ qPersistentDispose(constructorContext);
+ qPersistentDispose(constructorGradient);
+ qPersistentDispose(constructorPattern);
+ qPersistentDispose(constructorImageData);
+ qPersistentDispose(constructorPixelArray);
}
-void QSGContext2D::release()
+void QSGContext2D::popState()
{
- Q_D(QSGContext2D);
- Q_ASSERT(d->agentData);
- if (!d->agentData->ref.deref()) {
- deleteLater();
- }
-}
+ if (m_stateStack.isEmpty())
+ return;
-void QSGContext2D::processCommands(const QJSValue& commands)
-{
-#ifdef QSGCANVASITEM_DEBUG
- QElapsedTimer t;
- t.start();
-#endif
- int ii = 0;
- if (commands.isArray()) {
- QJSValue cmd = commands.property(ii);
- while(cmd.isValid()) {
- processCommand(cmd);
- ii++;
- cmd = commands.property(ii);
- }
- }
+ QSGContext2D::State newState = m_stateStack.pop();
-#ifdef QSGCANVASITEM_DEBUG
- qDebug() << "processed" << ii << "commands in " << t.nsecsElapsed() << "nsecs";
-#endif
- sync();
-}
+ if (state.matrix != newState.matrix)
+ buffer()->updateMatrix(newState.matrix);
-void QSGContext2D::sync()
-{
- Q_D(QSGContext2D);
+ if (newState.globalAlpha != state.globalAlpha)
+ buffer()->setGlobalAlpha(newState.globalAlpha);
-#ifdef QSGCANVASITEM_DEBUG
- QElapsedTimer t;
- t.start();
-#endif
- if (d->agentData) {
- if (d->agentData->ref == 1) return;
+ if (newState.globalCompositeOperation != state.globalCompositeOperation)
+ buffer()->setGlobalCompositeOperation(newState.globalCompositeOperation);
- Sync *s = new Sync;
- s->data = d->agentData;
+ if (newState.fillStyle != state.fillStyle)
+ buffer()->setFillStyle(newState.fillStyle);
- d->agentData->mutex.lock();
- QCoreApplication::postEvent(this, s);
- d->agentData->syncDone.wait(&d->agentData->mutex);
- d->agentData->mutex.unlock();
- } else {
- //qmlInfo(this) << "Context2D sync() can only be called from a WorkerScript;";
- emit changed();
- }
-
-#ifdef QSGCANVASITEM_DEBUG
- qDebug() << "syncing time:" << t.nsecsElapsed();
-#endif
-}
-
-
-bool QSGContext2D::event(QEvent *e)
-{
- Q_D(QSGContext2D);
- if (e->type() == QEvent::User && d->agentData) {
- QMutexLocker locker(&d->agentData->mutex);
- Sync *s = static_cast<Sync *>(e);
-
- QSGContext2DPrivate* origin_d = static_cast<QSGContext2DPrivate*>(s->data->orig->d_func());
-
- //quick copy
- memcpy_vector<PaintCommand>(&origin_d->commands, d->commands);
- memcpy_vector<int>(&origin_d->ints, d->ints);
- memcpy_vector<qreal>(&origin_d->reals, d->reals);
- memcpy_vector<QColor>(&origin_d->colors, d->colors);
- memcpy_vector<QMatrix>(&origin_d->matrixes, d->matrixes);
- memcpy_vector<QSize>(&origin_d->sizes, d->sizes);
-
- //slow copy
- copy_vector<QString>(&origin_d->strings, d->strings);
- copy_vector<QVariant>(&origin_d->variants, d->variants);
- copy_vector<QPen>(&origin_d->pens, d->pens);
- copy_vector<QBrush>(&origin_d->brushes, d->brushes);
- copy_vector<QPainterPath>(&origin_d->pathes, d->pathes);
- copy_vector<QFont>(&origin_d->fonts, d->fonts);
- copy_vector<QImage>(&origin_d->images, d->images);
- origin_d->state = d->state;
- d->clearCommands();
-
- if (d->waitingForPainting) {
- d->imageData.clear();
- origin_d->imageData.clear();
- emit s->data->orig->changed();
- while(origin_d->imageData.isEmpty()) {
- QCoreApplication::processEvents();
- }
- d->imageData = origin_d->imageData;
- d->waitingForPainting = false;
- qDebug() << "imageData size:" << d->imageData.size();
- } else {
- emit s->data->orig->changed();
- }
+ if (newState.strokeStyle != state.strokeStyle)
+ buffer()->setStrokeStyle(newState.strokeStyle);
- d->agentData->syncDone.wakeAll();
- return true;
- }
- return QObject::event(e);
-}
+ if (newState.lineWidth != state.lineWidth)
+ buffer()->setLineWidth(newState.lineWidth);
-void QSGContext2D::processCommand(const QJSValue& cmd)
-{
- int action = cmd.property(0).toInt32();
- switch (action) {
- case QSGContext2D::Save:
- save();
- break;
- case QSGContext2D::Restore:
- restore();
- break;
- case QSGContext2D::Scale:
- scale(cmd.property(1).toNumber(), cmd.property(2).toNumber());
- break;
- case QSGContext2D::Rotate:
- rotate(cmd.property(1).toNumber());
- break;
- case QSGContext2D::Translate:
- translate(cmd.property(1).toNumber(), cmd.property(2).toNumber());
- break;
- case QSGContext2D::Transform:
- transform(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber(),
- cmd.property(6).toNumber());
- break;
- case QSGContext2D::SetTransform:
- setTransform(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber(),
- cmd.property(6).toNumber());
- break;
- case QSGContext2D::ClearRect:
- clearRect(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber());
- break;
- case QSGContext2D::FillRect:
- fillRect(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber());
- break;
- case QSGContext2D::StrokeRect:
- strokeRect(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber());
- break;
- case QSGContext2D::BeginPath:
- beginPath();
- break;
- case QSGContext2D::ClosePath:
- closePath();
- break;
- case QSGContext2D::MoveTo:
- moveTo(cmd.property(1).toNumber(),
- cmd.property(2).toNumber());
- break;
- case QSGContext2D::LineTo:
- lineTo(cmd.property(1).toNumber(),
- cmd.property(2).toNumber());
- break;
- case QSGContext2D::QuadraticCurveTo:
- quadraticCurveTo(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber());
- break;
- case QSGContext2D::BezierCurveTo:
- bezierCurveTo(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber(),
- cmd.property(6).toNumber());
- break;
- case QSGContext2D::ArcTo:
- arcTo(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber());
- break;
- case QSGContext2D::Rect:
- rect(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber());
- break;
- case QSGContext2D::Arc:
- arc(cmd.property(1).toNumber(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber(),
- cmd.property(6).toBool());
- break;
- case QSGContext2D::Fill:
- fill();
- break;
- case QSGContext2D::Stroke:
- stroke();
- break;
- case QSGContext2D::Clip:
- clip();
- break;
- case QSGContext2D::GlobalAlpha:
- setGlobalAlpha(cmd.property(1).toNumber());
- break;
- case QSGContext2D::GlobalCompositeOperation:
- setGlobalCompositeOperation(cmd.property(1).toString());
- break;
- case QSGContext2D::StrokeStyle:
- setStrokeStyle(cmd.property(1).toVariant());
- break;
- case QSGContext2D::FillStyle:
- setFillStyle(cmd.property(1).toVariant());
- break;
- case QSGContext2D::FillColor:
- setFillColor(cmd.property(1).toVariant().value<QColor>());
- break;
- case QSGContext2D::StrokeColor:
- setStrokeColor(cmd.property(1).toVariant().value<QColor>());
- break;
- case QSGContext2D::LineWidth:
- setLineWidth(cmd.property(1).toNumber());
- break;
- case QSGContext2D::LineCap:
- setLineCap(cmd.property(1).toString());
- break;
- case QSGContext2D::LineJoin:
- setLineJoin(cmd.property(1).toString());
- break;
- case QSGContext2D::MiterLimit:
- setMiterLimit(cmd.property(1).toNumber());
- break;
- case QSGContext2D::ShadowOffsetX:
- setShadowOffsetX(cmd.property(1).toNumber());
- break;
- case QSGContext2D::ShadowOffsetY:
- setShadowOffsetY(cmd.property(1).toNumber());
- break;
- case QSGContext2D::ShadowBlur:
- setShadowBlur(cmd.property(1).toNumber());
- break;
- case QSGContext2D::ShadowColor:
- setShadowColor(cmd.property(1).toString());
- break;
- case QSGContext2D::Font:
- setFont(cmd.property(1).toString());
- break;
- case QSGContext2D::TextBaseline:
- setTextBaseline(cmd.property(1).toString());
- break;
- case QSGContext2D::TextAlign:
- setTextAlign(cmd.property(1).toString());
- break;
- case QSGContext2D::FillText:
- fillText(cmd.property(1).toString(), cmd.property(2).toNumber(), cmd.property(3).toNumber());
- break;
- case QSGContext2D::StrokeText:
- strokeText(cmd.property(1).toString(), cmd.property(2).toNumber(), cmd.property(3).toNumber());
- break;
- case QSGContext2D::DrawImage1:
- {
- drawImage(cmd.property(1).toString(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber());
- break;
- }
- case QSGContext2D::DrawImage2:
- drawImage(cmd.property(1).toString(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber());
- break;
- case QSGContext2D::DrawImage3:
- drawImage(cmd.property(1).toString(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber(),
- cmd.property(6).toNumber(),
- cmd.property(7).toNumber(),
- cmd.property(8).toNumber(),
- cmd.property(9).toNumber());
- break;
- case QSGContext2D::PutImageData:
- putImageData(cmd.property(1).toVariant(),
- cmd.property(2).toNumber(),
- cmd.property(3).toNumber(),
- cmd.property(4).toNumber(),
- cmd.property(5).toNumber());
- break;
- default:
- break;
- }
-}
+ if (newState.lineCap != state.lineCap)
+ buffer()->setLineCap(newState.lineCap);
-void QSGContext2D::paint(QPainter* p)
-{
- Q_D(QSGContext2D);
+ if (newState.lineJoin != state.lineJoin)
+ buffer()->setLineJoin(newState.lineJoin);
- QMatrix originMatrix = p->matrix();
- if (!d->commands.isEmpty()) {
- int matrix_idx, real_idx, int_idx, variant_idx, string_idx,color_idx,cmd_idx,
- pen_idx, brush_idx, font_idx, path_idx, image_idx, size_idx;
+ if (newState.miterLimit != state.miterLimit)
+ buffer()->setMiterLimit(newState.miterLimit);
- matrix_idx = real_idx = int_idx = variant_idx = string_idx =color_idx = cmd_idx
- = pen_idx = brush_idx = font_idx = path_idx = image_idx = size_idx = 0;
+ if (newState.clipPath != state.clipPath)
+ buffer()->clip(newState.clipPath);
- foreach(PaintCommand cmd, d->commands) {
- switch (cmd) {
- case UpdateMatrix:
- {
- d->state.matrix = d->matrixes[matrix_idx++];
- p->setMatrix(d->state.matrix * originMatrix);
- break;
- }
- case ClearRect:
- {
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- qreal w = d->reals[real_idx++];
- qreal h = d->reals[real_idx++];
- p->eraseRect(QRectF(x, y, w, h));
- break;
- }
- case FillRect:
- {
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- qreal w = d->reals[real_idx++];
- qreal h = d->reals[real_idx++];
- if (d->hasShadow())
- d->fillRectShadow(p, QRectF(x, y, w, h));
- else
- p->fillRect(QRectF(x, y, w, h), p->brush());
- break;
- }
- case ShadowColor:
- {
- QColor c = d->colors[color_idx++];
- d->state.shadowColor = c;
- break;
- }
- case ShadowBlur:
- {
- qreal blur = d->reals[real_idx++];
- d->state.shadowBlur = blur;
- break;
- }
- case ShadowOffsetX:
- {
- qreal x = d->reals[real_idx++];
- d->state.shadowOffsetX = x;
- break;
- }
- case ShadowOffsetY:
- {
- qreal y = d->reals[real_idx++];
- d->state.shadowOffsetY = y;
- break;
- }
- case Fill:
- {
- QPainterPath path = d->pathes[path_idx++];
- //qDebug() << "fill path:" << path.elementCount();
- if (d->hasShadow())
- d->fillShadowPath(p,path);
- else
- p->fillPath(path, p->brush());
- break;
- }
- case Stroke:
- {
- //p->setMatrix(d->state.matrix);
- //QPainterPath path = d->state.matrix.inverted().map(d->pathes[path_idx++]);
- //qDebug() << "stroke path:" << path.elementCount();
- QPainterPath path = d->pathes[path_idx++];
- if (d->hasShadow())
- d->strokeShadowPath(p,path);
- else
- p->strokePath(path, p->pen());
- break;
- }
- case Clip:
- {
- QPainterPath clipPath = d->pathes[path_idx++];
- p->setClipPath(clipPath);
- p->setClipping(true);
- break;
- }
- case UpdateBrush:
- {
- p->setBrush(d->brushes[brush_idx++]);
- break;
- }
- case UpdatePen:
- {
- p->setPen(d->pens[pen_idx++]);
- break;
- }
- case GlobalAlpha:
- {
- p->setOpacity(d->reals[real_idx++]);
- break;
- }
- case GlobalCompositeOperation:
- {
- p->setCompositionMode(static_cast<QPainter::CompositionMode>(d->ints[int_idx++]));
- break;
- }
- case Font:
- {
- p->setFont(d->fonts[font_idx++]);
- break;
- }
- case StrokeText:
- {
- QString text = d->strings[string_idx++];
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- int align = d->ints[int_idx++];
- int baseline = d->ints[int_idx++];
-
- QPen oldPen = p->pen();
- p->setPen(QPen(p->brush(),0));
- //p->setMatrix(state.matrix, false); // always set?
-
- QPainterPath textPath;
- QFont oldFont = p->font();
- QFont font = p->font();
- font.setStyleStrategy(QFont::ForceOutline);
- p->setFont(font);
- const QFontMetrics &metrics = p->fontMetrics();
- int yoffset = d->baseLineOffset(static_cast<QSGContext2D::TextBaseLineType>(baseline), metrics);
- int xoffset = d->textAlignOffset(static_cast<QSGContext2D::TextAlignType>(align), metrics, text);
- textPath.addText(x - xoffset, y - yoffset+metrics.ascent(), font, text);
- if (d->hasShadow())
- d->strokeShadowPath(p,textPath);
-
- p->strokePath(textPath, QPen(p->brush(), p->pen().widthF()));
-
- //reset old font
- p->setFont(oldFont);
- p->setPen(oldPen);
- break;
- }
- case FillText:
- {
- QString text = d->strings[string_idx++];
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- int align = d->ints[int_idx++];
- int baseline = d->ints[int_idx++];
-
- QFont oldFont = p->font();
- QPen oldPen = p->pen();
- p->setPen(QPen(p->brush(), p->pen().widthF()));
- //p->setMatrix(state.matrix, false);
- //QFont font = p->font();
- QFont font = d->state.font;
- font.setBold(true);
-
- p->setFont(font);
- int yoffset = d->baseLineOffset(static_cast<QSGContext2D::TextBaseLineType>(baseline), p->fontMetrics());
- int xoffset = d->textAlignOffset(static_cast<QSGContext2D::TextAlignType>(align), p->fontMetrics(), text);
- QTextOption opt; // Adjust baseLine etc
- if (d->hasShadow()) {
- const QFontMetrics &metrics = p->fontMetrics();
- QPainterPath textPath;
- textPath.addText(x - xoffset, y - yoffset+metrics.ascent(), font, text);
- d->fillShadowPath(p,textPath);
- }
- //p->drawText(QRectF(x - xoffset, y - yoffset, QWIDGETSIZE_MAX, p->fontMetrics().height()), text, opt);
- p->setFont(oldFont);
- p->setPen(oldPen);
- break;
- }
- case DrawImage1:
- {
- QUrl url(d->strings[string_idx++]);
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- QDeclarativePixmap px(qmlEngine(d->canvas), url);
- qDebug() << "draw image:" << url << px.pixmap().size();
- if (px.isReady()) {
- QPixmap pixmap = px.pixmap();
- if (d->hasShadow()) {
- QImage shadow = d->makeShadowImage(pixmap);
- qreal dx = x + (d->state.shadowOffsetX < 0? d->state.shadowOffsetX:0);
- qreal dy = y + (d->state.shadowOffsetY < 0? d->state.shadowOffsetY:0);
- p->drawImage(QPointF(dx, dy), shadow);
- }
- p->drawPixmap(QPointF(x, y), pixmap);
- }
- break;
- }
- case DrawImage2:
- {
- qreal dx = d->reals[real_idx++];
- qreal dy = d->reals[real_idx++];
- qreal dw = d->reals[real_idx++];
- qreal dh = d->reals[real_idx++];
- QUrl url(d->strings[string_idx++]);
- QDeclarativePixmap px(qmlEngine(d->canvas), url);
- if (px.isReady()) {
- QPixmap pixmap = px.pixmap().scaled(dw, dh);
- if (d->hasShadow()) {
- QImage shadow = d->makeShadowImage(pixmap);
- qreal shadow_dx = dx + (d->state.shadowOffsetX < 0? d->state.shadowOffsetX:0);
- qreal shadow_dy = dy + (d->state.shadowOffsetY < 0? d->state.shadowOffsetY:0);
- p->drawImage(QPointF(shadow_dx, shadow_dy), shadow);
- }
- p->drawPixmap(QPointF(dx, dy), pixmap);
- }
- break;
- }
- case DrawImage3:
- {
- qreal sx = d->reals[real_idx++];
- qreal sy = d->reals[real_idx++];
- qreal sw = d->reals[real_idx++];
- qreal sh = d->reals[real_idx++];
- qreal dx = d->reals[real_idx++];
- qreal dy = d->reals[real_idx++];
- qreal dw = d->reals[real_idx++];
- qreal dh = d->reals[real_idx++];
- QUrl url(d->strings[string_idx++]);
- QDeclarativePixmap px(qmlEngine(d->canvas), url);
- if (px.isReady()) {
- QPixmap pixmap = px.pixmap().copy(sx, sy, sw, sh).scaled(dw, dh);
- if (d->hasShadow()) {
- QImage shadow = d->makeShadowImage(pixmap);
- qreal shadow_dx = dx + (d->state.shadowOffsetX < 0? d->state.shadowOffsetX:0);
- qreal shadow_dy = dy + (d->state.shadowOffsetY < 0? d->state.shadowOffsetY:0);
- p->drawImage(QPointF(shadow_dx, shadow_dy), shadow);
- }
- p->drawPixmap(QPointF(dx, dy), pixmap);
- }
- break;
- }
- case GetImageData:
- {
- qreal sx = d->reals[real_idx++];
- qreal sy = d->reals[real_idx++];
- qreal sw = d->reals[real_idx++];
- qreal sh = d->reals[real_idx++];
- QImage img = toImage().copy(sx, sy, sw, sh);
- const uchar* data = img.constBits();
- int i = 0;
-
- while(i< img.byteCount()) {
- //the stored order in QImage:BGRA
- d->imageData << *(data+i+2);//R
- d->imageData << *(data+i+1);//G
- d->imageData << *(data+i);//B
- d->imageData << *(data+i+3);//A
- i+=4;
- }
- break;
- }
- case PutImageData:
- {
- QImage image = d->images[image_idx++];
- qreal x = d->reals[real_idx++];
- qreal y = d->reals[real_idx++];
- p->drawImage(QPointF(x, y), image);
- break;
- }
- default:
- break;
- }
- }
- d->clearCommands();
- }
-}
+ if (newState.shadowBlur != state.shadowBlur)
+ buffer()->setShadowBlur(newState.shadowBlur);
-QPaintDevice* QSGContext2D::paintDevice()
-{
- Q_D(QSGContext2D);
- return &d->cachedImage;
-}
-const QImage& QSGContext2D::toImage() const
-{
- Q_D(const QSGContext2D);
- return d->cachedImage;
-}
-bool QSGContext2D::requireCachedImage() const
-{
- Q_D(const QSGContext2D);
- return d->waitingForPainting;
-}
-void QSGContext2D::setCachedImage(const QImage& image)
-{
- Q_D(QSGContext2D);
-#ifndef QSGCANVASITEM_PAINTING_ON_IMAGE
- if (d->waitingForPainting) {
- d->cachedImage = image;
- d->waitingForPainting = false;
- }
-#endif
-}
+ if (newState.shadowColor != state.shadowColor)
+ buffer()->setShadowColor(newState.shadowColor);
-void QSGContext2D::clear()
-{
- Q_D(QSGContext2D);
- d->clear();
-}
+ if (newState.shadowOffsetX != state.shadowOffsetX)
+ buffer()->setShadowOffsetX(newState.shadowOffsetX);
-void QSGContext2D::reset()
-{
- Q_D(QSGContext2D);
- d->reset();
-}
+ if (newState.shadowOffsetY != state.shadowOffsetY)
+ buffer()->setShadowOffsetY(newState.shadowOffsetY);
-void QSGContext2D::drawImage(const QString& imgUrl, qreal dx, qreal dy)
-{
- Q_D(QSGContext2D);
- if (!imgUrl.isEmpty())
- d->drawImage(imgUrl, dx, dy);
+ state = newState;
}
-
-void QSGContext2D::drawImage(const QString& imgUrl, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh)
+void QSGContext2D::pushState()
{
- Q_D(QSGContext2D);
- if (!imgUrl.isEmpty())
- d->drawImage(imgUrl, sx, sy, sw, sh, dx, dy, dw, dh);
+ m_stateStack.push(state);
}
-void QSGContext2D::drawImage(const QString& imgUrl, qreal dx, qreal dy,
- qreal dw, qreal dh)
+void QSGContext2D::reset()
{
- Q_D(QSGContext2D);
- if (!imgUrl.isEmpty())
- d->drawImage(imgUrl, dx, dy, dw, dh);
+ QSGContext2D::State newState;
+ newState.matrix = QTransform();
+
+ QPainterPath defaultClipPath;
+ defaultClipPath.addRect(0, 0, m_canvas->canvasSize().width(), m_canvas->canvasSize().height());
+ newState.clipPath = defaultClipPath;
+ newState.clipPath.setFillRule(Qt::WindingFill);
+
+ newState.strokeStyle = Qt::black;
+ newState.fillStyle = Qt::black;
+ newState.fillRule = Qt::WindingFill;
+ newState.globalAlpha = 1.0;
+ newState.lineWidth = 1;
+ newState.lineCap = Qt::FlatCap;
+ newState.lineJoin = Qt::MiterJoin;
+ newState.miterLimit = 10;
+ newState.shadowOffsetX = 0;
+ newState.shadowOffsetY = 0;
+ newState.shadowBlur = 0;
+ newState.shadowColor = qRgba(0, 0, 0, 0);
+ newState.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
+ newState.font = QFont(QLatin1String("sans-serif"), 10);
+ newState.textAlign = QSGContext2D::Start;
+ newState.textBaseline = QSGContext2D::Alphabetic;
+
+ m_fontString = "";
+ m_stateStack.clear();
+ m_stateStack.push(newState);
+ popState();
}
-void QSGContext2D::setSize(int width, int height)
+void QSGContext2D::setV8Engine(QV8Engine *engine)
{
- QSize size(width, height);
- setSize(size);
-}
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
-void QSGContext2D::setSize(const QSize &size)
-{
- Q_D(QSGContext2D);
+ if (m_v8engine != engine) {
+ m_v8engine = engine;
- if (d->size == size)
- return;
- d->setSize(size);
- emit changed();
-}
+ qPersistentDispose(m_v8value);
-QSize QSGContext2D::size() const
-{
- Q_D(const QSGContext2D);
- return d->size;
-}
+ if (m_v8engine == 0)
+ return;
-QMatrix QSGContext2D::worldMatrix() const
-{
- Q_D(const QSGContext2D);
- return d->state.matrix;
+ QSGContext2DEngineData *ed = engineData(engine);
+ m_v8value = qPersistentNew(ed->constructorContext->NewInstance());
+ QV8Context2DResource *r = new QV8Context2DResource(engine);
+ r->context = this;
+ m_v8value->SetExternalResource(r);
+ }
}
QT_END_NAMESPACE
diff --git a/src/declarative/items/context2d/qsgcontext2d_p.h b/src/declarative/items/context2d/qsgcontext2d_p.h
index f8fc9b75a2..830a185a31 100644
--- a/src/declarative/items/context2d/qsgcontext2d_p.h
+++ b/src/declarative/items/context2d/qsgcontext2d_p.h
@@ -45,324 +45,73 @@
#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include "qsgtexturematerial.h"
-
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
-#include <QtGui/qpixmap.h>
#include <QtCore/qstring.h>
#include <QtCore/qstack.h>
-#include <QtCore/qmetatype.h>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qvariant.h>
-#include <QtDeclarative/qjsvalue.h>
#include <private/qv8engine_p.h>
-#include <QMutex>
-#include <QWaitCondition>
-#include "qsgimage_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-QColor colorFromString(const QString &name);
-class QSGCanvasGradient : public QObject
-{
- Q_OBJECT
-public:
- QSGCanvasGradient(const QGradient &gradient) : m_gradient(gradient) {}
-public slots:
- QGradient value() { return m_gradient; }
- void addColorStop(float pos, const QString &color) { m_gradient.setColorAt(pos, colorFromString(color));}
-public:
- QGradient m_gradient;
-};
+#define QSGCONTEXT2D_DEBUG //enable this for just DEBUG purpose!
-Q_DECLARE_METATYPE(QSGCanvasGradient*)
+#ifdef QSGCONTEXT2D_DEBUG
+#include <QElapsedTimer>
+#endif
+QT_BEGIN_HEADER
-class QSGCanvasPath : QObject
-{
- Q_OBJECT
-public:
- QSGCanvasPath(const QPainterPath& path, QObject* parent = 0) : QObject(parent), m_path(path) {}
+QT_BEGIN_NAMESPACE
- QPainterPath m_path;
-};
-Q_DECLARE_METATYPE(QSGCanvasPath*)
+QT_MODULE(Declarative)
-class QSGContext2DWorkerAgent;
-class QSGContext2DPrivate;
class QSGCanvasItem;
-class QSGContext2D : public QObject
-{
- Q_OBJECT
- // compositing
- Q_PROPERTY(qreal globalAlpha READ globalAlpha WRITE setGlobalAlpha)
- Q_PROPERTY(QString globalCompositeOperation READ globalCompositeOperation WRITE setGlobalCompositeOperation)
- Q_PROPERTY(QVariant strokeStyle READ strokeStyle WRITE setStrokeStyle)
- Q_PROPERTY(QVariant fillStyle READ fillStyle WRITE setFillStyle)
- Q_PROPERTY(QColor strokeColor READ strokeColor WRITE setStrokeColor)
- Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor)
- // line caps/joins
- Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth)
- Q_PROPERTY(QString lineCap READ lineCap WRITE setLineCap)
- Q_PROPERTY(QString lineJoin READ lineJoin WRITE setLineJoin)
- Q_PROPERTY(qreal miterLimit READ miterLimit WRITE setMiterLimit)
- // shadows
- Q_PROPERTY(qreal shadowOffsetX READ shadowOffsetX WRITE setShadowOffsetX)
- Q_PROPERTY(qreal shadowOffsetY READ shadowOffsetY WRITE setShadowOffsetY)
- Q_PROPERTY(qreal shadowBlur READ shadowBlur WRITE setShadowBlur)
- Q_PROPERTY(QString shadowColor READ shadowColor WRITE setShadowColor)
- // fonts
- Q_PROPERTY(QString font READ font WRITE setFont)
- Q_PROPERTY(QString textBaseline READ textBaseline WRITE setTextBaseline)
- Q_PROPERTY(QString textAlign READ textAlign WRITE setTextAlign)
+class QSGContext2DCommandBuffer;
+class QDeclarativePixmap;
- Q_PROPERTY(QSGCanvasPath* path READ path WRITE setPath)
- Q_ENUMS(PaintCommand)
+class QSGContext2D
+{
public:
enum TextBaseLineType { Alphabetic=0, Top, Middle, Bottom, Hanging};
enum TextAlignType { Start=0, End, Left, Right, Center};
enum PaintCommand {
Invalid = 0,
- Save,
- Restore,
- //matrix operations
UpdateMatrix,
- Scale,
- Rotate,
- Translate,
- Transform,
- SetTransform,
-
ClearRect,
FillRect,
-
- //path operations
- UpdatePath,
- BeginPath,
- ClosePath,
- MoveTo,
- LineTo,
- QuadraticCurveTo,
- BezierCurveTo,
- ArcTo,
- Rect,
- Arc,
+ StrokeRect,
Fill,
Stroke,
Clip,
- StrokeRect,
-
- //brushes and pens
UpdateBrush,
- UpdatePen,
GlobalAlpha,
GlobalCompositeOperation,
StrokeStyle,
FillStyle,
- StrokeColor,
- FillColor,
LineWidth,
LineCap,
LineJoin,
MiterLimit,
-
- //shadows
- UpdateShadow,
ShadowOffsetX,
ShadowOffsetY,
ShadowBlur,
ShadowColor,
-
- //font&text
Font,
TextBaseline,
TextAlign,
FillText,
StrokeText,
-
- //image
- DrawImage1,
- DrawImage2,
- DrawImage3,
- GetImageData,
- PutImageData
+ DrawImage,
+ GetImageData
};
- QSGContext2D(QObject *parent = 0);
- QSGContext2D(QSGContext2D *ctx2d, QSGContext2DWorkerAgent* agentData);
- ~QSGContext2D();
-
- QSGCanvasItem* canvas() const;
-
- void setSize(int width, int height);
- void setSize(const QSize &size);
- QSize size() const;
-
- void clear();
- void reset();
- QPaintDevice* paintDevice();
- const QImage& toImage() const;
- bool requireCachedImage() const;
- void setCachedImage(const QImage& image);
- // compositing
- qreal globalAlpha() const; // (default 1.0)
- QString globalCompositeOperation() const; // (default over)
- QVariant strokeStyle() const; // (default black)
- QVariant fillStyle() const; // (default black)
- QColor strokeColor() const; // (default black)
- QColor fillColor() const; // (default black)
-
- void setGlobalAlpha(qreal alpha);
- void setGlobalCompositeOperation(const QString &op);
- void setStrokeStyle(const QVariant &style);
- void setFillStyle(const QVariant &style);
- void setStrokeColor(const QColor& color);
- void setFillColor(const QColor& color);
-
- // line caps/joins
- qreal lineWidth() const; // (default 1)
- QString lineCap() const; // "butt", "round", "square" (default "butt")
- QString lineJoin() const; // "round", "bevel", "miter" (default "miter")
- qreal miterLimit() const; // (default 10)
-
- void setLineWidth(qreal w);
- void setLineCap(const QString &s);
- void setLineJoin(const QString &s);
- void setMiterLimit(qreal m);
-
- void setFont(const QString &font);
- QString font() const;
- void setTextBaseline(const QString &font);
- QString textBaseline() const;
- void setTextAlign(const QString &font);
- QString textAlign() const;
-
-
- // shadows
- qreal shadowOffsetX() const; // (default 0)
- qreal shadowOffsetY() const; // (default 0)
- qreal shadowBlur() const; // (default 0)
- QString shadowColor() const; // (default black)
-
- void setShadowOffsetX(qreal x);
- void setShadowOffsetY(qreal y);
- void setShadowBlur(qreal b);
- void setShadowColor(const QString &str);
-
- QSGCanvasPath* path();
- void setPath(QSGCanvasPath* path);
-public slots:
- void save(); // push state on state stack
- void restore(); // pop state stack and restore state
-
- // QTextMetrics measureText(const QString& text);
-
- void fillText(const QString &text, qreal x, qreal y);
- void strokeText(const QString &text, qreal x, qreal y);
-
- void scale(qreal x, qreal y);
- void rotate(qreal angle);
- void translate(qreal x, qreal y);
- void transform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
- void setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
-
- QSGCanvasGradient *createLinearGradient(qreal x0, qreal y0,
- qreal x1, qreal y1);
- QSGCanvasGradient *createRadialGradient(qreal x0, qreal y0,
- qreal r0, qreal x1,
- qreal y1, qreal r1);
-
- // rects
- void clearRect(qreal x, qreal y, qreal w, qreal h);
- void fillRect(qreal x, qreal y, qreal w, qreal h);
- void strokeRect(qreal x, qreal y, qreal w, qreal h);
-
- // path API
- void beginPath();
- void closePath();
- void moveTo(qreal x, qreal y);
- void lineTo(qreal x, qreal y);
- void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y);
- void bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y, qreal x, qreal y);
- void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius);
- void rect(qreal x, qreal y, qreal w, qreal h);
- void arc(qreal x, qreal y, qreal radius,
- qreal startAngle, qreal endAngle,
- bool anticlockwise);
- void fill();
- void stroke();
- void clip();
- bool isPointInPath(qreal x, qreal y) const;
-
- //path string parser
- //implement the W3C SVG path spec:
- //http://www.w3.org/TR/SVG/paths.html
- void setPathString(const QString& path);
- QSGCanvasPath* createPath(const QString& pathString);
-
- QSGImage *createImage(const QString &url);
-
- void drawImage(const QString& imgUrl, qreal dx, qreal dy);
- void drawImage(const QString& imgUrl, qreal dx, qreal dy, qreal dw, qreal dh);
- void drawImage(const QString& imgUrl, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh);
-
- // pixel manipulation
- QList<int> getImageData(qreal sx, qreal sy, qreal sw, qreal sh);
- void putImageData(const QVariant& imageData, qreal x, qreal y, qreal w, qreal h);
-
- void paint(QPainter* painter);
- void sync();
- void processCommands(const QJSValue& commands);
-signals:
- void changed();
- void painted();
-public:
- bool isDirty() const;
- v8::Handle<v8::Object> v8value() const;
- QV8Engine* v8Engine() const;
- void setV8Engine(QV8Engine *eng);
-
- bool valid() const;
- void setValid(bool valid);
- void setTileRect(const QRectF& region);
- void addref();
- void release();
-
- struct VariantRef
- {
- VariantRef() : a(0) {}
- VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); }
- VariantRef(QSGContext2D *_a) : a(_a) { if (a) a->addref(); }
- ~VariantRef() { if (a) a->release(); }
-
- VariantRef &operator=(const VariantRef &o) {
- if (o.a) o.a->addref();
- if (a) a->release(); a = o.a;
- return *this;
- }
- QSGContext2D *a;
- };
- struct Sync : public QEvent {
- Sync() : QEvent(QEvent::User) {}
- QSGContext2DWorkerAgent *data;
- };
struct State {
- QMatrix matrix;
+ QTransform matrix;
QPainterPath clipPath;
QBrush strokeStyle;
QBrush fillStyle;
+ Qt::FillRule fillRule;
qreal globalAlpha;
qreal lineWidth;
Qt::PenCapStyle lineCap;
@@ -376,24 +125,58 @@ public:
QFont font;
QSGContext2D::TextAlignType textAlign;
QSGContext2D::TextBaseLineType textBaseline;
- QPen pen;
};
- QMatrix worldMatrix() const;
+ QSGContext2D(QSGCanvasItem* item);
+ ~QSGContext2D();
+
+ inline QSGCanvasItem* canvas() const {return m_canvas;}
+ inline QSGContext2DCommandBuffer* buffer() const {return m_buffer;}
+
+ v8::Handle<v8::Object> v8value() const;
+ void setV8Engine(QV8Engine *eng);
+ void popState();
+ void pushState();
+ void reset();
+
+ // path API
+ void beginPath();
+ void closePath();
+ void moveTo(qreal x, qreal y);
+ void lineTo(qreal x, qreal y);
+ void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y);
+ void bezierCurveTo(qreal cp1x, qreal cp1y,
+ qreal cp2x, qreal cp2y, qreal x, qreal y);
+ void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius);
+ void rect(qreal x, qreal y, qreal w, qreal h);
+ void roundedRect(qreal x, qreal y,qreal w, qreal h, qreal xr, qreal yr);
+ void ellipse(qreal x, qreal y,qreal w, qreal h);
+ void text(const QString& str, qreal x, qreal y);
+ void arc(qreal x, qreal y, qreal radius,
+ qreal startAngle, qreal endAngle,
+ bool anticlockwise, bool transform=true);
+ void addArcTo(const QPointF& p1, const QPointF& p2, float radius);
-protected:
- virtual bool event(QEvent *);
+ bool isPointInPath(qreal x, qreal y) const;
-private:
- void processCommand(const QJSValue& command);
+ QPainterPath createTextGlyphs(qreal x, qreal y, const QString& text);
+ QImage createImage(const QUrl& url);
- Q_DECLARE_PRIVATE(QSGContext2D)
+ State state;
+ QStack<QSGContext2D::State> m_stateStack;
+ QSGCanvasItem* m_canvas;
+ QSGContext2DCommandBuffer* m_buffer;
+ QPainterPath m_path;
+ v8::Local<v8::Value> m_fillStyle;
+ v8::Local<v8::Value> m_strokeStyle;
+ v8::Handle<v8::Value> m_v8path;
+ QString m_fontString;
+ QV8Engine *m_v8engine;
+ v8::Persistent<v8::Object> m_v8value;
};
QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QSGContext2D::VariantRef)
QML_DECLARE_TYPE(QSGContext2D)
QT_END_HEADER
diff --git a/src/declarative/items/context2d/qsgcontext2d_p_p.h b/src/declarative/items/context2d/qsgcontext2d_p_p.h
deleted file mode 100644
index d71a0bccf2..0000000000
--- a/src/declarative/items/context2d/qsgcontext2d_p_p.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSGCONTEXT2D_P_P_H
-#define QSGCONTEXT2D_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qsgcontext2d_p.h"
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-class QSGCanvasItem;
-struct QSGContext2DWorkerAgent {
- QSGContext2DWorkerAgent()
- :ref(1)
- , orig(0)
- {}
-
- QAtomicInt ref;
- QSGContext2D *orig;
- QMutex mutex;
- QWaitCondition syncDone;
-};
-
-class QSGContext2DPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QSGContext2D)
-
-public:
- QSGContext2DPrivate()
- : agent(0)
- , agentData(0)
- , v8engine(0)
- , cachedImage(1,1, QImage::Format_ARGB32)
- , canvas(0)
- , waitingForPainting(false)
- , valid(false)
- {
- }
- ~QSGContext2DPrivate()
- {
- qPersistentDispose(v8value);
- }
-
- void updateMatrix(const QMatrix& m);
-
- void setSize(const QSize &s)
- {
- size = s;
- cachedImage = QImage(s, QImage::Format_ARGB32);
- }
- void clear();
- void reset();
-
- // compositing
- void setGlobalAlpha(qreal alpha);
- void setGlobalCompositeOperation(const QString &op);
- void setStrokeStyle(const QVariant &style);
- void setFillStyle(const QVariant &style);
- void setStrokeColor(const QColor& color);
- void setFillColor(const QColor& color);
-
- // line caps/joins
- void setLineWidth(qreal w);
- void setLineCap(const QString &s);
- void setLineJoin(const QString &s);
- void setMiterLimit(qreal m);
-
- void setFont(const QString &font);
- void setTextBaseline(const QString &font);
- void setTextAlign(const QString &font);
-
-
- // shadows
- void setShadowOffsetX(qreal x);
- void setShadowOffsetY(qreal y);
- void setShadowBlur(qreal b);
- void setShadowColor(const QString &str);
-
- bool hasShadow() const;
- void clearShadow();
- QImage makeShadowImage(const QPixmap& pix);
- void fillRectShadow(QPainter* p, QRectF shadowRect);
- void fillShadowPath(QPainter* p, const QPainterPath& path);
- void strokeShadowPath(QPainter* p, const QPainterPath& path);
- void save();
- void restore();
-
- // QTextMetrics measureText(const QString& text);
-
- void fillText(const QString &text, qreal x, qreal y);
- void strokeText(const QString &text, qreal x, qreal y);
-
- void scale(qreal x, qreal y);
- void rotate(qreal angle);
- void translate(qreal x, qreal y);
- void transform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
- void setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
-
- // rects
- void clearRect(qreal x, qreal y, qreal w, qreal h);
- void fillRect(qreal x, qreal y, qreal w, qreal h);
- void strokeRect(qreal x, qreal y, qreal w, qreal h);
-
- // path API
- void beginPath();
- void closePath();
- void moveTo(qreal x, qreal y);
- void lineTo(qreal x, qreal y);
- void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y);
- void bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y, qreal x, qreal y);
- void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius);
- void rect(qreal x, qreal y, qreal w, qreal h);
- void arc(qreal x, qreal y, qreal radius,
- qreal startAngle, qreal endAngle,
- bool anticlockwise);
- void fill();
- void stroke();
- void clip();
-
- void drawImage(const QString& url, qreal dx, qreal dy);
- void drawImage(const QString& url, qreal dx, qreal dy, qreal dw, qreal dh);
- void drawImage(const QString& url, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh);
-
- QList<int> getImageData(qreal sx, qreal sy, qreal sw, qreal sh);
- void putImageData(const QVariantList& imageData, qreal x, qreal y, qreal w, qreal h);
-
- int baseLineOffset(QSGContext2D::TextBaseLineType value, const QFontMetrics &metrics);
- int textAlignOffset(QSGContext2D::TextAlignType value, const QFontMetrics &metrics, const QString &string);
-
- void clearCommands()
- {
- //qDebug() << "painting commands:" << commands.size();
- commands.remove(0, commands.size());
- variants.remove(0, variants.size());
- pens.remove(0, pens.size());
- ints.remove(0, ints.size());
- reals.remove(0, reals.size());
- strings.remove(0, strings.size());
- colors.remove(0, colors.size());
- matrixes.remove(0, matrixes.size());
- brushes.remove(0, brushes.size());
- pathes.remove(0, pathes.size());
- fonts.remove(0, fonts.size());
- images.remove(0, images.size());
- sizes.remove(0, sizes.size());
- }
-
- //current context2d variables
- QPainterPath path;
- QSize size;
- QSGContext2D::State state;
- QStack<QSGContext2D::State> stateStack;
-
- //variables for actual painting
- QVector<QSGContext2D::PaintCommand> commands;
- QVector<QVariant> variants;
- QVector<int> ints;
- QVector<qreal> reals;
- QVector<QString> strings;
- QVector<QColor> colors;
- QVector<QMatrix> matrixes;
- QVector<QPen> pens;
- QVector<QBrush> brushes;
- QVector<QPainterPath> pathes;
- QVector<QFont> fonts;
- QVector<QImage> images;
- QVector<QSize> sizes;
- QList<int> imageData;
-
- //workerscript agent
- QSGContext2D* agent;
- QSGContext2DWorkerAgent* agentData;
-
- QV8Engine *v8engine;
- v8::Persistent<v8::Object> v8value;
-
- QImage cachedImage;
- QSGCanvasItem* canvas;
- bool waitingForPainting;
- bool valid;
- QRectF tileRect;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSGCONTEXT2D_P_P_H
diff --git a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp
new file mode 100644
index 0000000000..8eb9513433
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp
@@ -0,0 +1,402 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcontext2dcommandbuffer_p.h"
+#include "qsgcanvasitem_p.h"
+#include "qdeclarative.h"
+#include <QtGui/QApplication>
+#include <QtCore/QMutex>
+
+#define HAS_SHADOW(offsetX, offsetY, blur, color) (color.isValid() && color.alpha() && (blur || offsetX || offsetY))
+static QImage makeShadowImage(const QImage& image, qreal offsetX, qreal offsetY, qreal blur, const QColor& color)
+{
+ QImage shadowImg(image.width() + blur * 2 + qAbs(offsetX),
+ image.height() + blur *2 + qAbs(offsetY),
+ QImage::Format_ARGB32);
+ shadowImg.fill(0);
+ QPainter tmpPainter(&shadowImg);
+ tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ qreal shadowX = offsetX > 0? offsetX : 0;
+ qreal shadowY = offsetY > 0? offsetY : 0;
+
+ tmpPainter.drawImage(shadowX, shadowY, image);
+ tmpPainter.end();
+
+ // blur the alpha channel
+ if (blur > 0) {
+ QImage blurred(shadowImg.size(), QImage::Format_ARGB32);
+ blurred.fill(0);
+ QPainter blurPainter(&blurred);
+ qt_blurImage(&blurPainter, shadowImg, blur, true, false);
+ blurPainter.end();
+ shadowImg = blurred;
+ }
+
+ // blacken the image with shadow color...
+ tmpPainter.begin(&shadowImg);
+ tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
+ tmpPainter.fillRect(shadowImg.rect(), color);
+ tmpPainter.end();
+ return shadowImg;
+}
+
+static void fillRectShadow(QPainter* p, QRectF shadowRect, qreal offsetX, qreal offsetY, qreal blur, const QColor& color)
+{
+ QRectF r = shadowRect;
+ r.moveTo(0, 0);
+
+ QImage shadowImage(r.size().width() + 1, r.size().height() + 1, QImage::Format_ARGB32);
+ QPainter tp;
+ tp.begin(&shadowImage);
+ tp.fillRect(r, p->brush());
+ tp.end();
+ shadowImage = makeShadowImage(shadowImage, offsetX, offsetY, blur, color);
+
+ qreal dx = shadowRect.left() + (offsetX < 0? offsetX:0);
+ qreal dy = shadowRect.top() + (offsetY < 0? offsetY:0);
+
+ p->drawImage(dx, dy, shadowImage);
+ p->fillRect(shadowRect, p->brush());
+}
+
+static void fillShadowPath(QPainter* p, const QPainterPath& path, qreal offsetX, qreal offsetY, qreal blur, const QColor& color)
+{
+ QRectF r = path.boundingRect();
+ QImage img(r.size().width() + r.left() + 1,
+ r.size().height() + r.top() + 1,
+ QImage::Format_ARGB32);
+ img.fill(0);
+ QPainter tp(&img);
+ tp.fillPath(path.translated(0, 0), p->brush());
+ tp.end();
+
+ QImage shadowImage = makeShadowImage(img, offsetX, offsetY, blur, color);
+ qreal dx = r.left() + (offsetX < 0? offsetX:0);
+ qreal dy = r.top() + (offsetY < 0? offsetY:0);
+
+ p->drawImage(dx, dy, shadowImage);
+ p->fillPath(path, p->brush());
+}
+
+static void strokeShadowPath(QPainter* p, const QPainterPath& path, qreal offsetX, qreal offsetY, qreal blur, const QColor& color)
+{
+ QRectF r = path.boundingRect();
+ QImage img(r.size().width() + r.left() + 1,
+ r.size().height() + r.top() + 1,
+ QImage::Format_ARGB32);
+ img.fill(0);
+ QPainter tp(&img);
+ tp.strokePath(path, p->pen());
+ tp.end();
+
+ QImage shadowImage = makeShadowImage(img, offsetX, offsetY, blur, color);
+ qreal dx = r.left() + (offsetX < 0? offsetX:0);
+ qreal dy = r.top() + (offsetY < 0? offsetY:0);
+ p->drawImage(dx, dy, shadowImage);
+ p->strokePath(path, p->pen());
+}
+
+QPen QSGContext2DCommandBuffer::makePen(QSGContext2D::State state)
+{
+ QPen pen;
+ pen.setWidthF(state.lineWidth);
+ pen.setCapStyle(state.lineCap);
+ pen.setJoinStyle(state.lineJoin);
+ pen.setMiterLimit(state.miterLimit);
+ pen.setBrush(state.strokeStyle);
+ return pen;
+}
+
+void QSGContext2DCommandBuffer::setPainterState(QPainter* p, QSGContext2D::State state, const QPen& pen)
+{
+ p->setTransform(state.matrix * p->transform());
+
+ if (pen != p->pen())
+ p->setPen(pen);
+
+ if (state.fillStyle != p->brush())
+ p->setBrush(state.fillStyle);
+
+ if (state.font != p->font())
+ p->setFont(state.font);
+
+ if (state.globalAlpha != p->opacity()) {
+ p->setOpacity(state.globalAlpha);
+ }
+
+ if (state.globalCompositeOperation != p->compositionMode())
+ p->setCompositionMode(state.globalCompositeOperation);
+}
+
+QSGContext2D::State QSGContext2DCommandBuffer::replay(QPainter* p, QSGContext2D::State state)
+{
+ if (!p)
+ return state;
+
+ reset();
+
+ QTransform originMatrix = p->transform();
+
+ QPen pen = makePen(state);
+ setPainterState(p, state, pen);
+
+ while (hasNext()) {
+ QSGContext2D::PaintCommand cmd = takeNextCommand();
+ switch (cmd) {
+ case QSGContext2D::UpdateMatrix:
+ {
+ state.matrix = takeMatrix();
+ p->setTransform(state.matrix * originMatrix);
+ break;
+ }
+ case QSGContext2D::ClearRect:
+ {
+ p->eraseRect(takeRect());
+ break;
+ }
+ case QSGContext2D::FillRect:
+ {
+ QRectF r = takeRect();
+ if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor))
+ fillRectShadow(p, r, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor);
+ else
+ p->fillRect(r, p->brush());
+ break;
+ }
+ case QSGContext2D::ShadowColor:
+ {
+ state.shadowColor = takeColor();
+ break;
+ }
+ case QSGContext2D::ShadowBlur:
+ {
+ state.shadowBlur = takeShadowBlur();
+ break;
+ }
+ case QSGContext2D::ShadowOffsetX:
+ {
+ state.shadowOffsetX = takeShadowOffsetX();
+ break;
+ }
+ case QSGContext2D::ShadowOffsetY:
+ {
+ state.shadowOffsetY = takeShadowOffsetY();
+ break;
+ }
+ case QSGContext2D::FillStyle:
+ {
+ state.fillStyle = takeFillStyle();
+ p->setBrush(state.fillStyle);
+ break;
+ }
+ case QSGContext2D::StrokeStyle:
+ {
+ state.strokeStyle = takeStrokeStyle();
+ pen.setBrush(state.strokeStyle);
+ p->setPen(pen);
+ break;
+ }
+ case QSGContext2D::LineWidth:
+ {
+ state.lineWidth = takeLineWidth();
+ pen.setWidth(state.lineWidth);
+ p->setPen(pen);
+ break;
+ }
+ case QSGContext2D::LineCap:
+ {
+ state.lineCap = takeLineCap();
+ pen.setCapStyle(state.lineCap);
+ p->setPen(pen);
+ break;
+ }
+ case QSGContext2D::LineJoin:
+ {
+ state.lineJoin = takeLineJoin();
+ pen.setJoinStyle(state.lineJoin);
+ p->setPen(pen);
+ break;
+ }
+ case QSGContext2D::MiterLimit:
+ {
+ state.miterLimit = takeMiterLimit();
+ pen.setMiterLimit(state.miterLimit);
+ p->setPen(pen);
+ break;
+ }
+ case QSGContext2D::TextAlign:
+ case QSGContext2D::TextBaseline:
+ break;
+ case QSGContext2D::Fill:
+ {
+ if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor))
+ fillShadowPath(p,takePath(), state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor);
+ else
+ p->fillPath(takePath(), p->brush());
+ break;
+ }
+ case QSGContext2D::Stroke:
+ {
+ if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor))
+ strokeShadowPath(p,takePath(), state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor);
+ else
+ p->strokePath(takePath(), p->pen());
+ break;
+ }
+ case QSGContext2D::Clip:
+ {
+ QPainterPath clipPath = takePath();
+ clipPath.closeSubpath();
+ state.clipPath = state.clipPath.intersected(clipPath);
+ if (!p->clipPath().isEmpty())
+ clipPath = clipPath.intersected(p->clipPath());
+ p->setClipping(true);
+ p->setClipPath(clipPath);
+ break;
+ }
+ case QSGContext2D::UpdateBrush:
+ {
+ state.fillStyle = takeBrush();
+ p->setBrush(state.fillStyle);
+ break;
+ }
+
+ case QSGContext2D::GlobalAlpha:
+ {
+ state.globalAlpha = takeGlobalAlpha();
+ p->setOpacity(state.globalAlpha);
+ break;
+ }
+ case QSGContext2D::GlobalCompositeOperation:
+ {
+ state.globalCompositeOperation = takeGlobalCompositeOperation();
+ p->setCompositionMode(state.globalCompositeOperation);
+ break;
+ }
+ case QSGContext2D::DrawImage:
+ {
+ qreal sx = takeReal();
+ qreal sy = takeReal();
+ qreal sw = takeReal();
+ qreal sh = takeReal();
+ qreal dx = takeReal();
+ qreal dy = takeReal();
+ qreal dw = takeReal();
+ qreal dh = takeReal();
+ QImage image = takeImage();
+
+ if (!image.isNull()) {
+ if (sw == -1 || sh == -1) {
+ sw = image.width();
+ sh = image.height();
+ }
+ if (sx != 0 || sy != 0 || sw != image.width() || sh != image.height())
+ image = image.copy(sx, sy, sw, sh);
+
+ image = image.scaled(dw, dh);
+
+ if (HAS_SHADOW(state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor)) {
+ QImage shadow = makeShadowImage(image, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor);
+ qreal shadow_dx = dx + (state.shadowOffsetX < 0? state.shadowOffsetY:0);
+ qreal shadow_dy = dy + (state.shadowOffsetX < 0? state.shadowOffsetY:0);
+ p->drawImage(shadow_dx, shadow_dy, shadow);
+ }
+ p->drawImage(dx, dy, image);
+ }
+ break;
+ }
+ case QSGContext2D::GetImageData:
+ {
+ //TODO:
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ p->end();
+ return state;
+}
+
+QSGContext2DCommandBuffer::QSGContext2DCommandBuffer()
+ : cmdIdx(0)
+ , intIdx(0)
+ , realIdx(0)
+ , colorIdx(0)
+ , matrixIdx(0)
+ , brushIdx(0)
+ , pathIdx(0)
+ , imageIdx(0)
+{
+}
+
+
+QSGContext2DCommandBuffer::~QSGContext2DCommandBuffer()
+{
+}
+
+void QSGContext2DCommandBuffer::clear()
+{
+ commands.clear();
+ ints.clear();
+ reals.clear();
+ colors.clear();
+ matrixes.clear();
+ brushes.clear();
+ pathes.clear();
+ images.clear();
+ reset();
+}
+
+void QSGContext2DCommandBuffer::reset()
+{
+ cmdIdx = 0;
+ intIdx = 0;
+ realIdx = 0;
+ colorIdx = 0;
+ matrixIdx = 0;
+ brushIdx = 0;
+ pathIdx = 0;
+ imageIdx = 0;
+}
+
+
diff --git a/src/declarative/items/context2d/qsgcontext2dcommandbuffer_p.h b/src/declarative/items/context2d/qsgcontext2dcommandbuffer_p.h
new file mode 100644
index 0000000000..d238027c05
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dcommandbuffer_p.h
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGCONTEXT2DCOMMANDBUFFER_P_H
+#define QSGCONTEXT2DCOMMANDBUFFER_P_H
+
+#include "qsgcontext2d_p.h"
+#include "qdeclarativepixmapcache_p.h"
+
+// Note, this is exported but in a private header as qtopengl depends on it.
+// But it really should be considered private API
+void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
+void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGCanvasItem;
+class QMutex;
+
+class QSGContext2DCommandBuffer
+{
+public:
+ QSGContext2DCommandBuffer();
+ ~QSGContext2DCommandBuffer();
+ void reset();
+ void clear();
+ inline int size() {return commands.size();}
+ inline bool isEmpty() const {return commands.isEmpty(); }
+ inline bool hasNext() const {return cmdIdx < commands.size(); }
+ inline QSGContext2D::PaintCommand takeNextCommand() { return commands[cmdIdx++]; }
+
+ inline qreal takeGlobalAlpha() { return takeReal(); }
+ inline QPainter::CompositionMode takeGlobalCompositeOperation(){ return static_cast<QPainter::CompositionMode>(takeInt()); }
+ inline QBrush takeStrokeStyle() { return takeBrush(); }
+ inline QBrush takeFillStyle() { return takeBrush(); }
+
+ inline qreal takeLineWidth() { return takeReal(); }
+ inline Qt::PenCapStyle takeLineCap() { return static_cast<Qt::PenCapStyle>(takeInt());}
+ inline Qt::PenJoinStyle takeLineJoin(){ return static_cast<Qt::PenJoinStyle>(takeInt());}
+ inline qreal takeMiterLimit() { return takeReal(); }
+
+ inline void setGlobalAlpha( qreal alpha)
+ {
+ commands << QSGContext2D::GlobalAlpha;
+ reals << alpha;
+ }
+
+ inline void setGlobalCompositeOperation(QPainter::CompositionMode cm)
+ {
+ commands << QSGContext2D::GlobalCompositeOperation;
+ ints << cm;
+ }
+
+ inline void setStrokeStyle(const QBrush &style)
+ {
+ commands << QSGContext2D::StrokeStyle;
+ brushes << style;
+ }
+
+ inline void drawImage(const QImage& image, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh)
+ {
+ commands << QSGContext2D::DrawImage;
+ images << image;
+ reals << sx << sy << sw << sh << dx << dy << dw << dh;
+ }
+
+ inline qreal takeShadowOffsetX() { return takeReal(); }
+ inline qreal takeShadowOffsetY() { return takeReal(); }
+ inline qreal takeShadowBlur() { return takeReal(); }
+ inline QColor takeShadowColor() { return takeColor(); }
+
+
+ inline void updateMatrix(const QTransform& matrix)
+ {
+ commands << QSGContext2D::UpdateMatrix;
+ matrixes << matrix;
+ }
+
+ inline void clearRect(qreal x, qreal y, qreal w, qreal h)
+ {
+ commands << QSGContext2D::ClearRect;
+ reals << x << y << w << h;
+ }
+
+ inline void fillRect(qreal x, qreal y, qreal w, qreal h)
+ {
+ commands << QSGContext2D::FillRect;
+ reals << x << y << w << h;
+ }
+
+ inline void strokeRect(qreal x, qreal y, qreal w, qreal h)
+ {
+ QPainterPath p;
+ p.addRect(x, y, w, h);
+
+ commands << QSGContext2D::Stroke;
+ pathes << p;
+ }
+
+
+ inline void fill(const QPainterPath& path)
+ {
+ commands << QSGContext2D::Fill;
+ pathes << path;
+
+ }
+
+ inline void stroke(const QPainterPath& path)
+ {
+ commands << QSGContext2D::Stroke;
+ pathes << path;
+ }
+
+ inline void clip(const QPainterPath& path)
+ {
+ commands << QSGContext2D::Clip;
+ pathes << path;
+ }
+
+
+
+ inline void setFillStyle(const QBrush &style)
+ {
+ commands << QSGContext2D::UpdateBrush;
+ brushes << style;
+ }
+
+
+ inline void setLineWidth( qreal w)
+ {
+ commands << QSGContext2D::LineWidth;
+ reals << w;
+ }
+
+ inline void setLineCap(Qt::PenCapStyle cap)
+ {
+ commands << QSGContext2D::LineCap;
+ ints << cap;
+ }
+
+ inline void setLineJoin(Qt::PenJoinStyle join)
+ {
+ commands << QSGContext2D::LineJoin;
+ ints << join;
+ }
+
+ inline void setMiterLimit( qreal limit)
+ {
+ commands << QSGContext2D::MiterLimit;
+ reals << limit;
+ }
+
+ inline void setShadowOffsetX( qreal x)
+ {
+ commands << QSGContext2D::ShadowOffsetX;
+ reals << x;
+ }
+
+ inline void setShadowOffsetY( qreal y)
+ {
+ commands << QSGContext2D::ShadowOffsetY;
+ reals << y;
+ }
+
+ inline void setShadowBlur( qreal b)
+ {
+ commands << QSGContext2D::ShadowBlur;
+ reals << b;
+ }
+
+ inline void setShadowColor(const QColor &color)
+ {
+ commands << QSGContext2D::ShadowColor;
+ colors << color;
+ }
+
+ inline QTransform takeMatrix() { return matrixes[matrixIdx++]; }
+
+ // rects
+ inline QRectF takeRect() {
+ qreal x, y, w, h;
+ x = takeReal();
+ y = takeReal();
+ w = takeReal();
+ h = takeReal();
+ return QRectF(x, y, w ,h);
+ }
+
+ inline QPainterPath takePath() { return pathes[pathIdx++]; }
+
+ inline const QImage& takeImage() { return images[imageIdx++]; }
+
+ inline int takeInt() { return ints[intIdx++]; }
+ inline qreal takeReal() { return reals[realIdx++]; }
+ inline QColor takeColor() { return colors[colorIdx++]; }
+ inline QBrush takeBrush() { return brushes[brushIdx++]; }
+
+ QSGContext2D::State replay(QPainter* painter, QSGContext2D::State state);
+private:
+ QPen makePen(QSGContext2D::State state);
+ void setPainterState(QPainter* painter, QSGContext2D::State state, const QPen& pen);
+ int cmdIdx;
+ int intIdx;
+ int realIdx;
+ int colorIdx;
+ int matrixIdx;
+ int brushIdx;
+ int pathIdx;
+ int imageIdx;
+ QVector<QSGContext2D::PaintCommand> commands;
+
+ QVector<int> ints;
+ QVector<qreal> reals;
+ QVector<QColor> colors;
+ QVector<QTransform> matrixes;
+ QVector<QBrush> brushes;
+ QVector<QPainterPath> pathes;
+ QVector<QImage> images;
+};
+
+QT_END_HEADER
+
+QT_END_NAMESPACE
+
+#endif // QSGCONTEXT2DCOMMANDBUFFER_P_H
diff --git a/src/declarative/items/context2d/qsgcontext2dnode.cpp b/src/declarative/items/context2d/qsgcontext2dnode.cpp
new file mode 100644
index 0000000000..4173b32e60
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dnode.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcontext2dnode_p.h"
+
+#include <private/qsgcontext_p.h>
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+
+QSGContext2DNode::QSGContext2DNode(QSGCanvasItem* item)
+ : QSGGeometryNode()
+ , m_item(item)
+ , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
+ , m_texture(0)
+ , m_dirtyGeometry(false)
+ , m_dirtyTexture(false)
+{
+ setMaterial(&m_materialO);
+ setOpaqueMaterial(&m_material);
+ setGeometry(&m_geometry);
+ setFlag(UsePreprocess, true);
+}
+
+QSGContext2DNode::~QSGContext2DNode()
+{
+}
+
+void QSGContext2DNode::preprocess()
+{
+ bool doDirty = false;
+ QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(m_material.texture());
+ if (t) {
+ doDirty = t->updateTexture();
+ updateGeometry();
+ }
+ if (doDirty) {
+ m_dirtyTexture = true;
+ markDirty(DirtyMaterial);
+ }
+}
+void QSGContext2DNode::setTexture(QSGContext2DTexture* texture)
+{
+ if (texture != m_texture) {
+ m_dirtyTexture = true;
+ m_texture = texture;
+ }
+}
+
+void QSGContext2DNode::update()
+{
+ if (m_dirtyGeometry)
+ updateGeometry();
+ if (m_dirtyTexture)
+ updateTexture();
+
+ m_dirtyGeometry = false;
+ m_dirtyTexture = false;
+}
+
+void QSGContext2DNode::updateTexture()
+{
+ m_material.setTexture(m_texture);
+ m_materialO.setTexture(m_texture);
+ markDirty(DirtyMaterial);
+}
+
+void QSGContext2DNode::updateGeometry()
+{
+ QSizeF size = m_item->canvasWindow().size();
+ QRectF source = m_texture->textureSubRect();
+ QSGGeometry::updateTexturedRectGeometry(&m_geometry,
+ QRectF(0, 0, size.width(), size.height()),
+ source);
+ markDirty(DirtyGeometry);
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/items/context2d/qsgcontext2dnode_p.h b/src/declarative/items/context2d/qsgcontext2dnode_p.h
new file mode 100644
index 0000000000..70446d7357
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dnode_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGCONTEXT2DNODE_P_H
+#define QSGCONTEXT2DNODE_P_H
+
+#include "qsgnode.h"
+#include "qsgtexturematerial.h"
+
+#include "qsgcanvasitem_p.h"
+#include "qsgcontext2dtexture_p.h"
+#include "qsgcontext2d_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGContext2DNode : public QSGGeometryNode
+{
+public:
+ QSGContext2DNode(QSGCanvasItem* item);
+ virtual ~QSGContext2DNode();
+ void setTexture(QSGContext2DTexture* texture);
+ void update();
+ void preprocess();
+private:
+ void updateTexture();
+ void updateGeometry();
+
+ QSGCanvasItem* m_item;
+ QSGOpaqueTextureMaterial m_material;
+ QSGTextureMaterial m_materialO;
+ QSGGeometry m_geometry;
+ QSGContext2DTexture* m_texture;
+
+ bool m_dirtyGeometry;
+ bool m_dirtyTexture;
+};
+
+QT_END_HEADER
+
+QT_END_NAMESPACE
+
+#endif // QSGCONTEXT2DNODE_P_H
diff --git a/src/declarative/items/context2d/qsgcontext2dtexture.cpp b/src/declarative/items/context2d/qsgcontext2dtexture.cpp
new file mode 100644
index 0000000000..6e2c7c3e3c
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dtexture.cpp
@@ -0,0 +1,673 @@
+#include "qsgcontext2dtexture_p.h"
+#include "qsgcontext2dtile_p.h"
+#include "qsgcanvasitem_p.h"
+#include "qsgitem_p.h"
+#include "private/qsgtexture_p.h"
+#include "qsgcontext2dcommandbuffer_p.h"
+
+#include <QtOpenGL/QGLFramebufferObject>
+#include <QtOpenGL/QGLFramebufferObjectFormat>
+#include <QtCore/QThread>
+
+#define QT_MINIMUM_FBO_SIZE 64
+
+static inline int qt_next_power_of_two(int v)
+{
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ ++v;
+ return v;
+}
+
+
+Q_GLOBAL_STATIC(QThread, globalCanvasThreadRenderInstance)
+
+
+QSGContext2DTexture::QSGContext2DTexture()
+ : QSGDynamicTexture()
+ , m_context(0)
+ , m_canvasSize(QSize(1, 1))
+ , m_tileSize(QSize(1, 1))
+ , m_canvasWindow(QRect(0, 0, 1, 1))
+ , m_dirtyCanvas(false)
+ , m_dirtyTexture(false)
+ , m_threadRendering(false)
+ , m_smooth(false)
+ , m_tiledCanvas(false)
+ , m_doGrabImage(false)
+ , m_painting(false)
+{
+}
+
+QSGContext2DTexture::~QSGContext2DTexture()
+{
+ clearTiles();
+}
+
+QSize QSGContext2DTexture::textureSize() const
+{
+ return m_canvasWindow.size();
+}
+
+void QSGContext2DTexture::markDirtyTexture()
+{
+ lock();
+ m_dirtyTexture = true;
+ unlock();
+ emit textureChanged();
+}
+
+bool QSGContext2DTexture::setCanvasSize(const QSize &size)
+{
+ if (m_canvasSize != size) {
+ m_canvasSize = size;
+ m_dirtyCanvas = true;
+ return true;
+ }
+ return false;
+}
+
+bool QSGContext2DTexture::setTileSize(const QSize &size)
+{
+ if (m_tileSize != size) {
+ m_tileSize = size;
+ m_dirtyCanvas = true;
+ return true;
+ }
+ return false;
+}
+
+void QSGContext2DTexture::setSmooth(bool smooth)
+{
+ m_smooth = smooth;
+}
+
+void QSGContext2DTexture::setItem(QSGCanvasItem* item)
+{
+ if (!item) {
+ lock();
+ m_item = 0;
+ m_context = 0;
+ unlock();
+ wake();
+ } else if (m_item != item) {
+ lock();
+ m_item = item;
+ m_context = item->context();
+ m_state = m_context->state;
+ unlock();
+ connect(this, SIGNAL(textureChanged()), m_item, SIGNAL(painted()), Qt::QueuedConnection);
+ canvasChanged(item->canvasSize().toSize()
+ , item->tileSize()
+ , item->canvasWindow().toAlignedRect()
+ , item->canvasWindow().toAlignedRect()
+ , item->smooth());
+ }
+}
+
+bool QSGContext2DTexture::setCanvasWindow(const QRect& r)
+{
+ if (m_canvasWindow != r) {
+ m_canvasWindow = r;
+ }
+}
+
+bool QSGContext2DTexture::setDirtyRect(const QRect &r)
+{
+ bool doDirty = false;
+ foreach (QSGContext2DTile* t, m_tiles) {
+ bool dirty = t->rect().intersected(r).isValid();
+ t->markDirty(dirty);
+ if (dirty)
+ doDirty = true;
+ }
+ return doDirty;
+}
+
+void QSGContext2DTexture::canvasChanged(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth)
+{
+ lock();
+
+ QSize ts = tileSize;
+ if (ts.width() > canvasSize.width())
+ ts.setWidth(canvasSize.width());
+
+ if (ts.height() > canvasSize.height())
+ ts.setHeight(canvasSize.height());
+
+ bool canvasChanged = setCanvasSize(canvasSize);
+ bool tileChanged = setTileSize(ts);
+
+ bool doDirty = false;
+ if (canvasSize == canvasWindow.size()) {
+ m_tiledCanvas = false;
+ m_dirtyCanvas = false;
+ } else {
+ m_tiledCanvas = true;
+ if (dirtyRect.isValid())
+ doDirty = setDirtyRect(dirtyRect);
+ }
+
+ bool windowChanged = setCanvasWindow(canvasWindow);
+
+ if (windowChanged || doDirty) {
+ if (m_threadRendering)
+ QMetaObject::invokeMethod(this, "paint", Qt::QueuedConnection);
+ else if (supportDirectRendering())
+ QMetaObject::invokeMethod(this, "paint", Qt::DirectConnection);
+ }
+
+ setSmooth(smooth);
+ unlock();
+}
+
+void QSGContext2DTexture::paintWithoutTiles()
+{
+ QSGContext2DCommandBuffer* ccb = m_context->buffer();
+
+ if (ccb->isEmpty() && m_threadRendering && !m_doGrabImage) {
+ lock();
+ if (m_item)
+ QMetaObject::invokeMethod(m_item, "_doPainting", Qt::QueuedConnection, Q_ARG(QRectF, QRectF(0, 0, m_canvasSize.width(), m_canvasSize.height())));
+ wait();
+ unlock();
+ }
+ if (ccb->isEmpty()) {
+ return;
+ }
+
+ QPaintDevice* device = beginPainting();
+ if (!device) {
+ endPainting();
+ return;
+ }
+
+ QPainter p;
+ p.begin(device);
+ if (m_smooth)
+ p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing
+ | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
+ else
+ p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing
+ | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, false);
+ p.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ m_state = ccb->replay(&p, m_state);
+
+ ccb->clear();
+ markDirtyTexture();
+ endPainting();
+}
+
+bool QSGContext2DTexture::canvasDestroyed()
+{
+ bool noCanvas = false;
+ lock();
+ noCanvas = m_item == 0;
+ unlock();
+ return noCanvas;
+}
+
+void QSGContext2DTexture::paint()
+{
+ if (canvasDestroyed())
+ return;
+
+ if (!m_tiledCanvas) {
+ paintWithoutTiles();
+ } else {
+ QSGContext2D::State oldState = m_state;
+ QSGContext2DCommandBuffer* ccb = m_context->buffer();
+
+ lock();
+ QRect tiledRegion = createTiles(m_canvasWindow.intersected(QRect(QPoint(0, 0), m_canvasSize)));
+ unlock();
+
+ if (!tiledRegion.isEmpty()) {
+ if (m_threadRendering && !m_doGrabImage) {
+ QRect dirtyRect;
+
+ lock();
+ foreach (QSGContext2DTile* tile, m_tiles) {
+ if (tile->dirty()) {
+ if (dirtyRect.isEmpty())
+ dirtyRect = tile->rect();
+ else
+ dirtyRect |= tile->rect();
+ }
+ }
+ unlock();
+
+ if (dirtyRect.isValid()) {
+ lock();
+ if (m_item)
+ QMetaObject::invokeMethod(m_item, "_doPainting", Qt::QueuedConnection, Q_ARG(QRectF, dirtyRect));
+ wait();
+ unlock();
+ }
+ }
+
+ if (beginPainting()) {
+ foreach (QSGContext2DTile* tile, m_tiles) {
+ bool dirtyTile = false, dirtyCanvas = false, smooth = false;
+
+ lock();
+ dirtyTile = tile->dirty();
+ smooth = m_smooth;
+ dirtyCanvas = m_dirtyCanvas;
+ unlock();
+
+ //canvas size or tile size may change during painting tiles
+ if (dirtyCanvas) {
+ if (m_threadRendering)
+ QMetaObject::invokeMethod(this, "paint", Qt::QueuedConnection);
+ endPainting();
+ return;
+ } else if (dirtyTile) {
+ m_state = ccb->replay(tile->createPainter(smooth), oldState);
+
+ lock();
+ tile->markDirty(false);
+ unlock();
+ }
+
+ compositeTile(tile);
+ }
+ ccb->clear();
+ endPainting();
+ markDirtyTexture();
+ }
+ }
+ }
+}
+
+QRect QSGContext2DTexture::tiledRect(const QRectF& window, const QSize& tileSize)
+{
+ if (window.isEmpty())
+ return QRect();
+
+ const int tw = tileSize.width();
+ const int th = tileSize.height();
+ const int h1 = window.left() / tw;
+ const int v1 = window.top() / th;
+
+ const int htiles = ((window.right() - h1 * tw) + tw - 1)/tw;
+ const int vtiles = ((window.bottom() - v1 * th) + th - 1)/th;
+
+ return QRect(h1 * tw, v1 * th, htiles * tw, vtiles * th);
+}
+
+QRect QSGContext2DTexture::createTiles(const QRect& window)
+{
+ QList<QSGContext2DTile*> oldTiles = m_tiles;
+ m_tiles.clear();
+
+ if (window.isEmpty()) {
+ m_dirtyCanvas = false;
+ return QRect();
+ }
+
+ QRect r = tiledRect(window, m_tileSize);
+
+ const int tw = m_tileSize.width();
+ const int th = m_tileSize.height();
+ const int h1 = window.left() / tw;
+ const int v1 = window.top() / th;
+
+
+ const int htiles = r.width() / tw;
+ const int vtiles = r.height() / th;
+
+ for (int yy = 0; yy < vtiles; ++yy) {
+ for (int xx = 0; xx < htiles; ++xx) {
+ int ht = xx + h1;
+ int vt = yy + v1;
+
+ QSGContext2DTile* tile = 0;
+
+ QPoint pos(ht * tw, vt * th);
+ QRect rect(pos, m_tileSize);
+
+ for (int i = 0; i < oldTiles.size(); i++) {
+ if (oldTiles[i]->rect() == rect) {
+ tile = oldTiles.takeAt(i);
+ break;
+ }
+ }
+
+ if (!tile)
+ tile = createTile();
+
+ tile->setRect(rect);
+ m_tiles.append(tile);
+ }
+ }
+
+ qDeleteAll(oldTiles);
+
+ m_dirtyCanvas = false;
+ return r;
+}
+
+void QSGContext2DTexture::clearTiles()
+{
+ qDeleteAll(m_tiles);
+ m_tiles.clear();
+}
+
+QSGContext2DFBOTexture::QSGContext2DFBOTexture()
+ : QSGContext2DTexture()
+ , m_fbo(0)
+{
+ m_threadRendering = false;
+}
+
+bool QSGContext2DFBOTexture::setCanvasSize(const QSize &size)
+{
+ QSize s = QSize(qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(size.width()))
+ , qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(size.height())));
+
+ if (m_canvasSize != s) {
+ m_canvasSize = s;
+ m_dirtyCanvas = true;
+ return true;
+ }
+ return false;
+}
+
+bool QSGContext2DFBOTexture::setTileSize(const QSize &size)
+{
+ QSize s = QSize(qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(size.width()))
+ , qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(size.height())));
+ if (m_tileSize != s) {
+ m_tileSize = s;
+ m_dirtyCanvas = true;
+ return true;
+ }
+ return false;
+}
+
+bool QSGContext2DFBOTexture::setCanvasWindow(const QRect& canvasWindow)
+{
+ QSize s = QSize(qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(canvasWindow.size().width()))
+ , qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(canvasWindow.size().height())));
+
+
+ bool doChanged = false;
+ if (m_fboSize != s) {
+ m_fboSize = s;
+ doChanged = true;
+ }
+
+ if (m_canvasWindow != canvasWindow)
+ m_canvasWindow = canvasWindow;
+
+ return doChanged;
+}
+
+void QSGContext2DFBOTexture::bind()
+{
+ glBindTexture(GL_TEXTURE_2D, textureId());
+ updateBindOptions();
+}
+
+QRectF QSGContext2DFBOTexture::textureSubRect() const
+{
+ return QRectF(0
+ , 1
+ , qreal(m_canvasWindow.width()) / m_fboSize.width()
+ , qreal(-m_canvasWindow.height()) / m_fboSize.height());
+}
+
+
+int QSGContext2DFBOTexture::textureId() const
+{
+ return m_fbo? m_fbo->texture() : 0;
+}
+
+
+bool QSGContext2DFBOTexture::updateTexture()
+{
+ if (!m_context->buffer()->isEmpty()) {
+ paint();
+ }
+
+ bool textureUpdated = m_dirtyTexture;
+
+ m_dirtyTexture = false;
+
+ if (m_doGrabImage) {
+ grabImage();
+ m_condition.wakeOne();
+ m_doGrabImage = false;
+ }
+ return textureUpdated;
+}
+
+QSGContext2DTile* QSGContext2DFBOTexture::createTile() const
+{
+ return new QSGContext2DFBOTile();
+}
+
+void QSGContext2DFBOTexture::grabImage()
+{
+ if (m_fbo) {
+ m_grabedImage = m_fbo->toImage();
+ }
+}
+
+QImage QSGContext2DFBOTexture::toImage(const QRectF& region)
+{
+#define QML_CONTEXT2D_WAIT_MAX 5000
+
+ m_doGrabImage = true;
+ if (m_item)
+ m_item->update();
+
+ QImage grabbed;
+ m_mutex.lock();
+ bool ok = m_condition.wait(&m_mutex, QML_CONTEXT2D_WAIT_MAX);
+
+ if (!ok)
+ grabbed = QImage();
+
+ if (region.isValid())
+ grabbed = m_grabedImage.copy(region.toRect());
+ else
+ grabbed = m_grabedImage;
+ m_grabedImage = QImage();
+ return grabbed;
+}
+
+void QSGContext2DFBOTexture::compositeTile(QSGContext2DTile* tile)
+{
+ QSGContext2DFBOTile* t = static_cast<QSGContext2DFBOTile*>(tile);
+ QRect target = t->rect().intersect(m_canvasWindow);
+ if (target.isValid()) {
+ QRect source = target;
+
+ source.moveTo(source.topLeft() - t->rect().topLeft());
+ target.moveTo(target.topLeft() - m_canvasWindow.topLeft());
+
+ QGLFramebufferObject::blitFramebuffer(m_fbo, target, t->fbo(), source);
+ }
+}
+QSGCanvasItem::RenderTarget QSGContext2DFBOTexture::renderTarget() const
+{
+ return QSGCanvasItem::FramebufferObject;
+}
+QPaintDevice* QSGContext2DFBOTexture::beginPainting()
+{
+ QSGContext2DTexture::beginPainting();
+
+ if (m_canvasWindow.size().isEmpty() && !m_threadRendering) {
+ delete m_fbo;
+ m_fbo = 0;
+ } else if (!m_fbo || m_fbo->size() != m_fboSize) {
+ QGLFramebufferObjectFormat format;
+ format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format.setInternalTextureFormat(GL_RGBA);
+ format.setMipmap(false);
+ format.setTextureTarget(GL_TEXTURE_2D);
+ delete m_fbo;
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(false);
+
+ m_fbo = new QGLFramebufferObject(m_fboSize, format);
+ glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
+ updateBindOptions(false);
+ }
+ return m_fbo;
+}
+
+void qt_quit_context2d_render_thread()
+{
+ QThread* thread = globalCanvasThreadRenderInstance();
+ thread->quit();
+ thread->wait();
+}
+
+QSGContext2DImageTexture::QSGContext2DImageTexture(bool threadRendering)
+ : QSGContext2DTexture()
+ , m_texture(new QSGPlainTexture())
+{
+ m_texture->setOwnsTexture(true);
+ m_texture->setHasMipmaps(false);
+
+ m_threadRendering = threadRendering;
+
+ if (m_threadRendering) {
+ QThread* thread = globalCanvasThreadRenderInstance();
+ moveToThread(thread);
+
+ if (!thread->isRunning()) {
+ qAddPostRoutine(qt_quit_context2d_render_thread);
+ thread->start();
+ }
+ }
+}
+
+QSGContext2DImageTexture::~QSGContext2DImageTexture()
+{
+ m_texture->deleteLater();
+}
+
+int QSGContext2DImageTexture::textureId() const
+{
+ return m_texture->textureId();
+}
+
+void QSGContext2DImageTexture::lock()
+{
+ if (m_threadRendering)
+ m_mutex.lock();
+}
+void QSGContext2DImageTexture::unlock()
+{
+ if (m_threadRendering)
+ m_mutex.unlock();
+}
+
+void QSGContext2DImageTexture::wait()
+{
+ if (m_threadRendering)
+ m_waitCondition.wait(&m_mutex);
+}
+
+void QSGContext2DImageTexture::wake()
+{
+ if (m_threadRendering)
+ m_waitCondition.wakeOne();
+}
+
+bool QSGContext2DImageTexture::supportDirectRendering() const
+{
+ return !m_threadRendering;
+}
+
+QSGCanvasItem::RenderTarget QSGContext2DImageTexture::renderTarget() const
+{
+ return QSGCanvasItem::Image;
+}
+
+void QSGContext2DImageTexture::bind()
+{
+ m_texture->bind();
+}
+
+bool QSGContext2DImageTexture::updateTexture()
+{
+ lock();
+ bool textureUpdated = m_dirtyTexture;
+ if (m_dirtyTexture) {
+ m_texture->setImage(m_image);
+ m_dirtyTexture = false;
+ }
+ unlock();
+ return textureUpdated;
+}
+
+QSGContext2DTile* QSGContext2DImageTexture::createTile() const
+{
+ return new QSGContext2DImageTile();
+}
+
+void QSGContext2DImageTexture::grabImage(const QRect& r)
+{
+ m_doGrabImage = true;
+ paint();
+ m_doGrabImage = false;
+ m_grabedImage = m_image.copy(r);
+}
+
+QImage QSGContext2DImageTexture::toImage(const QRectF& region)
+{
+ QRect r = region.isValid() ? region.toRect() : QRect(QPoint(0, 0), m_canvasWindow.size());
+ if (threadRendering()) {
+ wake();
+ QMetaObject::invokeMethod(this, "grabImage", Qt::BlockingQueuedConnection, Q_ARG(QRect, r));
+ } else {
+ QMetaObject::invokeMethod(this, "grabImage", Qt::DirectConnection, Q_ARG(QRect, r));
+ }
+ QImage image = m_grabedImage;
+ m_grabedImage = QImage();
+ return image;
+}
+
+QPaintDevice* QSGContext2DImageTexture::beginPainting()
+{
+ QSGContext2DTexture::beginPainting();
+
+ if (m_canvasWindow.size().isEmpty())
+ return 0;
+
+ lock();
+ if (m_image.size() != m_canvasWindow.size()) {
+ m_image = QImage(m_canvasWindow.size(), QImage::Format_ARGB32_Premultiplied);
+ m_image.fill(Qt::transparent);
+ }
+ unlock();
+ return &m_image;
+}
+
+void QSGContext2DImageTexture::compositeTile(QSGContext2DTile* tile)
+{
+ Q_ASSERT(!tile->dirty());
+ QSGContext2DImageTile* t = static_cast<QSGContext2DImageTile*>(tile);
+ QRect target = t->rect().intersect(m_canvasWindow);
+ if (target.isValid()) {
+ QRect source = target;
+ source.moveTo(source.topLeft() - t->rect().topLeft());
+ target.moveTo(target.topLeft() - m_canvasWindow.topLeft());
+
+ lock();
+ m_painter.begin(&m_image);
+ m_painter.setCompositionMode(QPainter::CompositionMode_Source);
+ m_painter.drawImage(target, t->image(), source);
+ m_painter.end();
+ unlock();
+ }
+}
diff --git a/src/declarative/items/context2d/qsgcontext2dtexture_p.h b/src/declarative/items/context2d/qsgcontext2dtexture_p.h
new file mode 100644
index 0000000000..50e5be774d
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dtexture_p.h
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGCONTEXT2DTEXTURE_P_H
+#define QSGCONTEXT2DTEXTURE_P_H
+
+#include "qsgtexture.h"
+#include "qsgcanvasitem_p.h"
+#include "qsgcontext2d_p.h"
+
+#include <QtOpenGL/QGLContext>
+#include <QtOpenGL/QGLFramebufferObject>
+
+#include <QtCore/QMutex>
+#include <QtCore/QWaitCondition>
+#include <QtCore/QThread>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGContext2DTile;
+class QSGContext2DCommandBuffer;
+
+class QSGContext2DTexture : public QSGDynamicTexture
+{
+ Q_OBJECT
+public:
+ QSGContext2DTexture();
+ ~QSGContext2DTexture();
+
+ virtual bool hasAlphaChannel() const {return true;}
+ virtual bool hasMipmaps() const {return false;}
+ virtual QSize textureSize() const;
+ virtual void lock() {}
+ virtual void unlock() {}
+ virtual void wait() {}
+ virtual void wake() {}
+ bool threadRendering() const {return m_threadRendering;}
+ virtual bool supportThreadRendering() const = 0;
+ virtual bool supportDirectRendering() const = 0;
+ virtual QSGCanvasItem::RenderTarget renderTarget() const = 0;
+ virtual QImage toImage(const QRectF& region = QRectF()) = 0;
+ static QRect tiledRect(const QRectF& window, const QSize& tileSize);
+
+ virtual bool setCanvasSize(const QSize &size);
+ virtual bool setTileSize(const QSize &size);
+ virtual bool setCanvasWindow(const QRect& canvasWindow);
+ void setSmooth(bool smooth);
+ bool setDirtyRect(const QRect &dirtyRect);
+ virtual void canvasChanged(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth);
+ bool canvasDestroyed();
+Q_SIGNALS:
+ void textureChanged();
+
+public Q_SLOTS:
+ void markDirtyTexture();
+ void setItem(QSGCanvasItem* item);
+ void paint();
+
+protected:
+ void paintWithoutTiles();
+ virtual QPaintDevice* beginPainting() {m_painting = true;}
+ virtual void endPainting() {m_painting = false;}
+ virtual QSGContext2DTile* createTile() const = 0;
+ virtual void compositeTile(QSGContext2DTile* tile) = 0;
+
+ void clearTiles();
+ QRect createTiles(const QRect& window);
+
+ QList<QSGContext2DTile*> m_tiles;
+ QSGContext2D* m_context;
+
+ QSGContext2D::State m_state;
+
+ QSGCanvasItem* m_item;
+ QSize m_canvasSize;
+ QSize m_tileSize;
+ QRect m_canvasWindow;
+
+ uint m_dirtyCanvas : 1;
+ uint m_dirtyTexture : 1;
+ uint m_threadRendering : 1;
+ uint m_smooth : 1;
+ uint m_tiledCanvas : 1;
+ uint m_doGrabImage : 1;
+ uint m_painting : 1;
+};
+
+class QSGContext2DFBOTexture : public QSGContext2DTexture
+{
+ Q_OBJECT
+
+public:
+ QSGContext2DFBOTexture();
+ virtual int textureId() const;
+ virtual bool updateTexture();
+ virtual QSGContext2DTile* createTile() const;
+ virtual QImage toImage(const QRectF& region = QRectF());
+ virtual QPaintDevice* beginPainting();
+ QRectF textureSubRect() const;
+ virtual bool supportThreadRendering() const {return false;}
+ virtual bool supportDirectRendering() const {return false;}
+ virtual QSGCanvasItem::RenderTarget renderTarget() const;
+ virtual void compositeTile(QSGContext2DTile* tile);
+ virtual void bind();
+ virtual bool setCanvasSize(const QSize &size);
+ virtual bool setTileSize(const QSize &size);
+ virtual bool setCanvasWindow(const QRect& canvasWindow);
+private Q_SLOTS:
+ void grabImage();
+
+private:
+ QImage m_grabedImage;
+ QGLFramebufferObject *m_fbo;
+ QMutex m_mutex;
+ QWaitCondition m_condition;
+ QSize m_fboSize;
+};
+
+class QSGPlainTexture;
+class QSGContext2DImageTexture : public QSGContext2DTexture
+{
+ Q_OBJECT
+
+public:
+ QSGContext2DImageTexture(bool threadRendering = true);
+ ~QSGContext2DImageTexture();
+ virtual int textureId() const;
+ virtual void bind();
+ virtual bool supportThreadRendering() const {return true;}
+ virtual bool supportDirectRendering() const;
+ virtual QSGCanvasItem::RenderTarget renderTarget() const;
+ virtual void lock();
+ virtual void unlock();
+ virtual void wait();
+ virtual void wake();
+
+ virtual bool updateTexture();
+ virtual QSGContext2DTile* createTile() const;
+ virtual QImage toImage(const QRectF& region = QRectF());
+ virtual QPaintDevice* beginPainting();
+ virtual void compositeTile(QSGContext2DTile* tile);
+
+private Q_SLOTS:
+ void grabImage(const QRect& r);
+private:
+ QImage m_image;
+ QImage m_grabedImage;
+ QMutex m_mutex;
+ QWaitCondition m_waitCondition;
+ QPainter m_painter;
+ QSGPlainTexture* m_texture;
+};
+
+QT_END_HEADER
+
+QT_END_NAMESPACE
+
+#endif // QSGCONTEXT2DTEXTURE_P_H
diff --git a/src/declarative/items/context2d/qsgcontext2dtile.cpp b/src/declarative/items/context2d/qsgcontext2dtile.cpp
new file mode 100644
index 0000000000..695c30f211
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dtile.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcontext2dtile_p.h"
+
+#include <QtOpenGL/QGLFramebufferObject>
+#include <QtOpenGL/QGLFramebufferObjectFormat>
+
+QSGContext2DTile::QSGContext2DTile()
+ : m_dirty(true)
+ , m_rect(QRect(0, 0, 1, 1))
+ , m_device(0)
+{
+}
+
+QSGContext2DTile::~QSGContext2DTile()
+{
+ if (m_painter.isActive())
+ m_painter.end();
+}
+
+QPainter* QSGContext2DTile::createPainter(bool smooth)
+{
+ if (m_painter.isActive())
+ m_painter.end();
+
+ if (m_device) {
+ m_painter.begin(m_device);
+ m_painter.resetTransform();
+ m_painter.setCompositionMode(QPainter::CompositionMode_Source);
+
+#ifdef QSGCONTEXT2D_DEBUG
+ int v = 100;
+ int gray = (m_rect.x() / m_rect.width() + m_rect.y() / m_rect.height()) % 2;
+ if (gray)
+ v = 150;
+ m_painter.fillRect(QRect(0, 0, m_rect.width(), m_rect.height()), QColor(v, v, v, 255));
+#endif
+ if (smooth)
+ m_painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing
+ | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
+ else
+ m_painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing
+ | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, false);
+
+ m_painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ m_painter.translate(-m_rect.left(), -m_rect.top());
+ m_painter.setClipRect(m_rect);
+ m_painter.setClipping(false);
+ return &m_painter;
+ }
+
+ return 0;
+}
+
+QSGContext2DFBOTile::QSGContext2DFBOTile()
+ : QSGContext2DTile()
+ , m_fbo(0)
+{
+}
+
+QSGContext2DFBOTile::~QSGContext2DFBOTile()
+{
+ delete m_fbo;
+}
+
+void QSGContext2DFBOTile::setRect(const QRect& r)
+{
+ if (m_rect == r)
+ return;
+ m_rect = r;
+ m_dirty = true;
+ if (!m_fbo || m_fbo->size() != r.size()) {
+ QGLFramebufferObjectFormat format;
+ format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format.setInternalTextureFormat(GL_RGBA);
+ format.setMipmap(false);
+
+ if (m_painter.isActive())
+ m_painter.end();
+
+ delete m_fbo;
+ m_fbo = new QGLFramebufferObject(r.size(), format);
+ }
+ m_device = m_fbo;
+}
+
+
+QSGContext2DImageTile::QSGContext2DImageTile()
+ : QSGContext2DTile()
+{
+}
+
+QSGContext2DImageTile::~QSGContext2DImageTile()
+{
+}
+
+void QSGContext2DImageTile::setRect(const QRect& r)
+{
+ if (m_rect == r)
+ return;
+ m_rect = r;
+ m_dirty = true;
+ if (m_image.size() != r.size()) {
+ m_image = QImage(r.size(), QImage::Format_ARGB32_Premultiplied);
+ }
+ m_device = &m_image;
+}
diff --git a/src/declarative/items/context2d/qsgcontext2dtile_p.h b/src/declarative/items/context2d/qsgcontext2dtile_p.h
new file mode 100644
index 0000000000..cee2125f73
--- /dev/null
+++ b/src/declarative/items/context2d/qsgcontext2dtile_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGCONTEXT2DTILE_P_H
+#define QSGCONTEXT2DTILE_P_H
+
+#include "qsgcontext2d_p.h"
+#include <QtOpenGL/QGLFramebufferObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGContext2DTexture;
+class QSGContext2DCommandBuffer;
+
+class QSGContext2DTile
+{
+public:
+ QSGContext2DTile();
+ ~QSGContext2DTile();
+
+ bool dirty() const {return m_dirty;}
+ void markDirty(bool dirty) {m_dirty = dirty;}
+
+ QRect rect() const {return m_rect;}
+
+ virtual void setRect(const QRect& r) = 0;
+ virtual QPainter* createPainter(bool smooth = false);
+
+protected:
+ uint m_dirty : 1;
+ QRect m_rect;
+ QPaintDevice* m_device;
+ QPainter m_painter;
+};
+
+
+class QSGContext2DFBOTile : public QSGContext2DTile
+{
+public:
+ QSGContext2DFBOTile();
+ ~QSGContext2DFBOTile();
+ virtual void setRect(const QRect& r);
+ QGLFramebufferObject* fbo() const {return m_fbo;}
+private:
+ QGLFramebufferObject *m_fbo;
+};
+
+class QSGContext2DImageTile : public QSGContext2DTile
+{
+public:
+ QSGContext2DImageTile();
+ ~QSGContext2DImageTile();
+ void setRect(const QRect& r);
+ const QImage& image() const {return m_image;}
+private:
+ QImage m_image;
+};
+QT_END_HEADER
+
+QT_END_NAMESPACE
+
+#endif // QSGCONTEXT2DTILE_P_H
diff --git a/src/declarative/items/qsgitemsmodule.cpp b/src/declarative/items/qsgitemsmodule.cpp
index 8eb7cb36e1..6d9408500a 100644
--- a/src/declarative/items/qsgitemsmodule.cpp
+++ b/src/declarative/items/qsgitemsmodule.cpp
@@ -184,8 +184,6 @@ static void qt_sgitems_defineModule(const char *uri, int major, int minor)
qmlRegisterUncreatableType<QSGPaintedItem>("QtQuick", 2, 0, "PaintedItem", QSGPaintedItem::tr("Cannot create instance of abstract class PaintedItem"));
qmlRegisterType<QSGCanvasItem>("QtQuick", 2, 0, "Canvas");
- qmlRegisterType<QSGContext2D>();
- qmlRegisterType<QSGCanvasGradient>();
qmlRegisterType<QSGSprite>("QtQuick", 2, 0, "Sprite");
qmlRegisterType<QSGSpriteImage>("QtQuick", 2, 0, "SpriteImage");
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index 6f09e977d5..60c98f3950 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -135,7 +135,7 @@ public:
QV8ObjectResource(QV8Engine *engine) : engine(engine) { Q_ASSERT(engine); }
enum ResourceType { ContextType, QObjectType, TypeType, ListType, VariantType,
ValueTypeType, XMLHttpRequestType, DOMNodeType, SQLDatabaseType,
- ListModelType, Context2DType, ParticleDataType, SignalHandlerType };
+ ListModelType, Context2DType, Context2DStyleType, Context2DPixelArrayType, ParticleDataType, SignalHandlerType};
virtual ResourceType resourceType() const = 0;
QV8Engine *engine;
@@ -577,4 +577,4 @@ QV8Engine::Deletable *QV8Engine::extensionData(int index) const
QT_END_NAMESPACE
-#endif // QDECLARATIVEV8ENGINE_P_H
+#endif // QDECLARATIVEV8ENGINE_P_H \ No newline at end of file