2011-05-16 00:15:24 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2013-01-02 11:17:46 +00:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-09-20 05:21:40 +00:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-05-16 00:15:24 +00:00
|
|
|
**
|
2012-02-16 04:43:03 +00:00
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
2011-05-16 00:15:24 +00:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2012-09-20 05:21:40 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-05-16 00:15:24 +00:00
|
|
|
**
|
2012-09-20 05:21:40 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, 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, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-05-16 00:15:24 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-07-07 12:52:03 +00:00
|
|
|
** GNU General Public License Usage
|
2012-09-20 05:21:40 +00:00
|
|
|
** 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.
|
2011-05-16 00:15:24 +00:00
|
|
|
**
|
2012-01-24 03:37:23 +00:00
|
|
|
**
|
2011-05-16 00:15:24 +00:00
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2011-10-12 06:26:22 +00:00
|
|
|
#include <private/qsgadaptationlayer_p.h>
|
2011-10-14 08:51:42 +00:00
|
|
|
#include "qquickcanvasitem_p.h"
|
|
|
|
#include <private/qquickitem_p.h>
|
2012-02-09 05:46:09 +00:00
|
|
|
#include <private/qquickcanvascontext_p.h>
|
|
|
|
#include <private/qquickcontext2d_p.h>
|
2012-03-02 06:24:04 +00:00
|
|
|
#include <qsgsimpletexturenode.h>
|
2012-02-16 04:43:03 +00:00
|
|
|
#include <QtQuick/private/qquickpixmapcache_p.h>
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
#include <qqmlinfo.h>
|
|
|
|
#include <private/qqmlengine_p.h>
|
2011-05-16 00:15:24 +00:00
|
|
|
#include <QtCore/QBuffer>
|
2013-04-17 16:17:30 +00:00
|
|
|
#include <QtCore/qdatetime.h>
|
2011-05-16 00:15:24 +00:00
|
|
|
|
2013-05-08 12:25:40 +00:00
|
|
|
#include <private/qv4value_p.h>
|
|
|
|
#include <private/qv4functionobject_p.h>
|
2013-09-05 11:22:23 +00:00
|
|
|
#include <private/qv4scopedvalue_p.h>
|
2013-05-08 12:25:40 +00:00
|
|
|
|
2011-05-16 00:15:24 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2012-07-11 07:32:16 +00:00
|
|
|
QQuickCanvasPixmap::QQuickCanvasPixmap(const QImage& image, QQuickWindow *window)
|
2012-06-04 06:34:17 +00:00
|
|
|
: m_pixmap(0)
|
|
|
|
, m_image(image)
|
|
|
|
, m_texture(0)
|
2012-07-11 07:32:16 +00:00
|
|
|
, m_window(window)
|
2012-06-04 06:34:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-11 07:32:16 +00:00
|
|
|
QQuickCanvasPixmap::QQuickCanvasPixmap(QQuickPixmap *pixmap, QQuickWindow *window)
|
2012-06-04 06:34:17 +00:00
|
|
|
: m_pixmap(pixmap)
|
|
|
|
, m_texture(0)
|
2012-07-11 07:32:16 +00:00
|
|
|
, m_window(window)
|
2012-06-04 06:34:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QQuickCanvasPixmap::~QQuickCanvasPixmap()
|
|
|
|
{
|
|
|
|
delete m_pixmap;
|
|
|
|
if (m_texture)
|
|
|
|
m_texture->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal QQuickCanvasPixmap::width() const
|
|
|
|
{
|
|
|
|
if (m_pixmap)
|
|
|
|
return m_pixmap->width();
|
|
|
|
|
|
|
|
return m_image.width();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal QQuickCanvasPixmap::height() const
|
|
|
|
{
|
|
|
|
if (m_pixmap)
|
|
|
|
return m_pixmap->height();
|
|
|
|
|
|
|
|
return m_image.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QQuickCanvasPixmap::isValid() const
|
|
|
|
{
|
|
|
|
if (m_pixmap)
|
|
|
|
return m_pixmap->isReady();
|
|
|
|
return !m_image.isNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSGTexture *QQuickCanvasPixmap::texture()
|
|
|
|
{
|
|
|
|
if (!m_texture) {
|
|
|
|
if (m_pixmap) {
|
|
|
|
Q_ASSERT(m_pixmap->textureFactory());
|
2012-07-11 07:32:16 +00:00
|
|
|
m_texture = m_pixmap->textureFactory()->createTexture(m_window);
|
2012-06-04 06:34:17 +00:00
|
|
|
} else {
|
2012-07-11 07:32:16 +00:00
|
|
|
m_texture = QQuickWindowPrivate::get(m_window)->context->createTexture(m_image);
|
2012-06-04 06:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_texture;
|
|
|
|
}
|
|
|
|
QImage QQuickCanvasPixmap::image()
|
|
|
|
{
|
|
|
|
if (m_image.isNull() && m_pixmap)
|
|
|
|
m_image = m_pixmap->image();
|
|
|
|
|
|
|
|
return m_image;
|
|
|
|
}
|
|
|
|
|
2012-05-03 13:31:17 +00:00
|
|
|
QHash<QQmlEngine *,QQuickContext2DRenderThread*> QQuickContext2DRenderThread::renderThreads;
|
|
|
|
QMutex QQuickContext2DRenderThread::renderThreadsMutex;
|
|
|
|
|
|
|
|
QQuickContext2DRenderThread::QQuickContext2DRenderThread(QQmlEngine *eng)
|
|
|
|
: QThread(eng), m_engine(eng), m_eventLoopQuitHack(0)
|
|
|
|
{
|
|
|
|
Q_ASSERT(eng);
|
|
|
|
m_eventLoopQuitHack = new QObject;
|
|
|
|
m_eventLoopQuitHack->moveToThread(this);
|
|
|
|
connect(m_eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
|
|
|
|
start(QThread::IdlePriority);
|
|
|
|
}
|
|
|
|
|
|
|
|
QQuickContext2DRenderThread::~QQuickContext2DRenderThread()
|
|
|
|
{
|
|
|
|
renderThreadsMutex.lock();
|
|
|
|
renderThreads.remove(m_engine);
|
|
|
|
renderThreadsMutex.unlock();
|
|
|
|
|
|
|
|
m_eventLoopQuitHack->deleteLater();
|
|
|
|
wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
QQuickContext2DRenderThread *QQuickContext2DRenderThread::instance(QQmlEngine *engine)
|
|
|
|
{
|
|
|
|
QQuickContext2DRenderThread *thread = 0;
|
|
|
|
renderThreadsMutex.lock();
|
|
|
|
if (renderThreads.contains(engine))
|
|
|
|
thread = renderThreads.value(engine);
|
|
|
|
else {
|
|
|
|
thread = new QQuickContext2DRenderThread(engine);
|
|
|
|
renderThreads.insert(engine, thread);
|
|
|
|
}
|
|
|
|
renderThreadsMutex.unlock();
|
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
class QQuickCanvasItemPrivate : public QQuickItemPrivate
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItemPrivate();
|
|
|
|
~QQuickCanvasItemPrivate();
|
2012-06-04 06:34:17 +00:00
|
|
|
QQuickCanvasContext *context;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QSizeF canvasSize;
|
|
|
|
QSize tileSize;
|
|
|
|
QRectF canvasWindow;
|
|
|
|
QRectF dirtyRect;
|
|
|
|
uint hasCanvasSize :1;
|
|
|
|
uint hasTileSize :1;
|
|
|
|
uint hasCanvasWindow :1;
|
2012-02-09 05:46:09 +00:00
|
|
|
uint available :1;
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItem::RenderTarget renderTarget;
|
2012-02-09 05:46:09 +00:00
|
|
|
QQuickCanvasItem::RenderStrategy renderStrategy;
|
|
|
|
QString contextType;
|
2012-06-04 06:34:17 +00:00
|
|
|
QHash<QUrl, QQmlRefPointer<QQuickCanvasPixmap> > pixmaps;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl baseUrl;
|
2013-05-08 12:25:40 +00:00
|
|
|
QMap<int, QV4::PersistentValue> animationCallbacks;
|
2011-05-16 00:15:24 +00:00
|
|
|
};
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItemPrivate::QQuickCanvasItemPrivate()
|
|
|
|
: QQuickItemPrivate()
|
2011-05-16 00:15:24 +00:00
|
|
|
, context(0)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
, canvasSize(1, 1)
|
|
|
|
, tileSize(1, 1)
|
|
|
|
, hasCanvasSize(false)
|
|
|
|
, hasTileSize(false)
|
|
|
|
, hasCanvasWindow(false)
|
2012-02-09 05:46:09 +00:00
|
|
|
, available(false)
|
2013-02-26 12:35:46 +00:00
|
|
|
, renderTarget(QQuickCanvasItem::Image)
|
2012-03-06 23:28:27 +00:00
|
|
|
, renderStrategy(QQuickCanvasItem::Cooperative)
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2013-02-26 12:35:46 +00:00
|
|
|
antialiasing = true;
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate()
|
2011-05-30 06:14:42 +00:00
|
|
|
{
|
2012-06-04 06:34:17 +00:00
|
|
|
pixmaps.clear();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
2012-07-27 15:18:12 +00:00
|
|
|
\qmltype Canvas
|
|
|
|
\instantiates QQuickCanvasItem
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
\inqmlmodule QtQuick 2
|
|
|
|
\since QtQuick 2.0
|
|
|
|
\inherits Item
|
2012-05-28 17:40:02 +00:00
|
|
|
\ingroup qtquick-canvas
|
2012-05-28 07:12:56 +00:00
|
|
|
\ingroup qtquick-visual
|
2012-07-11 06:29:42 +00:00
|
|
|
\brief Provides a 2D canvas item enabling drawing via JavaScript
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2011-11-20 23:40:11 +00:00
|
|
|
The Canvas item allows drawing of straight and curved lines, simple and
|
2012-02-09 05:46:09 +00:00
|
|
|
complex shapes, graphs, and referenced graphic images. It can also add
|
|
|
|
text, colors, shadows, gradients, and patterns, and do low level pixel
|
|
|
|
operations. The Canvas output may be saved as an image file or serialized
|
|
|
|
to a URL.
|
|
|
|
|
|
|
|
To define a drawing area in the Canvas item set the \c width and \c height
|
|
|
|
properties. For example, the following code creates a Canvas item which
|
|
|
|
has a drawing area with a height of 100 pixels and width of 200 pixels:
|
2011-09-15 12:17:28 +00:00
|
|
|
\qml
|
|
|
|
import QtQuick 2.0
|
|
|
|
Canvas {
|
2012-02-09 05:46:09 +00:00
|
|
|
id: mycanvas
|
|
|
|
width: 100
|
|
|
|
height: 200
|
2011-09-15 12:17:28 +00:00
|
|
|
}
|
|
|
|
\endqml
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
Currently the Canvas item only supports the two-dimensional rendering context.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2011-11-20 23:40:11 +00:00
|
|
|
\section1 Threaded Rendering and Render Target
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The Canvas item supports two render targets: \c Canvas.Image and
|
|
|
|
\c Canvas.FramebufferObject.
|
2011-11-20 23:40:11 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The \c Canvas.Image render target is a \a QImage object. This render
|
|
|
|
target supports background thread rendering, allowing complex or long
|
|
|
|
running painting to be executed without blocking the UI.
|
2011-11-20 23:40:11 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The Canvas.FramebufferObject render target utilizes OpenGL hardware
|
|
|
|
acceleration rather than rendering into system memory, which in many cases
|
|
|
|
results in faster rendering.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The default render target is Canvas.Image and the default renderStrategy is
|
2013-02-26 13:56:43 +00:00
|
|
|
Canvas.Cooperative.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
\section1 Tiled Canvas
|
2011-11-20 23:40:11 +00:00
|
|
|
The Canvas item supports tiled rendering by setting \l canvasSize, \l tileSize
|
|
|
|
and \l canvasWindow properties.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
Tiling allows efficient display of a very large virtual canvas via a smaller
|
|
|
|
canvas window. The actual memory consumption is in relation to the canvas
|
|
|
|
window size. The painting code can draw within the virtual canvas without
|
|
|
|
handling coordinate system transformations.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The tiles overlapping with the canvas window may be cached eliminating the
|
|
|
|
need to redraw, which can lead to significantly improved performance in
|
|
|
|
some situations.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
|
|
|
\section1 Pixel Operations
|
2012-02-09 05:46:09 +00:00
|
|
|
All HTML5 2D context pixel operations are supported. In order to ensure
|
|
|
|
improved pixel reading/writing performance the \a Canvas.Image render
|
|
|
|
target should be chosen. The \a Canvas.FramebufferObject render target
|
|
|
|
requires the pixel data to be exchanged between the system memory and the
|
|
|
|
graphic card, which is significantly more expensive. Rendering may also be
|
|
|
|
synchronized with the V-sync signal (to avoid
|
2013-05-16 15:53:02 +00:00
|
|
|
\l{http://en.wikipedia.org/wiki/Screen_tearing}{screen tearing}) which will further
|
2012-02-09 05:46:09 +00:00
|
|
|
impact pixel operations with \c Canvas.FrambufferObject render target.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
|
|
|
\section1 Tips for Porting Existing HTML5 Canvas applications
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
Although the Canvas item is provides a HTML5 like API, HTML5 canvas
|
|
|
|
applications need to be modified to run in the Canvas item:
|
2011-09-15 12:17:28 +00:00
|
|
|
\list
|
2012-03-01 17:05:16 +00:00
|
|
|
\li Replace all DOM API calls with QML property bindings or Canvas item methods.
|
2012-08-06 04:21:58 +00:00
|
|
|
\li Replace all HTML event handlers with the MouseArea item.
|
|
|
|
\li Change setInterval/setTimeout function calls with the \l Timer item or
|
|
|
|
the use of requestAnimationFrame().
|
|
|
|
\li Place painting code into the onPaint handler and trigger
|
|
|
|
painting by calling the markDirty() or requestPaint() methods.
|
|
|
|
\li To draw images, load them by calling the Canvas's loadImage() method and then request to paint
|
2011-09-15 12:17:28 +00:00
|
|
|
them in the onImageLoaded handler.
|
|
|
|
\endlist
|
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa Context2D
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItem::QQuickCanvasItem(QQuickItem *parent)
|
|
|
|
: QQuickItem(*(new QQuickCanvasItemPrivate), parent)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
|
|
|
setFlag(ItemHasContents);
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItem::~QQuickCanvasItem()
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
delete d->context;
|
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty size QtQuick2::Canvas::available
|
|
|
|
|
|
|
|
Indicates when Canvas is able to provide a drawing context to operate on.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool QQuickCanvasItem::isAvailable() const
|
|
|
|
{
|
|
|
|
return d_func()->available;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlproperty string QtQuick2::Canvas::contextType
|
|
|
|
The type of drawing context to use.
|
|
|
|
|
|
|
|
This property is set to the name of the active context type.
|
|
|
|
|
|
|
|
If set explicitly the canvas will attempt to create a context of the
|
|
|
|
named type after becoming available.
|
|
|
|
|
|
|
|
The type name is the same as used in the getContext() call, for the 2d
|
|
|
|
canvas the value will be "2d".
|
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa getContext(), available
|
2012-02-09 05:46:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
QString QQuickCanvasItem::contextType() const
|
|
|
|
{
|
|
|
|
return d_func()->contextType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QQuickCanvasItem::setContextType(const QString &contextType)
|
|
|
|
{
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
|
|
|
if (contextType.compare(d->contextType, Qt::CaseInsensitive) == 0)
|
|
|
|
return;
|
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context) {
|
2012-02-09 05:46:09 +00:00
|
|
|
qmlInfo(this) << "Canvas already initialized with a different context type";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->contextType = contextType;
|
|
|
|
|
|
|
|
if (d->available)
|
|
|
|
createContext(contextType);
|
|
|
|
|
|
|
|
emit contextTypeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlproperty object QtQuick2::Canvas::context
|
|
|
|
Holds the active drawing context.
|
|
|
|
|
|
|
|
If the canvas is ready and there has been a successful call to getContext()
|
|
|
|
or the contextType property has been set with a supported context type,
|
|
|
|
this property will contain the current drawing context, otherwise null.
|
|
|
|
*/
|
|
|
|
|
2013-04-19 08:59:41 +00:00
|
|
|
QQmlV4Handle QQuickCanvasItem::context() const
|
2012-02-09 05:46:09 +00:00
|
|
|
{
|
|
|
|
Q_D(const QQuickCanvasItem);
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context)
|
2013-05-10 11:48:47 +00:00
|
|
|
return QQmlV4Handle(d->context->v4value());
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2013-05-08 13:56:03 +00:00
|
|
|
return QQmlV4Handle(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty size QtQuick2::Canvas::canvasSize
|
2012-02-09 05:46:09 +00:00
|
|
|
Holds the logical canvas size that the context paints on.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
By default, the canvas size is the same size as the current canvas item
|
|
|
|
size.
|
|
|
|
|
|
|
|
By setting the canvasSize, tileSize and canvasWindow, the Canvas item can
|
2012-08-06 04:21:58 +00:00
|
|
|
act as a large virtual canvas with many separately rendered tile rectangles.
|
2012-02-09 05:46:09 +00:00
|
|
|
Only those tiles within the current canvas window are painted by the Canvas
|
|
|
|
render engine.
|
2011-11-20 23:40:11 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa tileSize, canvasWindow
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
QSizeF QQuickCanvasItem::canvasSize() const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return d->canvasSize;
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::setCanvasSize(const QSizeF & size)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
if (d->canvasSize != size) {
|
|
|
|
d->hasCanvasSize = true;
|
|
|
|
d->canvasSize = size;
|
|
|
|
emit canvasSizeChanged();
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context)
|
2012-02-09 05:46:09 +00:00
|
|
|
polish();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-05-30 06:14:42 +00:00
|
|
|
}
|
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
|
|
|
\qmlproperty size QtQuick2::Canvas::tileSize
|
2012-02-09 05:46:09 +00:00
|
|
|
Holds the canvas rendering tile size.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
The Canvas item enters tiled mode by setting canvasSize, tileSize and the
|
|
|
|
canvasWindow. This can improve rendering performance by rendering and
|
|
|
|
caching tiles instead of rendering the whole canvas every time.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
Memory will be consumed only by those tiles within the current visible
|
|
|
|
region.
|
2011-11-20 23:40:11 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
By default the tileSize is the same as the canvasSize.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa canvasSize, canvasWindow
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
QSize QQuickCanvasItem::tileSize() const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return d->tileSize;
|
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::setTileSize(const QSize & size)
|
2011-07-11 23:21:27 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
if (d->tileSize != size) {
|
|
|
|
d->hasTileSize = true;
|
|
|
|
d->tileSize = size;
|
|
|
|
|
|
|
|
emit tileSizeChanged();
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context)
|
2012-02-09 05:46:09 +00:00
|
|
|
polish();
|
2011-07-11 23:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlproperty rect QtQuick2::Canvas::canvasWindow
|
|
|
|
Holds the current canvas visible window.
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
By default the canvasWindow size is the same as the Canvas item size with
|
|
|
|
the top-left point as (0, 0).
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
If the canvasSize is different to the Canvas item size, the Canvas item
|
|
|
|
can display different visible areas by changing the canvas windowSize
|
2011-09-15 12:17:28 +00:00
|
|
|
and/or position.
|
2011-11-20 23:40:11 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa canvasSize, tileSize
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
QRectF QQuickCanvasItem::canvasWindow() const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return d->canvasWindow;
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::setCanvasWindow(const QRectF& rect)
|
2011-07-11 23:21:27 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
if (d->canvasWindow != rect) {
|
|
|
|
d->canvasWindow = rect;
|
|
|
|
|
|
|
|
d->hasCanvasWindow = true;
|
|
|
|
emit canvasWindowChanged();
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context)
|
2012-02-09 05:46:09 +00:00
|
|
|
polish();
|
2011-07-11 23:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-05-21 04:50:40 +00:00
|
|
|
\qmlproperty enumeration QtQuick2::Canvas::renderTarget
|
2012-02-09 05:46:09 +00:00
|
|
|
Holds the current canvas render target.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
\list
|
2012-03-01 17:05:16 +00:00
|
|
|
\li Canvas.Image - render to an in memory image buffer.
|
|
|
|
\li Canvas.FramebufferObject - render to an OpenGL frame buffer
|
2012-02-09 05:46:09 +00:00
|
|
|
\endlist
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
This hint is supplied along with renderStrategy to the graphics context to
|
|
|
|
determine the method of rendering. A renderStrategy, renderTarget or a
|
|
|
|
combination may not be supported by a graphics context, in which case the
|
|
|
|
context will choose appropriate options and Canvas will signal the change
|
|
|
|
to the properties.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-03-06 23:28:27 +00:00
|
|
|
The default render target is \c Canvas.FramebufferObject.
|
2011-09-15 12:17:28 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickCanvasItem::RenderTarget QQuickCanvasItem::renderTarget() const
|
2011-07-11 23:21:27 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return d->renderTarget;
|
2011-07-11 23:21:27 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::setRenderTarget(QQuickCanvasItem::RenderTarget target)
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
if (d->renderTarget != target) {
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context) {
|
2012-05-04 01:18:08 +00:00
|
|
|
qmlInfo(this) << "Canvas:renderTarget not changeble once context is active.";
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
2012-05-04 01:18:08 +00:00
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
d->renderTarget = target;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
emit renderTargetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
/*!
|
2012-05-21 04:50:40 +00:00
|
|
|
\qmlproperty enumeration QtQuick2::Canvas::renderStrategy
|
2012-02-09 05:46:09 +00:00
|
|
|
Holds the current canvas rendering strategy.
|
|
|
|
|
|
|
|
\list
|
2012-03-01 17:05:16 +00:00
|
|
|
\li Canvas.Immediate - context will perform graphics commands immediately in the main UI thread.
|
|
|
|
\li Canvas.Threaded - context will defer graphics commands to a private rendering thread.
|
|
|
|
\li Canvas.Cooperative - context will defer graphics commands to the applications global render thread.
|
2012-02-09 05:46:09 +00:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
This hint is supplied along with renderTarget to the graphics context to
|
|
|
|
determine the method of rendering. A renderStrategy, renderTarget or a
|
|
|
|
combination may not be supported by a graphics context, in which case the
|
|
|
|
context will choose appropriate options and Canvas will signal the change
|
|
|
|
to the properties.
|
|
|
|
|
|
|
|
Configuration or runtime tests may cause the QML Scene Graph to render in
|
|
|
|
the GUI thread. Selecting \c Canvas.Cooperative, does not guarantee
|
|
|
|
rendering will occur on a thread separate from the GUI thread.
|
|
|
|
|
2012-03-06 23:28:27 +00:00
|
|
|
The default value is \c Canvas.Cooperative.
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa renderTarget
|
2012-02-09 05:46:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
QQuickCanvasItem::RenderStrategy QQuickCanvasItem::renderStrategy() const
|
|
|
|
{
|
|
|
|
return d_func()->renderStrategy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QQuickCanvasItem::setRenderStrategy(QQuickCanvasItem::RenderStrategy strategy)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2012-02-09 05:46:09 +00:00
|
|
|
if (d->renderStrategy != strategy) {
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context) {
|
2012-05-04 01:18:08 +00:00
|
|
|
qmlInfo(this) << "Canvas:renderStrategy not changeable once context is active.";
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
2012-05-04 01:18:08 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
d->renderStrategy = strategy;
|
|
|
|
emit renderStrategyChanged();
|
|
|
|
}
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
QQuickCanvasContext* QQuickCanvasItem::rawContext() const
|
|
|
|
{
|
|
|
|
return d_func()->context;
|
|
|
|
}
|
|
|
|
|
2012-04-02 00:02:28 +00:00
|
|
|
bool QQuickCanvasItem::isPaintConnected()
|
|
|
|
{
|
2012-06-03 18:30:49 +00:00
|
|
|
IS_SIGNAL_CONNECTED(this, QQuickCanvasItem, paint, (const QRect &));
|
2012-04-02 00:02:28 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::sceneGraphInitialized()
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
d->available = true;
|
|
|
|
connect(this, SIGNAL(visibleChanged()), SLOT(checkAnimationCallbacks()));
|
|
|
|
QMetaObject::invokeMethod(this, "availableChanged", Qt::QueuedConnection);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
if (!d->contextType.isNull())
|
|
|
|
QMetaObject::invokeMethod(this, "delayedCreate", Qt::QueuedConnection);
|
2012-04-02 00:02:28 +00:00
|
|
|
else if (isPaintConnected())
|
2012-02-09 05:46:09 +00:00
|
|
|
QMetaObject::invokeMethod(this, "requestPaint", Qt::QueuedConnection);
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-03-06 23:34:18 +00:00
|
|
|
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-03-06 23:34:18 +00:00
|
|
|
QSizeF newSize = newGeometry.size();
|
|
|
|
if (!d->hasCanvasSize && d->canvasSize != newSize) {
|
|
|
|
d->canvasSize = newSize;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
emit canvasSizeChanged();
|
|
|
|
}
|
|
|
|
|
2012-03-06 23:34:18 +00:00
|
|
|
if (!d->hasTileSize && d->tileSize != newSize) {
|
|
|
|
d->tileSize = newSize.toSize();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
emit tileSizeChanged();
|
|
|
|
}
|
2011-05-16 00:15:24 +00:00
|
|
|
|
2012-03-06 23:34:18 +00:00
|
|
|
const QRectF rect = QRectF(QPointF(0, 0), newSize);
|
|
|
|
|
|
|
|
if (!d->hasCanvasWindow && d->canvasWindow != rect) {
|
|
|
|
d->canvasWindow = rect;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
emit canvasWindowChanged();
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2013-08-15 13:04:01 +00:00
|
|
|
if (d->available && newSize != oldGeometry.size())
|
2012-03-06 23:34:18 +00:00
|
|
|
requestPaint();
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 21:09:07 +00:00
|
|
|
void QQuickCanvasItem::releaseResources()
|
|
|
|
{
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
|
|
|
if (d->context) {
|
|
|
|
delete d->context;
|
|
|
|
d->context = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::componentComplete()
|
2011-06-24 01:10:34 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickItem::componentComplete();
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
d->baseUrl = qmlEngine(this)->contextForObject(this)->baseUrl();
|
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2012-02-09 05:46:09 +00:00
|
|
|
QQuickItem::itemChange(change, value);
|
|
|
|
if (change != QQuickItem::ItemSceneChange)
|
|
|
|
return;
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2013-06-25 11:37:30 +00:00
|
|
|
if (d->available) {
|
|
|
|
if (d->dirtyAttributes & QQuickItemPrivate::ContentUpdateMask)
|
|
|
|
requestPaint();
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
2013-06-25 11:37:30 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2012-07-11 07:32:16 +00:00
|
|
|
if (value.window== 0)
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-11 07:32:16 +00:00
|
|
|
d->window = value.window;
|
|
|
|
if (d->window->openglContext() != 0) // available context == initialized
|
2012-02-09 05:46:09 +00:00
|
|
|
sceneGraphInitialized();
|
|
|
|
else
|
2012-07-11 07:32:16 +00:00
|
|
|
connect(d->window, SIGNAL(sceneGraphInitialized()), SLOT(sceneGraphInitialized()));
|
2012-02-09 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QQuickCanvasItem::updatePolish()
|
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickItem::updatePolish();
|
2012-02-09 05:46:09 +00:00
|
|
|
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
2013-06-12 14:30:05 +00:00
|
|
|
if (d->context && d->renderStrategy != QQuickCanvasItem::Cooperative)
|
2012-08-27 01:36:42 +00:00
|
|
|
d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing);
|
2012-02-09 05:46:09 +00:00
|
|
|
|
|
|
|
if (d->animationCallbacks.size() > 0 && isVisible()) {
|
2013-05-08 12:25:40 +00:00
|
|
|
QMap<int, QV4::PersistentValue> animationCallbacks = d->animationCallbacks;
|
2012-02-09 05:46:09 +00:00
|
|
|
d->animationCallbacks.clear();
|
|
|
|
|
2013-09-11 12:36:01 +00:00
|
|
|
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(qmlEngine(this));
|
2013-09-11 12:47:34 +00:00
|
|
|
QV4::Scope scope(v4);
|
2013-09-11 12:36:01 +00:00
|
|
|
QV4::ScopedCallData callData(scope, 1);
|
2013-09-12 20:37:41 +00:00
|
|
|
callData->thisObject = QV4::Value::fromReturnedValue(QV4::QObjectWrapper::wrap(v4, this));
|
2013-09-11 12:36:01 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
foreach (int key, animationCallbacks.keys()) {
|
2013-05-08 12:25:40 +00:00
|
|
|
QV4::FunctionObject *f = animationCallbacks.value(key).value().asFunctionObject();
|
2013-09-05 11:22:23 +00:00
|
|
|
callData->args[0] = QV4::Value::fromUInt32(QDateTime::currentDateTimeUtc().toTime_t());
|
|
|
|
f->call(callData);
|
2012-02-09 05:46:09 +00:00
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
else {
|
|
|
|
if (d->dirtyRect.isValid()) {
|
|
|
|
if (d->hasTileSize && d->hasCanvasWindow)
|
|
|
|
emit paint(tiledRect(d->canvasWindow.intersected(d->dirtyRect.toAlignedRect()), d->tileSize));
|
|
|
|
else
|
|
|
|
emit paint(d->dirtyRect.toRect());
|
|
|
|
d->dirtyRect = QRectF();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context) {
|
2012-03-02 06:28:16 +00:00
|
|
|
if (d->renderStrategy == QQuickCanvasItem::Cooperative)
|
|
|
|
update();
|
|
|
|
else
|
|
|
|
d->context->flush();
|
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2013-06-12 14:35:46 +00:00
|
|
|
if (!d->context || d->canvasWindow.size().isEmpty()) {
|
2013-04-23 07:38:19 +00:00
|
|
|
delete oldNode;
|
2012-02-09 05:46:09 +00:00
|
|
|
return 0;
|
2013-04-23 07:38:19 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2012-06-05 21:09:07 +00:00
|
|
|
QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode*>(oldNode);
|
|
|
|
if (!node)
|
|
|
|
node = new QSGSimpleTextureNode;
|
2012-02-09 05:46:09 +00:00
|
|
|
|
2012-08-27 01:36:42 +00:00
|
|
|
if (d->smooth)
|
|
|
|
node->setFiltering(QSGTexture::Linear);
|
|
|
|
else
|
|
|
|
node->setFiltering(QSGTexture::Nearest);
|
|
|
|
|
2013-06-12 14:30:05 +00:00
|
|
|
if (d->renderStrategy == QQuickCanvasItem::Cooperative) {
|
|
|
|
d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing);
|
2012-03-02 06:28:16 +00:00
|
|
|
d->context->flush();
|
2013-06-12 14:30:05 +00:00
|
|
|
}
|
2012-02-17 03:52:09 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
node->setTexture(d->context->texture());
|
2013-04-25 10:34:29 +00:00
|
|
|
node->markDirty(QSGNode::DirtyMaterial);
|
2012-03-02 06:24:04 +00:00
|
|
|
node->setRect(QRectF(QPoint(0, 0), d->canvasWindow.size()));
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
/*!
|
|
|
|
\qmlmethod object QtQuick2::Canvas::getContext(string contextId, any... args)
|
|
|
|
|
|
|
|
Returns a drawing context or null if no context available.
|
|
|
|
|
2012-07-11 06:29:42 +00:00
|
|
|
The \a contextId parameter names the required context. The Canvas item
|
2012-02-09 05:46:09 +00:00
|
|
|
will return a context that implements the required drawing mode. After the
|
|
|
|
first call to getContext any subsequent call to getContext with the same
|
|
|
|
contextId will return the same context object.
|
|
|
|
|
|
|
|
If the context type is not supported or the canvas has previously been
|
|
|
|
requested to provide a different and incompatible context type, null will
|
|
|
|
be returned.
|
|
|
|
|
|
|
|
Canvas only supports a 2d context.
|
|
|
|
*/
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
void QQuickCanvasItem::getContext(QQmlV4Function *args)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
if (args->length() < 1 || !(*args)[0].isString()) {
|
2012-02-09 05:46:09 +00:00
|
|
|
qmlInfo(this) << "getContext should be called with a string naming the required context type";
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
if (!d->available) {
|
|
|
|
qmlInfo(this) << "Unable to use getContext() at this time, please wait for available: true";
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2013-09-09 12:33:28 +00:00
|
|
|
QString contextId = (*args)[0].toQStringNoThrow();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
if (d->context != 0) {
|
|
|
|
if (d->context->contextNames().contains(contextId, Qt::CaseInsensitive)) {
|
2013-05-10 11:48:47 +00:00
|
|
|
args->setReturnValue(d->context->v4value());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
}
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
qmlInfo(this) << "Canvas already initialized with a different context type";
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
|
|
|
|
if (createContext(contextId))
|
2013-05-10 11:48:47 +00:00
|
|
|
args->setReturnValue(d->context->v4value());
|
2012-02-09 05:46:09 +00:00
|
|
|
else
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2011-06-24 01:10:34 +00:00
|
|
|
}
|
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
/*!
|
|
|
|
\qmlmethod long QtQuick2::Canvas::requestAnimationFrame(callback)
|
|
|
|
|
2013-04-23 14:19:05 +00:00
|
|
|
This function schedules callback to be invoked before composing the Qt Quick
|
2012-02-09 05:46:09 +00:00
|
|
|
scene.
|
|
|
|
*/
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
void QQuickCanvasItem::requestAnimationFrame(QQmlV4Function *args)
|
2011-07-11 23:21:27 +00:00
|
|
|
{
|
2013-05-08 14:22:39 +00:00
|
|
|
if (args->length() < 1 || !(*args)[0].asFunctionObject()) {
|
2012-02-09 05:46:09 +00:00
|
|
|
qmlInfo(this) << "requestAnimationFrame should be called with an animation callback function";
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
static int id = 0;
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
d->animationCallbacks.insert(++id, QV4::PersistentValue((*args)[0]));
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
if (isVisible())
|
|
|
|
polish();
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::fromInt32(id));
|
2011-07-11 23:21:27 +00:00
|
|
|
}
|
2011-06-24 01:10:34 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::cancelRequestAnimationFrame(long handle)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
This function will cancel the animation callback referenced by \a handle.
|
|
|
|
*/
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
void QQuickCanvasItem::cancelRequestAnimationFrame(QQmlV4Function *args)
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2013-05-08 14:22:39 +00:00
|
|
|
if (args->length() < 1 || !(*args)[0].isInteger()) {
|
2012-02-09 05:46:09 +00:00
|
|
|
qmlInfo(this) << "cancelRequestAnimationFrame should be called with an animation callback id";
|
2013-05-08 14:22:39 +00:00
|
|
|
args->setReturnValue(QV4::Value::nullValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-08 14:22:39 +00:00
|
|
|
d_func()->animationCallbacks.remove((*args)[0].integerValue());
|
2012-02-09 05:46:09 +00:00
|
|
|
}
|
2011-10-04 07:12:12 +00:00
|
|
|
|
2011-06-09 02:35:34 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::requestPaint()
|
2012-02-09 05:46:09 +00:00
|
|
|
|
|
|
|
Request the entire visible region be re-drawn.
|
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa markDirty()
|
2012-02-09 05:46:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void QQuickCanvasItem::requestPaint()
|
|
|
|
{
|
|
|
|
markDirty(d_func()->canvasWindow);
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::markDirty(rect area)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
Mark the given \a area as dirty, so that when this area is visible the
|
2012-08-06 04:21:58 +00:00
|
|
|
canvas renderer will redraw it. This will trigger the onPaint signal
|
2011-11-20 23:40:11 +00:00
|
|
|
handler function.
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa paint, requestPaint()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2012-02-09 05:46:09 +00:00
|
|
|
|
|
|
|
void QQuickCanvasItem::markDirty(const QRectF& rect)
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2012-02-09 05:46:09 +00:00
|
|
|
if (!d->available)
|
|
|
|
return;
|
|
|
|
|
|
|
|
d->dirtyRect |= rect;
|
|
|
|
|
|
|
|
polish();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::checkAnimationCallbacks()
|
|
|
|
{
|
|
|
|
if (d_func()->animationCallbacks.size() > 0 && isVisible())
|
|
|
|
polish();
|
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
|
|
|
\qmlmethod bool QtQuick2::Canvas::save(string filename)
|
2011-07-11 23:21:27 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
Save the current canvas content into an image file \a filename.
|
|
|
|
The saved image format is automatically decided by the \a filename's
|
|
|
|
suffix.
|
|
|
|
|
2011-11-20 23:40:11 +00:00
|
|
|
Note: calling this method will force painting the whole canvas, not just the
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
current canvas visible window.
|
2011-05-16 00:15:24 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa canvasWindow, canvasSize, toDataURL()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
bool QQuickCanvasItem::save(const QString &filename) const
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
2011-10-04 07:12:12 +00:00
|
|
|
QUrl url = d->baseUrl.resolved(QUrl::fromLocalFile(filename));
|
|
|
|
return toImage().save(url.toLocalFile());
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 06:34:17 +00:00
|
|
|
QQmlRefPointer<QQuickCanvasPixmap> QQuickCanvasItem::loadedPixmap(const QUrl& url)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl fullPathUrl = d->baseUrl.resolved(url);
|
2012-06-04 06:34:17 +00:00
|
|
|
if (!d->pixmaps.contains(fullPathUrl)) {
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
loadImage(url);
|
|
|
|
}
|
2012-06-04 06:34:17 +00:00
|
|
|
return d->pixmaps.value(fullPathUrl);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-09-15 12:17:28 +00:00
|
|
|
|
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlsignal QtQuick2::Canvas::onImageLoaded()
|
|
|
|
|
|
|
|
This handler is called when an image has been loaded.
|
|
|
|
|
|
|
|
\sa loadImage()
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlmethod QtQuick2::Canvas::loadImage(url image)
|
2011-11-20 23:40:11 +00:00
|
|
|
Loads the given \c image asynchronously.
|
|
|
|
|
|
|
|
When the image is ready, onImageLoaded will be emitted.
|
2012-08-06 04:21:58 +00:00
|
|
|
The loaded image can be unloaded by the unloadImage() method.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
|
|
|
Note: Only loaded images can be painted on the Canvas item.
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa unloadImage, onImageLoaded, isImageLoaded(),
|
|
|
|
Context2D::createImageData(), Context2D::drawImage()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::loadImage(const QUrl& url)
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl fullPathUrl = d->baseUrl.resolved(url);
|
2012-06-04 06:34:17 +00:00
|
|
|
if (!d->pixmaps.contains(fullPathUrl)) {
|
2012-02-16 04:43:03 +00:00
|
|
|
QQuickPixmap* pix = new QQuickPixmap();
|
2012-06-04 06:34:17 +00:00
|
|
|
QQmlRefPointer<QQuickCanvasPixmap> canvasPix;
|
2012-07-11 07:32:16 +00:00
|
|
|
canvasPix.take(new QQuickCanvasPixmap(pix, d->window));
|
2012-06-04 06:34:17 +00:00
|
|
|
d->pixmaps.insert(fullPathUrl, canvasPix);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
|
|
|
|
pix->load(qmlEngine(this)
|
|
|
|
, fullPathUrl
|
2012-02-16 04:43:03 +00:00
|
|
|
, QQuickPixmap::Cache | QQuickPixmap::Asynchronous);
|
2011-12-07 03:04:20 +00:00
|
|
|
if (pix->isLoading())
|
|
|
|
pix->connectFinished(this, SIGNAL(imageLoaded()));
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::unloadImage(url image)
|
2011-09-15 12:17:28 +00:00
|
|
|
Unloads the \c image.
|
|
|
|
|
2011-11-20 23:40:11 +00:00
|
|
|
Once an image is unloaded it cannot be painted by the canvas context
|
|
|
|
unless it is loaded again.
|
2011-05-16 00:15:24 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa loadImage(), onImageLoaded, isImageLoaded(),
|
|
|
|
Context2D::createImageData(), Context2D::drawImage
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
void QQuickCanvasItem::unloadImage(const QUrl& url)
|
2011-07-11 23:21:27 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(QQuickCanvasItem);
|
2012-06-04 06:34:17 +00:00
|
|
|
d->pixmaps.remove(d->baseUrl.resolved(url));
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::isImageError(url image)
|
2011-11-20 23:40:11 +00:00
|
|
|
Returns true if the \a image failed to load.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa loadImage()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
bool QQuickCanvasItem::isImageError(const QUrl& url) const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl fullPathUrl = d->baseUrl.resolved(url);
|
2012-06-04 06:34:17 +00:00
|
|
|
return d->pixmaps.contains(fullPathUrl)
|
|
|
|
&& d->pixmaps.value(fullPathUrl)->pixmap()->isError();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::isImageLoading(url image)
|
2011-11-20 23:40:11 +00:00
|
|
|
Returns true if the \a image is currently loading.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa loadImage()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
bool QQuickCanvasItem::isImageLoading(const QUrl& url) const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl fullPathUrl = d->baseUrl.resolved(url);
|
2012-06-04 06:34:17 +00:00
|
|
|
return d->pixmaps.contains(fullPathUrl)
|
|
|
|
&& d->pixmaps.value(fullPathUrl)->pixmap()->isLoading();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-08-06 04:21:58 +00:00
|
|
|
\qmlmethod QtQuick2::Canvas::isImageLoaded(url image)
|
2012-09-06 21:44:08 +00:00
|
|
|
Returns true if the \a image is successfully loaded and ready to use.
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa loadImage()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
bool QQuickCanvasItem::isImageLoaded(const QUrl& url) const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QUrl fullPathUrl = d->baseUrl.resolved(url);
|
2012-06-04 06:34:17 +00:00
|
|
|
return d->pixmaps.contains(fullPathUrl)
|
|
|
|
&& d->pixmaps.value(fullPathUrl)->pixmap()->isReady();
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
QImage QQuickCanvasItem::toImage(const QRectF& rect) const
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
{
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_D(const QQuickCanvasItem);
|
2013-04-23 07:38:19 +00:00
|
|
|
if (d->context) {
|
2012-02-09 05:46:09 +00:00
|
|
|
if (rect.isEmpty())
|
|
|
|
return d->context->toImage(canvasWindow());
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
else
|
2012-02-09 05:46:09 +00:00
|
|
|
return d->context->toImage(rect);
|
2011-07-11 23:21:27 +00:00
|
|
|
}
|
2012-02-09 05:46:09 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return QImage();
|
|
|
|
}
|
2011-07-11 23:21:27 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
/*!
|
|
|
|
\qmlmethod string QtQuick2::Canvas::toDataURL(string mimeType)
|
2011-07-11 23:21:27 +00:00
|
|
|
|
2011-11-20 23:40:11 +00:00
|
|
|
Returns a data URL for the image in the canvas.
|
2011-07-11 23:21:27 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
The default \a mimeType is "image/png".
|
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
\sa save()
|
2012-05-10 11:20:35 +00:00
|
|
|
*/
|
2011-10-14 08:51:42 +00:00
|
|
|
QString QQuickCanvasItem::toDataURL(const QString& mimeType) const
|
2011-05-16 00:15:24 +00:00
|
|
|
{
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
QImage image = toImage();
|
2011-05-16 00:15:24 +00:00
|
|
|
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
if (!image.isNull()) {
|
2011-05-16 00:15:24 +00:00
|
|
|
QByteArray ba;
|
|
|
|
QBuffer buffer(&ba);
|
|
|
|
buffer.open(QIODevice::WriteOnly);
|
2011-10-04 07:12:12 +00:00
|
|
|
QString mime = mimeType.toLower();
|
2011-05-16 00:15:24 +00:00
|
|
|
QString type;
|
2012-04-24 03:22:22 +00:00
|
|
|
if (mime == QLatin1String("image/png")) {
|
|
|
|
type = QStringLiteral("PNG");
|
|
|
|
} else if (mime == QLatin1String("image/bmp"))
|
|
|
|
type = QStringLiteral("BMP");
|
|
|
|
else if (mime == QLatin1String("image/jpeg"))
|
|
|
|
type = QStringLiteral("JPEG");
|
|
|
|
else if (mime == QLatin1String("image/x-portable-pixmap"))
|
|
|
|
type = QStringLiteral("PPM");
|
|
|
|
else if (mime == QLatin1String("image/tiff"))
|
|
|
|
type = QStringLiteral("TIFF");
|
|
|
|
else if (mime == QLatin1String("image/xpm"))
|
|
|
|
type = QStringLiteral("XPM");
|
2011-10-04 07:12:12 +00:00
|
|
|
else
|
2012-04-24 03:22:22 +00:00
|
|
|
return QStringLiteral("data:,");
|
2011-10-04 07:12:12 +00:00
|
|
|
|
2012-05-03 12:42:53 +00:00
|
|
|
image.save(&buffer, type.toLatin1());
|
2011-05-16 00:15:24 +00:00
|
|
|
buffer.close();
|
2012-04-24 03:22:22 +00:00
|
|
|
QString dataUrl = QStringLiteral("data:%1;base64,%2");
|
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>
2011-08-09 06:44:38 +00:00
|
|
|
return dataUrl.arg(mime).arg(QLatin1String(ba.toBase64().constData()));
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
2012-04-24 03:22:22 +00:00
|
|
|
return QStringLiteral("data:,");
|
2011-05-16 00:15:24 +00:00
|
|
|
}
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
void QQuickCanvasItem::delayedCreate()
|
|
|
|
{
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
2013-04-23 07:38:19 +00:00
|
|
|
if (!d->context && !d->contextType.isNull())
|
2012-02-09 05:46:09 +00:00
|
|
|
createContext(d->contextType);
|
|
|
|
|
|
|
|
requestPaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QQuickCanvasItem::createContext(const QString &contextType)
|
|
|
|
{
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
|
|
|
if (contextType == QLatin1String("2d")) {
|
2012-02-15 09:23:33 +00:00
|
|
|
if (d->contextType.compare(QLatin1String("2d"), Qt::CaseInsensitive) != 0) {
|
2012-02-09 05:46:09 +00:00
|
|
|
d->contextType = QLatin1String("2d");
|
|
|
|
emit contextTypeChanged(); // XXX: can't be in setContextType()
|
|
|
|
}
|
|
|
|
initializeContext(new QQuickContext2D(this));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QQuickCanvasItem::initializeContext(QQuickCanvasContext *context, const QVariantMap &args)
|
|
|
|
{
|
|
|
|
Q_D(QQuickCanvasItem);
|
|
|
|
|
|
|
|
d->context = context;
|
|
|
|
d->context->init(this, args);
|
2012-02-16 04:43:03 +00:00
|
|
|
d->context->setV8Engine(QQmlEnginePrivate::getV8Engine(qmlEngine(this)));
|
2012-02-09 05:46:09 +00:00
|
|
|
connect(d->context, SIGNAL(textureChanged()), SLOT(update()));
|
|
|
|
connect(d->context, SIGNAL(textureChanged()), SIGNAL(painted()));
|
|
|
|
emit contextChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect QQuickCanvasItem::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);
|
|
|
|
}
|
|
|
|
|
2011-09-15 12:17:28 +00:00
|
|
|
/*!
|
2012-02-09 05:46:09 +00:00
|
|
|
\qmlsignal QtQuick2::Canvas::onPaint(rect region)
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-02-09 05:46:09 +00:00
|
|
|
This handler is called to render the \a region. If a context is active it
|
|
|
|
can be referenced from the context property.
|
2011-09-15 12:17:28 +00:00
|
|
|
|
2012-08-06 04:21:58 +00:00
|
|
|
This signal can be triggered markdirty(), requestPaint() or by changing
|
|
|
|
the current canvas window.
|
2011-09-15 12:17:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmlsignal QtQuick2::Canvas::onPainted()
|
|
|
|
|
|
|
|
This handler is called after all context painting commands are executed and
|
2011-11-20 23:40:11 +00:00
|
|
|
the Canvas has been rendered.
|
2011-09-15 12:17:28 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-03 18:30:49 +00:00
|
|
|
QT_END_NAMESPACE
|