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