Bug 1236750 - Add some specialized typedefs of Matrix4x4 to represent layer transform matrices. r=kats

Also add a related PixelCastJustification and a utility function.
This commit is contained in:
Botond Ballo 2016-01-06 18:56:25 -05:00
parent 26c1902ef0
commit b717649dfa
3 changed files with 34 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#include "mozilla/layers/GonkNativeHandle.h"
#endif
#include "Units.h"
#include "mozilla/gfx/Point.h" // for IntPoint
#include "mozilla/TypedEnumBits.h"
#include "nsRegion.h"
@ -284,6 +285,22 @@ enum TextureDumpMode {
DoNotCompress // dump texture uncompressed
};
// Some specialized typedefs of Matrix4x4Typed.
typedef gfx::Matrix4x4Typed<LayerPixel, CSSTransformedLayerPixel> CSSTransformMatrix;
// Several different async transforms can contribute to a layer's transform
// (specifically, an async animation can contribute a transform, and each APZC
// that scrolls a layer can contribute async scroll/zoom and overscroll
// transforms).
// To try to model this with typed units, we represent individual async
// transforms as ParentLayer -> ParentLayer transforms (aliased as
// AsyncTransformComponentMatrix), and we represent the product of all of them
// as a CSSTransformLayer -> ParentLayer transform (aliased as
// AsyncTransformMatrix). To create an AsyncTransformMatrix from component
// matrices, a ViewAs operation is needed. A MultipleAsyncTransforms
// PixelCastJustification is provided for this purpose.
typedef gfx::Matrix4x4Typed<ParentLayerPixel, ParentLayerPixel> AsyncTransformComponentMatrix;
typedef gfx::Matrix4x4Typed<CSSTransformedLayerPixel, ParentLayerPixel> AsyncTransformMatrix;
} // namespace layers
} // namespace mozilla

View File

@ -8,6 +8,8 @@
#define mozilla_layers_APZUtils_h
#include <stdint.h> // for uint32_t
#include "LayersTypes.h"
#include "UnitTransforms.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/FloatingPoint.h"
@ -61,6 +63,16 @@ static bool IsZero(const gfx::PointTyped<Units>& aPoint)
&& FuzzyEqualsAdditive(aPoint.y, 0.0f, COORDINATE_EPSILON);
}
// Deem an AsyncTransformComponentMatrix (obtained by multiplying together
// one or more AsyncTransformComponentMatrix objects) as constituting a
// complete async transform.
inline AsyncTransformMatrix
CompleteAsyncTransform(const AsyncTransformComponentMatrix& aMatrix)
{
return ViewAs<AsyncTransformMatrix>(aMatrix,
PixelCastJustification::MultipleAsyncTransforms);
}
} // namespace layers
} // namespace mozilla

View File

@ -47,7 +47,11 @@ enum class PixelCastJustification : uint8_t {
LayoutDeviceIsScreenForTabDims,
// A combination of LayoutDeviceIsScreenForBounds and
// ScreenIsParentLayerForRoot, which is how we're using it.
LayoutDeviceIsParentLayerForRCDRSF
LayoutDeviceIsParentLayerForRCDRSF,
// Used to treat the product of AsyncTransformComponentMatrix objects
// as an AsyncTransformMatrix. See the definitions of these matrices in
// LayersTypes.h for details.
MultipleAsyncTransforms
};
template <class TargetUnits, class SourceUnits>