зеркало из https://github.com/mozilla/gecko-dev.git
Bug 937994 - Make the SMIL animateMotion code use a Moz2D PathBuilder instead of gfxContext. r=dholbert
This commit is contained in:
Родитель
ff4b20243d
Коммит
dc9a078082
|
@ -4,11 +4,15 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "SVGMotionSMILPathUtils.h"
|
#include "SVGMotionSMILPathUtils.h"
|
||||||
|
|
||||||
|
#include "gfxPath.h"
|
||||||
#include "nsCharSeparatedTokenizer.h"
|
#include "nsCharSeparatedTokenizer.h"
|
||||||
#include "nsContentUtils.h" // for NS_ENSURE_FINITE2
|
#include "nsContentUtils.h" // for NS_ENSURE_FINITE2
|
||||||
#include "SVGContentUtils.h"
|
#include "SVGContentUtils.h"
|
||||||
#include "SVGLength.h"
|
#include "SVGLength.h"
|
||||||
|
|
||||||
|
using namespace mozilla::gfx;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -22,7 +26,7 @@ SVGMotionSMILPathUtils::PathGenerator::
|
||||||
NS_ABORT_IF_FALSE(!mHaveReceivedCommands,
|
NS_ABORT_IF_FALSE(!mHaveReceivedCommands,
|
||||||
"Not expecting requests for mid-path MoveTo commands");
|
"Not expecting requests for mid-path MoveTo commands");
|
||||||
mHaveReceivedCommands = true;
|
mHaveReceivedCommands = true;
|
||||||
mGfxContext.MoveTo(gfxPoint(0, 0));
|
mPathBuilder->MoveTo(Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For 'from' and the first entry in 'values'.
|
// For 'from' and the first entry in 'values'.
|
||||||
|
@ -38,7 +42,7 @@ SVGMotionSMILPathUtils::PathGenerator::
|
||||||
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mGfxContext.MoveTo(gfxPoint(xVal, yVal));
|
mPathBuilder->MoveTo(Point(xVal, yVal));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +57,9 @@ SVGMotionSMILPathUtils::PathGenerator::
|
||||||
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gfxPoint initialPoint = mGfxContext.CurrentPoint();
|
Point initialPoint = mPathBuilder->CurrentPoint();
|
||||||
|
|
||||||
mGfxContext.LineTo(gfxPoint(xVal, yVal));
|
mPathBuilder->LineTo(Point(xVal, yVal));
|
||||||
aSegmentDistance = NS_hypot(initialPoint.x - xVal, initialPoint.y -yVal);
|
aSegmentDistance = NS_hypot(initialPoint.x - xVal, initialPoint.y -yVal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +75,7 @@ SVGMotionSMILPathUtils::PathGenerator::
|
||||||
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mGfxContext.LineTo(mGfxContext.CurrentPoint() + gfxPoint(xVal, yVal));
|
mPathBuilder->LineTo(mPathBuilder->CurrentPoint() + Point(xVal, yVal));
|
||||||
aSegmentDistance = NS_hypot(xVal, yVal);
|
aSegmentDistance = NS_hypot(xVal, yVal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +83,9 @@ SVGMotionSMILPathUtils::PathGenerator::
|
||||||
already_AddRefed<gfxPath>
|
already_AddRefed<gfxPath>
|
||||||
SVGMotionSMILPathUtils::PathGenerator::GetResultingPath()
|
SVGMotionSMILPathUtils::PathGenerator::GetResultingPath()
|
||||||
{
|
{
|
||||||
return mGfxContext.CopyPath();
|
RefPtr<Path> path = mPathBuilder->Finish();
|
||||||
|
nsRefPtr<gfxPath> thebesPath = new gfxPath(path);
|
||||||
|
return thebesPath.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#define MOZILLA_SVGMOTIONSMILPATHUTILS_H_
|
#define MOZILLA_SVGMOTIONSMILPATHUTILS_H_
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "gfxContext.h"
|
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
|
#include "mozilla/RefPtr.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
#include "nsSMILParserUtils.h"
|
#include "nsSMILParserUtils.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
@ -23,7 +23,11 @@ class nsSVGElement;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
class SVGMotionSMILPathUtils {
|
class SVGMotionSMILPathUtils
|
||||||
|
{
|
||||||
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||||
|
typedef mozilla::gfx::PathBuilder PathBuilder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Class to assist in generating a gfxPath, based on
|
// Class to assist in generating a gfxPath, based on
|
||||||
// coordinates in the <animateMotion> from/by/to/values attributes.
|
// coordinates in the <animateMotion> from/by/to/values attributes.
|
||||||
|
@ -31,9 +35,16 @@ public:
|
||||||
public:
|
public:
|
||||||
PathGenerator(const nsSVGElement* aSVGElement)
|
PathGenerator(const nsSVGElement* aSVGElement)
|
||||||
: mSVGElement(aSVGElement),
|
: mSVGElement(aSVGElement),
|
||||||
mGfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface()),
|
|
||||||
mHaveReceivedCommands(false)
|
mHaveReceivedCommands(false)
|
||||||
{}
|
{
|
||||||
|
RefPtr<DrawTarget> drawTarget =
|
||||||
|
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
||||||
|
NS_ASSERTION(gfxPlatform::GetPlatform()->
|
||||||
|
SupportsAzureContentForDrawTarget(drawTarget),
|
||||||
|
"Should support Moz2D content drawing");
|
||||||
|
|
||||||
|
mPathBuilder = drawTarget->CreatePathBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
// Methods for adding various path commands to output path.
|
// Methods for adding various path commands to output path.
|
||||||
// Note: aCoordPairStr is expected to be a whitespace and/or
|
// Note: aCoordPairStr is expected to be a whitespace and/or
|
||||||
|
@ -59,7 +70,7 @@ public:
|
||||||
|
|
||||||
// Member data
|
// Member data
|
||||||
const nsSVGElement* mSVGElement; // context for converting to user units
|
const nsSVGElement* mSVGElement; // context for converting to user units
|
||||||
gfxContext mGfxContext;
|
RefPtr<PathBuilder> mPathBuilder;
|
||||||
bool mHaveReceivedCommands;
|
bool mHaveReceivedCommands;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче