Backed out 11 changesets (bug 952977) for reftest-no-accel failures

Backed out changeset ea2367c19da3 (bug 952977)
Backed out changeset c401c8748eb3 (bug 952977)
Backed out changeset a93e9ff1043b (bug 952977)
Backed out changeset 765b7f67163e (bug 952977)
Backed out changeset 3d8cf4f5777f (bug 952977)
Backed out changeset 8993710a3ab3 (bug 952977)
Backed out changeset 1298c39b745a (bug 952977)
Backed out changeset be0b899fbe5e (bug 952977)
Backed out changeset f69bea1f1feb (bug 952977)
Backed out changeset 1a745777f07e (bug 952977)
Backed out changeset 5ad1d18dfe17 (bug 952977)
This commit is contained in:
Wes Kocher 2014-07-29 18:58:46 -07:00
parent 20570bebfc
commit 02d44fddfa
42 changed files with 368 additions and 435 deletions

View File

@ -3672,9 +3672,9 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement,
MaybeTransform transform;
forwarder->GetShadowManager()->SendGetAnimationTransform(
layer->AsShadowableLayer()->GetShadow(), &transform);
if (transform.type() == MaybeTransform::TMatrix4x4) {
gfx3DMatrix matrix = To3DMatrix(transform.get_Matrix4x4());
cssValue = nsComputedDOMStyle::MatrixToCSSValue(matrix);
if (transform.type() == MaybeTransform::Tgfx3DMatrix) {
cssValue =
nsComputedDOMStyle::MatrixToCSSValue(transform.get_gfx3DMatrix());
}
}
}

View File

@ -14,11 +14,6 @@
namespace mozilla {
namespace gfx {
static bool FuzzyEqual(Float aV1, Float aV2) {
// XXX - Check if fabs does the smart thing and just negates the sign bit.
return fabs(aV2 - aV1) < 1e-6;
}
class Matrix
{
public:
@ -224,16 +219,6 @@ public:
!FuzzyEqual(_12, 0.0) || !FuzzyEqual(_21, 0.0);
}
/**
* Returns true if the matrix has any transform other
* than a translation or a -1 y scale (y axis flip)
*/
bool HasNonTranslationOrFlip() const {
return !FuzzyEqual(_11, 1.0) ||
(!FuzzyEqual(_22, 1.0) && !FuzzyEqual(_22, -1.0)) ||
!FuzzyEqual(_21, 0.0) || !FuzzyEqual(_12, 0.0);
}
/* Returns true if the matrix is an identity matrix.
*/
bool IsIdentity() const
@ -294,6 +279,12 @@ public:
return !FuzzyEqual(_11, floor(_11 + 0.5)) ||
!FuzzyEqual(_22, floor(_22 + 0.5));
}
private:
static bool FuzzyEqual(Float aV1, Float aV2) {
// XXX - Check if fabs does the smart thing and just negates the sign bit.
return fabs(aV2 - aV1) < 1e-6;
}
};
class Matrix4x4
@ -565,85 +556,6 @@ public:
bool Invert();
void ScalePost(Float aX, Float aY, Float aZ)
{
_11 *= aX;
_21 *= aX;
_31 *= aX;
_41 *= aX;
_12 *= aY;
_22 *= aY;
_32 *= aY;
_42 *= aY;
_13 *= aZ;
_23 *= aZ;
_33 *= aZ;
_43 *= aZ;
}
void TranslatePost(Float aX, Float aY, Float aZ)
{
_11 += _14 * aX;
_21 += _24 * aX;
_31 += _34 * aX;
_41 += _44 * aX;
_12 += _14 * aY;
_22 += _24 * aY;
_32 += _34 * aY;
_42 += _44 * aY;
_13 += _14 * aZ;
_23 += _24 * aZ;
_33 += _34 * aZ;
_43 += _44 * aZ;
}
bool FuzzyEqual(const Matrix4x4& o) const
{
return gfx::FuzzyEqual(_11, o._11) && gfx::FuzzyEqual(_12, o._12) &&
gfx::FuzzyEqual(_13, o._13) && gfx::FuzzyEqual(_14, o._14) &&
gfx::FuzzyEqual(_21, o._21) && gfx::FuzzyEqual(_22, o._22) &&
gfx::FuzzyEqual(_23, o._23) && gfx::FuzzyEqual(_24, o._24) &&
gfx::FuzzyEqual(_31, o._31) && gfx::FuzzyEqual(_32, o._32) &&
gfx::FuzzyEqual(_33, o._33) && gfx::FuzzyEqual(_34, o._34) &&
gfx::FuzzyEqual(_41, o._41) && gfx::FuzzyEqual(_42, o._42) &&
gfx::FuzzyEqual(_43, o._43) && gfx::FuzzyEqual(_44, o._44);
}
bool IsBackfaceVisible() const
{
// Inverse()._33 < 0;
Float det = Determinant();
Float __33 = _12*_24*_41 - _14*_22*_41 +
_14*_21*_42 - _11*_24*_42 -
_12*_21*_44 + _11*_22*_44;
return (__33 * det) < 0;
}
void NudgeToIntegersFixedEpsilon()
{
static const float error = 1e-5f;
NudgeToInteger(&_11, error);
NudgeToInteger(&_12, error);
NudgeToInteger(&_13, error);
NudgeToInteger(&_14, error);
NudgeToInteger(&_21, error);
NudgeToInteger(&_22, error);
NudgeToInteger(&_23, error);
NudgeToInteger(&_24, error);
NudgeToInteger(&_31, error);
NudgeToInteger(&_32, error);
NudgeToInteger(&_33, error);
NudgeToInteger(&_34, error);
NudgeToInteger(&_41, error);
NudgeToInteger(&_42, error);
NudgeToInteger(&_43, error);
NudgeToInteger(&_44, error);
}
// Set all the members of the matrix to NaN
void SetNAN();
};

View File

@ -10,6 +10,7 @@
#include "GLTypes.h"
#include "nsRect.h"
#include "nsTArray.h"
#include "gfx3DMatrix.h"
namespace mozilla {
namespace gl {

View File

@ -29,6 +29,7 @@
#include "GLDefs.h"
#include "GLLibraryLoader.h"
#include "gfx3DMatrix.h"
#include "nsISupportsImpl.h"
#include "plstr.h"
#include "nsDataHashtable.h"

View File

@ -13,11 +13,11 @@
#include <stdint.h>
#include "gfx3DMatrix.h"
#include "gfxColor.h"
#include "mozilla/gfx/Matrix.h"
#include "GraphicsFilter.h"
#include "gfxPoint.h"
#include "gfxPoint3D.h"
#include "gfxRect.h"
#include "nsRect.h"
#include "nsRegion.h"
@ -217,6 +217,32 @@ struct ParamTraits<gfxRect>
}
};
template<>
struct ParamTraits<gfx3DMatrix>
{
typedef gfx3DMatrix paramType;
static void Write(Message* msg, const paramType& param)
{
#define Wr(_f) WriteParam(msg, param. _f)
Wr(_11); Wr(_12); Wr(_13); Wr(_14);
Wr(_21); Wr(_22); Wr(_23); Wr(_24);
Wr(_31); Wr(_32); Wr(_33); Wr(_34);
Wr(_41); Wr(_42); Wr(_43); Wr(_44);
#undef Wr
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
#define Rd(_f) ReadParam(msg, iter, &result-> _f)
return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
#undef Rd
}
};
template <>
struct ParamTraits<gfxContentType>
: public ContiguousTypedEnumSerializer<

View File

@ -8,6 +8,7 @@
#include "ImageContainer.h" // for ImageContainer
#include "ImageLayers.h" // for ImageLayer, etc
#include "Layers.h" // for Layer, ContainerLayer, etc
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxColor.h" // for gfxRGBA
#include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxPoint3D.h" // for gfxPoint3D
@ -25,8 +26,6 @@
#include "nsRect.h" // for nsIntRect
#include "nsTArray.h" // for nsAutoTArray, nsTArray_Impl
using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
@ -34,18 +33,18 @@ struct LayerPropertiesBase;
LayerPropertiesBase* CloneLayerTreePropertiesInternal(Layer* aRoot);
static nsIntRect
TransformRect(const nsIntRect& aRect, const Matrix4x4& aTransform)
TransformRect(const nsIntRect& aRect, const gfx3DMatrix& aTransform)
{
if (aRect.IsEmpty()) {
return nsIntRect();
}
Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height);
rect = aTransform.TransformBounds(rect);
rect.RoundOut();
nsIntRect intRect;
if (!gfxUtils::GfxRectToIntRect(ThebesRect(rect), &intRect)) {
if (!gfxUtils::GfxRectToIntRect(rect, &intRect)) {
return nsIntRect();
}
@ -53,7 +52,7 @@ TransformRect(const nsIntRect& aRect, const Matrix4x4& aTransform)
}
static void
AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform)
AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const gfx3DMatrix& aTransform)
{
nsIntRegionRectIterator iter(aSource);
const nsIntRect *r;
@ -115,7 +114,7 @@ struct LayerPropertiesBase : public LayerProperties
if (mUseClipRect) {
mClipRect = *aLayer->GetClipRect();
}
mTransform = aLayer->GetTransform();
mTransform = gfx::To3DMatrix(aLayer->GetTransform());
}
LayerPropertiesBase()
: mLayer(nullptr)
@ -137,7 +136,8 @@ struct LayerPropertiesBase : public LayerProperties
nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback,
bool& aGeometryChanged)
{
bool transformChanged = !mTransform.FuzzyEqual(mLayer->GetTransform()) ||
gfx3DMatrix transform = gfx::To3DMatrix(mLayer->GetTransform());
bool transformChanged = !mTransform.FuzzyEqual(transform) ||
mLayer->GetPostXScale() != mPostXScale ||
mLayer->GetPostYScale() != mPostYScale;
Layer* otherMask = mLayer->GetMaskLayer();
@ -184,7 +184,8 @@ struct LayerPropertiesBase : public LayerProperties
nsIntRect NewTransformedBounds()
{
return TransformRect(mLayer->GetVisibleRegion().GetBounds(), mLayer->GetTransform());
return TransformRect(mLayer->GetVisibleRegion().GetBounds(),
gfx::To3DMatrix(mLayer->GetTransform()));
}
nsIntRect OldTransformedBounds()
@ -202,7 +203,7 @@ struct LayerPropertiesBase : public LayerProperties
nsAutoPtr<LayerPropertiesBase> mMaskLayer;
nsIntRegion mVisibleRegion;
nsIntRegion mInvalidRegion;
Matrix4x4 mTransform;
gfx3DMatrix mTransform;
float mPostXScale;
float mPostYScale;
float mOpacity;
@ -291,7 +292,8 @@ struct ContainerLayerProperties : public LayerPropertiesBase
}
if (invalidateChildsCurrentArea) {
aGeometryChanged = true;
AddTransformedRegion(result, child->GetVisibleRegion(), child->GetTransform());
AddTransformedRegion(result, child->GetVisibleRegion(),
gfx::To3DMatrix(child->GetTransform()));
if (aCallback) {
NotifySubdocumentInvalidationRecursive(child, aCallback);
} else {
@ -440,8 +442,8 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu
} else {
ClearInvalidations(aRoot);
}
nsIntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(),
aRoot->GetTransform());
gfx3DMatrix transform = gfx::To3DMatrix(aRoot->GetTransform());
nsIntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(), transform);
result = result.Union(OldTransformedBounds());
if (aGeometryChanged != nullptr) {
*aGeometryChanged = true;
@ -460,7 +462,7 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu
void
LayerPropertiesBase::MoveBy(const nsIntPoint& aOffset)
{
mTransform.TranslatePost(aOffset.x, aOffset.y, 0);
mTransform.TranslatePost(gfxPoint3D(aOffset.x, aOffset.y, 0));
}
} // namespace layers

View File

@ -7,6 +7,7 @@
#include "LayersLogging.h"
#include <stdint.h> // for uint8_t
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxColor.h" // for gfxRGBA
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
#include "nsDebug.h" // for NS_ERROR

View File

@ -7,6 +7,7 @@
#include <sys/types.h> // for int32_t
#include "Layers.h" // for Layer, ThebesLayer, etc
#include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext
#include "gfxRect.h" // for gfxRect

View File

@ -24,14 +24,14 @@ static gfx::Matrix4x4 GetRootTransform(Layer *aLayer) {
return layerTrans;
}
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx::Matrix4x4 aRootTransform, bool aReset) {
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset) {
if (!aLayer)
return;
gfx::Matrix4x4 trans = aRootTransform * aLayer->GetTransform();
gfx3DMatrix trans = aRootTransform * aLayer->GetTransform();
trans.ProjectTo2D();
nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds();
Rect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
gfxRect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
trans.TransformBounds(rect);
if (strcmp(aLayer->Name(), "ContainerLayer") != 0 &&

View File

@ -15,15 +15,15 @@
#ifndef GFX_RENDERTRACE_H
#define GFX_RENDERTRACE_H
#include "gfx3DMatrix.h"
#include "nsRect.h"
#include "mozilla/gfx/Matrix.h"
namespace mozilla {
namespace layers {
class Layer;
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx::Matrix4x4 aRootTransform = gfx::Matrix4x4(), bool aReset = true);
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform = gfx3DMatrix(), bool aReset = true);
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect);
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor);
@ -49,7 +49,7 @@ private:
};
#ifndef MOZ_RENDERTRACE
inline void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx::Matrix4x4 aRootTransform, bool aReset)
inline void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset)
{}
inline void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect)

View File

@ -8,6 +8,7 @@
#include "CompositorParent.h" // for CompositorParent, etc
#include "InputData.h" // for InputData, etc
#include "Layers.h" // for ContainerLayer, Layer, etc
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "mozilla/dom/Touch.h" // for Touch
#include "mozilla/gfx/Point.h" // for Point
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
@ -31,9 +32,6 @@
namespace mozilla {
namespace layers {
typedef mozilla::gfx::Point Point;
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
float APZCTreeManager::sDPI = 160.0;
APZCTreeManager::APZCTreeManager()
@ -141,7 +139,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
aRoot,
// aCompositor is null in gtest scenarios
aCompositor ? aCompositor->RootLayerTreeId() : 0,
Matrix4x4(), nullptr, nullptr,
gfx3DMatrix(), nullptr, nullptr,
aIsFirstPaint, aOriginatingLayersId,
paintLogger, &apzcsToDestroy, nsIntRegion());
mApzcTreeLog << "[end]\n";
@ -156,7 +154,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
AsyncPanZoomController*
APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
Layer* aLayer, uint64_t aLayersId,
Matrix4x4 aTransform,
gfx3DMatrix aTransform,
AsyncPanZoomController* aParent,
AsyncPanZoomController* aNextSibling,
bool aIsFirstPaint,
@ -167,7 +165,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
{
mTreeLock.AssertCurrentThreadOwns();
Matrix4x4 transform = aLayer->GetTransform();
gfx3DMatrix transform = gfx::To3DMatrix(aLayer->GetTransform());
ContainerLayer* container = aLayer->AsContainerLayer();
AsyncPanZoomController* apzc = nullptr;
@ -321,7 +319,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
// Accumulate the CSS transform between layers that have an APZC, but exclude any
// any layers that do have an APZC, and reset the accumulation at those layers.
if (apzc) {
aTransform = Matrix4x4();
aTransform = gfx3DMatrix();
} else {
// Multiply child layer transforms on the left so they get applied first
aTransform = transform * aTransform;
@ -343,7 +341,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
// have to check for mask layers and so on in order to properly handle
// that case.
obscured = aObscured;
obscured.Transform(To3DMatrix(transform).Inverse());
obscured.Transform(transform.Inverse());
}
// If there's no APZC at this level, any APZCs for our child layers will
@ -380,25 +378,25 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
}
/*static*/ template<class T> void
ApplyTransform(gfx::PointTyped<T>* aPoint, const Matrix4x4& aMatrix)
ApplyTransform(gfx::PointTyped<T>* aPoint, const gfx3DMatrix& aMatrix)
{
Point result = aMatrix * aPoint->ToUnknownPoint();
gfxPoint result = aMatrix.Transform(gfxPoint(aPoint->x, aPoint->y));
aPoint->x = result.x;
aPoint->y = result.y;
}
/*static*/ template<class T> void
ApplyTransform(gfx::IntPointTyped<T>* aPoint, const Matrix4x4& aMatrix)
ApplyTransform(gfx::IntPointTyped<T>* aPoint, const gfx3DMatrix& aMatrix)
{
Point result = aMatrix * aPoint->ToUnknownPoint();
aPoint->x = result.x;
aPoint->y = result.y;
gfxPoint result = aMatrix.Transform(gfxPoint(aPoint->x, aPoint->y));
aPoint->x = NS_lround(result.x);
aPoint->y = NS_lround(result.y);
}
/*static*/ void
ApplyTransform(nsIntPoint* aPoint, const Matrix4x4& aMatrix)
ApplyTransform(nsIntPoint* aPoint, const gfx3DMatrix& aMatrix)
{
Point result = aMatrix * Point(aPoint->x, aPoint->y);
gfxPoint result = aMatrix.Transform(gfxPoint(aPoint->x, aPoint->y));
aPoint->x = NS_lround(result.x);
aPoint->y = NS_lround(result.y);
}
@ -406,7 +404,7 @@ ApplyTransform(nsIntPoint* aPoint, const Matrix4x4& aMatrix)
/*static*/ template<class T> void
TransformScreenToGecko(T* aPoint, AsyncPanZoomController* aApzc, APZCTreeManager* aApzcTm)
{
Matrix4x4 transformToApzc, transformToGecko;
gfx3DMatrix transformToApzc, transformToGecko;
aApzcTm->GetInputTransforms(aApzc, transformToApzc, transformToGecko);
ApplyTransform(aPoint, transformToApzc * transformToGecko);
}
@ -416,8 +414,8 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid)
{
nsEventStatus result = nsEventStatus_eIgnore;
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
switch (aEvent.mInputType) {
case MULTITOUCH_INPUT: {
MultiTouchInput& touchInput = aEvent.AsMultiTouchInput();
@ -561,11 +559,11 @@ APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput,
if (mApzcForInputBlock) {
// Cache apz transform so it can be used for future events in this block.
Matrix4x4 transformToGecko;
gfx3DMatrix transformToGecko;
GetInputTransforms(mApzcForInputBlock, mCachedTransformToApzcForInputBlock, transformToGecko);
} else {
// Reset the cached apz transform
mCachedTransformToApzcForInputBlock = Matrix4x4();
mCachedTransformToApzcForInputBlock = gfx3DMatrix();
}
} else if (mApzcForInputBlock) {
APZCTM_LOG("Re-using APZC %p as continuation of event block\n", mApzcForInputBlock.get());
@ -598,7 +596,7 @@ APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput,
// For computing the input for the APZC, used the cached transform.
// This ensures that the sequence of touch points an APZC sees in an
// input block are all in the same coordinate space.
Matrix4x4 transformToApzc = mCachedTransformToApzcForInputBlock;
gfx3DMatrix transformToApzc = mCachedTransformToApzcForInputBlock;
MultiTouchInput inputForApzc(aInput);
for (size_t i = 0; i < inputForApzc.mTouches.Length(); i++) {
ApplyTransform(&(inputForApzc.mTouches[i].mScreenPoint), transformToApzc);
@ -608,9 +606,9 @@ APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput,
// For computing the event to pass back to Gecko, use the up-to-date transforms.
// This ensures that transformToApzc and transformToGecko are in sync
// (note that transformToGecko isn't cached).
Matrix4x4 transformToGecko;
gfx3DMatrix transformToGecko;
GetInputTransforms(mApzcForInputBlock, transformToApzc, transformToGecko);
Matrix4x4 outTransform = transformToApzc * transformToGecko;
gfx3DMatrix outTransform = transformToApzc * transformToGecko;
for (size_t i = 0; i < aInput.mTouches.Length(); i++) {
ApplyTransform(&(aInput.mTouches[i].mScreenPoint), outTransform);
}
@ -651,10 +649,10 @@ APZCTreeManager::TransformCoordinateToGecko(const ScreenIntPoint& aPoint,
MOZ_ASSERT(aOutTransformedPoint);
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aPoint, nullptr);
if (apzc && aOutTransformedPoint) {
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
GetInputTransforms(apzc, transformToApzc, transformToGecko);
Matrix4x4 outTransform = transformToApzc * transformToGecko;
gfx3DMatrix outTransform = transformToApzc * transformToGecko;
aOutTransformedPoint->x = aPoint.x;
aOutTransformedPoint->y = aPoint.y;
ApplyTransform(aOutTransformedPoint, outTransform);
@ -674,10 +672,10 @@ APZCTreeManager::ProcessEvent(WidgetInputEvent& aEvent,
&inOverscrolledApzc);
if (apzc) {
apzc->GetGuid(aOutTargetGuid);
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
GetInputTransforms(apzc, transformToApzc, transformToGecko);
Matrix4x4 outTransform = transformToApzc * transformToGecko;
gfx3DMatrix outTransform = transformToApzc * transformToGecko;
ApplyTransform(&(aEvent.refPoint), outTransform);
}
return inOverscrolledApzc ? nsEventStatus_eConsumeNoDefault
@ -806,15 +804,13 @@ TransformDisplacement(APZCTreeManager* aTreeManager,
AsyncPanZoomController* aTarget,
ScreenPoint& aStartPoint,
ScreenPoint& aEndPoint) {
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko; // ignored
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko; // ignored
// Convert start and end points to untransformed screen coordinates.
aTreeManager->GetInputTransforms(aSource, transformToApzc, transformToGecko);
Matrix4x4 untransformToApzc = transformToApzc;
untransformToApzc.Invert();
ApplyTransform(&aStartPoint, untransformToApzc);
ApplyTransform(&aEndPoint, untransformToApzc);
ApplyTransform(&aStartPoint, transformToApzc.Inverse());
ApplyTransform(&aEndPoint, transformToApzc.Inverse());
// Convert start and end points to aTarget's transformed screen coordinates.
aTreeManager->GetInputTransforms(aTarget, transformToApzc, transformToGecko);
@ -1184,13 +1180,12 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc,
// to aApzc's parent layer's layer coordinates.
// It is OC.Inverse() * NC.Inverse() * MC.Inverse() at recursion level for L,
// and RC.Inverse() * QC.Inverse() at recursion level for P.
Matrix4x4 ancestorUntransform = aApzc->GetAncestorTransform();
ancestorUntransform.Invert();
gfx3DMatrix ancestorUntransform = aApzc->GetAncestorTransform().Inverse();
// Hit testing for this layer takes place in our parent layer coordinates,
// since the composition bounds (used to initialize the visible rect against
// which we hit test are in those coordinates).
gfxPointH3D hitTestPointForThisLayer = To3DMatrix(ancestorUntransform).ProjectPoint(aHitTestPoint);
gfxPointH3D hitTestPointForThisLayer = ancestorUntransform.ProjectPoint(aHitTestPoint);
APZCTM_LOG("Untransformed %f %f to transient coordinates %f %f for hit-testing APZC %p\n",
aHitTestPoint.x, aHitTestPoint.y,
hitTestPointForThisLayer.x, hitTestPointForThisLayer.y, aApzc);
@ -1199,12 +1194,10 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc,
// to aApzc's layer coordinates (which are aApzc's children's ParentLayer coordinates).
// It is OC.Inverse() * NC.Inverse() * MC.Inverse() * LC.Inverse() * LA.Inverse() at L
// and RC.Inverse() * QC.Inverse() * PC.Inverse() * PA.Inverse() at P.
Matrix4x4 cssUntransform = aApzc->GetCSSTransform();
cssUntransform.Invert();
Matrix4x4 asyncUntransform = aApzc->GetCurrentAsyncTransform();
asyncUntransform.Invert();
Matrix4x4 childUntransform = ancestorUntransform * cssUntransform * asyncUntransform;
gfxPointH3D hitTestPointForChildLayers = To3DMatrix(childUntransform).ProjectPoint(aHitTestPoint);
gfx3DMatrix childUntransform = ancestorUntransform
* aApzc->GetCSSTransform().Inverse()
* gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse();
gfxPointH3D hitTestPointForChildLayers = childUntransform.ProjectPoint(aHitTestPoint);
APZCTM_LOG("Untransformed %f %f to layer coordinates %f %f for APZC %p\n",
aHitTestPoint.x, aHitTestPoint.y,
hitTestPointForChildLayers.x, hitTestPointForChildLayers.y, aApzc);
@ -1337,8 +1330,8 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc,
required can be generated.
*/
void
APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, Matrix4x4& aTransformToApzcOut,
Matrix4x4& aTransformToGeckoOut)
APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& aTransformToApzcOut,
gfx3DMatrix& aTransformToGeckoOut)
{
MonitorAutoLock lock(mTreeLock);
@ -1349,36 +1342,26 @@ APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, Matrix4x4& aT
// leftmost matrix in a multiplication is applied first.
// ancestorUntransform is OC.Inverse() * NC.Inverse() * MC.Inverse()
Matrix4x4 ancestorUntransform = aApzc->GetAncestorTransform();
ancestorUntransform.Invert();
gfx3DMatrix ancestorUntransform = aApzc->GetAncestorTransform().Inverse();
// asyncUntransform is LA.Inverse()
Matrix4x4 asyncUntransform = aApzc->GetCurrentAsyncTransform();
asyncUntransform.Invert();
gfx3DMatrix asyncUntransform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse();
// nontransientAsyncTransform is LN
Matrix4x4 nontransientAsyncTransform = aApzc->GetNontransientAsyncTransform();
gfx3DMatrix nontransientAsyncTransform = aApzc->GetNontransientAsyncTransform();
// transientAsyncUntransform is LT.Inverse()
Matrix4x4 transientAsyncUntransform = nontransientAsyncTransform * asyncUntransform;
gfx3DMatrix transientAsyncUntransform = nontransientAsyncTransform * asyncUntransform;
// aTransformToApzcOut is initialized to OC.Inverse() * NC.Inverse() * MC.Inverse() * LC.Inverse() * LN.Inverse()
Matrix4x4 cssUntransform = aApzc->GetCSSTransform();
cssUntransform.Invert();
Matrix4x4 nontransientAsyncUntransform = nontransientAsyncTransform;
nontransientAsyncUntransform.Invert();
aTransformToApzcOut = ancestorUntransform * cssUntransform * nontransientAsyncUntransform;
aTransformToApzcOut = ancestorUntransform * aApzc->GetCSSTransform().Inverse() * nontransientAsyncTransform.Inverse();
// aTransformToGeckoOut is initialized to LT.Inverse() * LD * LC * MC * NC * OC
aTransformToGeckoOut = transientAsyncUntransform * aApzc->GetTransformToLastDispatchedPaint() * aApzc->GetCSSTransform() * aApzc->GetAncestorTransform();
for (AsyncPanZoomController* parent = aApzc->GetParent(); parent; parent = parent->GetParent()) {
// ancestorUntransform is updated to RC.Inverse() * QC.Inverse() when parent == P
ancestorUntransform = parent->GetAncestorTransform();
ancestorUntransform.Invert();
ancestorUntransform = parent->GetAncestorTransform().Inverse();
// asyncUntransform is updated to PA.Inverse() when parent == P
asyncUntransform = parent->GetCurrentAsyncTransform();
asyncUntransform.Invert();
asyncUntransform = gfx3DMatrix(parent->GetCurrentAsyncTransform()).Inverse();
// untransformSinceLastApzc is RC.Inverse() * QC.Inverse() * PC.Inverse() * PA.Inverse()
cssUntransform = parent->GetCSSTransform();
cssUntransform.Invert();
Matrix4x4 untransformSinceLastApzc = ancestorUntransform * cssUntransform * asyncUntransform;
gfx3DMatrix untransformSinceLastApzc = ancestorUntransform * parent->GetCSSTransform().Inverse() * asyncUntransform;
// aTransformToApzcOut is RC.Inverse() * QC.Inverse() * PC.Inverse() * PA.Inverse() * OC.Inverse() * NC.Inverse() * MC.Inverse() * LC.Inverse() * LN.Inverse()
aTransformToApzcOut = untransformSinceLastApzc * aTransformToApzcOut;

View File

@ -10,10 +10,10 @@
#include "FrameMetrics.h" // for FrameMetrics, etc
#include "Units.h" // for CSSPoint, CSSRect, etc
#include "gfxPoint.h" // for gfxPoint
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/EventForwards.h" // for WidgetInputEvent, nsEventStatus
#include "mozilla/Monitor.h" // for Monitor
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
@ -21,6 +21,7 @@
#include "nsTArrayForwardDeclare.h" // for nsTArray, nsTArray_Impl, etc
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
class gfx3DMatrix;
class nsIntRegion;
namespace mozilla {
@ -326,8 +327,8 @@ public:
already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const ScrollableLayerGuid& aGuid);
already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const ScreenPoint& aPoint,
bool* aOutInOverscrolledApzc);
void GetInputTransforms(AsyncPanZoomController *aApzc, gfx::Matrix4x4& aTransformToApzcOut,
gfx::Matrix4x4& aTransformToGeckoOut);
void GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& aTransformToApzcOut,
gfx3DMatrix& aTransformToGeckoOut);
private:
/* Helpers */
AsyncPanZoomController* FindTargetAPZC(AsyncPanZoomController* aApzc, FrameMetrics::ViewID aScrollId);
@ -357,7 +358,7 @@ private:
*/
AsyncPanZoomController* UpdatePanZoomControllerTree(CompositorParent* aCompositor,
Layer* aLayer, uint64_t aLayersId,
gfx::Matrix4x4 aTransform,
gfx3DMatrix aTransform,
AsyncPanZoomController* aParent,
AsyncPanZoomController* aNextSibling,
bool aIsFirstPaint,
@ -400,7 +401,7 @@ private:
* but for some operations we need to use the initial transform.
* Meaningless if mApzcForInputBlock is nullptr.
*/
gfx::Matrix4x4 mCachedTransformToApzcForInputBlock;
gfx3DMatrix mCachedTransformToApzcForInputBlock;
/* The chain of APZCs that will handle pans for the current touch input
* block, in the order in which they will be scrolled. When one APZC has
* been scrolled as far as it can, any overscroll will be handed off to

View File

@ -129,8 +129,6 @@ namespace layers {
typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior;
typedef GeckoContentController::APZStateChange APZStateChange;
typedef mozilla::gfx::Point Point;
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
/*
* The following prefs are used to control the behaviour of the APZC.
@ -1294,10 +1292,10 @@ AsyncPanZoomController::ConvertToGecko(const ScreenPoint& aPoint, CSSPoint* aOut
{
APZCTreeManager* treeManagerLocal = mTreeManager;
if (treeManagerLocal) {
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
treeManagerLocal->GetInputTransforms(this, transformToApzc, transformToGecko);
Point result = transformToGecko * Point(aPoint.x, aPoint.y);
gfxPoint result = transformToGecko.Transform(gfxPoint(aPoint.x, aPoint.y));
// NOTE: This isn't *quite* LayoutDevicePoint, we just don't have a name
// for this coordinate space and it maps the closest to LayoutDevicePoint.
LayoutDevicePoint layoutPoint = LayoutDevicePoint(result.x, result.y);
@ -2301,20 +2299,20 @@ ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() {
/ mFrameMetrics.GetParentResolution());
}
Matrix4x4 AsyncPanZoomController::GetNontransientAsyncTransform() {
gfx3DMatrix AsyncPanZoomController::GetNontransientAsyncTransform() {
ReentrantMonitorAutoEnter lock(mMonitor);
return Matrix4x4().Scale(mLastContentPaintMetrics.mResolution.scale,
mLastContentPaintMetrics.mResolution.scale,
1.0f);
return gfx3DMatrix::ScalingMatrix(mLastContentPaintMetrics.mResolution.scale,
mLastContentPaintMetrics.mResolution.scale,
1.0f);
}
Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() {
gfx3DMatrix AsyncPanZoomController::GetTransformToLastDispatchedPaint() {
ReentrantMonitorAutoEnter lock(mMonitor);
LayerPoint scrollChange = (mLastContentPaintMetrics.GetScrollOffset() - mLastDispatchedPaintMetrics.GetScrollOffset())
* mLastContentPaintMetrics.LayersPixelsPerCSSPixel();
float zoomChange = mLastContentPaintMetrics.GetZoom().scale / mLastDispatchedPaintMetrics.GetZoom().scale;
return Matrix4x4().Translate(scrollChange.x, scrollChange.y, 0) *
Matrix4x4().Scale(zoomChange, zoomChange, 1);
return gfx3DMatrix::Translation(scrollChange.x, scrollChange.y, 0) *
gfx3DMatrix::ScalingMatrix(zoomChange, zoomChange, 1);
}
void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetrics, bool aIsFirstPaint) {
@ -2856,16 +2854,16 @@ void AsyncPanZoomController::ShareCompositorFrameMetrics() {
ParentLayerPoint AsyncPanZoomController::ToParentLayerCoords(const ScreenPoint& aPoint)
{
return TransformTo<ParentLayerPixel>(To3DMatrix(GetNontransientAsyncTransform() * GetCSSTransform()), aPoint);
return TransformTo<ParentLayerPixel>(GetNontransientAsyncTransform() * GetCSSTransform(), aPoint);
}
void AsyncPanZoomController::UpdateTransformScale()
{
Matrix4x4 nontransientTransforms = GetNontransientAsyncTransform() * GetCSSTransform();
if (!FuzzyEqualsMultiplicative(nontransientTransforms._11, nontransientTransforms._22)) {
gfx3DMatrix nontransientTransforms = GetNontransientAsyncTransform() * GetCSSTransform();
if (!FuzzyEqualsMultiplicative(nontransientTransforms.GetXScale(), nontransientTransforms.GetYScale())) {
NS_WARNING("The x- and y-scales of the nontransient transforms should be equal");
}
mFrameMetrics.mTransformScale.scale = nontransientTransforms._11;
mFrameMetrics.mTransformScale.scale = nontransientTransforms.GetXScale();
}
}

View File

@ -20,7 +20,7 @@
#include "InputData.h"
#include "Axis.h"
#include "TaskThrottler.h"
#include "mozilla/gfx/Matrix.h"
#include "gfx3DMatrix.h"
#include "nsRegion.h"
#include "base/message_loop.h"
@ -69,7 +69,6 @@ class AsyncPanZoomController {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncPanZoomController)
typedef mozilla::MonitorAutoLock MonitorAutoLock;
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
typedef uint32_t TouchBehaviorFlags;
public:
@ -222,9 +221,9 @@ public:
/**
* Returns the part of the async transform that will remain once Gecko does a
* repaint at the desired metrics. That is, in the steady state:
* Matrix4x4(GetCurrentAsyncTransform()) === GetNontransientAsyncTransform()
* gfx3DMatrix(GetCurrentAsyncTransform()) === GetNontransientAsyncTransform()
*/
Matrix4x4 GetNontransientAsyncTransform();
gfx3DMatrix GetNontransientAsyncTransform();
/**
* Returns the transform to take something from the coordinate space of the
@ -233,7 +232,7 @@ public:
* processed, this is needed to transform input events properly into a space
* gecko will understand.
*/
Matrix4x4 GetTransformToLastDispatchedPaint();
gfx3DMatrix GetTransformToLastDispatchedPaint();
/**
* Recalculates the displayport. Ideally, this should paint an area bigger
@ -943,19 +942,19 @@ private:
* hit-testing to see which APZC instance should handle touch events.
*/
public:
void SetLayerHitTestData(const nsIntRegion& aRegion, const Matrix4x4& aTransformToLayer,
const Matrix4x4& aTransformForLayer) {
void SetLayerHitTestData(const nsIntRegion& aRegion, const gfx3DMatrix& aTransformToLayer,
const gfx3DMatrix& aTransformForLayer) {
mVisibleRegion = aRegion;
mAncestorTransform = aTransformToLayer;
mCSSTransform = aTransformForLayer;
UpdateTransformScale();
}
Matrix4x4 GetAncestorTransform() const {
gfx3DMatrix GetAncestorTransform() const {
return mAncestorTransform;
}
Matrix4x4 GetCSSTransform() const {
gfx3DMatrix GetCSSTransform() const {
return mCSSTransform;
}
@ -975,9 +974,9 @@ private:
nsIntRegion mVisibleRegion;
/* This is the cumulative CSS transform for all the layers between the parent
* APZC and this one (not inclusive) */
Matrix4x4 mAncestorTransform;
gfx3DMatrix mAncestorTransform;
/* This is the CSS transform for this APZC's layer. */
Matrix4x4 mCSSTransform;
gfx3DMatrix mCSSTransform;
/* ===================================================================

View File

@ -154,7 +154,7 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest,
}
static pixman_transform
Matrix4x4ToPixman(const Matrix4x4& aMatrix)
Matrix3DToPixman(const gfx3DMatrix& aMatrix)
{
pixman_f_transform transform;
@ -177,7 +177,7 @@ Matrix4x4ToPixman(const Matrix4x4& aMatrix)
static void
PixmanTransform(DataSourceSurface* aDest,
DataSourceSurface* aSource,
const Matrix4x4& aTransform,
const gfx3DMatrix& aTransform,
const Point& aDestOffset)
{
IntSize destSize = aDest->GetSize();
@ -196,7 +196,7 @@ PixmanTransform(DataSourceSurface* aDest,
NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
pixman_transform pixTransform = Matrix4x4ToPixman(aTransform);
pixman_transform pixTransform = Matrix3DToPixman(aTransform);
pixman_transform pixTransformInverted;
// If the transform is singular then nothing would be drawn anyway, return here
@ -249,7 +249,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
Matrix newTransform;
Rect transformBounds;
Matrix4x4 new3DTransform;
gfx3DMatrix new3DTransform;
IntPoint offset = mRenderTarget->GetOrigin();
if (aTransform.Is2D()) {
@ -266,10 +266,11 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
dest->SetTransform(destTransform);
// Get the bounds post-transform.
new3DTransform = aTransform;
Rect transformBounds = new3DTransform.TransformBounds(aRect);
transformBounds.IntersectRect(transformBounds, Rect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
new3DTransform = To3DMatrix(aTransform);
gfxRect bounds = new3DTransform.TransformBounds(ThebesRect(aRect));
bounds.IntersectRect(bounds, gfxRect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
transformBounds = ToRect(bounds);
transformBounds.RoundOut();
// Propagate the coordinate offset to our 2D draw target.
@ -277,7 +278,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
// When we apply the 3D transformation, we do it against a temporary
// surface, so undo the coordinate offset.
new3DTransform = Matrix4x4().Translate(aRect.x, aRect.y, 0) * new3DTransform;
new3DTransform = gfx3DMatrix::Translation(aRect.x, aRect.y, 0) * new3DTransform;
}
newTransform.PostTranslate(-offset.x, -offset.y);

View File

@ -16,6 +16,7 @@
#include "RenderTrace.h" // for RenderTraceLayers, etc
#include "basic/BasicImplData.h" // for BasicImplData
#include "basic/BasicLayers.h" // for BasicLayerManager, etc
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxASurface.h" // for gfxASurface, etc
#include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext, etc
@ -608,7 +609,7 @@ BasicLayerManager::SetRoot(Layer* aLayer)
}
static pixman_transform
BasicLayerManager_Matrix4x4ToPixman(const Matrix4x4& aMatrix)
BasicLayerManager_Matrix3DToPixman(const gfx3DMatrix& aMatrix)
{
pixman_f_transform transform;
@ -631,8 +632,8 @@ BasicLayerManager_Matrix4x4ToPixman(const Matrix4x4& aMatrix)
static void
PixmanTransform(const gfxImageSurface* aDest,
RefPtr<DataSourceSurface> aSrc,
const Matrix4x4& aTransform,
Point aDestOffset)
const gfx3DMatrix& aTransform,
gfxPoint aDestOffset)
{
IntSize destSize = ToIntSize(aDest->GetSize());
pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
@ -650,7 +651,7 @@ PixmanTransform(const gfxImageSurface* aDest,
NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
pixman_transform pixTransform = BasicLayerManager_Matrix4x4ToPixman(aTransform);
pixman_transform pixTransform = BasicLayerManager_Matrix3DToPixman(aTransform);
pixman_transform pixTransformInverted;
// If the transform is singular then nothing would be drawn anyway, return here
@ -679,7 +680,7 @@ PixmanTransform(const gfxImageSurface* aDest,
}
/**
* Transform a surface using a Matrix4x4 and blit to the destination if
* Transform a surface using a gfx3DMatrix and blit to the destination if
* it is efficient to do so.
*
* @param aSource Source surface.
@ -694,16 +695,16 @@ PixmanTransform(const gfxImageSurface* aDest,
static already_AddRefed<gfxASurface>
Transform3D(RefPtr<SourceSurface> aSource,
gfxContext* aDest,
const Rect& aBounds,
const Matrix4x4& aTransform,
Rect& aDestRect)
const gfxRect& aBounds,
const gfx3DMatrix& aTransform,
gfxRect& aDestRect)
{
// Find the transformed rectangle of our layer.
Rect offsetRect = aTransform.TransformBounds(aBounds);
gfxRect offsetRect = aTransform.TransformBounds(aBounds);
// Intersect the transformed layer with the destination rectangle.
// This is in device space since we have an identity transform set on aTarget.
aDestRect = ToRect(aDest->GetClipExtents());
aDestRect = aDest->GetClipExtents();
aDestRect.IntersectRect(aDestRect, offsetRect);
aDestRect.RoundOut();
@ -712,10 +713,10 @@ Transform3D(RefPtr<SourceSurface> aSource,
nsRefPtr<gfxImageSurface> destImage = new gfxImageSurface(gfxIntSize(aDestRect.width,
aDestRect.height),
gfxImageFormat::ARGB32);
Point offset = aDestRect.TopLeft();
gfxPoint offset = aDestRect.TopLeft();
// Include a translation to the correct origin.
Matrix4x4 translation = Matrix4x4().Translate(aBounds.x, aBounds.y, 0);
gfx3DMatrix translation = gfx3DMatrix::Translation(aBounds.x, aBounds.y, 0);
// Transform the content and offset it such that the content begins at the origin.
PixmanTransform(destImage, aSource->GetDataSurface(), translation * aTransform, offset);
@ -883,7 +884,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
// Revert these changes when 725886 is ready
NS_ABORT_IF_FALSE(untransformedDT,
"We should always allocate an untransformed surface with 3d transforms!");
gfx::Rect destRect;
gfxRect destRect;
#ifdef DEBUG
if (aLayer->GetDebugColorIndex() != 0) {
gfxRGBA color((aLayer->GetDebugColorIndex() & 1) ? 1.0 : 0.0,
@ -896,17 +897,18 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
temp->Paint();
}
#endif
gfx3DMatrix effectiveTransform = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
nsRefPtr<gfxASurface> result =
Transform3D(untransformedDT->Snapshot(), aTarget, ToRect(bounds),
aLayer->GetEffectiveTransform(), destRect);
Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
effectiveTransform, destRect);
if (result) {
aTarget->SetSource(result, ThebesPoint(destRect.TopLeft()));
aTarget->SetSource(result, destRect.TopLeft());
// Azure doesn't support EXTEND_NONE, so to avoid extending the edges
// of the source surface out to the current clip region, clip to
// the rectangle of the result surface now.
aTarget->NewPath();
aTarget->SnappedRectangle(ThebesRect(destRect));
aTarget->SnappedRectangle(destRect);
aTarget->Clip();
FlushGroup(paintLayerContext, needsClipToVisibleRegion);
}

View File

@ -7,6 +7,7 @@
#include "Units.h" // for ScreenIntRect, CSSPoint, etc
#include "UnitTransforms.h" // for TransformTo
#include "ClientLayerManager.h" // for ClientLayerManager, etc
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxRect.h" // for gfxRect
@ -57,12 +58,12 @@ ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
}
static LayerRect
ApplyParentLayerToLayerTransform(const gfx::Matrix4x4& aTransform, const ParentLayerRect& aParentLayerRect)
ApplyParentLayerToLayerTransform(const gfx3DMatrix& aTransform, const ParentLayerRect& aParentLayerRect)
{
return TransformTo<LayerPixel>(gfx::To3DMatrix(aTransform), aParentLayerRect);
return TransformTo<LayerPixel>(aTransform, aParentLayerRect);
}
static gfx::Matrix4x4
static gfx3DMatrix
GetTransformToAncestorsParentLayer(Layer* aStart, Layer* aAncestor)
{
gfx::Matrix4x4 transform;
@ -76,7 +77,7 @@ GetTransformToAncestorsParentLayer(Layer* aStart, Layer* aAncestor)
}
transform = transform * iter->GetTransform();
}
return transform;
return gfx::To3DMatrix(transform);
}
void
@ -144,9 +145,8 @@ ClientTiledThebesLayer::BeginPaint()
// Calculate the transform required to convert ParentLayer space of our
// display port ancestor to the Layer space of this layer.
gfx::Matrix4x4 transformDisplayPortToLayer =
GetTransformToAncestorsParentLayer(this, displayPortAncestor);
transformDisplayPortToLayer.Invert();
gfx3DMatrix transformDisplayPortToLayer =
GetTransformToAncestorsParentLayer(this, displayPortAncestor).Inverse();
// Note that below we use GetZoomToParent() in a number of places. Because this
// code runs on the client side, the mTransformScale field of the FrameMetrics
@ -171,10 +171,8 @@ ClientTiledThebesLayer::BeginPaint()
// Store the applicable composition bounds in this layer's Layer units.
mPaintData.mTransformToCompBounds =
GetTransformToAncestorsParentLayer(this, scrollAncestor);
gfx::Matrix4x4 transformToBounds = mPaintData.mTransformToCompBounds;
transformToBounds.Invert();
mPaintData.mCompositionBounds = ApplyParentLayerToLayerTransform(
transformToBounds, scrollMetrics.mCompositionBounds);
mPaintData.mTransformToCompBounds.Inverse(), scrollMetrics.mCompositionBounds);
TILING_LOG("TILING %p: Composition bounds %s\n", this, Stringify(mPaintData.mCompositionBounds).c_str());
// Calculate the scroll offset since the last transaction

View File

@ -1082,31 +1082,30 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
*/
static LayerRect
GetCompositorSideCompositionBounds(ContainerLayer* aScrollAncestor,
const Matrix4x4& aTransformToCompBounds,
const gfx3DMatrix& aTransformToCompBounds,
const ViewTransform& aAPZTransform)
{
Matrix4x4 nonTransientAPZUntransform = Matrix4x4().Scale(
gfx3DMatrix nonTransientAPZTransform = gfx3DMatrix::ScalingMatrix(
aScrollAncestor->GetFrameMetrics().mResolution.scale,
aScrollAncestor->GetFrameMetrics().mResolution.scale,
1.f);
nonTransientAPZUntransform.Invert();
Matrix4x4 layerTransform = aScrollAncestor->GetTransform();
Matrix4x4 layerUntransform = layerTransform;
layerUntransform.Invert();
gfx3DMatrix layerTransform = gfx::To3DMatrix(aScrollAncestor->GetTransform());
// First take off the last two "terms" of aTransformToCompBounds, which
// are the scroll ancestor's local transform and the APZ's nontransient async
// transform.
Matrix4x4 transform = aTransformToCompBounds * layerUntransform * nonTransientAPZUntransform;
gfx3DMatrix transform = aTransformToCompBounds;
transform = transform * layerTransform.Inverse();
transform = transform * nonTransientAPZTransform.Inverse();
// Next, apply the APZ's async transform (this includes the nontransient component
// as well).
transform = transform * Matrix4x4(aAPZTransform);
transform = transform * gfx3DMatrix(aAPZTransform);
// Finally, put back the scroll ancestor's local transform.
transform = transform * layerTransform;
return TransformTo<LayerPixel>(To3DMatrix(transform).Inverse(),
return TransformTo<LayerPixel>(transform.Inverse(),
aScrollAncestor->GetFrameMetrics().mCompositionBounds);
}

View File

@ -12,6 +12,7 @@
#include "Layers.h" // for LayerManager, etc
#include "TiledLayerBuffer.h" // for TiledLayerBuffer
#include "Units.h" // for CSSPoint
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxTypes.h"
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
#include "mozilla/RefPtr.h" // for RefPtr
@ -269,7 +270,7 @@ struct BasicTiledLayerPaintData {
* the closest ancestor layer which scrolls, and is used to obtain
* the composition bounds that are relevant for this layer.
*/
gfx::Matrix4x4 mTransformToCompBounds;
gfx3DMatrix mTransformToCompBounds;
/*
* The critical displayport of the content from the nearest ancestor layer

View File

@ -509,9 +509,9 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
}
Matrix4x4
AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer)
AdjustAndCombineWithCSSTransform(const gfx3DMatrix& asyncTransform, Layer* aLayer)
{
Matrix4x4 result = asyncTransform;
Matrix4x4 result = ToMatrix4x4(asyncTransform);
// Container layers start at the origin, but they are clipped to where they
// actually have content on the screen. The tree transform is meant to apply
@ -675,11 +675,9 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer
apzc->SampleContentTransformForFrame(aCurrentFrame, &asyncTransform, scrollOffset);
}
Matrix4x4 asyncTransform = apzc->GetCurrentAsyncTransform();
Matrix4x4 nontransientTransform = apzc->GetNontransientAsyncTransform();
Matrix4x4 nontransientUntransform = nontransientTransform;
nontransientUntransform.Invert();
Matrix4x4 transientTransform = asyncTransform * nontransientUntransform;
gfx3DMatrix asyncTransform = gfx3DMatrix(apzc->GetCurrentAsyncTransform());
gfx3DMatrix nontransientTransform = apzc->GetNontransientAsyncTransform();
gfx3DMatrix transientTransform = asyncTransform * nontransientTransform.Inverse();
// |transientTransform| represents the amount by which we have scrolled and
// zoomed since the last paint. Because the scrollbar was sized and positioned based
@ -697,12 +695,12 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer
Matrix4x4 scrollbarTransform;
if (aScrollbar->GetScrollbarDirection() == Layer::VERTICAL) {
float scale = metrics.CalculateCompositedSizeInCssPixels().height / metrics.mScrollableRect.height;
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f, 1.f / transientTransform._22, 1.f);
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f, 1.f / transientTransform.GetYScale(), 1.f);
scrollbarTransform = scrollbarTransform * Matrix4x4().Translate(0, -transientTransform._42 * scale, 0);
}
if (aScrollbar->GetScrollbarDirection() == Layer::HORIZONTAL) {
float scale = metrics.CalculateCompositedSizeInCssPixels().width / metrics.mScrollableRect.width;
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f / transientTransform._11, 1.f, 1.f);
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f / transientTransform.GetXScale(), 1.f, 1.f);
scrollbarTransform = scrollbarTransform * Matrix4x4().Translate(-transientTransform._41 * scale, 0, 0);
}
@ -714,8 +712,7 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer
// the content. This is needed because otherwise that transient async transform is
// part of the effective transform of this scrollbar, and the scrollbar will jitter
// as the content scrolls.
transientTransform.Invert();
transform = transform * transientTransform;
transform = transform * ToMatrix4x4(transientTransform.Inverse());
}
// GetTransform already takes the pre- and post-scale into account. Since we
@ -783,8 +780,11 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
const FrameMetrics& metrics = container->GetFrameMetrics();
// We must apply the resolution scale before a pan/zoom transform, so we call
// GetTransform here.
gfx3DMatrix currentTransform = To3DMatrix(aLayer->GetTransform());
Matrix4x4 oldTransform = aLayer->GetTransform();
gfx3DMatrix treeTransform;
CSSToLayerScale geckoZoom = metrics.LayersPixelsPerCSSPixel();
LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.GetScrollOffset() * geckoZoom);
@ -842,22 +842,22 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
}
LayerPoint translation = (userScroll / zoomAdjust) - geckoScroll;
Matrix4x4 treeTransform = ViewTransform(-translation,
treeTransform = gfx3DMatrix(ViewTransform(-translation,
userZoom
/ metrics.mDevPixelsPerCSSPixel
/ metrics.GetParentResolution());
/ metrics.GetParentResolution()));
// The transform already takes the resolution scale into account. Since we
// will apply the resolution scale again when computing the effective
// transform, we must apply the inverse resolution scale here.
Matrix4x4 computedTransform = treeTransform * oldTransform;
gfx3DMatrix computedTransform = treeTransform * currentTransform;
computedTransform.Scale(1.0f/container->GetPreXScale(),
1.0f/container->GetPreYScale(),
1);
computedTransform.ScalePost(1.0f/container->GetPostXScale(),
1.0f/container->GetPostYScale(),
1);
layerComposite->SetShadowTransform(computedTransform);
layerComposite->SetShadowTransform(ToMatrix4x4(computedTransform));
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");

View File

@ -8,12 +8,12 @@
#include "Units.h" // for LayerPoint, etc
#include "mozilla/layers/LayerManagerComposite.h" // for LayerManagerComposite
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "mozilla/Attributes.h" // for MOZ_DELETE, MOZ_FINAL, etc
#include "mozilla/RefPtr.h" // for RefCounted
#include "mozilla/TimeStamp.h" // for TimeStamp
#include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation
#include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsISupportsImpl.h" // for LayerManager::AddRef, etc
@ -34,17 +34,17 @@ struct ViewTransform {
, mScale(aScale)
{}
operator gfx::Matrix4x4() const
operator gfx3DMatrix() const
{
return
gfx::Matrix4x4().Translate(mTranslation.x, mTranslation.y, 0) *
gfx::Matrix4x4().Scale(mScale.scale, mScale.scale, 1);
gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0) *
gfx3DMatrix::ScalingMatrix(mScale.scale, mScale.scale, 1);
}
// For convenience, to avoid writing the cumbersome
// "gfx::Matrix4x4(a) * gfx::Matrix4x4(b)".
friend gfx::Matrix4x4 operator*(const ViewTransform& a, const ViewTransform& b) {
return gfx::Matrix4x4(a) * gfx::Matrix4x4(b);
// "gfx3dMatrix(a) * gfx3DMatrix(b)".
friend gfx3DMatrix operator*(const ViewTransform& a, const ViewTransform& b) {
return gfx3DMatrix(a) * gfx3DMatrix(b);
}
bool operator==(const ViewTransform& rhs) const {

View File

@ -8,6 +8,7 @@
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for LayerRect, LayerPixel, etc
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc

View File

@ -22,6 +22,7 @@
#include "TiledLayerBuffer.h" // for TiledLayerComposer
#include "Units.h" // for ScreenIntRect
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPrefs.h" // for gfxPrefs
#ifdef XP_MACOSX
#include "gfxPlatformMac.h"
@ -563,7 +564,7 @@ LayerManagerComposite::WorldTransformRect(nsIntRect& aRect)
static void
SubtractTransformedRegion(nsIntRegion& aRegion,
const nsIntRegion& aRegionToSubtract,
const Matrix4x4& aTransform)
const gfx3DMatrix& aTransform)
{
if (aRegionToSubtract.IsEmpty()) {
return;
@ -573,7 +574,7 @@ SubtractTransformedRegion(nsIntRegion& aRegion,
// subtract it from the screen region.
nsIntRegionRectIterator it(aRegionToSubtract);
while (const nsIntRect* rect = it.Next()) {
Rect incompleteRect = aTransform.TransformBounds(ToRect(*rect));
gfxRect incompleteRect = aTransform.TransformBounds(gfxRect(*rect));
aRegion.Sub(aRegion, nsIntRect(incompleteRect.x,
incompleteRect.y,
incompleteRect.width,
@ -585,7 +586,7 @@ SubtractTransformedRegion(nsIntRegion& aRegion,
LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
nsIntRegion& aScreenRegion,
nsIntRegion& aLowPrecisionScreenRegion,
const Matrix4x4& aTransform)
const gfx3DMatrix& aTransform)
{
if (aLayer->GetOpacity() <= 0.f ||
(aScreenRegion.IsEmpty() && aLowPrecisionScreenRegion.IsEmpty())) {
@ -596,10 +597,10 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
ContainerLayer* container = aLayer->AsContainerLayer();
if (container) {
// Accumulate the transform of intermediate surfaces
Matrix4x4 transform = aTransform;
gfx3DMatrix transform = aTransform;
if (container->UseIntermediateSurface()) {
transform = aLayer->GetEffectiveTransform();
transform = aTransform * transform;
transform = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
transform.PreMultiply(aTransform);
}
for (Layer* child = aLayer->GetFirstChild(); child;
child = child->GetNextSibling()) {
@ -620,8 +621,8 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
if (!incompleteRegion.IsEmpty()) {
// Calculate the transform to get between screen and layer space
Matrix4x4 transformToScreen = aLayer->GetEffectiveTransform();
transformToScreen = aTransform * transformToScreen;
gfx3DMatrix transformToScreen = To3DMatrix(aLayer->GetEffectiveTransform());
transformToScreen.PreMultiply(aTransform);
SubtractTransformedRegion(aScreenRegion, incompleteRegion, transformToScreen);
@ -649,12 +650,14 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
#ifdef MOZ_ANDROID_OMTC
static float
GetDisplayportCoverage(const CSSRect& aDisplayPort,
const Matrix4x4& aTransformToScreen,
const gfx3DMatrix& aTransformToScreen,
const nsIntRect& aScreenRect)
{
Rect transformedDisplayport =
aTransformToScreen.TransformBounds(aDisplayPort.ToUnknownRect());
gfxRect transformedDisplayport =
aTransformToScreen.TransformBounds(gfxRect(aDisplayPort.x,
aDisplayPort.y,
aDisplayPort.width,
aDisplayPort.height));
transformedDisplayport.RoundOut();
nsIntRect displayport = nsIntRect(transformedDisplayport.x,
transformedDisplayport.y,
@ -697,15 +700,15 @@ LayerManagerComposite::ComputeRenderIntegrity()
// This is derived from the code in
// AsyncCompositionManager::TransformScrollableLayer
const FrameMetrics& metrics = primaryScrollable->AsContainerLayer()->GetFrameMetrics();
Matrix4x4 transform = primaryScrollable->GetEffectiveTransform();
gfx3DMatrix transform = gfx::To3DMatrix(primaryScrollable->GetEffectiveTransform());
transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1);
// Clip the screen rect to the document bounds
Rect documentBounds =
transform.TransformBounds(Rect(metrics.mScrollableRect.x - metrics.GetScrollOffset().x,
metrics.mScrollableRect.y - metrics.GetScrollOffset().y,
metrics.mScrollableRect.width,
metrics.mScrollableRect.height));
gfxRect documentBounds =
transform.TransformBounds(gfxRect(metrics.mScrollableRect.x - metrics.GetScrollOffset().x,
metrics.mScrollableRect.y - metrics.GetScrollOffset().y,
metrics.mScrollableRect.width,
metrics.mScrollableRect.height));
documentBounds.RoundOut();
screenRect = screenRect.Intersect(nsIntRect(documentBounds.x, documentBounds.y,
documentBounds.width, documentBounds.height));
@ -744,7 +747,7 @@ LayerManagerComposite::ComputeRenderIntegrity()
nsIntRegion screenRegion(screenRect);
nsIntRegion lowPrecisionScreenRegion(screenRect);
Matrix4x4 transform;
gfx3DMatrix transform;
ComputeRenderIntegrityInternal(root, screenRegion,
lowPrecisionScreenRegion, transform);

View File

@ -252,7 +252,7 @@ private:
static void ComputeRenderIntegrityInternal(Layer* aLayer,
nsIntRegion& aScreenRegion,
nsIntRegion& aLowPrecisionScreenRegion,
const gfx::Matrix4x4& aTransform);
const gfx3DMatrix& aTransform);
/**
* Render the current layer tree to the active target.

View File

@ -11,6 +11,7 @@
#include "ImageLayers.h" // for ImageLayer
#include "Layers.h" // for Layer, ContainerLayer, etc
#include "ShadowLayerParent.h" // for ShadowLayerParent
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxPoint3D.h" // for gfxPoint3D
#include "CompositableTransactionParent.h" // for EditReplyVector
#include "ShadowLayersManager.h" // for ShadowLayersManager
@ -630,7 +631,7 @@ LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
// from the shadow transform by undoing the translations in
// AsyncCompositionManager::SampleValue.
Matrix4x4 transform = layer->AsLayerComposite()->GetShadowTransform();
gfx3DMatrix transform = gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform());
if (ContainerLayer* c = layer->AsContainerLayer()) {
// Undo the scale transform applied by AsyncCompositionManager::SampleValue
transform.ScalePost(1.0f/c->GetInheritedXScale(),
@ -657,12 +658,11 @@ LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
// Undo the translation to the origin of the reference frame applied by
// AsyncCompositionManager::SampleValue
transform.Translate(-scaledOrigin.x, -scaledOrigin.y, -scaledOrigin.z);
transform.Translate(-scaledOrigin);
// Undo the rebasing applied by
// nsDisplayTransform::GetResultingTransformMatrixInternal
gfxPoint3D basis = -scaledOrigin - transformOrigin;
transform.ChangeBasis(basis.x, basis.y, basis.z);
transform.ChangeBasis(-scaledOrigin - transformOrigin);
// Convert to CSS pixels (this undoes the operations performed by
// nsStyleTransformMatrix::ProcessTranslatePart which is called from

View File

@ -17,6 +17,8 @@
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
class gfx3DMatrix;
namespace mozilla {
namespace ipc {

View File

@ -20,6 +20,7 @@ using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h";
using struct gfxRGBA from "gfxColor.h";
using struct gfxPoint3D from "gfxPoint3D.h";
using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h";
using class gfx3DMatrix from "gfx3DMatrix.h";
using nscoord from "nsCoord.h";
using struct nsIntPoint from "nsPoint.h";
using struct nsRect from "nsRect.h";
@ -150,7 +151,7 @@ struct AnimationSegment {
};
// Transforms need extra information to correctly convert the list of transform
// functions to a Matrix4x4 that can be applied directly to the layer.
// functions to a gfx3DMatrix that can be applied directly to the layer.
struct TransformData {
// the origin of the frame being transformed in app units
nsPoint origin;

View File

@ -32,7 +32,7 @@ namespace mozilla {
namespace layers {
union MaybeTransform {
Matrix4x4;
gfx3DMatrix;
void_t;
};

View File

@ -13,6 +13,7 @@
#include "Layers.h" // for WriteSnapshotToDumpFile
#include "LayerScope.h" // for LayerScope
#include "gfx2DGlue.h" // for ThebesFilter
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter
#include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxPlatform.h" // for gfxPlatform

View File

@ -35,6 +35,7 @@
#include <ui/GraphicBuffer.h>
#endif
class gfx3DMatrix;
class nsIWidget;
namespace mozilla {

View File

@ -7,6 +7,7 @@
#define GFX_OGLSHADERPROGRAM_H
#include "GLContext.h" // for fast inlines of glUniform*
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxTypes.h"
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr
@ -470,6 +471,10 @@ protected:
}
}
void SetMatrixUniform(KnownUniform::KnownUniformName aKnownUniform, const gfx3DMatrix& aMatrix) {
SetMatrixUniform(aKnownUniform, &aMatrix._11);
}
void SetMatrixUniform(KnownUniform::KnownUniformName aKnownUniform, const gfx::Matrix4x4& aMatrix) {
SetMatrixUniform(aKnownUniform, &aMatrix._11);
}

View File

@ -710,9 +710,9 @@ TEST_F(APZCBasicTester, ComplexTransform) {
nsIntRegion(nsIntRect(0, 0, 300, 300)),
nsIntRegion(nsIntRect(0, 0, 150, 300)),
};
Matrix4x4 transforms[] = {
Matrix4x4(),
Matrix4x4(),
gfx3DMatrix transforms[] = {
gfx3DMatrix(),
gfx3DMatrix(),
};
transforms[0].ScalePost(0.5f, 0.5f, 1.0f); // this results from the 2.0 resolution on the root layer
transforms[1].ScalePost(2.0f, 1.0f, 1.0f); // this is the 2.0 x-axis CSS transform on the child layer
@ -1450,12 +1450,12 @@ CreateTestLayerTree1(nsRefPtr<LayerManager>& aLayerManager, nsTArray<nsRefPtr<La
nsIntRegion(nsIntRect(10,10,20,20)),
nsIntRegion(nsIntRect(5,5,20,20)),
};
Matrix4x4 transforms[] = {
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
gfx3DMatrix transforms[] = {
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
};
return CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, aLayerManager, aLayers);
}
@ -1471,11 +1471,11 @@ CreateTestLayerTree2(nsRefPtr<LayerManager>& aLayerManager, nsTArray<nsRefPtr<La
nsIntRegion(nsIntRect(10,60,40,40)),
nsIntRegion(nsIntRect(10,60,40,40)),
};
Matrix4x4 transforms[] = {
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
gfx3DMatrix transforms[] = {
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
};
return CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, aLayerManager, aLayers);
}
@ -1499,7 +1499,7 @@ SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId,
static already_AddRefed<AsyncPanZoomController>
GetTargetAPZC(APZCTreeManager* manager, const ScreenPoint& aPoint,
Matrix4x4& aTransformToApzcOut, Matrix4x4& aTransformToGeckoOut)
gfx3DMatrix& aTransformToApzcOut, gfx3DMatrix& aTransformToGeckoOut)
{
nsRefPtr<AsyncPanZoomController> hit = manager->GetTargetAPZC(aPoint, nullptr);
if (hit) {
@ -1520,15 +1520,15 @@ TEST_F(APZCTreeManagerTester, HitTesting1) {
ScopedLayerTreeRegistration controller(0, root, mcc);
nsRefPtr<APZCTreeManager> manager = new TestAPZCTreeManager();
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
// No APZC attached so hit testing will return no APZC at (20,20)
nsRefPtr<AsyncPanZoomController> hit = GetTargetAPZC(manager, ScreenPoint(20, 20), transformToApzc, transformToGecko);
AsyncPanZoomController* nullAPZC = nullptr;
EXPECT_EQ(nullAPZC, hit.get());
EXPECT_EQ(Matrix4x4(), transformToApzc);
EXPECT_EQ(Matrix4x4(), transformToGecko);
EXPECT_EQ(gfx3DMatrix(), transformToApzc);
EXPECT_EQ(gfx3DMatrix(), transformToGecko);
uint32_t paintSequenceNumber = 0;
@ -1538,8 +1538,8 @@ TEST_F(APZCTreeManagerTester, HitTesting1) {
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
EXPECT_EQ(root->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
// expect hit point at LayerIntPoint(15, 15)
EXPECT_EQ(Point(15, 15), transformToApzc * Point(15, 15));
EXPECT_EQ(Point(15, 15), transformToGecko * Point(15, 15));
EXPECT_EQ(gfxPoint(15, 15), transformToApzc.Transform(gfxPoint(15, 15)));
EXPECT_EQ(gfxPoint(15, 15), transformToGecko.Transform(gfxPoint(15, 15)));
// Now we have a sub APZC with a better fit
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 1);
@ -1548,8 +1548,8 @@ TEST_F(APZCTreeManagerTester, HitTesting1) {
hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToGecko);
EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
// expect hit point at LayerIntPoint(25, 25)
EXPECT_EQ(Point(25, 25), transformToApzc * Point(25, 25));
EXPECT_EQ(Point(25, 25), transformToGecko * Point(25, 25));
EXPECT_EQ(gfxPoint(25, 25), transformToApzc.Transform(gfxPoint(25, 25)));
EXPECT_EQ(gfxPoint(25, 25), transformToGecko.Transform(gfxPoint(25, 25)));
// At this point, layers[4] obscures layers[3] at the point (15, 15) so
// hitting there should hit the root APZC
@ -1562,25 +1562,25 @@ TEST_F(APZCTreeManagerTester, HitTesting1) {
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
EXPECT_EQ(layers[4]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
// expect hit point at LayerIntPoint(15, 15)
EXPECT_EQ(Point(15, 15), transformToApzc * Point(15, 15));
EXPECT_EQ(Point(15, 15), transformToGecko * Point(15, 15));
EXPECT_EQ(gfxPoint(15, 15), transformToApzc.Transform(gfxPoint(15, 15)));
EXPECT_EQ(gfxPoint(15, 15), transformToGecko.Transform(gfxPoint(15, 15)));
// Hit test ouside the reach of layer[3,4] but inside root
hit = GetTargetAPZC(manager, ScreenPoint(90, 90), transformToApzc, transformToGecko);
EXPECT_EQ(root->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
// expect hit point at LayerIntPoint(90, 90)
EXPECT_EQ(Point(90, 90), transformToApzc * Point(90, 90));
EXPECT_EQ(Point(90, 90), transformToGecko * Point(90, 90));
EXPECT_EQ(gfxPoint(90, 90), transformToApzc.Transform(gfxPoint(90, 90)));
EXPECT_EQ(gfxPoint(90, 90), transformToGecko.Transform(gfxPoint(90, 90)));
// Hit test ouside the reach of any layer
hit = GetTargetAPZC(manager, ScreenPoint(1000, 10), transformToApzc, transformToGecko);
EXPECT_EQ(nullAPZC, hit.get());
EXPECT_EQ(Matrix4x4(), transformToApzc);
EXPECT_EQ(Matrix4x4(), transformToGecko);
EXPECT_EQ(gfx3DMatrix(), transformToApzc);
EXPECT_EQ(gfx3DMatrix(), transformToGecko);
hit = GetTargetAPZC(manager, ScreenPoint(-1000, 10), transformToApzc, transformToGecko);
EXPECT_EQ(nullAPZC, hit.get());
EXPECT_EQ(Matrix4x4(), transformToApzc);
EXPECT_EQ(Matrix4x4(), transformToGecko);
EXPECT_EQ(gfx3DMatrix(), transformToApzc);
EXPECT_EQ(gfx3DMatrix(), transformToGecko);
manager->ClearTree();
}
@ -1598,8 +1598,8 @@ TEST_F(APZCTreeManagerTester, HitTesting2) {
nsRefPtr<TestAPZCTreeManager> manager = new TestAPZCTreeManager();
nsRefPtr<AsyncPanZoomController> hit;
Matrix4x4 transformToApzc;
Matrix4x4 transformToGecko;
gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko;
// Set a CSS transform on one of the layers.
Matrix4x4 transform;
@ -1626,8 +1626,8 @@ TEST_F(APZCTreeManagerTester, HitTesting2) {
// Hit an area that's clearly on the root layer but not any of the child layers.
hit = GetTargetAPZC(manager, ScreenPoint(75, 25), transformToApzc, transformToGecko);
EXPECT_EQ(apzcroot, hit.get());
EXPECT_EQ(Point(75, 25), transformToApzc * Point(75, 25));
EXPECT_EQ(Point(75, 25), transformToGecko * Point(75, 25));
EXPECT_EQ(gfxPoint(75, 25), transformToApzc.Transform(gfxPoint(75, 25)));
EXPECT_EQ(gfxPoint(75, 25), transformToGecko.Transform(gfxPoint(75, 25)));
// Hit an area on the root that would be on layers[3] if layers[2]
// weren't transformed.
@ -1638,31 +1638,31 @@ TEST_F(APZCTreeManagerTester, HitTesting2) {
// start at x=10 but its content at x=20).
hit = GetTargetAPZC(manager, ScreenPoint(15, 75), transformToApzc, transformToGecko);
EXPECT_EQ(apzcroot, hit.get());
EXPECT_EQ(Point(15, 75), transformToApzc * Point(15, 75));
EXPECT_EQ(Point(15, 75), transformToGecko * Point(15, 75));
EXPECT_EQ(gfxPoint(15, 75), transformToApzc.Transform(gfxPoint(15, 75)));
EXPECT_EQ(gfxPoint(15, 75), transformToGecko.Transform(gfxPoint(15, 75)));
// Hit an area on layers[1].
hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToGecko);
EXPECT_EQ(apzc1, hit.get());
EXPECT_EQ(Point(25, 25), transformToApzc * Point(25, 25));
EXPECT_EQ(Point(25, 25), transformToGecko * Point(25, 25));
EXPECT_EQ(gfxPoint(25, 25), transformToApzc.Transform(gfxPoint(25, 25)));
EXPECT_EQ(gfxPoint(25, 25), transformToGecko.Transform(gfxPoint(25, 25)));
// Hit an area on layers[3].
hit = GetTargetAPZC(manager, ScreenPoint(25, 75), transformToApzc, transformToGecko);
EXPECT_EQ(apzc3, hit.get());
// transformToApzc should unapply layers[2]'s transform
EXPECT_EQ(Point(12.5, 75), transformToApzc * Point(25, 75));
EXPECT_EQ(gfxPoint(12.5, 75), transformToApzc.Transform(gfxPoint(25, 75)));
// and transformToGecko should reapply it
EXPECT_EQ(Point(25, 75), transformToGecko * Point(12.5, 75));
EXPECT_EQ(gfxPoint(25, 75), transformToGecko.Transform(gfxPoint(12.5, 75)));
// Hit an area on layers[3] that would be on the root if layers[2]
// weren't transformed.
hit = GetTargetAPZC(manager, ScreenPoint(75, 75), transformToApzc, transformToGecko);
EXPECT_EQ(apzc3, hit.get());
// transformToApzc should unapply layers[2]'s transform
EXPECT_EQ(Point(37.5, 75), transformToApzc * Point(75, 75));
EXPECT_EQ(gfxPoint(37.5, 75), transformToApzc.Transform(gfxPoint(75, 75)));
// and transformToGecko should reapply it
EXPECT_EQ(Point(75, 75), transformToGecko * Point(37.5, 75));
EXPECT_EQ(gfxPoint(75, 75), transformToGecko.Transform(gfxPoint(37.5, 75)));
// Pan the root layer upward by 50 pixels.
// This causes layers[1] to scroll out of view, and an async transform
@ -1684,21 +1684,21 @@ TEST_F(APZCTreeManagerTester, HitTesting2) {
hit = GetTargetAPZC(manager, ScreenPoint(75, 75), transformToApzc, transformToGecko);
EXPECT_EQ(apzcroot, hit.get());
// transformToApzc doesn't unapply the root's own async transform
EXPECT_EQ(Point(75, 75), transformToApzc * Point(75, 75));
EXPECT_EQ(gfxPoint(75, 75), transformToApzc.Transform(gfxPoint(75, 75)));
// and transformToGecko unapplies it and then reapplies it, because by the
// time the event being transformed reaches Gecko the new paint request will
// have been handled.
EXPECT_EQ(Point(75, 75), transformToGecko * Point(75, 75));
EXPECT_EQ(gfxPoint(75, 75), transformToGecko.Transform(gfxPoint(75, 75)));
// Hit where layers[1] used to be and where layers[3] should now be.
hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToGecko);
EXPECT_EQ(apzc3, hit.get());
// transformToApzc unapplies both layers[2]'s css transform and the root's
// async transform
EXPECT_EQ(Point(12.5, 75), transformToApzc * Point(25, 25));
EXPECT_EQ(gfxPoint(12.5, 75), transformToApzc.Transform(gfxPoint(25, 25)));
// transformToGecko reapplies both the css transform and the async transform
// because we have already issued a paint request with it.
EXPECT_EQ(Point(25, 25), transformToGecko * Point(12.5, 75));
EXPECT_EQ(gfxPoint(25, 25), transformToGecko.Transform(gfxPoint(12.5, 75)));
// This second pan will move the APZC by another 50 pixels but since the paint
// request dispatched above has not "completed", we will not dispatch another
@ -1712,19 +1712,19 @@ TEST_F(APZCTreeManagerTester, HitTesting2) {
hit = GetTargetAPZC(manager, ScreenPoint(75, 75), transformToApzc, transformToGecko);
EXPECT_EQ(apzcroot, hit.get());
// transformToApzc doesn't unapply the root's own async transform
EXPECT_EQ(Point(75, 75), transformToApzc * Point(75, 75));
EXPECT_EQ(gfxPoint(75, 75), transformToApzc.Transform(gfxPoint(75, 75)));
// transformToGecko unapplies the full async transform of -100 pixels, and then
// reapplies the "D" transform of -50 leading to an overall adjustment of +50
EXPECT_EQ(Point(75, 125), transformToGecko * Point(75, 75));
EXPECT_EQ(gfxPoint(75, 125), transformToGecko.Transform(gfxPoint(75, 75)));
// Hit where layers[1] used to be. It should now hit the root.
hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToGecko);
EXPECT_EQ(apzcroot, hit.get());
// transformToApzc doesn't unapply the root's own async transform
EXPECT_EQ(Point(25, 25), transformToApzc * Point(25, 25));
EXPECT_EQ(gfxPoint(25, 25), transformToApzc.Transform(gfxPoint(25, 25)));
// transformToGecko unapplies the full async transform of -100 pixels, and then
// reapplies the "D" transform of -50 leading to an overall adjustment of +50
EXPECT_EQ(Point(25, 75), transformToGecko * Point(25, 25));
EXPECT_EQ(gfxPoint(25, 75), transformToGecko.Transform(gfxPoint(25, 25)));
manager->ClearTree();
}

View File

@ -162,7 +162,7 @@ already_AddRefed<Layer> CreateLayer(char aLayerType, LayerManager* aManager) {
already_AddRefed<Layer> CreateLayerTree(
const char* aLayerTreeDescription,
nsIntRegion* aVisibleRegions,
const Matrix4x4* aTransforms,
const gfx3DMatrix* aTransforms,
nsRefPtr<LayerManager>& manager,
nsTArray<nsRefPtr<Layer> >& aLayersOut) {
@ -194,7 +194,7 @@ already_AddRefed<Layer> CreateLayerTree(
layer->SetVisibleRegion(aVisibleRegions[layerNumber]);
}
if (aTransforms) {
layer->SetBaseTransform(aTransforms[layerNumber]);
layer->SetBaseTransform(ToMatrix4x4(aTransforms[layerNumber]));
}
aLayersOut.AppendElement(layer);
layerNumber++;
@ -225,11 +225,11 @@ TEST(Layers, LayerTree) {
nsIntRegion(nsIntRect(0,0,100,100)),
nsIntRegion(nsIntRect(10,10,20,20)),
};
Matrix4x4 transforms[] = {
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
Matrix4x4(),
gfx3DMatrix transforms[] = {
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
gfx3DMatrix(),
};
nsTArray<nsRefPtr<Layer> > layers;

View File

@ -27,7 +27,7 @@
already_AddRefed<mozilla::layers::Layer> CreateLayerTree(
const char* aLayerTreeDescription,
nsIntRegion* aVisibleRegions,
const mozilla::gfx::Matrix4x4* aTransforms,
const gfx3DMatrix* aTransforms,
nsRefPtr<mozilla::layers::LayerManager>& aLayerManager,
nsTArray<nsRefPtr<mozilla::layers::Layer> >& aLayersOut);

View File

@ -3564,7 +3564,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
nsDisplayListBuilder* aDisplayListBuilder,
nsIFrame* aContainerFrame,
const nsRect& aVisibleRect,
const Matrix4x4* aTransform,
const gfx3DMatrix* aTransform,
const ContainerLayerParameters& aIncomingScale,
ContainerLayer* aLayer,
LayerState aState,
@ -3572,8 +3572,8 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
{
nsIntPoint offset;
Matrix4x4 transform =
Matrix4x4().Scale(aIncomingScale.mXScale, aIncomingScale.mYScale, 1.0);
gfx3DMatrix transform =
gfx3DMatrix::ScalingMatrix(aIncomingScale.mXScale, aIncomingScale.mYScale, 1.0);
if (aTransform) {
// aTransform is applied first, then the scale is applied to the result
transform = (*aTransform)*transform;
@ -3584,7 +3584,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
// to depend on the scroll position.
transform.NudgeToIntegersFixedEpsilon();
}
Matrix transform2d;
gfxMatrix transform2d;
if (aContainerFrame &&
(aState == LAYER_INACTIVE || aState == LAYER_SVG_EFFECTS) &&
(!aTransform || (aTransform->Is2D(&transform2d) &&
@ -3602,7 +3602,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.x, appUnitsPerDevPixel)*aIncomingScale.mXScale),
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.y, appUnitsPerDevPixel)*aIncomingScale.mYScale));
}
transform = transform * Matrix4x4().Translate(offset.x + aIncomingScale.mOffset.x, offset.y + aIncomingScale.mOffset.y, 0);
transform = transform * gfx3DMatrix::Translation(offset.x + aIncomingScale.mOffset.x, offset.y + aIncomingScale.mOffset.y, 0);
if (transform.IsSingular()) {
return false;
@ -3620,14 +3620,14 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
scale = nsLayoutUtils::ComputeSuitableScaleForAnimation(aContainerFrame->GetContent());
} else {
// Scale factors are normalized to a power of 2 to reduce the number of resolution changes
scale = RoundToFloatPrecision(ThebesMatrix(transform2d).ScaleFactors(true));
scale = RoundToFloatPrecision(transform2d.ScaleFactors(true));
// For frames with a changing transform that's not just a translation,
// round scale factors up to nearest power-of-2 boundary so that we don't
// keep having to redraw the content as it scales up and down. Rounding up to nearest
// power-of-2 boundary ensures we never scale up, only down --- avoiding
// jaggies. It also ensures we never scale down by more than a factor of 2,
// avoiding bad downscaling quality.
Matrix frameTransform;
gfxMatrix frameTransform;
if (ActiveLayerTracker::IsStyleAnimated(aContainerFrame, eCSSProperty_transform) &&
aTransform &&
(!aTransform->Is2D(&frameTransform) || frameTransform.HasNonTranslationOrFlip())) {
@ -3665,7 +3665,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
}
// Store the inverse of our resolution-scale on the layer
aLayer->SetBaseTransform(transform);
aLayer->SetBaseTransform(ToMatrix4x4(transform));
aLayer->SetPreScale(1.0f/float(scale.width),
1.0f/float(scale.height));
aLayer->SetInheritedScale(aIncomingScale.mXScale,
@ -3728,7 +3728,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
nsDisplayItem* aContainerItem,
nsDisplayList* aChildren,
const ContainerLayerParameters& aParameters,
const Matrix4x4* aTransform,
const gfx3DMatrix* aTransform,
uint32_t aFlags)
{
uint32_t containerDisplayItemKey =

View File

@ -29,10 +29,6 @@ class BasicLayerManager;
class ThebesLayer;
}
namespace gfx {
class Matrix4x4;
}
class FrameLayerBuilder;
class LayerManagerData;
class ThebesLayerData;
@ -233,7 +229,7 @@ public:
nsDisplayItem* aContainerItem,
nsDisplayList* aChildren,
const ContainerLayerParameters& aContainerParameters,
const gfx::Matrix4x4* aTransform,
const gfx3DMatrix* aTransform,
uint32_t aFlags = 0);
/**

View File

@ -63,8 +63,6 @@ using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::dom;
using namespace mozilla::layout;
using namespace mozilla::gfx;
typedef FrameMetrics::ViewID ViewID;
#ifdef DEBUG
@ -4587,7 +4585,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
gfx3DMatrix result;
// Call IsSVGTransformed() regardless of the value of
// disp->mSpecifiedTransform, since we still need any transformFromSVGParent.
Matrix svgTransform, transformFromSVGParent;
mozilla::gfx::Matrix svgTransform, transformFromSVGParent;
bool hasSVGTransforms =
frame && frame->IsSVGTransformed(&svgTransform, &transformFromSVGParent);
/* Transformed frames always have a transform, or are preserving 3d (and might still have perspective!) */
@ -4747,7 +4745,7 @@ nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBui
}
/* If the matrix is singular, or a hidden backface is shown, the frame won't be visible or hit. */
static bool IsFrameVisible(nsIFrame* aFrame, const Matrix4x4& aMatrix)
static bool IsFrameVisible(nsIFrame* aFrame, const gfx3DMatrix& aMatrix)
{
if (aMatrix.IsSingular()) {
return false;
@ -4759,7 +4757,7 @@ static bool IsFrameVisible(nsIFrame* aFrame, const Matrix4x4& aMatrix)
return true;
}
const Matrix4x4&
const gfx3DMatrix&
nsDisplayTransform::GetTransform()
{
if (mTransform.IsIdentity()) {
@ -4770,7 +4768,7 @@ nsDisplayTransform::GetTransform()
0.0f);
if (mTransformGetter) {
mTransform = mTransformGetter(mFrame, scale);
mTransform.ChangeBasis(newOrigin.x, newOrigin.y, newOrigin.z);
mTransform.ChangeBasis(newOrigin);
} else {
/**
* Passing true as the final argument means that we want to shift the
@ -4780,9 +4778,9 @@ nsDisplayTransform::GetTransform()
* to be an ancestor of the preserve-3d chain, so we only need to do
* this once.
*/
mTransform = ToMatrix4x4(
mTransform =
GetResultingTransformMatrix(mFrame, ToReferenceFrame(), scale,
nullptr, nullptr, true));
nullptr, nullptr, true);
}
}
return mTransform;
@ -4798,7 +4796,7 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu
LayerManager *aManager,
const ContainerLayerParameters& aContainerParameters)
{
const Matrix4x4& newTransformMatrix = GetTransform();
const gfx3DMatrix& newTransformMatrix = GetTransform();
if (mFrame->StyleDisplay()->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
newTransformMatrix.IsBackfaceVisible()) {
@ -4912,7 +4910,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
*/
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
Matrix4x4 matrix = GetTransform();
gfx3DMatrix matrix = GetTransform();
if (!IsFrameVisible(mFrame, matrix)) {
return;
@ -4927,7 +4925,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
nsRect resultingRect;
if (aRect.width == 1 && aRect.height == 1) {
// Magic width/height indicating we're hit testing a point, not a rect
gfxPointH3D point = To3DMatrix(matrix).Inverse().ProjectPoint(gfxPoint(NSAppUnitsToFloatPixels(aRect.x, factor),
gfxPointH3D point = matrix.Inverse().ProjectPoint(gfxPoint(NSAppUnitsToFloatPixels(aRect.x, factor),
NSAppUnitsToFloatPixels(aRect.y, factor)));
if (!point.HasPositiveWCoord()) {
return;
@ -4945,7 +4943,7 @@ void nsDisplayTransform::HitTest(nsDisplayListBuilder *aBuilder,
NSAppUnitsToFloatPixels(aRect.width, factor),
NSAppUnitsToFloatPixels(aRect.height, factor));
gfxRect rect = To3DMatrix(matrix).Inverse().ProjectRectBounds(originalRect);
gfxRect rect = matrix.Inverse().ProjectRectBounds(originalRect);
bool snap;
nsRect childBounds = mStoredList.GetBounds(aBuilder, &snap);
@ -4988,17 +4986,17 @@ nsDisplayTransform::GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsP
{
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
Matrix4x4 matrix = GetTransform();
gfx3DMatrix matrix = GetTransform();
NS_ASSERTION(IsFrameVisible(mFrame, matrix), "We can't have hit a frame that isn't visible!");
gfxPointH3D point = To3DMatrix(matrix).Inverse().ProjectPoint(gfxPoint(NSAppUnitsToFloatPixels(aPoint.x, factor),
gfxPointH3D point = matrix.Inverse().ProjectPoint(gfxPoint(NSAppUnitsToFloatPixels(aPoint.x, factor),
NSAppUnitsToFloatPixels(aPoint.y, factor)));
NS_ASSERTION(point.HasPositiveWCoord(), "Why are we trying to get the depth for a point we didn't hit?");
gfxPoint point2d = point.As2DPoint();
Point3D transformed = matrix * Point3D(point2d.x, point2d.y, 0);
gfxPoint3D transformed = matrix.Transform3D(gfxPoint3D(point2d.x, point2d.y, 0));
return transformed.z;
}
@ -5015,7 +5013,7 @@ nsRect nsDisplayTransform::GetBounds(nsDisplayListBuilder *aBuilder, bool* aSnap
// GetTransform always operates in dev pixels.
float factor = mFrame->PresContext()->AppUnitsPerDevPixel();
return nsLayoutUtils::MatrixTransformRect(untransformedBounds,
To3DMatrix(GetTransform()),
GetTransform(),
factor);
}
@ -5051,10 +5049,10 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
return nsRegion();
}
const Matrix4x4& matrix = GetTransform();
const gfx3DMatrix& matrix = GetTransform();
nsRegion result;
Matrix matrix2d;
gfxMatrix matrix2d;
bool tmpSnap;
if (matrix.Is2D(&matrix2d) &&
matrix2d.PreservesAxisAlignedRectangles() &&
@ -5074,9 +5072,9 @@ bool nsDisplayTransform::IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aCol
if (!UntransformVisibleRect(aBuilder, &untransformedVisible)) {
return false;
}
const Matrix4x4& matrix = GetTransform();
const gfx3DMatrix& matrix = GetTransform();
Matrix matrix2d;
gfxMatrix matrix2d;
return matrix.Is2D(&matrix2d) &&
matrix2d.PreservesAxisAlignedRectangles() &&
mStoredList.GetVisibleRect().Contains(untransformedVisible) &&
@ -5201,7 +5199,7 @@ bool nsDisplayTransform::UntransformRect(const nsRect &aTransformedBounds,
bool nsDisplayTransform::UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
nsRect *aOutRect)
{
const gfx3DMatrix& matrix = To3DMatrix(GetTransform());
const gfx3DMatrix& matrix = GetTransform();
if (matrix.IsSingular())
return false;
@ -5233,7 +5231,7 @@ void
nsDisplayTransform::WriteDebugInfo(nsACString& aTo)
{
std::stringstream ss;
AppendToString(ss, GetTransform());
AppendToString(ss, gfx::ToMatrix4x4(GetTransform()));
aTo += ss.str().c_str();
}
#endif

View File

@ -3157,7 +3157,6 @@ private:
*/
class nsDisplayTransform: public nsDisplayItem
{
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
public:
/**
* Returns a matrix (in pixels) for the current frame. The matrix should be relative to
@ -3166,7 +3165,7 @@ public:
* @param aFrame The frame to compute the transform for.
* @param aAppUnitsPerPixel The number of app units per graphics unit.
*/
typedef Matrix4x4 (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
typedef gfx3DMatrix (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
/* Constructor accepts a display list, empties it, and wraps it up. It also
* ferries the underlying frame to the nsDisplayItem constructor.
@ -3245,7 +3244,7 @@ public:
INDEX_MAX = UINT32_MAX >> nsDisplayItem::TYPE_BITS
};
const Matrix4x4& GetTransform();
const gfx3DMatrix& GetTransform();
float GetHitDepthAtPoint(nsDisplayListBuilder* aBuilder, const nsPoint& aPoint);
@ -3384,7 +3383,7 @@ private:
bool aOffsetByOrigin);
nsDisplayWrapList mStoredList;
Matrix4x4 mTransform;
gfx3DMatrix mTransform;
ComputeTransformFunction mTransformGetter;
nsRect mChildrenVisibleRect;
uint32_t mIndex;

View File

@ -2416,7 +2416,7 @@ nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
new (&builder) nsDisplayTransform(&builder, aFrame, &list, nsRect());
*aTransform =
To3DMatrix(item->GetTransform());
item->GetTransform();
item->~nsDisplayTransform();
return true;

View File

@ -462,10 +462,10 @@ static void PaintHeaderFooter(nsIFrame* aFrame, nsRenderingContext* aCtx,
static_cast<nsPageFrame*>(aFrame)->PaintHeaderFooter(*aCtx, aPt);
}
static gfx::Matrix4x4 ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
static gfx3DMatrix ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
{
float scale = aFrame->PresContext()->GetPageScale();
return gfx::Matrix4x4().Scale(scale, scale, 1);
return gfx3DMatrix::ScalingMatrix(scale, scale, 1);
}
//------------------------------------------------------------------------------

View File

@ -766,11 +766,11 @@ nsSimplePageSequenceFrame::DoPageEnd()
return rv;
}
static gfx::Matrix4x4
static gfx3DMatrix
ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
{
float scale = aFrame->PresContext()->GetPrintPreviewScale();
return gfx::Matrix4x4().Scale(scale, scale, 1);
return gfx3DMatrix::ScalingMatrix(scale, scale, 1);
}
void

View File

@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "BasicLayers.h"
#include "gfx3DMatrix.h"
#ifdef MOZ_ENABLE_D3D9_LAYER
# include "LayerManagerD3D9.h"
#endif //MOZ_ENABLE_D3D9_LAYER
@ -30,7 +31,6 @@
typedef nsContentView::ViewConfig ViewConfig;
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::layers;
namespace mozilla {
@ -47,11 +47,11 @@ struct ViewTransform {
, mYScale(aYScale)
{}
operator Matrix4x4() const
operator gfx3DMatrix() const
{
return
Matrix4x4().Translate(mTranslation.x, mTranslation.y, 0) *
Matrix4x4().Scale(mXScale, mYScale, 1);
gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0) *
gfx3DMatrix::ScalingMatrix(mXScale, mYScale, 1);
}
nsIntPoint mTranslation;
@ -65,23 +65,23 @@ struct ViewTransform {
// much easier because we only expect the diagonals and the translation
// coordinates of the matrix to be non-zero.
static double GetXScale(const Matrix4x4& aTransform)
static double GetXScale(const gfx3DMatrix& aTransform)
{
return aTransform._11;
}
static double GetYScale(const Matrix4x4& aTransform)
static double GetYScale(const gfx3DMatrix& aTransform)
{
return aTransform._22;
}
static void Scale(Matrix4x4& aTransform, double aXScale, double aYScale)
static void Scale(gfx3DMatrix& aTransform, double aXScale, double aYScale)
{
aTransform._11 *= aXScale;
aTransform._22 *= aYScale;
}
static void ReverseTranslate(Matrix4x4& aTransform, const gfxPoint& aOffset)
static void ReverseTranslate(gfx3DMatrix& aTransform, const gfxPoint& aOffset)
{
aTransform._41 -= aOffset.x;
aTransform._42 -= aOffset.y;
@ -89,7 +89,7 @@ static void ReverseTranslate(Matrix4x4& aTransform, const gfxPoint& aOffset)
static void ApplyTransform(nsRect& aRect,
Matrix4x4& aTransform,
gfx3DMatrix& aTransform,
nscoord auPerDevPixel)
{
aRect.x = aRect.x * aTransform._11 + aTransform._41 * auPerDevPixel;
@ -203,14 +203,14 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
static void
BuildListForLayer(Layer* aLayer,
nsFrameLoader* aRootFrameLoader,
const Matrix4x4& aTransform,
const gfx3DMatrix& aTransform,
nsDisplayListBuilder* aBuilder,
nsDisplayList& aShadowTree,
nsIFrame* aSubdocFrame)
{
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
Matrix4x4 transform;
gfx3DMatrix transform;
if (metrics && metrics->IsScrollable()) {
const ViewID scrollId = metrics->GetScrollId();
@ -225,14 +225,14 @@ BuildListForLayer(Layer* aLayer,
aRootFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
// XXX why don't we include aLayer->GetTransform() in the inverse-scale here?
// This seems wrong, but it doesn't seem to cause bugs!
Matrix4x4 applyTransform = ComputeShadowTreeTransform(
gfx3DMatrix applyTransform = ComputeShadowTreeTransform(
aSubdocFrame, aRootFrameLoader, metrics, view->GetViewConfig(),
1 / GetXScale(aTransform), 1 / GetYScale(aTransform));
transform = applyTransform * aLayer->GetTransform() * aTransform;
transform = applyTransform * To3DMatrix(aLayer->GetTransform()) * aTransform;
// As mentioned above, bounds calculation also depends on the scale
// of this layer.
Matrix4x4 tmpTransform = aTransform;
gfx3DMatrix tmpTransform = aTransform;
Scale(tmpTransform, GetXScale(applyTransform), GetYScale(applyTransform));
// Calculate rect for this layer based on aTransform.
@ -247,7 +247,7 @@ BuildListForLayer(Layer* aLayer,
new (aBuilder) nsDisplayRemoteShadow(aBuilder, aSubdocFrame, bounds, scrollId));
} else {
transform = aLayer->GetTransform() * aTransform;
transform = To3DMatrix(aLayer->GetTransform()) * aTransform;
}
for (Layer* child = aLayer->GetFirstChild(); child;
@ -272,7 +272,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
Matrix4x4 shadowTransform = aLayer->GetTransform();
gfx3DMatrix shadowTransform = To3DMatrix(aLayer->GetTransform());
ViewTransform layerTransform = aTransform;
if (metrics && metrics->IsScrollable()) {
@ -280,7 +280,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
const nsContentView* view =
aFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
NS_ABORT_IF_FALSE(view, "Array of views should be consistent with layer tree");
Matrix4x4 currentTransform = aLayer->GetTransform();
gfx3DMatrix currentTransform = To3DMatrix(aLayer->GetTransform());
const ViewConfig& config = view->GetViewConfig();
// With temporary scale we should compensate translation
@ -293,14 +293,14 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
);
// Apply the layer's own transform *before* the view transform
shadowTransform = Matrix4x4(viewTransform) * currentTransform;
shadowTransform = gfx3DMatrix(viewTransform) * currentTransform;
layerTransform = viewTransform;
if (metrics->IsRootScrollable()) {
// Apply the translation *before* we do the rest of the transforms.
nsIntPoint offset = GetContentRectLayerOffset(aFrame, aBuilder);
shadowTransform = shadowTransform *
Matrix4x4().Translate(float(offset.x), float(offset.y), 0.0);
gfx3DMatrix::Translation(float(offset.x), float(offset.y), 0.0);
}
}
@ -332,7 +332,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
1.0f/aLayer->GetPostYScale(),
1);
shadow->SetShadowTransform(shadowTransform);
shadow->SetShadowTransform(gfx::ToMatrix4x4(shadowTransform));
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, layerTransform,
@ -376,7 +376,7 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
return;
const FrameMetrics metrics = container->GetFrameMetrics();
const ViewID scrollId = metrics.GetScrollId();
Matrix4x4 transform = aLayer->GetTransform();
gfx3DMatrix transform = To3DMatrix(aLayer->GetTransform());
aXScale *= GetXScale(transform);
aYScale *= GetYScale(transform);