diff options
Diffstat (limited to 'WebCore/rendering/RenderLayerBacking.cpp')
| -rw-r--r-- | WebCore/rendering/RenderLayerBacking.cpp | 279 |
1 files changed, 167 insertions, 112 deletions
diff --git a/WebCore/rendering/RenderLayerBacking.cpp b/WebCore/rendering/RenderLayerBacking.cpp index e16ecf7..e98c458 100644 --- a/WebCore/rendering/RenderLayerBacking.cpp +++ b/WebCore/rendering/RenderLayerBacking.cpp @@ -55,10 +55,9 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer* layer) : m_owningLayer(layer) , m_ancestorClippingLayer(0) , m_graphicsLayer(0) - , m_contentsLayer(0) + , m_foregroundLayer(0) , m_clippingLayer(0) , m_hasDirectlyCompositedContent(false) - , m_compositingContentOffsetDirty(true) { createGraphicsLayer(); } @@ -66,7 +65,7 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer* layer) RenderLayerBacking::~RenderLayerBacking() { updateClippingLayers(false, false); - updateContentsLayer(false); + updateForegroundLayer(false); destroyGraphicsLayer(); } @@ -75,14 +74,17 @@ void RenderLayerBacking::createGraphicsLayer() m_graphicsLayer = GraphicsLayer::createGraphicsLayer(this); #ifndef NDEBUG - if (renderer()->node()->isDocumentNode()) - m_graphicsLayer->setName("Document Node"); - else { - if (renderer()->node()->isHTMLElement() && renderer()->node()->hasID()) - m_graphicsLayer->setName(renderer()->renderName() + String(" ") + static_cast<HTMLElement*>(renderer()->node())->id()); - else - m_graphicsLayer->setName(renderer()->renderName()); - } + if (renderer()->node()) { + if (renderer()->node()->isDocumentNode()) + m_graphicsLayer->setName("Document Node"); + else { + if (renderer()->node()->isHTMLElement() && renderer()->node()->hasID()) + m_graphicsLayer->setName(renderer()->renderName() + String(" ") + static_cast<HTMLElement*>(renderer()->node())->id()); + else + m_graphicsLayer->setName(renderer()->renderName()); + } + } else + m_graphicsLayer->setName("Anonymous Node"); #endif // NDEBUG updateLayerOpacity(); @@ -97,8 +99,8 @@ void RenderLayerBacking::destroyGraphicsLayer() delete m_graphicsLayer; m_graphicsLayer = 0; - delete m_contentsLayer; - m_contentsLayer = 0; + delete m_foregroundLayer; + m_foregroundLayer = 0; delete m_clippingLayer; m_clippingLayer = 0; @@ -106,7 +108,7 @@ void RenderLayerBacking::destroyGraphicsLayer() void RenderLayerBacking::updateLayerOpacity() { - m_graphicsLayer->setOpacity(compositingOpacity(renderer()->opacity()), 0, 0); + m_graphicsLayer->setOpacity(compositingOpacity(renderer()->opacity())); } void RenderLayerBacking::updateLayerTransform() @@ -118,17 +120,31 @@ void RenderLayerBacking::updateLayerTransform() TransformationMatrix t; if (m_owningLayer->hasTransform()) { style->applyTransform(t, toRenderBox(renderer())->borderBoxRect().size(), RenderStyle::ExcludeTransformOrigin); - makeMatrixRenderable(t); + makeMatrixRenderable(t, compositor()->hasAcceleratedCompositing()); } m_graphicsLayer->setTransform(t); } -void RenderLayerBacking::updateAfterLayout() +void RenderLayerBacking::updateAfterLayout(UpdateDepth updateDepth) { - // Only need to update geometry if there isn't a layer update pending. - if (!compositor()->compositingLayersNeedUpdate()) - updateGraphicsLayerGeometry(); + RenderLayerCompositor* layerCompositor = compositor(); + if (!layerCompositor->compositingLayersNeedRebuild()) { + // Calling updateGraphicsLayerGeometry() here gives incorrect results, because the + // position of this layer's GraphicsLayer depends on the position of our compositing + // ancestor's GraphicsLayer. That cannot be determined until all the descendant + // RenderLayers of that ancestor have been processed via updateLayerPositions(). + // + // The solution is to update compositing children of this layer here, + // via updateCompositingChildrenGeometry(). + setCompositedBounds(layerCompositor->calculateCompositedBounds(m_owningLayer, m_owningLayer)); + layerCompositor->updateCompositingDescendantGeometry(m_owningLayer, m_owningLayer, updateDepth); + + if (!m_owningLayer->parent()) { + updateGraphicsLayerGeometry(); + layerCompositor->updateRootLayerPosition(); + } + } } bool RenderLayerBacking::updateGraphicsLayerConfiguration() @@ -136,7 +152,7 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration() RenderLayerCompositor* compositor = this->compositor(); bool layerConfigChanged = false; - if (updateContentsLayer(compositor->needsContentsCompositingLayer(m_owningLayer))) + if (updateForegroundLayer(compositor->needsContentsCompositingLayer(m_owningLayer))) layerConfigChanged = true; if (updateClippingLayers(compositor->clippedByAncestor(m_owningLayer), compositor->clipsCompositingDescendants(m_owningLayer))) @@ -178,16 +194,16 @@ void RenderLayerBacking::updateGraphicsLayerGeometry() m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3DPreserve3D); m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == BackfaceVisibilityVisible); - m_compositingContentOffsetDirty = true; - RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); // We compute everything relative to the enclosing compositing layer. IntRect ancestorCompositingBounds; - if (compAncestor) - ancestorCompositingBounds = compositor()->calculateCompositedBounds(compAncestor, compAncestor); - - IntRect localCompositingBounds = compositor()->calculateCompositedBounds(m_owningLayer, m_owningLayer); + if (compAncestor) { + ASSERT(compAncestor->backing()); + ancestorCompositingBounds = compAncestor->backing()->compositedBounds(); + } + + IntRect localCompositingBounds = compositedBounds(); IntRect relativeCompositingBounds(localCompositingBounds); int deltaX = 0, deltaY = 0; @@ -276,21 +292,21 @@ void RenderLayerBacking::updateGraphicsLayerGeometry() m_graphicsLayer->setAnchorPoint(FloatPoint3D(0.5f, 0.5f, 0)); } - if (m_contentsLayer) { + if (m_foregroundLayer) { // The contents layer is always coincidental with the graphicsLayer for now. - m_contentsLayer->setPosition(IntPoint(0, 0)); - m_contentsLayer->setSize(newSize); - m_contentsLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()); + m_foregroundLayer->setPosition(IntPoint(0, 0)); + m_foregroundLayer->setSize(newSize); + m_foregroundLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()); } - m_graphicsLayer->updateContentsRect(); + m_graphicsLayer->setContentsRect(contentsBox()); if (!m_hasDirectlyCompositedContent) m_graphicsLayer->setDrawsContent(!isSimpleContainerCompositingLayer() && !paintingGoesToWindow()); } void RenderLayerBacking::updateInternalHierarchy() { - // m_contentsLayer has to be inserted in the correct order with child layers, + // m_foregroundLayer has to be inserted in the correct order with child layers, // so it's not inserted here. if (m_ancestorClippingLayer) { m_ancestorClippingLayer->removeAllChildren(); @@ -347,24 +363,24 @@ bool RenderLayerBacking::updateClippingLayers(bool needsAncestorClip, bool needs return layersChanged; } -bool RenderLayerBacking::updateContentsLayer(bool needsContentsLayer) +bool RenderLayerBacking::updateForegroundLayer(bool needsForegroundLayer) { bool layerChanged = false; - if (needsContentsLayer) { - if (!m_contentsLayer) { - m_contentsLayer = GraphicsLayer::createGraphicsLayer(this); + if (needsForegroundLayer) { + if (!m_foregroundLayer) { + m_foregroundLayer = GraphicsLayer::createGraphicsLayer(this); #ifndef NDEBUG - m_contentsLayer->setName("Contents"); + m_foregroundLayer->setName("Contents"); #endif - m_contentsLayer->setDrawsContent(true); - m_contentsLayer->setDrawingPhase(GraphicsLayerPaintForegroundMask); + m_foregroundLayer->setDrawsContent(true); + m_foregroundLayer->setDrawingPhase(GraphicsLayerPaintForegroundMask); m_graphicsLayer->setDrawingPhase(GraphicsLayerPaintBackgroundMask); layerChanged = true; } - } else if (m_contentsLayer) { - m_contentsLayer->removeFromParent(); - delete m_contentsLayer; - m_contentsLayer = 0; + } else if (m_foregroundLayer) { + m_foregroundLayer->removeFromParent(); + delete m_foregroundLayer; + m_foregroundLayer = 0; m_graphicsLayer->setDrawingPhase(GraphicsLayerPaintAllMask); layerChanged = true; } @@ -410,7 +426,7 @@ static bool hasBoxDecorationsWithBackgroundImage(const RenderStyle* style) bool RenderLayerBacking::rendererHasBackground() const { // FIXME: share more code here - if (renderer()->node()->isDocumentNode()) { + if (renderer()->node() && renderer()->node()->isDocumentNode()) { RenderObject* htmlObject = renderer()->firstChild(); if (!htmlObject) return false; @@ -433,7 +449,7 @@ bool RenderLayerBacking::rendererHasBackground() const const Color& RenderLayerBacking::rendererBackgroundColor() const { // FIXME: share more code here - if (renderer()->node()->isDocumentNode()) { + if (renderer()->node() && renderer()->node()->isDocumentNode()) { RenderObject* htmlObject = renderer()->firstChild(); RenderStyle* style = htmlObject->style(); if (style->hasBackground()) @@ -469,7 +485,7 @@ bool RenderLayerBacking::isSimpleContainerCompositingLayer() const if (!renderObject->firstChild()) return true; - if (renderObject->node()->isDocumentNode()) { + if (renderObject->node() && renderObject->node()->isDocumentNode()) { // Look to see if the root object has a non-simple backgound RenderObject* rootObject = renderObject->document()->documentElement()->renderer(); if (!rootObject) @@ -529,29 +545,29 @@ bool RenderLayerBacking::hasNonCompositingContent() const // FIXME: test for overflow controls. if (m_owningLayer->isStackingContext()) { // Use the m_hasCompositingDescendant bit to optimize? - Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList(); - if (negZOrderList && negZOrderList->size() > 0) { - for (Vector<RenderLayer*>::const_iterator it = negZOrderList->begin(); it != negZOrderList->end(); ++it) { - RenderLayer* curLayer = (*it); + if (Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList()) { + size_t listSize = negZOrderList->size(); + for (size_t i = 0; i < listSize; ++i) { + RenderLayer* curLayer = negZOrderList->at(i); if (!curLayer->isComposited()) return true; } } - Vector<RenderLayer*>* posZOrderList = m_owningLayer->posZOrderList(); - if (posZOrderList && posZOrderList->size() > 0) { - for (Vector<RenderLayer*>::const_iterator it = posZOrderList->begin(); it != posZOrderList->end(); ++it) { - RenderLayer* curLayer = (*it); + if (Vector<RenderLayer*>* posZOrderList = m_owningLayer->posZOrderList()) { + size_t listSize = posZOrderList->size(); + for (size_t i = 0; i < listSize; ++i) { + RenderLayer* curLayer = posZOrderList->at(i); if (!curLayer->isComposited()) return true; } } } - Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList(); - if (normalFlowList && normalFlowList->size() > 0) { - for (Vector<RenderLayer*>::const_iterator it = normalFlowList->begin(); it != normalFlowList->end(); ++it) { - RenderLayer* curLayer = (*it); + if (Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList()) { + size_t listSize = normalFlowList->size(); + for (size_t i = 0; i < listSize; ++i) { + RenderLayer* curLayer = normalFlowList->at(i); if (!curLayer->isComposited()) return true; } @@ -567,11 +583,15 @@ bool RenderLayerBacking::canUseDirectCompositing() const RenderObject* renderObject = renderer(); // Reject anything that isn't an image - if (!renderObject->isImage()) + if (!renderObject->isImage() && !renderObject->isVideo()) return false; if (renderObject->hasMask() || renderObject->hasReflection()) return false; + + // Video can use an inner layer even if it has box decorations; we draw those into another layer. + if (renderObject->isVideo()) + return true; // Reject anything that would require the image to be drawn via the GraphicsContext, // like border, shadows etc. Solid background color is OK. @@ -587,7 +607,7 @@ void RenderLayerBacking::rendererContentChanged() void RenderLayerBacking::updateImageContents() { ASSERT(renderer()->isImage()); - RenderImage* imageRenderer = static_cast<RenderImage*>(renderer()); + RenderImage* imageRenderer = toRenderImage(renderer()); CachedImage* cachedImage = imageRenderer->cachedImage(); if (!cachedImage) @@ -637,24 +657,25 @@ FloatPoint RenderLayerBacking::computePerspectiveOrigin(const IntRect& borderBox } // Return the offset from the top-left of this compositing layer at which the renderer's contents are painted. -IntSize RenderLayerBacking::contentOffsetInCompostingLayer() +IntSize RenderLayerBacking::contentOffsetInCompostingLayer() const { - if (!m_compositingContentOffsetDirty) - return m_compositingContentOffset; - - IntRect relativeCompositingBounds = compositor()->calculateCompositedBounds(m_owningLayer, m_owningLayer); - m_compositingContentOffset = IntSize(-relativeCompositingBounds.x(), -relativeCompositingBounds.y()); - m_compositingContentOffsetDirty = false; - - return m_compositingContentOffset; + return IntSize(-m_compositedBounds.x(), -m_compositedBounds.y()); } -IntRect RenderLayerBacking::contentsBox(const GraphicsLayer*) +IntRect RenderLayerBacking::contentsBox() const { if (!renderer()->isBox()) return IntRect(); - IntRect contentsRect = toRenderBox(renderer())->contentBoxRect(); + IntRect contentsRect; +#if ENABLE(VIDEO) + if (renderer()->isVideo()) { + RenderVideo* videoRenderer = toRenderVideo(renderer()); + contentsRect = videoRenderer->videoBox(); + } else +#endif + contentsRect = toRenderBox(renderer())->contentBoxRect(); + IntSize contentOffset = contentOffsetInCompostingLayer(); contentsRect.move(contentOffset); return contentsRect; @@ -679,16 +700,17 @@ bool RenderLayerBacking::paintingGoesToWindow() const void RenderLayerBacking::setContentsNeedDisplay() { - if (m_graphicsLayer) + if (m_graphicsLayer && m_graphicsLayer->drawsContent()) m_graphicsLayer->setNeedsDisplay(); - if (m_contentsLayer) - m_contentsLayer->setNeedsDisplay(); + + if (m_foregroundLayer && m_foregroundLayer->drawsContent()) + m_foregroundLayer->setNeedsDisplay(); } // r is in the coordinate space of the layer's render object void RenderLayerBacking::setContentsNeedDisplayInRect(const IntRect& r) { - if (m_graphicsLayer) { + if (m_graphicsLayer && m_graphicsLayer->drawsContent()) { FloatPoint dirtyOrigin = contentsToGraphicsLayerCoordinates(m_graphicsLayer, FloatPoint(r.x(), r.y())); FloatRect dirtyRect(dirtyOrigin, r.size()); FloatRect bounds(FloatPoint(), m_graphicsLayer->size()); @@ -696,9 +718,9 @@ void RenderLayerBacking::setContentsNeedDisplayInRect(const IntRect& r) m_graphicsLayer->setNeedsDisplayInRect(dirtyRect); } - if (m_contentsLayer) { + if (m_foregroundLayer && m_foregroundLayer->drawsContent()) { // FIXME: do incremental repaint - m_contentsLayer->setNeedsDisplay(); + m_foregroundLayer->setNeedsDisplay(); } } @@ -720,7 +742,7 @@ static void restoreClip(GraphicsContext* p, const IntRect& paintDirtyRect, const // Share this with RenderLayer::paintLayer, which would have to be educated about GraphicsLayerPaintingPhase? void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* context, const IntRect& paintDirtyRect, // in the coords of rootLayer - bool haveTransparency, PaintRestriction paintRestriction, GraphicsLayerPaintingPhase paintingPhase, + PaintRestriction paintRestriction, GraphicsLayerPaintingPhase paintingPhase, RenderObject* paintingRoot) { if (paintingGoesToWindow()) { @@ -730,6 +752,14 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* m_owningLayer->updateLayerListsIfNeeded(); + // Paint the reflection first if we have one. + if (m_owningLayer->hasReflection()) { + // Mark that we are now inside replica painting. + m_owningLayer->setPaintingInsideReflection(true); + m_owningLayer->reflectionLayer()->paintLayer(rootLayer, context, paintDirtyRect, paintRestriction, paintingRoot, 0, RenderLayer::PaintLayerPaintingReflection); + m_owningLayer->setPaintingInsideReflection(false); + } + // Calculate the clip rects we should use. IntRect layerBounds, damageRect, clipRectToApply, outlineRect; m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect); @@ -747,13 +777,15 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) paintingRootForRenderer = paintingRoot; - if (paintingPhase & GraphicsLayerPaintBackgroundMask) { + bool shouldPaint = m_owningLayer->hasVisibleContent() && m_owningLayer->isSelfPaintingLayer(); + + if (shouldPaint && (paintingPhase & GraphicsLayerPaintBackgroundMask)) { // If this is the root then we need to send in a bigger bounding box // because we'll be painting the background as well (see RenderBox::paintRootBoxDecorations()). IntRect paintBox = clipRectToApply; // FIXME: do we need this code? - if (renderer()->node()->isDocumentNode() && renderer()->document()->isHTMLDocument()) { + if (renderer()->node() && renderer()->node()->isDocumentNode() && renderer()->document()->isHTMLDocument()) { RenderBox* box = toRenderBox(renderer()); int w = box->width(); int h = box->height(); @@ -791,13 +823,13 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* restoreClip(context, paintDirtyRect, damageRect); } - if (paintingPhase & GraphicsLayerPaintForegroundMask) { + if (shouldPaint && (paintingPhase & GraphicsLayerPaintForegroundMask)) { // Now walk the sorted list of children with negative z-indices. Only RenderLayers without compositing layers will paint. // FIXME: should these be painted as background? Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList(); if (negZOrderList) { for (Vector<RenderLayer*>::iterator it = negZOrderList->begin(); it != negZOrderList->end(); ++it) - it[0]->paintLayer(rootLayer, context, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot); + it[0]->paintLayer(rootLayer, context, paintDirtyRect, paintRestriction, paintingRoot); } bool forceBlackText = paintRestriction == PaintRestrictionSelectionOnlyBlackText; @@ -836,14 +868,14 @@ void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList(); if (normalFlowList) { for (Vector<RenderLayer*>::iterator it = normalFlowList->begin(); it != normalFlowList->end(); ++it) - it[0]->paintLayer(rootLayer, context, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot); + it[0]->paintLayer(rootLayer, context, paintDirtyRect, paintRestriction, paintingRoot); } // Now walk the sorted list of children with positive z-indices. Vector<RenderLayer*>* posZOrderList = m_owningLayer->posZOrderList(); if (posZOrderList) { for (Vector<RenderLayer*>::iterator it = posZOrderList->begin(); it != posZOrderList->end(); ++it) - it[0]->paintLayer(rootLayer, context, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot); + it[0]->paintLayer(rootLayer, context, paintDirtyRect, paintRestriction, paintingRoot); } if (renderer()->hasMask() && !selectionOnly && !damageRect.isEmpty()) { @@ -866,7 +898,7 @@ void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& co { // We have to use the same root as for hit testing, because both methods // can compute and cache clipRects. - IntRect enclosingBBox = compositor()->calculateCompositedBounds(m_owningLayer, m_owningLayer); + IntRect enclosingBBox = compositedBounds(); IntRect clipRect(clip); @@ -880,7 +912,7 @@ void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& co IntRect dirtyRect = enclosingBBox; dirtyRect.intersect(clipRect); - paintIntoLayer(m_owningLayer, &context, dirtyRect, false, PaintRestrictionNone, drawingPhase, renderer()); + paintIntoLayer(m_owningLayer, &context, dirtyRect, PaintRestrictionNone, drawingPhase, renderer()); } bool RenderLayerBacking::startAnimation(double beginTime, const Animation* anim, const KeyframeList& keyframes) @@ -891,8 +923,8 @@ bool RenderLayerBacking::startAnimation(double beginTime, const Animation* anim, if (!hasOpacity && !hasTransform) return false; - GraphicsLayer::TransformValueList transformVector; - GraphicsLayer::FloatValueList opacityVector; + KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); + KeyframeValueList opacityVector(AnimatedPropertyOpacity); for (Vector<KeyframeValue>::const_iterator it = keyframes.beginKeyframes(); it != keyframes.endKeyframes(); ++it) { const RenderStyle* keyframeStyle = it->style(); @@ -905,22 +937,26 @@ bool RenderLayerBacking::startAnimation(double beginTime, const Animation* anim, const TimingFunction* tf = keyframeStyle->hasAnimations() ? &((*keyframeStyle->animations()).animation(0)->timingFunction()) : 0; if (hasTransform) - transformVector.insert(key, &(keyframeStyle->transform()), tf); - + transformVector.insert(new TransformAnimationValue(key, &(keyframeStyle->transform()), tf)); + if (hasOpacity) - opacityVector.insert(key, keyframeStyle->opacity(), tf); + opacityVector.insert(new FloatAnimationValue(key, keyframeStyle->opacity(), tf)); } bool didAnimateTransform = !hasTransform; bool didAnimateOpacity = !hasOpacity; - if (hasTransform && m_graphicsLayer->animateTransform(transformVector, toRenderBox(renderer())->borderBoxRect().size(), anim, beginTime, false)) + if (hasTransform && m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->borderBoxRect().size(), anim, keyframes.animationName(), beginTime)) didAnimateTransform = true; - if (hasOpacity && m_graphicsLayer->animateFloat(AnimatedPropertyOpacity, opacityVector, anim, beginTime)) + if (hasOpacity && m_graphicsLayer->addAnimation(opacityVector, IntSize(), anim, keyframes.animationName(), beginTime)) didAnimateOpacity = true; - return didAnimateTransform && didAnimateOpacity; + bool runningAcceleratedAnimation = didAnimateTransform && didAnimateOpacity; + if (runningAcceleratedAnimation) + compositor()->didStartAcceleratedAnimation(); + + return runningAcceleratedAnimation; } bool RenderLayerBacking::startTransition(double beginTime, int property, const RenderStyle* fromStyle, const RenderStyle* toStyle) @@ -931,29 +967,27 @@ bool RenderLayerBacking::startTransition(double beginTime, int property, const R if (property == (int)CSSPropertyOpacity) { const Animation* opacityAnim = toStyle->transitionForProperty(CSSPropertyOpacity); if (opacityAnim && !opacityAnim->isEmptyOrZeroDuration()) { - // If beginTime is not 0, we are restarting this transition, so first set the from value - // in case it was smashed by a previous animation. - if (beginTime > 0) - m_graphicsLayer->setOpacity(compositingOpacity(fromStyle->opacity()), 0, 0); - - if (m_graphicsLayer->setOpacity(compositingOpacity(toStyle->opacity()), opacityAnim, beginTime)) + KeyframeValueList opacityVector(AnimatedPropertyOpacity); + opacityVector.insert(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity()))); + opacityVector.insert(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity()))); + if (m_graphicsLayer->addAnimation(opacityVector, toRenderBox(renderer())->borderBoxRect().size(), opacityAnim, String(), beginTime)) didAnimate = true; } } if (property == (int)CSSPropertyWebkitTransform && m_owningLayer->hasTransform()) { - // We get a TransformOperation, which is a linked list of primitive operations and their arguments. - // Arguments can be floats or Length values, which need to be converted to numbers using - // val.calcFloatValue(renderer()->width()) (or height()). const Animation* transformAnim = toStyle->transitionForProperty(CSSPropertyWebkitTransform); if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { - GraphicsLayer::TransformValueList transformVector; - transformVector.insert(0, &fromStyle->transform(), 0); - transformVector.insert(1, &toStyle->transform(), 0); - if (m_graphicsLayer->animateTransform(transformVector, toRenderBox(renderer())->borderBoxRect().size(), transformAnim, beginTime, true)) + KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); + transformVector.insert(new TransformAnimationValue(0, &fromStyle->transform())); + transformVector.insert(new TransformAnimationValue(1, &toStyle->transform())); + if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->borderBoxRect().size(), transformAnim, String(), beginTime)) didAnimate = true; } } + + if (didAnimate) + compositor()->didStartAcceleratedAnimation(); return didAnimate; } @@ -963,21 +997,32 @@ void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double tim renderer()->animation()->notifyAnimationStarted(renderer(), time); } -void RenderLayerBacking::animationFinished(const String& name, int index, bool reset) +void RenderLayerBacking::notifySyncRequired(const GraphicsLayer*) { - m_graphicsLayer->removeFinishedAnimations(name, index, reset); + if (!renderer()->documentBeingDestroyed()) + compositor()->scheduleSync(); +} + +void RenderLayerBacking::animationFinished(const String& animationName) +{ + m_graphicsLayer->removeAnimationsForKeyframes(animationName); +} + +void RenderLayerBacking::animationPaused(const String& animationName) +{ + m_graphicsLayer->pauseAnimation(animationName); } void RenderLayerBacking::transitionFinished(int property) { AnimatedPropertyID animatedProperty = cssToGraphicsLayerProperty(property); if (animatedProperty != AnimatedPropertyInvalid) - m_graphicsLayer->removeFinishedTransitions(animatedProperty); + m_graphicsLayer->removeAnimationsForProperty(animatedProperty); } -void RenderLayerBacking::suspendAnimations() +void RenderLayerBacking::suspendAnimations(double time) { - m_graphicsLayer->suspendAnimations(); + m_graphicsLayer->suspendAnimations(time); } void RenderLayerBacking::resumeAnimations() @@ -985,6 +1030,16 @@ void RenderLayerBacking::resumeAnimations() m_graphicsLayer->resumeAnimations(); } +IntRect RenderLayerBacking::compositedBounds() const +{ + return m_compositedBounds; +} + +void RenderLayerBacking::setCompositedBounds(const IntRect& bounds) +{ + m_compositedBounds = bounds; + +} int RenderLayerBacking::graphicsLayerToCSSProperty(AnimatedPropertyID property) { int cssProperty = CSSPropertyInvalid; |
