mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1099197 - Determine the bounds of unstroked polylines/polygons directly. r=jwatt
This commit is contained in:
parent
9a5408ffa8
commit
687a879b40
@ -119,3 +119,38 @@ nsSVGPolyElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
aMarks->LastElement().angle = prevAngle;
|
||||
aMarks->LastElement().type = nsSVGMark::eEnd;
|
||||
}
|
||||
|
||||
bool
|
||||
nsSVGPolyElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
|
||||
const Matrix& aTransform)
|
||||
{
|
||||
const SVGPointList &points = mPoints.GetAnimValue();
|
||||
|
||||
if (!points.Length()) {
|
||||
// Rendering of the element is disabled
|
||||
aBounds->SetEmpty();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aStrokeWidth > 0) {
|
||||
// We don't handle stroke-miterlimit etc. yet
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aTransform.IsRectilinear()) {
|
||||
// We can avoid transforming each point and just transform the result.
|
||||
// Important for large point lists.
|
||||
Rect bounds(points[0], Size());
|
||||
for (uint32_t i = 1; i < points.Length(); ++i) {
|
||||
bounds.ExpandToEnclose(points[i]);
|
||||
}
|
||||
*aBounds = aTransform.TransformBounds(bounds);
|
||||
} else {
|
||||
*aBounds = Rect(aTransform * points[0], Size());
|
||||
for (uint32_t i = 1; i < points.Length(); ++i) {
|
||||
aBounds->ExpandToEnclose(aTransform * points[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) MOZ_OVERRIDE;
|
||||
virtual bool IsMarkable() MOZ_OVERRIDE { return true; }
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
|
||||
virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
|
||||
const Matrix& aTransform) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<mozilla::DOMSVGPointList> Points();
|
||||
|
@ -177,6 +177,23 @@ struct BaseRect {
|
||||
*static_cast<Sub*>(this) = aRect1.UnionEdges(aRect2);
|
||||
}
|
||||
|
||||
// Expands the rect to include the point
|
||||
void ExpandToEnclose(const Point& aPoint)
|
||||
{
|
||||
if (aPoint.x < x) {
|
||||
width = XMost() - aPoint.x;
|
||||
x = aPoint.x;
|
||||
} else if (aPoint.x > XMost()) {
|
||||
width = aPoint.x - x;
|
||||
}
|
||||
if (aPoint.y < y) {
|
||||
height = YMost() - aPoint.y;
|
||||
y = aPoint.y;
|
||||
} else if (aPoint.y > YMost()) {
|
||||
height = aPoint.y - y;
|
||||
}
|
||||
}
|
||||
|
||||
void SetRect(T aX, T aY, T aWidth, T aHeight)
|
||||
{
|
||||
x = aX; y = aY; width = aWidth; height = aHeight;
|
||||
|
Loading…
Reference in New Issue
Block a user