summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfximage.cpp9
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp30
-rw-r--r--src/declarative/fx/qfxpainteditem.h7
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h3
-rw-r--r--src/declarative/fx/qfxwebview.cpp7
-rw-r--r--src/declarative/fx/qfxwebview.h1
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp6
7 files changed, 47 insertions, 16 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 40389c4..58d597a 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -336,7 +336,8 @@ void QFxImage::paintContents(QPainter &p)
if (d->pix.isNull())
return;
- QPainter::RenderHints oldHints = p.renderHints();
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
if (d->smooth)
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
@@ -428,8 +429,10 @@ void QFxImage::paintContents(QPainter &p)
QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb));
}
- if (d->smooth)
- p.setRenderHints(oldHints);
+ if (d->smooth) {
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
+ p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
}
#elif defined(QFX_RENDER_OPENGL)
uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 29d11ff..65589f2 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -156,7 +156,6 @@ void QFxPaintedItem::setSmooth(bool smooth)
Q_D(QFxPaintedItem);
if (d->smooth == smooth) return;
d->smooth = smooth;
- clearCache();
update();
}
@@ -304,7 +303,8 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
for (int i = 0; i < rects.count(); ++i) {
const QRect &r = rects.at(i);
QPixmap img(r.size());
- img.fill(Qt::transparent);
+ if (d->fillColor.isValid())
+ img.fill(d->fillColor);
{
QPainter qp(&img);
qp.translate(-r.x(),-r.y());
@@ -384,4 +384,30 @@ void QFxPaintedItem::setCacheSize(int pixels)
d->max_imagecache_size = pixels;
}
+/*!
+ \property QFxPaintedItem::fillColor
+
+ The color to be used to fill the item prior to calling drawContents().
+ By default, this is Qt::transparent.
+
+ Performance improvements can be achieved if subclasses call this with either an
+ invalid color (QColor()), or an appropriate solid color.
+*/
+void QFxPaintedItem::setFillColor(const QColor& c)
+{
+ Q_D(QFxPaintedItem);
+ if (d->fillColor == c)
+ return;
+ d->fillColor = c;
+ emit fillColorChanged();
+ update();
+}
+
+QColor QFxPaintedItem::fillColor() const
+{
+ Q_D(const QFxPaintedItem);
+ return d->fillColor;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index b7db2d9..6cb8fe7 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth)
+ Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
public:
@@ -80,11 +81,17 @@ public:
int cacheSize() const;
void setCacheSize(int pixels);
+ QColor fillColor() const;
+ void setFillColor(const QColor&);
+
protected:
QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
virtual void drawContents(QPainter *p, const QRect &) = 0;
+Q_SIGNALS:
+ void fillColorChanged();
+
protected Q_SLOTS:
void dirtyCache(const QRect &);
void clearCache();
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 21ac556..4e953a0 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -68,7 +68,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate
public:
QFxPaintedItemPrivate()
- : max_imagecache_size(100000), smooth(false)
+ : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent)
{
}
@@ -89,6 +89,7 @@ public:
int max_imagecache_size;
bool smooth;
QSize contentsSize;
+ QColor fillColor;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index adb33e8..f4a06ce 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -428,12 +428,6 @@ void QFxWebView::setInteractive(bool i)
emit interactiveChanged();
}
-void QFxWebView::updateCacheForVisibility()
-{
- if (!isVisible())
- clearCache();
-}
-
void QFxWebView::expandToWebPage()
{
Q_D(QFxWebView);
@@ -845,7 +839,6 @@ void QFxWebView::setPage(QWebPage *page)
d->idealheight>0 ? d->idealheight : -1));
d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
- connect(this,SIGNAL(visibleChanged()),this,SLOT(updateCacheForVisibility()));
connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SIGNAL(urlChanged()));
connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index c9a62cc..0ac1895 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -179,7 +179,6 @@ Q_SIGNALS:
void doubleClick();
private Q_SLOTS:
- void updateCacheForVisibility();
void expandToWebPage();
void paintPage(const QRect&);
void doLoadProgress(int p);
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp
index a679532..f02a176 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -830,7 +830,8 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) {
context->engine()->d_func()->loadCache(n, QLatin1String(id), static_cast<QmlContextPrivate*>(context->d_ptr));
- state = Incremental;
+ if (state != Reset)
+ state = Incremental;
}
if(!n.isValid())
@@ -855,7 +856,8 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
} else if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) {
context->engine()->d_func()->fetchCache(n, QLatin1String(id), obj);
guard(n);
- state = Incremental;
+ if (state != Reset)
+ state = Incremental;
} else if (!valid(n, obj)) {
clearCache(dataCache);
*cached = Reset;