aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-01-16 15:46:46 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-01-16 18:02:46 +0100
commitb0afb913e6e3440a61c2a692b1d15ee017fb3c40 (patch)
treedba3f96a42fe08eb108afe83b271101fef00382e /src/quick
parenta704040dc4dd312e6d0552e6d9e6715f988ea39a (diff)
parent291aea14636a0e779d874a01630524facb1397dd (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/doc/snippets/qml/itemGrab.qml2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp30
-rw-r--r--src/quick/items/qquickanimatedimage.cpp9
-rw-r--r--src/quick/items/qquicktext.cpp19
-rw-r--r--src/quick/items/qquicktext_p_p.h1
-rw-r--r--src/quick/items/qquicktextedit.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp5
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/shaders/visualization.frag2
9 files changed, 59 insertions, 15 deletions
diff --git a/src/quick/doc/snippets/qml/itemGrab.qml b/src/quick/doc/snippets/qml/itemGrab.qml
index 4ceaea6133..c8ffd30edc 100644
--- a/src/quick/doc/snippets/qml/itemGrab.qml
+++ b/src/quick/doc/snippets/qml/itemGrab.qml
@@ -70,7 +70,7 @@ Image {
// ...
source.grabToImage(function(result) {
- result.save("something.png");
+ result.saveToFile("something.png");
});
//! [grab-to-file]
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index da4212e5b1..bc5fd8504f 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -4170,13 +4170,35 @@ QQuickContext2DTexture *QQuickContext2D::texture() const
QImage QQuickContext2D::toImage(const QRectF& bounds)
{
- flush();
- if (m_texture->thread() == QThread::currentThread())
- m_texture->grabImage(bounds);
- else if (m_renderStrategy == QQuickCanvasItem::Cooperative) {
+ if (m_texture->thread() == QThread::currentThread()) {
+ // if we're either not rendering to an fbo or we have a separate opengl context we can just
+ // flush. Otherwise we have to make sure the shared opengl context is current before we do
+ // so. It may or may not be current already, depending on how this method is called.
+ if (m_renderTarget != QQuickCanvasItem::FramebufferObject || m_glContext) {
+ flush();
+ m_texture->grabImage(bounds);
+ } else {
+ QQuickWindow *window = m_canvas->window();
+ QOpenGLContext *ctx = window ? window->openglContext() : 0;
+ if (ctx && ctx->isValid()) {
+ if (ctx == QOpenGLContext::currentContext()) {
+ flush();
+ } else {
+ ctx->makeCurrent(window);
+ flush();
+ ctx->doneCurrent();
+ }
+ m_texture->grabImage(bounds);
+ } else {
+ qWarning() << "Cannot read pixels from canvas before opengl context is valid";
+ return QImage();
+ }
+ }
+ } else if (m_renderStrategy == QQuickCanvasItem::Cooperative) {
qWarning() << "Pixel readback is not supported in Cooperative mode, please try Threaded or Immediate mode";
return QImage();
} else {
+ flush();
QCoreApplication::postEvent(m_texture, new QEvent(QEvent::Type(QEvent::User + 10)));
QMetaObject::invokeMethod(m_texture,
"grabImage",
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 342394a74c..2fc00ad1d7 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -36,6 +36,7 @@
#ifndef QT_NO_MOVIE
+#include <QtGui/qguiapplication.h>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
#include <QtQml/qqmlengine.h>
@@ -293,7 +294,13 @@ void QQuickAnimatedImage::load()
if (isPlaying() != d->oldPlaying)
emit playingChanged();
} else {
- QString lf = QQmlFile::urlToLocalFileOrQrc(d->url);
+ const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
+ d->devicePixelRatio = 1.0;
+
+ QUrl loadUrl = d->url;
+ resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);
+ QString lf = QQmlFile::urlToLocalFileOrQrc(loadUrl);
+
if (!lf.isEmpty()) {
d->_movie = new QMovie(lf);
movieRequestFinished();
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 87255f4bd9..be86b2976b 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1166,6 +1166,17 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
/*!
+ Returns the y offset when aligning text with a non-1.0 lineHeight
+*/
+int QQuickTextPrivate::lineHeightOffset() const
+{
+ QFontMetricsF fm(font);
+ qreal fontHeight = qCeil(fm.height()); // QScriptLine and therefore QTextLine rounds up
+ return lineHeightMode() == QQuickText::FixedHeight ? fontHeight - lineHeight()
+ : (1.0 - lineHeight()) * fontHeight;
+}
+
+/*!
Ensures the QQuickTextPrivate::doc variable is set to a valid text document
*/
void QQuickTextPrivate::ensureDoc()
@@ -2090,7 +2101,7 @@ QRectF QQuickText::boundingRect() const
QRectF rect = d->layedOutTextRect;
rect.moveLeft(QQuickTextUtil::alignedX(rect.width(), width(), effectiveHAlign()));
- rect.moveTop(QQuickTextUtil::alignedY(rect.height(), height(), d->vAlign));
+ rect.moveTop(QQuickTextUtil::alignedY(rect.height() + d->lineHeightOffset(), height(), d->vAlign));
if (d->style != Normal)
rect.adjust(-1, 0, 1, 2);
@@ -2209,7 +2220,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
d->updateType = QQuickTextPrivate::UpdateNone;
- const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height(), height(), d->vAlign);
+ const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height() + d->lineHeightOffset(), height(), d->vAlign);
QQuickTextNode *node = 0;
if (!oldNode)
@@ -2513,7 +2524,7 @@ QString QQuickTextPrivate::anchorAt(const QPointF &mousePos) const
{
Q_Q(const QQuickText);
QPointF translatedMousePos = mousePos;
- translatedMousePos.ry() -= QQuickTextUtil::alignedY(layedOutTextRect.height(), q->height(), vAlign);
+ translatedMousePos.ry() -= QQuickTextUtil::alignedY(layedOutTextRect.height() + lineHeightOffset(), q->height(), vAlign);
if (styledText) {
QString link = anchorAt(&layout, translatedMousePos);
if (link.isEmpty() && elideLayout)
@@ -2597,7 +2608,7 @@ bool QQuickTextPrivate::isLinkHoveredConnected()
\qmlproperty string QtQuick::Text::hoveredLink
\since 5.2
- This property contains the link string when user hovers a link
+ This property contains the link string when the user hovers a link
embedded in the text. The link must be in rich text or HTML format
and the \a hoveredLink string provides access to the particular link.
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 3b83d37899..0acd77aab8 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -76,6 +76,7 @@ public:
bool isLineLaidOutConnected();
void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height);
+ int lineHeightOffset() const;
QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const;
void elideFormats(int start, int length, int offset, QList<QTextLayout::FormatRange> *elidedFormats);
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index c46df8f1b0..3446f65c19 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -175,7 +175,7 @@ QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)
QString QQuickTextEdit::text() const
{
Q_D(const QQuickTextEdit);
- if (!d->textCached) {
+ if (!d->textCached && isComponentComplete()) {
QQuickTextEditPrivate *d = const_cast<QQuickTextEditPrivate *>(d_func());
#ifndef QT_NO_TEXTHTMLPARSER
if (d->richText)
@@ -2578,7 +2578,7 @@ bool QQuickTextEditPrivate::isLinkHoveredConnected()
\qmlproperty string QtQuick::TextEdit::hoveredLink
\since 5.2
- This property contains the link string when user hovers a link
+ This property contains the link string when the user hovers a link
embedded in the text. The link must be in rich text or HTML format
and the link string provides access to the particular link.
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index aef5b4ee79..fd9b2a4480 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -2828,7 +2828,10 @@ void Renderer::visualizeBatch(Batch *b)
g = gn->geometry();
shader->setUniformValue(shader->matrix, matrix * *gn->matrix());
glVertexAttribPointer(a.position, a.tupleSize, a.type, false, g->sizeOfVertex(), (void *) (qintptr) offset);
- glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData());
+ if (g->indexCount())
+ glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData());
+ else
+ glDrawArrays(g->drawingMode(), 0, g->vertexCount());
offset += g->sizeOfVertex() * g->vertexCount();
e = e->nextInBatch;
}
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 58d618a049..9f74e259e3 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -437,7 +437,7 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
d->fireFrameSwapped();
qCDebug(QSG_LOG_TIME_RENDERLOOP()).nospace()
- << "Frame rendered with 'windows' renderloop in: " << time_swapped << "ms"
+ << "Frame rendered with 'windows' renderloop in: " << (time_swapped - time_start) / 1000000 << "ms"
<< ", polish=" << (time_polished - time_start) / 1000000
<< ", sync=" << (time_synced - time_polished) / 1000000
<< ", render=" << (time_rendered - time_synced) / 1000000
diff --git a/src/quick/scenegraph/shaders/visualization.frag b/src/quick/scenegraph/shaders/visualization.frag
index 6cfeac1985..458d9dde14 100644
--- a/src/quick/scenegraph/shaders/visualization.frag
+++ b/src/quick/scenegraph/shaders/visualization.frag
@@ -6,6 +6,6 @@ varying mediump vec2 pos;
void main(void)
{
lowp vec4 c = color;
- c.xyz += pow(max(sin(pos.x + pos.y), 0.0), 2.0) * pattern * 0.1;
+ c.xyz += pow(max(sin(pos.x + pos.y), 0.0), 2.0) * pattern * 0.25;
gl_FragColor = c;
}