Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tests for canvas and a few bug fixes
Change-Id: Icbbc7f2a0fe3b908963ce18afef51e25ea0170a0
Reviewed-on: http://codereview.qt-project.org/5805
Reviewed-by: Charles Yin <charles.yin@nokia.com>
  • Loading branch information
yinyunqiao authored and Qt by Nokia committed Sep 30, 2011
1 parent 20fb62f commit 8f69461
Show file tree
Hide file tree
Showing 25 changed files with 643 additions and 295 deletions.
2 changes: 1 addition & 1 deletion examples/declarative/canvas/bezierCurve/bezierCurve.qml
Expand Up @@ -120,4 +120,4 @@ Item {
}
}
}
}
}
Expand Up @@ -124,4 +124,4 @@ Item {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/declarative/canvas/roundedrect/roundedrect.qml
Expand Up @@ -121,4 +121,4 @@ Item {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/declarative/canvas/smile/smile.qml
Expand Up @@ -124,4 +124,4 @@ Item {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/declarative/canvas/squircle/squircle.qml
Expand Up @@ -151,4 +151,4 @@ Item {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/declarative/canvas/tiger/tiger.qml
Expand Up @@ -125,4 +125,4 @@ Item {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/declarative/canvas/twitterfriends/TwitterUser.qml
Expand Up @@ -291,4 +291,4 @@ Item {
x.send();
}
}
}
}
22 changes: 15 additions & 7 deletions src/declarative/items/context2d/qsgcanvasitem.cpp
Expand Up @@ -216,6 +216,7 @@ void QSGCanvasItem::setCanvasSize(const QSizeF & size)
d->canvasSize = size;
emit canvasSizeChanged();
polish();
update();
}
}

Expand Down Expand Up @@ -249,6 +250,7 @@ void QSGCanvasItem::setTileSize(const QSize & size)

emit tileSizeChanged();
polish();
update();
}
}

Expand Down Expand Up @@ -279,6 +281,7 @@ void QSGCanvasItem::setCanvasWindow(const QRectF& rect)
d->hasCanvasWindow = true;
emit canvasWindowChanged();
polish();
update();
}
}

Expand Down Expand Up @@ -378,6 +381,7 @@ void QSGCanvasItem::setRenderInThread(bool renderInThread)
disconnect(this, SIGNAL(painted()), this, SLOT(update()));
emit renderInThreadChanged();
polish();
update();
}
}

Expand Down Expand Up @@ -406,26 +410,29 @@ void QSGCanvasItem::geometryChanged(const QRectF &newGeometry,
}

polish();
update();
}

void QSGCanvasItem::componentComplete()
{
Q_D(QSGCanvasItem);

createContext();
if (!d->context)
createContext();
createTexture();

markDirty(d->canvasWindow);

_doPainting(canvasWindow());
QSGItem::componentComplete();

d->baseUrl = qmlEngine(this)->contextForObject(this)->baseUrl();
d->componentCompleted = true;
update();
}

void QSGCanvasItem::updatePolish()
{
Q_D(QSGCanvasItem);

QSGItem::updatePolish();
if (d->texture) {
if (!d->renderInThread && d->dirtyRect.isValid())
Expand Down Expand Up @@ -507,9 +514,9 @@ QDeclarativeV8Handle QSGCanvasItem::getContext(const QString &contextId)
Q_D(QSGCanvasItem);
Q_UNUSED(contextId);

if (d->context)
return QDeclarativeV8Handle::fromHandle(d->context->v8value());
return QDeclarativeV8Handle::fromHandle(v8::Undefined());
if (!d->context)
createContext();
return QDeclarativeV8Handle::fromHandle(d->context->v8value());
}

/*!
Expand All @@ -527,6 +534,7 @@ void QSGCanvasItem::markDirty(const QRectF& region)
Q_D(QSGCanvasItem);
d->dirtyRect |= region;
polish();
update();
}


Expand Down Expand Up @@ -717,4 +725,4 @@ QString QSGCanvasItem::toDataURL(const QString& mimeType) const
the Canvas is actually rendered.
*/

QT_END_NAMESPACE
QT_END_NAMESPACE
6 changes: 2 additions & 4 deletions src/declarative/items/context2d/qsgcanvasitem_p.h
Expand Up @@ -45,16 +45,14 @@
#include "qsgitem.h"
#include <private/qv8engine_p.h>



QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)
class QSGContext2D;
class QSGCanvasItemPrivate;
class QSGCanvasItem : public QSGItem
class Q_DECLARATIVE_EXPORT QSGCanvasItem : public QSGItem
{
Q_OBJECT
Q_ENUMS(RenderTarget)
Expand Down Expand Up @@ -147,4 +145,4 @@ QML_DECLARE_TYPE(QSGCanvasItem)

QT_END_HEADER

#endif //QSGCANVASITEM_P_H
#endif //QSGCANVASITEM_P_H

0 comments on commit 8f69461

Please sign in to comment.