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, toRenderBox(renderer())->borderBoxRect().size()
, RenderStyle::ExcludeTransformOrigin); | 119 style->applyTransform(t, renderer()->borderBoxRect().size(), false); |
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 = toRenderBox(renderer())->borderBoxRect(); | 241 const IntRect borderBox = 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 if (!renderer()->isBox()) | 597 IntRect contentsRect = renderer()->contentBoxRect(); |
598 return IntRect(); | |
599 | |
600 IntRect contentsRect = toRenderBox(renderer())->contentBoxRect(); | |
601 IntSize contentOffset = contentOffsetInCompostingLayer(); | 598 IntSize contentOffset = contentOffsetInCompostingLayer(); |
602 contentsRect.move(contentOffset); | 599 contentsRect.move(contentOffset); |
603 return contentsRect; | 600 return contentsRect; |
604 } | 601 } |
605 | 602 |
606 // Map the given point from coordinates in the GraphicsLayer to RenderLayer coor
dinates. | 603 // Map the given point from coordinates in the GraphicsLayer to RenderLayer coor
dinates. |
607 FloatPoint RenderLayerBacking::graphicsLayerToContentsCoordinates(const Graphics
Layer* graphicsLayer, const FloatPoint& point) | 604 FloatPoint RenderLayerBacking::graphicsLayerToContentsCoordinates(const Graphics
Layer* graphicsLayer, const FloatPoint& point) |
608 { | 605 { |
609 return point + FloatSize(graphicsLayer->offsetFromRenderer()); | 606 return point + FloatSize(graphicsLayer->offsetFromRenderer()); |
610 } | 607 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 669 } |
673 | 670 |
674 m_owningLayer->updateLayerListsIfNeeded(); | 671 m_owningLayer->updateLayerListsIfNeeded(); |
675 | 672 |
676 // Calculate the clip rects we should use. | 673 // Calculate the clip rects we should use. |
677 IntRect layerBounds, damageRect, clipRectToApply, outlineRect; | 674 IntRect layerBounds, damageRect, clipRectToApply, outlineRect; |
678 m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damage
Rect, clipRectToApply, outlineRect); | 675 m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damage
Rect, clipRectToApply, outlineRect); |
679 | 676 |
680 int x = layerBounds.x(); // layerBounds is computed relative to rootL
ayer | 677 int x = layerBounds.x(); // layerBounds is computed relative to rootL
ayer |
681 int y = layerBounds.y(); | 678 int y = layerBounds.y(); |
682 int tx = x - toRenderBox(renderer())->x(); | 679 int tx = x - renderer()->x(); |
683 int ty = y - toRenderBox(renderer())->y(); | 680 int ty = y - renderer()->y(); |
684 | 681 |
685 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | 682 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which |
686 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | 683 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). |
687 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | 684 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along |
688 // so it will be tested against as we decend through the renderers. | 685 // so it will be tested against as we decend through the renderers. |
689 RenderObject *paintingRootForRenderer = 0; | 686 RenderObject *paintingRootForRenderer = 0; |
690 if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) | 687 if (paintingRoot && !renderer()->isDescendantOf(paintingRoot)) |
691 paintingRootForRenderer = paintingRoot; | 688 paintingRootForRenderer = paintingRoot; |
692 | 689 |
693 if (paintingPhase & GraphicsLayerPaintBackgroundMask) { | 690 if (paintingPhase & GraphicsLayerPaintBackgroundMask) { |
694 // If this is the root then we need to send in a bigger bounding box | 691 // If this is the root then we need to send in a bigger bounding box |
695 // because we'll be painting the background as well (see RenderBox::pain
tRootBoxDecorations()). | 692 // because we'll be painting the background as well (see RenderBox::pain
tRootBoxDecorations()). |
696 IntRect paintBox = clipRectToApply; | 693 IntRect paintBox = clipRectToApply; |
697 | 694 |
698 // FIXME: do we need this code? | |
699 if (renderer()->node()->isDocumentNode() && renderer()->document()->isHT
MLDocument()) { | 695 if (renderer()->node()->isDocumentNode() && renderer()->document()->isHT
MLDocument()) { |
700 RenderBox* box = toRenderBox(renderer()); | 696 int w = renderer()->width(); |
701 int w = box->width(); | 697 int h = renderer()->height(); |
702 int h = box->height(); | |
703 | 698 |
704 int rw; | 699 int rw; |
705 int rh; | 700 int rh; |
706 if (box->view()->frameView()) { | 701 if (renderer()->view()->frameView()) { |
707 rw = box->view()->frameView()->contentsWidth(); | 702 rw = renderer()->view()->frameView()->contentsWidth(); |
708 rh = box->view()->frameView()->contentsHeight(); | 703 rh = renderer()->view()->frameView()->contentsHeight(); |
709 } else { | 704 } else { |
710 rw = box->view()->width(); | 705 rw = renderer()->view()->width(); |
711 rh = box->view()->height(); | 706 rh = renderer()->view()->height(); |
712 } | 707 } |
713 | 708 |
714 int bx = tx - box->marginLeft(); | 709 int bx = tx - renderer()->marginLeft(); |
715 int by = ty - box->marginTop(); | 710 int by = ty - renderer()->marginTop(); |
716 int bw = max(w + box->marginLeft() + box->marginRight() + box->borde
rLeft() + box->borderRight(), rw); | 711 int bw = max(w + renderer()->marginLeft() + renderer()->marginRight(
) + renderer()->borderLeft() + renderer()->borderRight(), rw); |
717 int bh = max(h + box->marginTop() + box->marginBottom() + box->borde
rTop() + box->borderBottom(), rh); | 712 int bh = max(h + renderer()->marginTop() + renderer()->marginBottom(
) + renderer()->borderTop() + renderer()->borderBottom(), rh); |
718 paintBox = IntRect(bx, by, bw, bh); | 713 paintBox = IntRect(bx, by, bw, bh); |
719 } | 714 } |
720 | 715 |
721 // Paint our background first, before painting any child layers. | 716 // Paint our background first, before painting any child layers. |
722 // Establish the clip used to paint our background. | 717 // Establish the clip used to paint our background. |
723 setClip(context, paintDirtyRect, damageRect); | 718 setClip(context, paintDirtyRect, damageRect); |
724 | 719 |
725 RenderObject::PaintInfo info(context, paintBox, PaintPhaseBlockBackgroun
d, false, paintingRootForRenderer, 0); | 720 RenderObject::PaintInfo info(context, paintBox, PaintPhaseBlockBackgroun
d, false, paintingRootForRenderer, 0); |
726 renderer()->paint(info, tx, ty); | 721 renderer()->paint(info, tx, ty); |
727 | 722 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 if (hasTransform) | 845 if (hasTransform) |
851 transformVector.insert(key, &(keyframeStyle->transform()), tf); | 846 transformVector.insert(key, &(keyframeStyle->transform()), tf); |
852 | 847 |
853 if (hasOpacity) | 848 if (hasOpacity) |
854 opacityVector.insert(key, keyframeStyle->opacity(), tf); | 849 opacityVector.insert(key, keyframeStyle->opacity(), tf); |
855 } | 850 } |
856 | 851 |
857 bool didAnimateTransform = !hasTransform; | 852 bool didAnimateTransform = !hasTransform; |
858 bool didAnimateOpacity = !hasOpacity; | 853 bool didAnimateOpacity = !hasOpacity; |
859 | 854 |
860 if (hasTransform && m_graphicsLayer->animateTransform(transformVector, toRen
derBox(renderer())->borderBoxRect().size(), anim, beginTime, false)) | 855 if (hasTransform && m_graphicsLayer->animateTransform(transformVector, rende
rer()->borderBoxRect().size(), anim, beginTime, false)) |
861 didAnimateTransform = true; | 856 didAnimateTransform = true; |
862 | 857 |
863 if (hasOpacity && m_graphicsLayer->animateFloat(AnimatedPropertyOpacity, opa
cityVector, anim, beginTime)) | 858 if (hasOpacity && m_graphicsLayer->animateFloat(AnimatedPropertyOpacity, opa
cityVector, anim, beginTime)) |
864 didAnimateOpacity = true; | 859 didAnimateOpacity = true; |
865 | 860 |
866 return didAnimateTransform && didAnimateOpacity; | 861 return didAnimateTransform && didAnimateOpacity; |
867 } | 862 } |
868 | 863 |
869 bool RenderLayerBacking::startTransition(double beginTime, int property, const R
enderStyle* fromStyle, const RenderStyle* toStyle) | 864 bool RenderLayerBacking::startTransition(double beginTime, int property, const R
enderStyle* fromStyle, const RenderStyle* toStyle) |
870 { | 865 { |
(...skipping 15 matching lines...) Expand all Loading... |
886 | 881 |
887 if (property == (int)CSSPropertyWebkitTransform && m_owningLayer->hasTransfo
rm()) { | 882 if (property == (int)CSSPropertyWebkitTransform && m_owningLayer->hasTransfo
rm()) { |
888 // We get a TransformOperation, which is a linked list of primitive oper
ations and their arguments. | 883 // We get a TransformOperation, which is a linked list of primitive oper
ations and their arguments. |
889 // Arguments can be floats or Length values, which need to be converted
to numbers using | 884 // Arguments can be floats or Length values, which need to be converted
to numbers using |
890 // val.calcFloatValue(renderer()->width()) (or height()). | 885 // val.calcFloatValue(renderer()->width()) (or height()). |
891 const Animation* transformAnim = toStyle->transitionForProperty(CSSPrope
rtyWebkitTransform); | 886 const Animation* transformAnim = toStyle->transitionForProperty(CSSPrope
rtyWebkitTransform); |
892 if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { | 887 if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { |
893 GraphicsLayer::TransformValueList transformVector; | 888 GraphicsLayer::TransformValueList transformVector; |
894 transformVector.insert(0, &fromStyle->transform(), 0); | 889 transformVector.insert(0, &fromStyle->transform(), 0); |
895 transformVector.insert(1, &toStyle->transform(), 0); | 890 transformVector.insert(1, &toStyle->transform(), 0); |
896 if (m_graphicsLayer->animateTransform(transformVector, toRenderBox(r
enderer())->borderBoxRect().size(), transformAnim, beginTime, true)) | 891 if (m_graphicsLayer->animateTransform(transformVector, renderer()->b
orderBoxRect().size(), transformAnim, beginTime, true)) |
897 didAnimate = true; | 892 didAnimate = true; |
898 } | 893 } |
899 } | 894 } |
900 | 895 |
901 return didAnimate; | 896 return didAnimate; |
902 } | 897 } |
903 | 898 |
| 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 |