| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 void RenderLayerBacking::updateLayerTransform() | 111 void RenderLayerBacking::updateLayerTransform() |
| 112 { | 112 { |
| 113 RenderStyle* style = renderer()->style(); | 113 RenderStyle* style = renderer()->style(); |
| 114 | 114 |
| 115 // FIXME: This could use m_owningLayer->transform(), but that currently has
transform-origin | 115 // FIXME: This could use m_owningLayer->transform(), but that currently has
transform-origin |
| 116 // baked into it, and we don't want that. | 116 // baked into it, and we don't want that. |
| 117 TransformationMatrix t; | 117 TransformationMatrix t; |
| 118 if (m_owningLayer->hasTransform()) | 118 if (m_owningLayer->hasTransform()) |
| 119 style->applyTransform(t, renderer()->borderBoxRect().size(), false); | 119 style->applyTransform(t, toRenderBox(renderer())->borderBoxRect().size()
, RenderStyle::ExcludeTransformOrigin); |
| 120 | 120 |
| 121 m_graphicsLayer->setTransform(t); | 121 m_graphicsLayer->setTransform(t); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void RenderLayerBacking::updateAfterLayout() | 124 void RenderLayerBacking::updateAfterLayout() |
| 125 { | 125 { |
| 126 invalidateDrawingOptimizations(); | 126 invalidateDrawingOptimizations(); |
| 127 detectDrawingOptimizations(); | 127 detectDrawingOptimizations(); |
| 128 | 128 |
| 129 updateGraphicsLayerGeometry(); | 129 updateGraphicsLayerGeometry(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 // If we have a layer that clips children, position it. | 232 // If we have a layer that clips children, position it. |
| 233 if (m_clippingLayer) { | 233 if (m_clippingLayer) { |
| 234 IntRect clippingBox = renderer()->getOverflowClipRect(0, 0); | 234 IntRect clippingBox = renderer()->getOverflowClipRect(0, 0); |
| 235 m_clippingLayer->setPosition(FloatPoint() + (clippingBox.location() - lo
calCompositingBounds.location())); | 235 m_clippingLayer->setPosition(FloatPoint() + (clippingBox.location() - lo
calCompositingBounds.location())); |
| 236 m_clippingLayer->setSize(clippingBox.size()); | 236 m_clippingLayer->setSize(clippingBox.size()); |
| 237 m_clippingLayer->setOffsetFromRenderer(clippingBox.location() - IntPoint
()); | 237 m_clippingLayer->setOffsetFromRenderer(clippingBox.location() - IntPoint
()); |
| 238 } | 238 } |
| 239 | 239 |
| 240 if (m_owningLayer->hasTransform()) { | 240 if (m_owningLayer->hasTransform()) { |
| 241 const IntRect borderBox = renderer()->borderBoxRect(); | 241 const IntRect borderBox = toRenderBox(renderer())->borderBoxRect(); |
| 242 | 242 |
| 243 IntRect layerBounds = IntRect(m_owningLayer->xPos(), m_owningLayer->yPos
(), borderBox.width(), borderBox.height()); | 243 IntRect layerBounds = IntRect(m_owningLayer->xPos(), m_owningLayer->yPos
(), borderBox.width(), borderBox.height()); |
| 244 // Convert to absolute coords to match bbox. | 244 // Convert to absolute coords to match bbox. |
| 245 int x = 0, y = 0; | 245 int x = 0, y = 0; |
| 246 m_owningLayer->convertToLayerCoords(compAncestor, x, y); | 246 m_owningLayer->convertToLayerCoords(compAncestor, x, y); |
| 247 layerBounds.move(x - m_owningLayer->xPos(), y - m_owningLayer->yPos()); | 247 layerBounds.move(x - m_owningLayer->xPos(), y - m_owningLayer->yPos()); |
| 248 | 248 |
| 249 // Update properties that depend on layer dimensions | 249 // Update properties that depend on layer dimensions |
| 250 FloatPoint3D transformOrigin = computeTransformOrigin(borderBox); | 250 FloatPoint3D transformOrigin = computeTransformOrigin(borderBox); |
| 251 // Compute the anchor point, which is in the center of the renderer box
unless transform-origin is set. | 251 // Compute the anchor point, which is in the center of the renderer box
unless transform-origin is set. |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 587 |
| 588 IntRect relativeCompositingBounds = compositor()->calculateCompositedBounds(
m_owningLayer, m_owningLayer); | 588 IntRect relativeCompositingBounds = compositor()->calculateCompositedBounds(
m_owningLayer, m_owningLayer); |
| 589 m_compositingContentOffset = IntSize(-relativeCompositingBounds.x(), -relati
veCompositingBounds.y()); | 589 m_compositingContentOffset = IntSize(-relativeCompositingBounds.x(), -relati
veCompositingBounds.y()); |
| 590 m_compositingContentOffsetDirty = false; | 590 m_compositingContentOffsetDirty = false; |
| 591 | 591 |
| 592 return m_compositingContentOffset; | 592 return m_compositingContentOffset; |
| 593 } | 593 } |
| 594 | 594 |
| 595 IntRect RenderLayerBacking::contentsBox(const GraphicsLayer*) | 595 IntRect RenderLayerBacking::contentsBox(const GraphicsLayer*) |
| 596 { | 596 { |
| 597 IntRect contentsRect = renderer()->contentBoxRect(); | 597 if (!renderer()->isBox()) |
| 598 return IntRect(); |
| 599 |
| 600 IntRect contentsRect = toRenderBox(renderer())->contentBoxRect(); |
| 598 IntSize contentOffset = contentOffsetInCompostingLayer(); | 601 IntSize contentOffset = contentOffsetInCompostingLayer(); |
| 599 contentsRect.move(contentOffset); | 602 contentsRect.move(contentOffset); |
| 600 return contentsRect; | 603 return contentsRect; |
| 601 } | 604 } |
| 602 | 605 |
| 603 // Map the given point from coordinates in the GraphicsLayer to RenderLayer coor
dinates. | 606 // Map the given point from coordinates in the GraphicsLayer to RenderLayer coor
dinates. |
| 604 FloatPoint RenderLayerBacking::graphicsLayerToContentsCoordinates(const Graphics
Layer* graphicsLayer, const FloatPoint& point) | 607 FloatPoint RenderLayerBacking::graphicsLayerToContentsCoordinates(const Graphics
Layer* graphicsLayer, const FloatPoint& point) |
| 605 { | 608 { |
| 606 return point + FloatSize(graphicsLayer->offsetFromRenderer()); | 609 return point + FloatSize(graphicsLayer->offsetFromRenderer()); |
| 607 } | 610 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 672 } |
| 670 | 673 |
| 671 m_owningLayer->updateLayerListsIfNeeded(); | 674 m_owningLayer->updateLayerListsIfNeeded(); |
| 672 | 675 |
| 673 // Calculate the clip rects we should use. | 676 // Calculate the clip rects we should use. |
| 674 IntRect layerBounds, damageRect, clipRectToApply, outlineRect; | 677 IntRect layerBounds, damageRect, clipRectToApply, outlineRect; |
| 675 m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damage
Rect, clipRectToApply, outlineRect); | 678 m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damage
Rect, clipRectToApply, outlineRect); |
| 676 | 679 |
| 677 int x = layerBounds.x(); // layerBounds is computed relative to rootL
ayer | 680 int x = layerBounds.x(); // layerBounds is computed relative to rootL
ayer |
| 678 int y = layerBounds.y(); | 681 int y = layerBounds.y(); |
| 679 int tx = x - renderer()->x(); | 682 int tx = x - toRenderBox(renderer())->x(); |
| 680 int ty = y - renderer()->y(); | 683 int ty = y - toRenderBox(renderer())->y(); |
| 681 | 684 |
| 682 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | 685 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which |
| 683 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | 686 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). |
| 684 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | 687 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along |
| 685 // so it will be tested against as we decend through the renderers. | 688 // so it will be tested against as we decend through the renderers. |
| 686 RenderObject *paintingRootForRenderer = 0; | 689 RenderObject *paintingRootForRenderer = 0; |
| 687 if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) | 690 if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) |
| 688 paintingRootForRenderer = paintingRoot; | 691 paintingRootForRenderer = paintingRoot; |
| 689 | 692 |
| 690 if (paintingPhase & GraphicsLayerPaintBackgroundMask) { | 693 if (paintingPhase & GraphicsLayerPaintBackgroundMask) { |
| 691 // If this is the root then we need to send in a bigger bounding box | 694 // If this is the root then we need to send in a bigger bounding box |
| 692 // because we'll be painting the background as well (see RenderBox::pain
tRootBoxDecorations()). | 695 // because we'll be painting the background as well (see RenderBox::pain
tRootBoxDecorations()). |
| 693 IntRect paintBox = clipRectToApply; | 696 IntRect paintBox = clipRectToApply; |
| 694 | 697 |
| 698 // FIXME: do we need this code? |
| 695 if (renderer()->node()->isDocumentNode() && renderer()->document()->isHT
MLDocument()) { | 699 if (renderer()->node()->isDocumentNode() && renderer()->document()->isHT
MLDocument()) { |
| 696 int w = renderer()->width(); | 700 RenderBox* box = toRenderBox(renderer()); |
| 697 int h = renderer()->height(); | 701 int w = box->width(); |
| 702 int h = box->height(); |
| 698 | 703 |
| 699 int rw; | 704 int rw; |
| 700 int rh; | 705 int rh; |
| 701 if (renderer()->view()->frameView()) { | 706 if (box->view()->frameView()) { |
| 702 rw = renderer()->view()->frameView()->contentsWidth(); | 707 rw = box->view()->frameView()->contentsWidth(); |
| 703 rh = renderer()->view()->frameView()->contentsHeight(); | 708 rh = box->view()->frameView()->contentsHeight(); |
| 704 } else { | 709 } else { |
| 705 rw = renderer()->view()->width(); | 710 rw = box->view()->width(); |
| 706 rh = renderer()->view()->height(); | 711 rh = box->view()->height(); |
| 707 } | 712 } |
| 708 | 713 |
| 709 int bx = tx - renderer()->marginLeft(); | 714 int bx = tx - box->marginLeft(); |
| 710 int by = ty - renderer()->marginTop(); | 715 int by = ty - box->marginTop(); |
| 711 int bw = max(w + renderer()->marginLeft() + renderer()->marginRight(
) + renderer()->borderLeft() + renderer()->borderRight(), rw); | 716 int bw = max(w + box->marginLeft() + box->marginRight() + box->borde
rLeft() + box->borderRight(), rw); |
| 712 int bh = max(h + renderer()->marginTop() + renderer()->marginBottom(
) + renderer()->borderTop() + renderer()->borderBottom(), rh); | 717 int bh = max(h + box->marginTop() + box->marginBottom() + box->borde
rTop() + box->borderBottom(), rh); |
| 713 paintBox = IntRect(bx, by, bw, bh); | 718 paintBox = IntRect(bx, by, bw, bh); |
| 714 } | 719 } |
| 715 | 720 |
| 716 // Paint our background first, before painting any child layers. | 721 // Paint our background first, before painting any child layers. |
| 717 // Establish the clip used to paint our background. | 722 // Establish the clip used to paint our background. |
| 718 setClip(context, paintDirtyRect, damageRect); | 723 setClip(context, paintDirtyRect, damageRect); |
| 719 | 724 |
| 720 RenderObject::PaintInfo info(context, paintBox, PaintPhaseBlockBackgroun
d, false, paintingRootForRenderer, 0); | 725 RenderObject::PaintInfo info(context, paintBox, PaintPhaseBlockBackgroun
d, false, paintingRootForRenderer, 0); |
| 721 renderer()->paint(info, tx, ty); | 726 renderer()->paint(info, tx, ty); |
| 722 | 727 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 if (hasTransform) | 850 if (hasTransform) |
| 846 transformVector.insert(key, &(keyframeStyle->transform()), tf); | 851 transformVector.insert(key, &(keyframeStyle->transform()), tf); |
| 847 | 852 |
| 848 if (hasOpacity) | 853 if (hasOpacity) |
| 849 opacityVector.insert(key, keyframeStyle->opacity(), tf); | 854 opacityVector.insert(key, keyframeStyle->opacity(), tf); |
| 850 } | 855 } |
| 851 | 856 |
| 852 bool didAnimateTransform = !hasTransform; | 857 bool didAnimateTransform = !hasTransform; |
| 853 bool didAnimateOpacity = !hasOpacity; | 858 bool didAnimateOpacity = !hasOpacity; |
| 854 | 859 |
| 855 if (hasTransform && m_graphicsLayer->animateTransform(transformVector, rende
rer()->borderBoxRect().size(), anim, beginTime, false)) | 860 if (hasTransform && m_graphicsLayer->animateTransform(transformVector, toRen
derBox(renderer())->borderBoxRect().size(), anim, beginTime, false)) |
| 856 didAnimateTransform = true; | 861 didAnimateTransform = true; |
| 857 | 862 |
| 858 if (hasOpacity && m_graphicsLayer->animateFloat(AnimatedPropertyOpacity, opa
cityVector, anim, beginTime)) | 863 if (hasOpacity && m_graphicsLayer->animateFloat(AnimatedPropertyOpacity, opa
cityVector, anim, beginTime)) |
| 859 didAnimateOpacity = true; | 864 didAnimateOpacity = true; |
| 860 | 865 |
| 861 return didAnimateTransform && didAnimateOpacity; | 866 return didAnimateTransform && didAnimateOpacity; |
| 862 } | 867 } |
| 863 | 868 |
| 864 bool RenderLayerBacking::startTransition(double beginTime, int property, const R
enderStyle* fromStyle, const RenderStyle* toStyle) | 869 bool RenderLayerBacking::startTransition(double beginTime, int property, const R
enderStyle* fromStyle, const RenderStyle* toStyle) |
| 865 { | 870 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 881 | 886 |
| 882 if (property == (int)CSSPropertyWebkitTransform && m_owningLayer->hasTransfo
rm()) { | 887 if (property == (int)CSSPropertyWebkitTransform && m_owningLayer->hasTransfo
rm()) { |
| 883 // We get a TransformOperation, which is a linked list of primitive oper
ations and their arguments. | 888 // We get a TransformOperation, which is a linked list of primitive oper
ations and their arguments. |
| 884 // Arguments can be floats or Length values, which need to be converted
to numbers using | 889 // Arguments can be floats or Length values, which need to be converted
to numbers using |
| 885 // val.calcFloatValue(renderer()->width()) (or height()). | 890 // val.calcFloatValue(renderer()->width()) (or height()). |
| 886 const Animation* transformAnim = toStyle->transitionForProperty(CSSPrope
rtyWebkitTransform); | 891 const Animation* transformAnim = toStyle->transitionForProperty(CSSPrope
rtyWebkitTransform); |
| 887 if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { | 892 if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { |
| 888 GraphicsLayer::TransformValueList transformVector; | 893 GraphicsLayer::TransformValueList transformVector; |
| 889 transformVector.insert(0, &fromStyle->transform(), 0); | 894 transformVector.insert(0, &fromStyle->transform(), 0); |
| 890 transformVector.insert(1, &toStyle->transform(), 0); | 895 transformVector.insert(1, &toStyle->transform(), 0); |
| 891 if (m_graphicsLayer->animateTransform(transformVector, renderer()->b
orderBoxRect().size(), transformAnim, beginTime, true)) | 896 if (m_graphicsLayer->animateTransform(transformVector, toRenderBox(r
enderer())->borderBoxRect().size(), transformAnim, beginTime, true)) |
| 892 didAnimate = true; | 897 didAnimate = true; |
| 893 } | 898 } |
| 894 } | 899 } |
| 895 | 900 |
| 896 return didAnimate; | 901 return didAnimate; |
| 897 } | 902 } |
| 898 | 903 |
| 899 void RenderLayerBacking::notifyTransitionStarted(const GraphicsLayer*, AnimatedP
ropertyID property, double time) | |
| 900 { | |
| 901 renderer()->animation()->notifyTransitionStarted(renderer(), graphicsLayerTo
CSSProperty(property), time); | |
| 902 } | |
| 903 | |
| 904 void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double tim
e) | 904 void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double tim
e) |
| 905 { | 905 { |
| 906 renderer()->animation()->notifyAnimationStarted(renderer(), time); | 906 renderer()->animation()->notifyAnimationStarted(renderer(), time); |
| 907 } | 907 } |
| 908 | 908 |
| 909 void RenderLayerBacking::animationFinished(const String& name, int index, bool r
eset) | 909 void RenderLayerBacking::animationFinished(const String& name, int index, bool r
eset) |
| 910 { | 910 { |
| 911 m_graphicsLayer->removeFinishedAnimations(name, index, reset); | 911 m_graphicsLayer->removeFinishedAnimations(name, index, reset); |
| 912 } | 912 } |
| 913 | 913 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 case CSSPropertyBackgroundColor: | 957 case CSSPropertyBackgroundColor: |
| 958 return AnimatedPropertyBackgroundColor; | 958 return AnimatedPropertyBackgroundColor; |
| 959 // It's fine if we see other css properties here; they are just not acce
lerated. | 959 // It's fine if we see other css properties here; they are just not acce
lerated. |
| 960 } | 960 } |
| 961 return AnimatedPropertyInvalid; | 961 return AnimatedPropertyInvalid; |
| 962 } | 962 } |
| 963 | 963 |
| 964 } // namespace WebCore | 964 } // namespace WebCore |
| 965 | 965 |
| 966 #endif // USE(ACCELERATED_COMPOSITING) | 966 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |