Commit 60953bc5 authored by rob.buis@samsung.com's avatar rob.buis@samsung.com

Move supplemental transform to rare data

The AffineTransformation for animateMotion is pretty rare
and just makes SVGGraphicsElement take up more memory, so
move it to SVGElementRareData.

Review URL: https://codereview.chromium.org/660653004

git-svn-id: svn://svn.chromium.org/blink/trunk@183854 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c0962354
...@@ -172,7 +172,7 @@ void SVGAnimateMotionElement::resetAnimatedType() ...@@ -172,7 +172,7 @@ void SVGAnimateMotionElement::resetAnimatedType()
SVGElement* targetElement = this->targetElement(); SVGElement* targetElement = this->targetElement();
if (!targetElement) if (!targetElement)
return; return;
if (AffineTransform* transform = targetElement->supplementalTransform()) if (AffineTransform* transform = targetElement->animateMotionTransform())
transform->makeIdentity(); transform->makeIdentity();
} }
...@@ -181,7 +181,7 @@ void SVGAnimateMotionElement::clearAnimatedType(SVGElement* targetElement) ...@@ -181,7 +181,7 @@ void SVGAnimateMotionElement::clearAnimatedType(SVGElement* targetElement)
if (!targetElement) if (!targetElement)
return; return;
AffineTransform* transform = targetElement->supplementalTransform(); AffineTransform* transform = targetElement->animateMotionTransform();
if (!transform) if (!transform)
return; return;
...@@ -225,7 +225,7 @@ void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned ...@@ -225,7 +225,7 @@ void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned
SVGElement* targetElement = this->targetElement(); SVGElement* targetElement = this->targetElement();
if (!targetElement) if (!targetElement)
return; return;
AffineTransform* transform = targetElement->supplementalTransform(); AffineTransform* transform = targetElement->animateMotionTransform();
if (!transform) if (!transform)
return; return;
...@@ -285,7 +285,7 @@ void SVGAnimateMotionElement::applyResultsToTarget() ...@@ -285,7 +285,7 @@ void SVGAnimateMotionElement::applyResultsToTarget()
if (RenderObject* renderer = targetElement->renderer()) if (RenderObject* renderer = targetElement->renderer())
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
AffineTransform* t = targetElement->supplementalTransform(); AffineTransform* t = targetElement->animateMotionTransform();
if (!t) if (!t)
return; return;
...@@ -295,7 +295,7 @@ void SVGAnimateMotionElement::applyResultsToTarget() ...@@ -295,7 +295,7 @@ void SVGAnimateMotionElement::applyResultsToTarget()
for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = instances.begin(); it != end; ++it) { for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = instances.begin(); it != end; ++it) {
SVGElement* shadowTreeElement = *it; SVGElement* shadowTreeElement = *it;
ASSERT(shadowTreeElement); ASSERT(shadowTreeElement);
AffineTransform* transform = shadowTreeElement->supplementalTransform(); AffineTransform* transform = shadowTreeElement->animateMotionTransform();
if (!transform) if (!transform)
continue; continue;
transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f());
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
void svgLoadEventTimerFired(Timer<SVGElement>*); void svgLoadEventTimerFired(Timer<SVGElement>*);
virtual Timer<SVGElement>* svgLoadEventTimer(); virtual Timer<SVGElement>* svgLoadEventTimer();
virtual AffineTransform* supplementalTransform() { return 0; } virtual AffineTransform* animateMotionTransform() { return 0; }
void invalidateSVGAttributes() { ensureUniqueElementData().m_animatedSVGAttributesAreDirty = true; } void invalidateSVGAttributes() { ensureUniqueElementData().m_animatedSVGAttributesAreDirty = true; }
void invalidateSVGPresentationAttributeStyle() { ensureUniqueElementData().m_presentationAttributeStyleIsDirty = true; } void invalidateSVGPresentationAttributeStyle() { ensureUniqueElementData().m_presentationAttributeStyleIsDirty = true; }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "core/css/resolver/StyleResolver.h" #include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/svg/SVGCursorElement.h" #include "core/svg/SVGCursorElement.h"
#include "platform/transforms/AffineTransform.h"
namespace blink { namespace blink {
...@@ -67,5 +68,11 @@ void SVGElementRareData::processWeakMembers(Visitor* visitor) ...@@ -67,5 +68,11 @@ void SVGElementRareData::processWeakMembers(Visitor* visitor)
#endif #endif
} }
AffineTransform* SVGElementRareData::animateMotionTransform()
{
if (!m_animateMotionTransform)
m_animateMotionTransform = adoptPtr(new AffineTransform);
return m_animateMotionTransform.get();
}
} }
...@@ -77,6 +77,8 @@ public: ...@@ -77,6 +77,8 @@ public:
void setUseOverrideComputedStyle(bool value) { m_useOverrideComputedStyle = value; } void setUseOverrideComputedStyle(bool value) { m_useOverrideComputedStyle = value; }
void setNeedsOverrideComputedStyleUpdate() { m_needsOverrideComputedStyleUpdate = true; } void setNeedsOverrideComputedStyleUpdate() { m_needsOverrideComputedStyleUpdate = true; }
AffineTransform* animateMotionTransform();
void trace(Visitor*); void trace(Visitor*);
void processWeakMembers(Visitor*); void processWeakMembers(Visitor*);
...@@ -95,6 +97,8 @@ private: ...@@ -95,6 +97,8 @@ private:
bool m_needsOverrideComputedStyleUpdate : 1; bool m_needsOverrideComputedStyleUpdate : 1;
RefPtrWillBeMember<MutableStylePropertySet> m_animatedSMILStyleProperties; RefPtrWillBeMember<MutableStylePropertySet> m_animatedSMILStyleProperties;
RefPtr<RenderStyle> m_overrideComputedStyle; RefPtr<RenderStyle> m_overrideComputedStyle;
// Used by <animateMotion>
OwnPtr<AffineTransform> m_animateMotionTransform;
}; };
} }
......
...@@ -24,9 +24,11 @@ ...@@ -24,9 +24,11 @@
#include "core/svg/SVGGraphicsElement.h" #include "core/svg/SVGGraphicsElement.h"
#include "core/SVGNames.h" #include "core/SVGNames.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/rendering/svg/RenderSVGPath.h" #include "core/rendering/svg/RenderSVGPath.h"
#include "core/rendering/svg/RenderSVGResource.h" #include "core/rendering/svg/RenderSVGResource.h"
#include "core/rendering/svg/SVGPathData.h" #include "core/rendering/svg/SVGPathData.h"
#include "core/svg/SVGElementRareData.h"
#include "platform/transforms/AffineTransform.h" #include "platform/transforms/AffineTransform.h"
namespace blink { namespace blink {
...@@ -155,16 +157,14 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const ...@@ -155,16 +157,14 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const
m_transform->currentValue()->concatenate(matrix); m_transform->currentValue()->concatenate(matrix);
} }
if (m_supplementalTransform) if (hasSVGRareData())
return *m_supplementalTransform * matrix; return *svgRareData()->animateMotionTransform() * matrix;
return matrix; return matrix;
} }
AffineTransform* SVGGraphicsElement::supplementalTransform() AffineTransform* SVGGraphicsElement::animateMotionTransform()
{ {
if (!m_supplementalTransform) return ensureSVGRareData()->animateMotionTransform();
m_supplementalTransform = adoptPtr(new AffineTransform);
return m_supplementalTransform.get();
} }
bool SVGGraphicsElement::isSupportedAttribute(const QualifiedName& attrName) bool SVGGraphicsElement::isSupportedAttribute(const QualifiedName& attrName)
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
virtual AffineTransform localCoordinateSpaceTransform(SVGElement::CTMScope) const override { return animatedLocalTransform(); } virtual AffineTransform localCoordinateSpaceTransform(SVGElement::CTMScope) const override { return animatedLocalTransform(); }
virtual AffineTransform animatedLocalTransform() const; virtual AffineTransform animatedLocalTransform() const;
virtual AffineTransform* supplementalTransform() override; virtual AffineTransform* animateMotionTransform() override;
virtual FloatRect getBBox(); virtual FloatRect getBBox();
PassRefPtr<SVGRectTearOff> getBBoxFromJavascript(); PassRefPtr<SVGRectTearOff> getBBoxFromJavascript();
...@@ -82,9 +82,6 @@ protected: ...@@ -82,9 +82,6 @@ protected:
private: private:
virtual bool isSVGGraphicsElement() const override final { return true; } virtual bool isSVGGraphicsElement() const override final { return true; }
// Used by <animateMotion>
OwnPtr<AffineTransform> m_supplementalTransform;
}; };
inline bool isSVGGraphicsElement(const SVGElement& element) inline bool isSVGGraphicsElement(const SVGElement& element)
......
...@@ -53,7 +53,7 @@ AffineTransform SVGTextElement::animatedLocalTransform() const ...@@ -53,7 +53,7 @@ AffineTransform SVGTextElement::animatedLocalTransform() const
transform()->currentValue()->concatenate(matrix); transform()->currentValue()->concatenate(matrix);
} }
const AffineTransform* transform = const_cast<SVGTextElement*>(this)->supplementalTransform(); const AffineTransform* transform = const_cast<SVGTextElement*>(this)->animateMotionTransform();
if (transform) if (transform)
return *transform * matrix; return *transform * matrix;
return matrix; return matrix;
......
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