Commit 774b4320 authored by abecsi@webkit.org's avatar abecsi@webkit.org

Unreviewed build fix.

        [Qt] Roll-out r54281 because it broke the build on the Qt Release bot.



git-svn-id: svn://svn.chromium.org/blink/trunk@54284 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 25fbe651
2010-02-03 Andras Becsi <abecsi@webkit.org>
Unreviewed build fix.
[Qt] Roll-out r54281 because it broke the build on the Qt Release bot.
* platform/graphics/qt/GraphicsLayerQt.cpp:
(WebCore::GraphicsLayerQtImpl::State::State):
(WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl):
(WebCore::GraphicsLayerQtImpl::setBaseTransform):
(WebCore::GraphicsLayerQtImpl::drawContents):
(WebCore::GraphicsLayerQtImpl::notifyChange):
(WebCore::GraphicsLayerQtImpl::flushChanges):
(WebCore::GraphicsLayerQt::setNeedsDisplayInRect):
(WebCore::applyTimingFunction):
(WebCore::webkitAnimationToQtAnimationValue):
(WebCore::AnimationQtBase::updateState):
(WebCore::AnimationQt::updateCurrentTime):
(WebCore::TransformAnimationQt::TransformAnimationQt):
(WebCore::TransformAnimationQt::~TransformAnimationQt):
(WebCore::TransformAnimationQt::applyFrame):
(WebCore::TransformAnimationQt::updateState):
(WebCore::OpacityAnimationQt::updateState):
(WebCore::GraphicsLayerQt::pauseAnimation):
2010-02-02 Bryan Yeung <bryeung@google.com>
Reviewed by Darin Adler.
......@@ -17,24 +42,6 @@
* dom/Element.cpp:
(WebCore::Element::baseURI):
2010-02-03 No'am Rosenthal <noam.rosenthal@nokia.com>
Reviewed by Laszlo Gombos.
[Qt] Tuning and optimizations to GraphicsLayerQt. Reduce unnecessary
recaching, remove QTimer::singleShot and QPixmap::scaled, more
accurate strategy of handling transform operation blends. Rotating a
bordered-table, for example, now runs at 50FPS instead of 40FPS on Maemo5.
https://bugs.webkit.org/show_bug.cgi?id=34062
This is tested by https://bugs.webkit.org/show_bug.cgi?id=34450, fps measurements.
* platform/graphics/qt/GraphicsLayerQt.cpp:
(WebCore::GraphicsLayerQtImpl::flushChanges): Fine-tune caching
(WebCore::TransformAnimationQt::TransformAnimationQt): transform bugs
(WebCore::OpacityAnimationQt::updateState): style change
2010-02-02 Joel Stanley <joel@jms.id.au>
Reviewed by David Levin.
......
......@@ -99,26 +99,14 @@ public:
// or ChromeClientQt::scheduleCompositingLayerSync (meaning the sync will happen ASAP)
void flushChanges(bool recursive = true);
// optimization: when we have an animation running on an element with no contents, that has child-elements with contents,
// ALL of them have to have ItemCoordinateCache and not DeviceCoordinateCache
void adjustCachingRecursively(bool animationIsRunning);
// optimization: returns true if this or an ancestor has a transform animation running.
// this enables us to use ItemCoordinatesCache while the animation is running, otherwise we have to recache for every frame
bool isTransformAnimationRunning() const;
public slots:
// we need to notify the client (aka the layer compositor) when the animation actually starts
void notifyAnimationStarted();
signals:
// optimization: we don't want to use QTimer::singleShot
void notifyAnimationStartedAsync();
public:
GraphicsLayerQt* m_layer;
QTransform m_baseTransform;
QTransform m_baseTransfom;
bool m_transformAnimationRunning;
bool m_opacityAnimationRunning;
......@@ -169,14 +157,12 @@ public:
bool backfaceVisibility: 1;
bool distributeOpacity: 1;
bool align: 2;
State(): maskLayer(0), opacity(1.f), preserves3D(false), masksToBounds(false),
State(): maskLayer(0), opacity(1), preserves3D(false), masksToBounds(false),
drawsContent(false), contentsOpaque(false), backfaceVisibility(false),
distributeOpacity(false)
{
}
} m_state;
friend class AnimationQtBase;
};
GraphicsLayerQtImpl::GraphicsLayerQtImpl(GraphicsLayerQt* newLayer)
......@@ -185,14 +171,16 @@ GraphicsLayerQtImpl::GraphicsLayerQtImpl(GraphicsLayerQt* newLayer)
, m_transformAnimationRunning(false)
, m_changeMask(NoChanges)
{
// better to calculate the exposed rect in QGraphicsView than over-render in WebCore
// FIXME: test different approaches
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
// we use graphics-view for compositing, not for interactivity
setAcceptedMouseButtons(Qt::NoButton);
setEnabled(false);
// we'll set the cache when we know what's going on
setCacheMode(NoCache);
connect(this, SIGNAL(notifyAnimationStartedAsync()), this, SLOT(notifyAnimationStarted()), Qt::QueuedConnection);
}
GraphicsLayerQtImpl::~GraphicsLayerQtImpl()
......@@ -215,42 +203,22 @@ GraphicsLayerQtImpl::~GraphicsLayerQtImpl()
delete anim;
}
void GraphicsLayerQtImpl::adjustCachingRecursively(bool animationIsRunning)
{
// optimization: we make sure all our children have ItemCoordinateCache -
// otherwise we end up re-rendering them during the animation
const QList<QGraphicsItem*> children = childItems();
for (QList<QGraphicsItem*>::const_iterator it = children.begin(); it != children.end(); ++it) {
if (QGraphicsItem* item = *it)
if (GraphicsLayerQtImpl* layer = qobject_cast<GraphicsLayerQtImpl*>(item->toGraphicsObject())) {
if (layer->m_layer->drawsContent() && layer->m_currentContent.contentType == HTMLContentType)
layer->setCacheMode(animationIsRunning ? QGraphicsItem::ItemCoordinateCache : QGraphicsItem::DeviceCoordinateCache);
}
}
}
void GraphicsLayerQtImpl::setBaseTransform(const QTransform& transform)
{
if (!m_layer)
return;
// webkit has relative-to-size originPoint, graphics-view has a pixel originPoint, here we convert
// we have to manage this ourselves because QGraphicsView's transformOrigin is incompatible
const qreal x = m_layer->anchorPoint().x() * m_layer->size().width();
const qreal y = m_layer->anchorPoint().y() * m_layer->size().height();
setTransform(QTransform::fromTranslate(x, y));
setTransform(transform, true);
translate(-x, -y);
m_baseTransform = transform;
}
// webkit has relative-to-size originPoint, graphics-view has a pixel originPoint
// here we convert
QPointF originTranslate(
m_layer->anchorPoint().x() * m_layer->size().width(), m_layer->anchorPoint().y() * m_layer->size().height());
bool GraphicsLayerQtImpl::isTransformAnimationRunning() const
{
if (m_transformAnimationRunning)
return true;
if (GraphicsLayerQtImpl* parent = qobject_cast<GraphicsLayerQtImpl*>(parentObject()))
return parent->isTransformAnimationRunning();
return false;
resetTransform();
// we have to manage this ourselves because QGraphicsView's transformOrigin is incomplete
translate(originTranslate.x(), originTranslate.y());
setTransform(transform, true);
translate(-originTranslate.x(), -originTranslate.y());
m_baseTransfom = transform;
}
QPainterPath GraphicsLayerQtImpl::opaqueArea() const
......@@ -302,31 +270,42 @@ void GraphicsLayerQtImpl::paint(QPainter* painter, const QStyleOptionGraphicsIte
drawContents(painter, option->exposedRect);
}
void GraphicsLayerQtImpl::drawContents(QPainter* painter, const QRectF& exposedRect, bool mask)
void GraphicsLayerQtImpl::drawContents(QPainter* painter, const QRectF& r, bool mask)
{
QRect rect = r.toAlignedRect();
if (m_currentContent.contentType != HTMLContentType && !m_state.contentsRect.isEmpty())
rect = rect.intersected(m_state.contentsRect);
if (m_currentContent.backgroundColor.isValid())
painter->fillRect(exposedRect, QColor(m_currentContent.backgroundColor));
painter->fillRect(r, QColor(m_currentContent.backgroundColor));
if (!rect.isEmpty()) {
switch (m_currentContent.contentType) {
case PixmapContentType:
painter->drawPixmap(m_state.contentsRect, m_currentContent.pixmap);
// we have to scale the image to the contentsRect
// FIXME: a better way would probably be drawPixmap with a src/target rect
painter->drawPixmap(rect.topLeft(), m_currentContent.pixmap.scaled(m_state.contentsRect.size()), r);
break;
case ColorContentType:
painter->fillRect(m_state.contentsRect, m_currentContent.contentsBackgroundColor);
painter->fillRect(rect, m_currentContent.contentsBackgroundColor);
break;
default:
if (m_state.drawsContent) {
// this is the "expensive" bit. we try to minimize calls to this neck of the woods by proper caching
// this is the "expensive" bit. we try to minimize calls to this
// neck of the woods by proper caching
GraphicsContext gc(painter);
m_layer->paintGraphicsLayerContents(gc, exposedRect.toAlignedRect());
m_layer->paintGraphicsLayerContents(gc, rect);
}
break;
}
}
}
void GraphicsLayerQtImpl::notifyChange(ChangeMask changeMask)
{
Q_ASSERT(this);
if (!this)
return;
m_changeMask |= changeMask;
......@@ -363,14 +342,14 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive)
const QSet<QGraphicsItem*> currentChildren = childItems().toSet();
const QSet<QGraphicsItem*> childrenToAdd = newChildren - currentChildren;
const QSet<QGraphicsItem*> childrenToRemove = currentChildren - newChildren;
for (QSet<QGraphicsItem*>::const_iterator it = childrenToAdd.begin(); it != childrenToAdd.end(); ++it)
for (QSet<QGraphicsItem*>::const_iterator it = childrenToAdd.begin(); it != childrenToAdd.end(); ++it) {
if (QGraphicsItem* w = *it)
w->setParentItem(this);
for (QSet<QGraphicsItem*>::const_iterator it = childrenToRemove.begin(); it != childrenToRemove.end(); ++it)
}
for (QSet<QGraphicsItem*>::const_iterator it = childrenToRemove.begin(); it != childrenToRemove.end(); ++it) {
if (QGraphicsItem* w = *it)
w->setParentItem(0);
}
// children are ordered by z-value, let graphics-view know.
for (size_t i = 0; i < newChildrenVector.size(); ++i)
......@@ -404,17 +383,17 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive)
// the anchor-point, transform and size from WebCore all affect the one
// that we give Qt
if (m_state.transform != m_layer->transform() || m_state.anchorPoint != m_layer->anchorPoint() || m_state.size != m_layer->size())
setBaseTransform(m_layer->transform());
setBaseTransform(QTransform(m_layer->transform()));
}
if (m_changeMask & (ContentChange | DrawsContentChange)) {
switch (m_pendingContent.contentType) {
case PixmapContentType:
// we need cache even for images, because they need to be resized
// to the contents rect. maybe this can be optimized though
setCacheMode(m_transformAnimationRunning ? ItemCoordinateCache : DeviceCoordinateCache);
update();
setFlag(ItemHasNoContents, false);
// we only use ItemUsesExtendedStyleOption for HTML content - pixmap can be handled better with regular clipping
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, false);
break;
case ColorContentType:
......@@ -424,9 +403,6 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive)
update();
m_state.drawsContent = false;
setFlag(ItemHasNoContents, false);
// we only use ItemUsesExtendedStyleOption for HTML content - colors don't gain much from that anyway
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, false);
break;
case HTMLContentType:
......@@ -434,16 +410,8 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive)
update();
if (!m_state.drawsContent && m_layer->drawsContent())
update();
if (m_layer->drawsContent()) {
const QGraphicsItem::CacheMode mewCacheMode = isTransformAnimationRunning() ? ItemCoordinateCache : DeviceCoordinateCache;
// optimization: QGraphicsItem doesn't always perform this test
if (mewCacheMode != cacheMode())
setCacheMode(mewCacheMode);
// HTML content: we want to use exposedRect so we don't use WebCore rendering if we don't have to
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
}
if (m_layer->drawsContent())
setCacheMode(m_transformAnimationRunning ? ItemCoordinateCache : DeviceCoordinateCache);
else
setCacheMode(NoCache);
......@@ -480,7 +448,7 @@ void GraphicsLayerQtImpl::flushChanges(bool recursive)
update();
// FIXME: the following flags are currently not handled, as they don't have a clear test or are in low priority
// GeometryOrientationChange, ContentsOrientationChange, BackfaceVisibilityChange, ChildrenTransformChange, Preserves3DChange
// GeometryOrientationChange, ContentsOrientationChange, BackfaceVisibilityChange, ChildrenTransformChange
m_state.maskLayer = m_layer->maskLayer();
m_state.pos = m_layer->position();
......@@ -555,9 +523,9 @@ void GraphicsLayerQt::setNeedsDisplay()
}
// reimp from GraphicsLayer.h
void GraphicsLayerQt::setNeedsDisplayInRect(const FloatRect& rect)
void GraphicsLayerQt::setNeedsDisplayInRect(const FloatRect& r)
{
m_impl->m_pendingContent.regionToUpdate|= QRectF(rect).toAlignedRect();
m_impl->m_pendingContent.regionToUpdate|= QRectF(r).toAlignedRect();
m_impl->notifyChange(GraphicsLayerQtImpl::DisplayChange);
}
......@@ -858,7 +826,9 @@ static void webkitAnimationToQtAnimationValue(const AnimationValue* animationVal
if (!animationValue)
return;
if (const TransformOperations* ops = static_cast<const TransformAnimationValue*>(animationValue)->value())
const TransformOperations* ops = static_cast<const TransformAnimationValue*>(animationValue)->value();
if (ops)
transformOperations = *ops;
}
......@@ -886,8 +856,8 @@ public:
QAbstractAnimation::updateState(newState, oldState);
// for some reason I have do this asynchronously - or the animation won't work
if (newState == Running && oldState == Stopped && m_layer.data())
m_layer.data()->notifyAnimationStartedAsync();
if (newState == Running && oldState == Stopped)
QTimer::singleShot(0, m_layer.data(), SLOT(notifyAnimationStarted()));
}
virtual int duration() const { return m_duration; }
......@@ -962,10 +932,9 @@ protected:
// now we have a source keyframe, origin keyframe and a timing function
// we can now process the progress and apply the frame
progress = (!progress || progress == 1 || it.key() == it2.key())
? progress
: applyTimingFunction(timingFunc, (progress - it.key()) / (it2.key() - it.key()), duration() / 1000);
applyFrame(fromValue, toValue, progress);
qreal normalizedProgress = (it.key() == it2.key()) ? 0 : (progress - it.key()) / (it2.key() - it.key());
normalizedProgress = applyTimingFunction(timingFunc, normalizedProgress, duration() / 1000);
applyFrame(fromValue, toValue, normalizedProgress);
}
QMap<qreal, KeyframeValueQt<T> > m_keyframeValues;
......@@ -983,7 +952,7 @@ public:
// this came up during the compositing/animation LayoutTests
// when the animation dies, the transform has to go back to default
if (m_layer)
m_layer.data()->setBaseTransform(m_layer.data()->m_layer->transform());
m_layer.data()->setBaseTransform(QTransform(m_layer.data()->m_layer->transform()));
}
// the idea is that we let WebCore manage the transform-operations
......@@ -994,22 +963,11 @@ public:
{
TransformationMatrix transformMatrix;
// sometimes the animation values from WebCore are misleading and we have to use the actual matrix as source
// The Mac implementation simply doesn't try to accelerate those (e.g. 360deg rotation), but we do.
if (progress == 1 || !targetOperations.size() || sourceOperations == targetOperations) {
TransformationMatrix sourceMatrix;
sourceOperations.apply(m_boxSize, sourceMatrix);
transformMatrix = m_sourceMatrix;
transformMatrix.blend(sourceMatrix, 1 - progress);
} else if (targetOperations.size() != sourceOperations.size()) {
transformMatrix = m_sourceMatrix;
targetOperations.apply(m_boxSize, transformMatrix);
transformMatrix.blend(m_sourceMatrix, progress);
} else {
// this looks simple but is really tricky to get right. Use caution.
for (size_t i = 0; i < targetOperations.size(); ++i)
targetOperations.operations()[i]->blend(sourceOperations.at(i), progress)->apply(transformMatrix, m_boxSize);
}
m_layer.data()->setBaseTransform(transformMatrix);
m_layer.data()->setBaseTransform(QTransform(transformMatrix));
}
virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
......@@ -1022,16 +980,15 @@ public:
// to increase FPS, we use a less accurate caching mechanism while animation is going on
// this is a UX choice that should probably be customizable
if (newState == QAbstractAnimation::Running) {
m_sourceMatrix = m_layer.data()->transform();
m_layer.data()->m_transformAnimationRunning = true;
m_layer.data()->adjustCachingRecursively(true);
if (m_layer.data()->cacheMode() == QGraphicsItem::DeviceCoordinateCache)
m_layer.data()->setCacheMode(QGraphicsItem::ItemCoordinateCache);
} else {
m_layer.data()->m_transformAnimationRunning = false;
m_layer.data()->adjustCachingRecursively(false);
if (m_layer.data()->cacheMode() == QGraphicsItem::ItemCoordinateCache)
m_layer.data()->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
}
TransformationMatrix m_sourceMatrix;
};
class OpacityAnimationQt : public AnimationQt<qreal> {
......@@ -1049,7 +1006,6 @@ public:
virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QAbstractAnimation::updateState(newState, oldState);
if (m_layer)
m_layer.data()->m_opacityAnimationRunning = (newState == QAbstractAnimation::Running);
}
......@@ -1123,13 +1079,12 @@ void GraphicsLayerQt::removeAnimationsForKeyframes(const String& name)
void GraphicsLayerQt::pauseAnimation(const String& name, double timeOffset)
{
for (QList<QWeakPointer<QAbstractAnimation> >::iterator it = m_impl->m_animations.begin(); it != m_impl->m_animations.end(); ++it) {
if (!(*it))
continue;
if (*it) {
AnimationQtBase* anim = static_cast<AnimationQtBase*>((*it).data());
if (anim && anim->m_keyframesName == QString(name))
QTimer::singleShot(timeOffset * 1000, anim, SLOT(pause()));
}
}
}
void GraphicsLayerQt::suspendAnimations(double time)
......
......@@ -27,7 +27,6 @@
#include "qwebpage_p.h"
#include "QWebPageClient.h"
#include <FrameView.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qtimer.h>
#include <QtGui/qapplication.h>
......@@ -79,14 +78,13 @@ public:
, page(0)
#if USE(ACCELERATED_COMPOSITING)
, rootGraphicsLayer(0)
, shouldSync(false)
, shouldSync(true)
#endif
{
#if USE(ACCELERATED_COMPOSITING)
// the overlay and stays alive for the lifetime of
// this QGraphicsWebView as the scrollbars are needed when there's no compositing
q->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption);
syncMetaMethod = q->metaObject()->method(q->metaObject()->indexOfMethod("syncLayers()"));
#endif
}
......@@ -133,9 +131,6 @@ public:
// compositor telling us to do so. We'll get that call from ChromeClientQt
bool shouldSync;
// we have to flush quite often, so we use a meta-method instead of QTimer::singleShot for putting the event in the queue
QMetaMethod syncMetaMethod;
// we need to put the root graphics layer behind the overlay (which contains the scrollbar)
enum { RootGraphicsLayerZValue, OverlayZValue };
#endif
......@@ -183,7 +178,7 @@ void QGraphicsWebViewPrivate::markForSync(bool scheduleSync)
{
shouldSync = true;
if (scheduleSync)
syncMetaMethod.invoke(q, Qt::QueuedConnection);
QTimer::singleShot(0, q, SLOT(syncLayers()));
}
void QGraphicsWebViewPrivate::updateCompositingScrollPosition()
......@@ -229,7 +224,6 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect)
#if USE(ACCELERATED_COMPOSITING)
if (overlay)
overlay->update(QRectF(dirtyRect));
syncLayers();
#endif
}
......@@ -448,6 +442,7 @@ void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem*
{
#if USE(ACCELERATED_COMPOSITING)
page()->mainFrame()->render(painter, d->overlay ? QWebFrame::ContentsLayer : QWebFrame::AllLayers, option->exposedRect.toAlignedRect());
d->syncLayers();
#else
page()->mainFrame()->render(painter, QWebFrame::AllLayers, option->exposedRect.toRect());
#endif
......
2010-02-03 No'am Rosenthal <noam.rosenthal@nokia.com>
2010-02-03 Andras Becsi <abecsi@webkit.org>
Reviewed by Laszlo Gombos.
Unreviewed build fix.
[Qt] Tuning and optimizations to GraphicsLayerQt. Mainly reduced usage
of QTimer::singleShot, and moved syncLayers() from paint() to update()
https://bugs.webkit.org/show_bug.cgi?id=34062
[Qt] Roll-out r54281 because it broke the build on the Qt Release bot.
* Api/qgraphicswebview.cpp:
(QGraphicsWebViewPrivate::update): Moved the sync operation to update
(QGraphicsWebView::paint): Moved the sync operation to update
(QGraphicsWebViewPrivate::QGraphicsWebViewPrivate):
(QGraphicsWebViewPrivate::markForSync):
(QGraphicsWebViewPrivate::update):
(QGraphicsWebView::paint):
2010-02-02 Kenneth Rohde Christiansen <kenneth@webkit.org>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment