Bug 1069417 - Remove the explicit template argument of TransformTo() and related functions. r=kats

In this process, TransformTo() and UntransformTo() are renamed TransformedBy()
and UntransformBy() so calls to them continue to read sensibly.

--HG--
extra : rebase_source : a2a4b36514cc54533757c075fcf2c53ab3020939
extra : source : 826da3dc12baeb84b32be50f4b2c0591ca73ab37
This commit is contained in:
Botond Ballo 2015-11-30 20:06:45 -05:00
Родитель 70b749edea
Коммит ae1bdc7602
12 изменённых файлов: 48 добавлений и 48 удалений

Просмотреть файл

@ -753,7 +753,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
// gecko space should only consist of overscroll-cancelling transforms.
ScreenToScreenMatrix4x4 transformToGecko = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
Maybe<ScreenPoint> untransformedOrigin = UntransformTo<ScreenPixel>(
Maybe<ScreenPoint> untransformedOrigin = UntransformBy(
transformToGecko, wheelInput.mOrigin);
if (!untransformedOrigin) {
@ -793,9 +793,9 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
// gecko space should only consist of overscroll-cancelling transforms.
ScreenToScreenMatrix4x4 transformToGecko = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
Maybe<ScreenPoint> untransformedStartPoint = UntransformTo<ScreenPixel>(
Maybe<ScreenPoint> untransformedStartPoint = UntransformBy(
transformToGecko, panInput.mPanStartPoint);
Maybe<ScreenPoint> untransformedDisplacement = UntransformVector<ScreenPixel>(
Maybe<ScreenPoint> untransformedDisplacement = UntransformVector(
transformToGecko, panInput.mPanDisplacement, panInput.mPanStartPoint);
if (!untransformedStartPoint || !untransformedDisplacement) {
@ -822,7 +822,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
ScreenToScreenMatrix4x4 outTransform = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
Maybe<ScreenPoint> untransformedFocusPoint = UntransformTo<ScreenPixel>(
Maybe<ScreenPoint> untransformedFocusPoint = UntransformBy(
outTransform, pinchInput.mFocusPoint);
if (!untransformedFocusPoint) {
@ -849,7 +849,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
ScreenToScreenMatrix4x4 outTransform = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
Maybe<ScreenIntPoint> untransformedPoint =
UntransformTo<ScreenPixel>(outTransform, tapInput.mPoint);
UntransformBy(outTransform, tapInput.mPoint);
if (!untransformedPoint) {
return result;
@ -957,7 +957,7 @@ APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput,
for (size_t i = 0; i < aInput.mTouches.Length(); i++) {
SingleTouchData& touchData = aInput.mTouches[i];
Maybe<ScreenIntPoint> untransformedScreenPoint = UntransformTo<ScreenPixel>(
Maybe<ScreenIntPoint> untransformedScreenPoint = UntransformBy(
outTransform, touchData.mScreenPoint);
if (!untransformedScreenPoint) {
return nsEventStatus_eIgnore;
@ -1046,7 +1046,7 @@ APZCTreeManager::ProcessEvent(WidgetInputEvent& aEvent,
ParentLayerToScreenMatrix4x4 transformToGecko = GetApzcToGeckoTransform(apzc);
ScreenToScreenMatrix4x4 outTransform = transformToApzc * transformToGecko;
Maybe<ScreenIntPoint> untransformedRefPoint =
UntransformTo<ScreenPixel>(outTransform, refPointAsScreen);
UntransformBy(outTransform, refPointAsScreen);
if (untransformedRefPoint) {
aEvent.refPoint = ViewAs<LayoutDevicePixel>(*untransformedRefPoint, LDIsScreen);
}
@ -1354,14 +1354,14 @@ TransformDisplacement(APZCTreeManager* aTreeManager,
// Convert start and end points to Screen coordinates.
ParentLayerToScreenMatrix4x4 untransformToApzc = aTreeManager->GetScreenToApzcTransform(aSource).Inverse();
ScreenPoint screenStart = TransformTo<ScreenPixel>(untransformToApzc, aStartPoint);
ScreenPoint screenEnd = TransformTo<ScreenPixel>(untransformToApzc, aEndPoint);
ScreenPoint screenStart = TransformBy(untransformToApzc, aStartPoint);
ScreenPoint screenEnd = TransformBy(untransformToApzc, aEndPoint);
// Convert start and end points to aTarget's ParentLayer coordinates.
ScreenToParentLayerMatrix4x4 transformToApzc = aTreeManager->GetScreenToApzcTransform(aTarget);
Maybe<ParentLayerPoint> startPoint = UntransformTo<ParentLayerPixel>(transformToApzc, screenStart);
Maybe<ParentLayerPoint> endPoint = UntransformTo<ParentLayerPixel>(transformToApzc, screenEnd);
Maybe<ParentLayerPoint> startPoint = UntransformBy(transformToApzc, screenStart);
Maybe<ParentLayerPoint> endPoint = UntransformBy(transformToApzc, screenEnd);
if (!startPoint || !endPoint) {
return false;
}

Просмотреть файл

@ -1554,7 +1554,7 @@ AsyncPanZoomController::ConvertToGecko(const ScreenIntPoint& aPoint, CSSPoint* a
treeManagerLocal->GetScreenToApzcTransform(this)
* treeManagerLocal->GetApzcToGeckoTransform(this);
Maybe<ScreenIntPoint> layoutPoint = UntransformTo<ScreenPixel>(
Maybe<ScreenIntPoint> layoutPoint = UntransformBy(
transformScreenToGecko, aPoint);
if (!layoutPoint) {
return false;
@ -2059,19 +2059,19 @@ ScreenToParentLayerMatrix4x4 AsyncPanZoomController::GetTransformToThis() const
ScreenPoint AsyncPanZoomController::ToScreenCoordinates(const ParentLayerPoint& aVector,
const ParentLayerPoint& aAnchor) const {
return TransformVector<ScreenPixel>(GetTransformToThis().Inverse(), aVector, aAnchor);
return TransformVector(GetTransformToThis().Inverse(), aVector, aAnchor);
}
// TODO: figure out a good way to check the w-coordinate is positive and return the result
ParentLayerPoint AsyncPanZoomController::ToParentLayerCoordinates(const ScreenPoint& aVector,
const ScreenPoint& aAnchor) const {
return TransformVector<ParentLayerPixel>(GetTransformToThis(), aVector, aAnchor);
return TransformVector(GetTransformToThis(), aVector, aAnchor);
}
bool AsyncPanZoomController::Contains(const ScreenIntPoint& aPoint) const
{
ScreenToParentLayerMatrix4x4 transformToThis = GetTransformToThis();
Maybe<ParentLayerIntPoint> point = UntransformTo<ParentLayerPixel>(transformToThis, aPoint);
Maybe<ParentLayerIntPoint> point = UntransformBy(transformToThis, aPoint);
if (!point) {
return false;
}

Просмотреть файл

@ -231,7 +231,7 @@ HitTestingTreeNode::Untransform(const ParentLayerPoint& aPoint) const
if (mApzc) {
localTransform = localTransform * mApzc->GetCurrentAsyncTransformWithOverscroll();
}
return UntransformTo<LayerPixel>(
return UntransformBy(
ViewAs<LayerToParentLayerMatrix4x4>(localTransform).Inverse(), aPoint);
}

Просмотреть файл

@ -60,7 +60,7 @@ ApplyParentLayerToLayerTransform(const ParentLayerToLayerMatrix4x4& aTransform,
const ParentLayerRect& aParentLayerRect,
const LayerRect& aClip)
{
return UntransformTo<LayerPixel>(aTransform, aParentLayerRect, aClip);
return UntransformBy(aTransform, aParentLayerRect, aClip);
}
static LayerToParentLayerMatrix4x4

Просмотреть файл

@ -1407,7 +1407,7 @@ GetCompositorSideCompositionBounds(const LayerMetricsWrapper& aScrollAncestor,
LayerToParentLayerMatrix4x4 transform = aTransformToCompBounds *
ViewAs<ParentLayerToParentLayerMatrix4x4>(aAPZTransform);
return UntransformTo<LayerPixel>(transform.Inverse(),
return UntransformBy(transform.Inverse(),
aScrollAncestor.Metrics().GetCompositionBounds(), aClip);
}

Просмотреть файл

@ -207,7 +207,7 @@ TransformClipRect(Layer* aLayer,
MOZ_ASSERT(aTransform.Is2D());
const Maybe<ParentLayerIntRect>& clipRect = aLayer->AsLayerComposite()->GetShadowClipRect();
if (clipRect) {
ParentLayerIntRect transformed = TransformTo<ParentLayerPixel>(aTransform, *clipRect);
ParentLayerIntRect transformed = TransformBy(aTransform, *clipRect);
aLayer->AsLayerComposite()->SetShadowClipRect(Some(transformed));
}
}
@ -469,8 +469,8 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer,
// where the local transform isn't applied yet, so apply it and then subtract
// to get the desired translation.
auto localTransformTyped = ViewAs<LayerToParentLayerMatrix4x4>(localTransform);
ParentLayerPoint translation = TransformTo<ParentLayerPixel>(localTransformTyped, transformedAnchor)
- TransformTo<ParentLayerPixel>(localTransformTyped, anchor);
ParentLayerPoint translation = TransformBy(localTransformTyped, transformedAnchor)
- TransformBy(localTransformTyped, anchor);
if (aLayer->GetIsStickyPosition()) {
// For sticky positioned layers, the difference between the two rectangles
@ -897,7 +897,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
// frame and should not be transformed.
if (asyncClip && !metrics.UsesContainerScrolling()) {
MOZ_ASSERT(asyncTransform.Is2D());
asyncClip = Some(TransformTo<ParentLayerPixel>(
asyncClip = Some(TransformBy(
ViewAs<ParentLayerToParentLayerMatrix4x4>(asyncTransform), *asyncClip));
}

Просмотреть файл

@ -308,7 +308,7 @@ LayerManagerComposite::PostProcessLayers(Layer* aLayer,
// Transform the newly calculated visible region into our parent's space,
// apply our clip to it (if any), and accumulate it into |aVisibleRegion|
// for the caller to use.
ParentLayerIntRegion visibleParentSpace = TransformTo<ParentLayerPixel>(
ParentLayerIntRegion visibleParentSpace = TransformBy(
ViewAs<LayerToParentLayerMatrix4x4>(transform), visible);
if (const Maybe<ParentLayerIntRect>& clipRect = composite->GetShadowClipRect()) {
visibleParentSpace.AndWith(*clipRect);

Просмотреть файл

@ -579,7 +579,7 @@ RenderWithAllMasks(Layer* aLayer, Compositor* aCompositor,
// Calculate the size of the intermediate surfaces.
gfx::Rect visibleRect(aLayer->GetEffectiveVisibleRegion().ToUnknownRegion().GetBounds());
gfx::Matrix4x4 transform = aLayer->GetEffectiveTransform();
// TODO: Use RenderTargetIntRect and TransformTo<...> here
// TODO: Use RenderTargetIntRect and TransformBy here
gfx::IntRect surfaceRect =
RoundedOut(transform.TransformAndClipBounds(visibleRect, gfx::Rect(aClipRect)));
if (surfaceRect.IsEmpty()) {

Просмотреть файл

@ -726,7 +726,7 @@ public:
return This();
}
// Prefer using TransformTo<TargetUnits>(region) from UnitTransforms.h,
// Prefer using TransformBy(matrix, 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.

Просмотреть файл

@ -140,35 +140,35 @@ TypedMatrix ViewAs(const gfx::Matrix4x4& aMatrix) {
// coordinate system to another using the provided transformation matrix.
template <typename TargetUnits, typename SourceUnits>
static gfx::PointTyped<TargetUnits>
TransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aPoint)
{
return aTransform * aPoint;
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntPointTyped<TargetUnits>
TransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntPointTyped<SourceUnits>& aPoint)
{
return RoundedToInt(TransformTo<TargetUnits>(aTransform, gfx::PointTyped<SourceUnits>(aPoint)));
return RoundedToInt(TransformBy(aTransform, gfx::PointTyped<SourceUnits>(aPoint)));
}
template <typename TargetUnits, typename SourceUnits>
static gfx::RectTyped<TargetUnits>
TransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::RectTyped<SourceUnits>& aRect)
{
return aTransform.TransformBounds(aRect);
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntRectTyped<TargetUnits>
TransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRectTyped<SourceUnits>& aRect)
{
return RoundedToInt(TransformTo<TargetUnits>(aTransform, gfx::RectTyped<SourceUnits>(aRect)));
return RoundedToInt(TransformBy(aTransform, gfx::RectTyped<SourceUnits>(aRect)));
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntRegionTyped<TargetUnits>
TransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRegionTyped<SourceUnits>& aRegion)
{
return ViewAs<TargetUnits>(aRegion.ToUnknownRegion().Transform(
@ -185,12 +185,12 @@ TransformVector(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aVector,
const gfx::PointTyped<SourceUnits>& aAnchor)
{
gfx::PointTyped<TargetUnits> transformedStart = TransformTo<TargetUnits>(aTransform, aAnchor);
gfx::PointTyped<TargetUnits> transformedEnd = TransformTo<TargetUnits>(aTransform, aAnchor + aVector);
gfx::PointTyped<TargetUnits> transformedStart = TransformBy(aTransform, aAnchor);
gfx::PointTyped<TargetUnits> transformedEnd = TransformBy(aTransform, aAnchor + aVector);
return transformedEnd - transformedStart;
}
// UntransformTo() and UntransformVector() are like TransformTo() and
// UntransformBy() and UntransformVector() are like TransformBy() and
// TransformVector(), respectively, but are intended for cases where
// the transformation matrix is the inverse of a 3D projection. When
// using such transforms, the resulting Point4D is only meaningful
@ -199,7 +199,7 @@ TransformVector(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
// result is meaningful
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::PointTyped<TargetUnits>>
UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aPoint)
{
gfx::Point4DTyped<TargetUnits> point = aTransform.ProjectPoint(aPoint);
@ -210,7 +210,7 @@ UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
}
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::IntPointTyped<TargetUnits>>
UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntPointTyped<SourceUnits>& aPoint)
{
gfx::PointTyped<SourceUnits> p = aPoint;
@ -221,13 +221,13 @@ UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
return Some(RoundedToInt(point.As2DPoint()));
}
// The versions of UntransformTo() that take a rectangle also take a clip,
// The versions of UntransformBy() that take a rectangle also take a clip,
// which represents the bounds within which the target must fall. The
// result of the transform is intersected with this clip, and is considered
// meaningful if the intersection is not empty.
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::RectTyped<TargetUnits>>
UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::RectTyped<SourceUnits>& aRect,
const gfx::RectTyped<TargetUnits>& aClip)
{
@ -239,7 +239,7 @@ UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
}
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::IntRectTyped<TargetUnits>>
UntransformTo(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRectTyped<SourceUnits>& aRect,
const gfx::IntRectTyped<TargetUnits>& aClip)
{

Просмотреть файл

@ -1242,7 +1242,7 @@ nsDisplayListBuilder::AdjustWindowDraggingRegion(nsIFrame* aFrame)
LayoutDeviceRect devPixelBorderBox =
LayoutDevicePixel::FromAppUnits(borderBox, aFrame->PresContext()->AppUnitsPerDevPixel());
LayoutDeviceRect transformedDevPixelBorderBox =
TransformTo<LayoutDevicePixel>(referenceFrameToRootReferenceFrame, devPixelBorderBox);
TransformBy(referenceFrameToRootReferenceFrame, devPixelBorderBox);
transformedDevPixelBorderBox.Round();
LayoutDeviceIntRect transformedDevPixelBorderBoxInt;
if (transformedDevPixelBorderBox.ToIntRect(&transformedDevPixelBorderBoxInt)) {

Просмотреть файл

@ -74,7 +74,7 @@ MouseInput::MouseInput(const WidgetMouseEventBase& aMouseEvent)
bool
MouseInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
Maybe<ParentLayerPoint> point = UntransformTo<ParentLayerPixel>(aTransform, mOrigin);
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mOrigin);
if (!point) {
return false;
}
@ -273,7 +273,7 @@ bool
MultiTouchInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
for (size_t i = 0; i < mTouches.Length(); i++) {
Maybe<ParentLayerIntPoint> point = UntransformTo<ParentLayerPixel>(aTransform, mTouches[i].mScreenPoint);
Maybe<ParentLayerIntPoint> point = UntransformBy(aTransform, mTouches[i].mScreenPoint);
if (!point) {
return false;
}
@ -319,13 +319,13 @@ PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
bool
PanGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
Maybe<ParentLayerPoint> panStartPoint = UntransformTo<ParentLayerPixel>(aTransform, mPanStartPoint);
Maybe<ParentLayerPoint> panStartPoint = UntransformBy(aTransform, mPanStartPoint);
if (!panStartPoint) {
return false;
}
mLocalPanStartPoint = *panStartPoint;
Maybe<ParentLayerPoint> panDisplacement = UntransformVector<ParentLayerPixel>(aTransform, mPanDisplacement, mPanStartPoint);
Maybe<ParentLayerPoint> panDisplacement = UntransformVector(aTransform, mPanDisplacement, mPanStartPoint);
if (!panDisplacement) {
return false;
}
@ -336,7 +336,7 @@ PanGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform
bool
PinchGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
Maybe<ParentLayerPoint> point = UntransformTo<ParentLayerPixel>(aTransform, mFocusPoint);
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mFocusPoint);
if (!point) {
return false;
}
@ -347,7 +347,7 @@ PinchGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransfo
bool
TapGestureInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
Maybe<ParentLayerIntPoint> point = UntransformTo<ParentLayerPixel>(aTransform, mPoint);
Maybe<ParentLayerIntPoint> point = UntransformBy(aTransform, mPoint);
if (!point) {
return false;
}
@ -411,7 +411,7 @@ ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
bool
ScrollWheelInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
{
Maybe<ParentLayerPoint> point = UntransformTo<ParentLayerPixel>(aTransform, mOrigin);
Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mOrigin);
if (!point) {
return false;
}