mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1208829 - Add utilities for converting between typed and untyped regions. r=mstange
This commit is contained in:
parent
cd91e2eec4
commit
6a9369d6f5
@ -729,6 +729,10 @@ public:
|
||||
return This();
|
||||
}
|
||||
|
||||
// Prefer using TransformTo<TargetUnits>(region) from UnitTransforms.h,
|
||||
// as applying the transform should typically change the unit system.
|
||||
// TODO(botond): Move this to IntRegionTyped and disable it for
|
||||
// unit != UnknownUnits.
|
||||
Derived& Transform (const mozilla::gfx::Matrix4x4 &aTransform)
|
||||
{
|
||||
mImpl.Transform(aTransform);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "Units.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "nsRegion.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -78,6 +79,10 @@ template <class TargetUnits, class SourceUnits>
|
||||
gfx::IntMarginTyped<TargetUnits> ViewAs(const gfx::IntMarginTyped<SourceUnits>& aMargin, PixelCastJustification) {
|
||||
return gfx::IntMarginTyped<TargetUnits>(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
|
||||
}
|
||||
template <class TargetUnits, class SourceUnits>
|
||||
gfx::IntRegionTyped<TargetUnits> ViewAs(const gfx::IntRegionTyped<SourceUnits>& aRegion, PixelCastJustification) {
|
||||
return gfx::IntRegionTyped<TargetUnits>::FromUnknownRegion(aRegion.ToUnknownRegion());
|
||||
}
|
||||
template <class NewTargetUnits, class OldTargetUnits, class SourceUnits>
|
||||
gfx::ScaleFactor<SourceUnits, NewTargetUnits> ViewTargetAs(
|
||||
const gfx::ScaleFactor<SourceUnits, OldTargetUnits>& aScaleFactor,
|
||||
@ -112,6 +117,10 @@ template <class TargetUnits>
|
||||
gfx::IntRectTyped<TargetUnits> ViewAs(const nsIntRect& aRect) {
|
||||
return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
}
|
||||
template <class TargetUnits>
|
||||
gfx::IntRegionTyped<TargetUnits> ViewAs(const nsIntRegion& aRegion) {
|
||||
return gfx::IntRegionTyped<TargetUnits>::FromUnknownRegion(aRegion);
|
||||
}
|
||||
|
||||
// Convenience functions for transforming an entity from one strongly-typed
|
||||
// coordinate system to another using the provided transformation matrix.
|
||||
@ -140,6 +149,12 @@ static gfx::IntRectTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransfo
|
||||
gfx::Rect rect(aRect.ToUnknownRect());
|
||||
return RoundedToInt(ViewAs<TargetUnits>(aTransform.TransformBounds(rect)));
|
||||
}
|
||||
template <typename TargetUnits, typename SourceUnits>
|
||||
static gfx::IntRegionTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
|
||||
const gfx::IntRegionTyped<SourceUnits>& aRegion)
|
||||
{
|
||||
return ViewAs<TargetUnits>(aRegion.ToUnknownRegion().Transform(aTransform));
|
||||
}
|
||||
|
||||
// Transform |aVector|, which is anchored at |aAnchor|, by the given transform
|
||||
// matrix, yielding a point in |TargetUnits|.
|
||||
|
Loading…
Reference in New Issue
Block a user