mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952977: Convert GetEffectiveTransform to gfx::Matrix4x4 r=nical
This commit is contained in:
parent
482b98b33e
commit
1a8648fa9e
@ -287,6 +287,89 @@ public:
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const Matrix4x4& o) const
|
||||
{
|
||||
// XXX would be nice to memcmp here, but that breaks IEEE 754 semantics
|
||||
return _11 == o._11 && _12 == o._12 && _13 == o._13 && _14 == o._14 &&
|
||||
_21 == o._21 && _22 == o._22 && _23 == o._23 && _24 == o._24 &&
|
||||
_31 == o._31 && _32 == o._32 && _33 == o._33 && _34 == o._34 &&
|
||||
_41 == o._41 && _42 == o._42 && _43 == o._43 && _44 == o._44;
|
||||
}
|
||||
|
||||
bool operator!=(const Matrix4x4& o) const
|
||||
{
|
||||
return !((*this) == o);
|
||||
}
|
||||
|
||||
Matrix4x4 operator*(const Matrix4x4 &aMatrix) const
|
||||
{
|
||||
Matrix4x4 matrix;
|
||||
|
||||
matrix._11 = _11 * aMatrix._11 + _12 * aMatrix._21 + _13 * aMatrix._31 + _14 * aMatrix._41;
|
||||
matrix._21 = _21 * aMatrix._11 + _22 * aMatrix._21 + _23 * aMatrix._31 + _24 * aMatrix._41;
|
||||
matrix._31 = _31 * aMatrix._11 + _32 * aMatrix._21 + _33 * aMatrix._31 + _34 * aMatrix._41;
|
||||
matrix._41 = _41 * aMatrix._11 + _42 * aMatrix._21 + _43 * aMatrix._31 + _44 * aMatrix._41;
|
||||
matrix._12 = _11 * aMatrix._12 + _12 * aMatrix._22 + _13 * aMatrix._32 + _14 * aMatrix._42;
|
||||
matrix._22 = _21 * aMatrix._12 + _22 * aMatrix._22 + _23 * aMatrix._32 + _24 * aMatrix._42;
|
||||
matrix._32 = _31 * aMatrix._12 + _32 * aMatrix._22 + _33 * aMatrix._32 + _34 * aMatrix._42;
|
||||
matrix._42 = _41 * aMatrix._12 + _42 * aMatrix._22 + _43 * aMatrix._32 + _44 * aMatrix._42;
|
||||
matrix._13 = _11 * aMatrix._13 + _12 * aMatrix._23 + _13 * aMatrix._33 + _14 * aMatrix._43;
|
||||
matrix._23 = _21 * aMatrix._13 + _22 * aMatrix._23 + _23 * aMatrix._33 + _24 * aMatrix._43;
|
||||
matrix._33 = _31 * aMatrix._13 + _32 * aMatrix._23 + _33 * aMatrix._33 + _34 * aMatrix._43;
|
||||
matrix._43 = _41 * aMatrix._13 + _42 * aMatrix._23 + _43 * aMatrix._33 + _44 * aMatrix._43;
|
||||
matrix._14 = _11 * aMatrix._14 + _12 * aMatrix._24 + _13 * aMatrix._34 + _14 * aMatrix._44;
|
||||
matrix._24 = _21 * aMatrix._14 + _22 * aMatrix._24 + _23 * aMatrix._34 + _24 * aMatrix._44;
|
||||
matrix._34 = _31 * aMatrix._14 + _32 * aMatrix._24 + _33 * aMatrix._34 + _34 * aMatrix._44;
|
||||
matrix._44 = _41 * aMatrix._14 + _42 * aMatrix._24 + _43 * aMatrix._34 + _44 * aMatrix._44;
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if the matrix is an identity matrix.
|
||||
*/
|
||||
bool IsIdentity() const
|
||||
{
|
||||
return _11 == 1.0f && _12 == 0.0f && _13 == 0.0f && _14 == 0.0f &&
|
||||
_21 == 0.0f && _22 == 1.0f && _23 == 0.0f && _24 == 0.0f &&
|
||||
_31 == 0.0f && _32 == 0.0f && _33 == 1.0f && _34 == 0.0f &&
|
||||
_41 == 0.0f && _42 == 0.0f && _43 == 0.0f && _44 == 1.0f;
|
||||
}
|
||||
|
||||
bool IsSingular() const
|
||||
{
|
||||
return Determinant() == 0.0;
|
||||
}
|
||||
|
||||
Float Determinant() const
|
||||
{
|
||||
return _14 * _23 * _32 * _41
|
||||
- _13 * _24 * _32 * _41
|
||||
- _14 * _22 * _33 * _41
|
||||
+ _12 * _24 * _33 * _41
|
||||
+ _13 * _22 * _34 * _41
|
||||
- _12 * _23 * _34 * _41
|
||||
- _14 * _23 * _31 * _42
|
||||
+ _13 * _24 * _31 * _42
|
||||
+ _14 * _21 * _33 * _42
|
||||
- _11 * _24 * _33 * _42
|
||||
- _13 * _21 * _34 * _42
|
||||
+ _11 * _23 * _34 * _42
|
||||
+ _14 * _22 * _31 * _43
|
||||
- _12 * _24 * _31 * _43
|
||||
- _14 * _21 * _32 * _43
|
||||
+ _11 * _24 * _32 * _43
|
||||
+ _12 * _21 * _34 * _43
|
||||
- _11 * _22 * _34 * _43
|
||||
- _13 * _22 * _31 * _44
|
||||
+ _12 * _23 * _31 * _44
|
||||
+ _13 * _21 * _32 * _44
|
||||
- _11 * _23 * _32 * _44
|
||||
- _12 * _21 * _33 * _44
|
||||
+ _11 * _22 * _33 * _44;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class Matrix5x4
|
||||
|
@ -47,9 +47,10 @@ void ImageLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurfa
|
||||
// This makes our snapping equivalent to what would happen if our content
|
||||
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
||||
// transform, then we'd snap again when compositing the ThebesLayer).
|
||||
mEffectiveTransform =
|
||||
gfx3DMatrix snappedTransform =
|
||||
SnapTransform(local, sourceRect, nullptr) *
|
||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/TelemetryHistogramEnums.h"
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/layers/AsyncPanZoomController.h"
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
@ -552,7 +553,9 @@ bool
|
||||
Layer::MayResample()
|
||||
{
|
||||
gfxMatrix transform2d;
|
||||
return !GetEffectiveTransform().Is2D(&transform2d) ||
|
||||
gfx3DMatrix effectiveTransform;
|
||||
To3DMatrix(GetEffectiveTransform(), effectiveTransform);
|
||||
return !effectiveTransform.Is2D(&transform2d) ||
|
||||
transform2d.HasNonIntegerTranslation() ||
|
||||
AncestorLayerMayChangeTransform(this);
|
||||
}
|
||||
@ -586,7 +589,9 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
|
||||
nsIntRect scissor = *clipRect;
|
||||
if (!container->UseIntermediateSurface()) {
|
||||
gfxMatrix matrix;
|
||||
DebugOnly<bool> is2D = container->GetEffectiveTransform().Is2D(&matrix);
|
||||
gfx3DMatrix effectiveTransform;
|
||||
To3DMatrix(container->GetEffectiveTransform(), effectiveTransform);
|
||||
DebugOnly<bool> is2D = effectiveTransform.Is2D(&matrix);
|
||||
// See DefaultComputeEffectiveTransforms below
|
||||
NS_ASSERTION(is2D && matrix.PreservesAxisAlignedRectangles(),
|
||||
"Non preserves axis aligned transform with clipped child should have forced intermediate surface");
|
||||
@ -688,14 +693,16 @@ void
|
||||
Layer::ComputeEffectiveTransformForMaskLayer(const gfx3DMatrix& aTransformToSurface)
|
||||
{
|
||||
if (mMaskLayer) {
|
||||
mMaskLayer->mEffectiveTransform = aTransformToSurface;
|
||||
ToMatrix4x4(aTransformToSurface, mMaskLayer->mEffectiveTransform);
|
||||
|
||||
#ifdef DEBUG
|
||||
gfxMatrix maskTranslation;
|
||||
bool maskIs2D = mMaskLayer->GetTransform().CanDraw2D(&maskTranslation);
|
||||
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
||||
#endif
|
||||
mMaskLayer->mEffectiveTransform.PreMultiply(mMaskLayer->GetTransform());
|
||||
Matrix4x4 maskTransform;
|
||||
ToMatrix4x4(mMaskLayer->GetTransform(), maskTransform);
|
||||
mMaskLayer->mEffectiveTransform = maskTransform * mMaskLayer->mEffectiveTransform;
|
||||
}
|
||||
}
|
||||
|
||||
@ -885,7 +892,8 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const gfx3DMatrix& aTransformT
|
||||
gfxMatrix residual;
|
||||
gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface;
|
||||
idealTransform.ProjectTo2D();
|
||||
mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual);
|
||||
gfx3DMatrix snappedTransform = SnapTransformTranslation(idealTransform, &residual);
|
||||
ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
|
||||
bool useIntermediateSurface;
|
||||
if (GetMaskLayer()) {
|
||||
@ -901,7 +909,9 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const gfx3DMatrix& aTransformT
|
||||
} else {
|
||||
useIntermediateSurface = false;
|
||||
gfxMatrix contTransform;
|
||||
if (!mEffectiveTransform.Is2D(&contTransform) ||
|
||||
gfx3DMatrix effectiveTransform;
|
||||
To3DMatrix(mEffectiveTransform, effectiveTransform);
|
||||
if (!effectiveTransform.Is2D(&contTransform) ||
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
!contTransform.PreservesAxisAlignedRectangles()) {
|
||||
#else
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
|
||||
#include "nscore.h" // for nsACString, nsAString
|
||||
#include "prlog.h" // for PRLogModuleInfo
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
class gfxASurface;
|
||||
class gfxContext;
|
||||
@ -1218,7 +1219,7 @@ public:
|
||||
* ancestor with UseIntermediateSurface() (or to the root, if there is no
|
||||
* such ancestor), but for BasicLayers it's different.
|
||||
*/
|
||||
const gfx3DMatrix& GetEffectiveTransform() const { return mEffectiveTransform; }
|
||||
const gfx::Matrix4x4& GetEffectiveTransform() const { return mEffectiveTransform; }
|
||||
|
||||
/**
|
||||
* @param aTransformToSurface the composition of the transforms
|
||||
@ -1405,7 +1406,7 @@ protected:
|
||||
nsAutoPtr<gfx3DMatrix> mPendingTransform;
|
||||
float mPostXScale;
|
||||
float mPostYScale;
|
||||
gfx3DMatrix mEffectiveTransform;
|
||||
gfx::Matrix4x4 mEffectiveTransform;
|
||||
AnimationArray mAnimations;
|
||||
InfallibleTArray<AnimData> mAnimationData;
|
||||
float mOpacity;
|
||||
@ -1481,8 +1482,9 @@ public:
|
||||
{
|
||||
gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface;
|
||||
gfxMatrix residual;
|
||||
mEffectiveTransform = SnapTransformTranslation(idealTransform,
|
||||
gfx3DMatrix snappedTransform = SnapTransformTranslation(idealTransform,
|
||||
mAllowResidualTranslation ? &residual : nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
// The residual can only be a translation because SnapTransformTranslation
|
||||
// only changes the transform if it's a translation
|
||||
NS_ASSERTION(!residual.HasNonTranslation(),
|
||||
@ -1752,7 +1754,8 @@ public:
|
||||
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
|
||||
{
|
||||
gfx3DMatrix idealTransform = GetLocalTransform()*aTransformToSurface;
|
||||
mEffectiveTransform = SnapTransformTranslation(idealTransform, nullptr);
|
||||
gfx3DMatrix snappedTransform = SnapTransformTranslation(idealTransform, nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
||||
}
|
||||
|
||||
@ -1895,10 +1898,11 @@ public:
|
||||
// This makes our snapping equivalent to what would happen if our content
|
||||
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
||||
// transform, then we'd snap again when compositing the ThebesLayer).
|
||||
mEffectiveTransform =
|
||||
gfx3DMatrix snappedTransform =
|
||||
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mBounds.width, mBounds.height),
|
||||
nullptr)*
|
||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
||||
}
|
||||
|
||||
|
@ -90,10 +90,11 @@ public:
|
||||
// This makes our snapping equivalent to what would happen if our content
|
||||
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
||||
// transform, then we'd snap again when compositing the ThebesLayer).
|
||||
mEffectiveTransform =
|
||||
gfx3DMatrix snappedTransform =
|
||||
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mSize.width, mSize.height),
|
||||
nullptr)*
|
||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,14 +44,15 @@ BasicContainerLayer::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToS
|
||||
idealTransform.ProjectTo2D();
|
||||
|
||||
if (!idealTransform.CanDraw2D()) {
|
||||
mEffectiveTransform = idealTransform;
|
||||
ToMatrix4x4(idealTransform, mEffectiveTransform);
|
||||
ComputeEffectiveTransformsForChildren(gfx3DMatrix());
|
||||
ComputeEffectiveTransformForMaskLayer(gfx3DMatrix());
|
||||
mUseIntermediateSurface = true;
|
||||
return;
|
||||
}
|
||||
|
||||
mEffectiveTransform = SnapTransformTranslation(idealTransform, &residual);
|
||||
gfx3DMatrix snappedTransform = SnapTransformTranslation(idealTransform, &residual);
|
||||
ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
// We always pass the ideal matrix down to our children, so there is no
|
||||
// need to apply any compensation using the residual from SnapTransformTranslation.
|
||||
ComputeEffectiveTransformsForChildren(idealTransform);
|
||||
@ -82,7 +83,9 @@ bool
|
||||
BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
|
||||
{
|
||||
gfxMatrix transform;
|
||||
if (!GetEffectiveTransform().CanDraw2D(&transform) ||
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), effectiveTransform);
|
||||
if (!effectiveTransform.CanDraw2D(&transform) ||
|
||||
transform.HasNonIntegerTranslation())
|
||||
return false;
|
||||
|
||||
@ -95,7 +98,9 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
|
||||
continue;
|
||||
|
||||
gfxMatrix childTransform;
|
||||
if (!l->GetEffectiveTransform().CanDraw2D(&childTransform) ||
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(l->GetEffectiveTransform(), effectiveTransform);
|
||||
if (!effectiveTransform.CanDraw2D(&childTransform) ||
|
||||
childTransform.HasNonIntegerTranslation() ||
|
||||
l->GetEffectiveOpacity() != 1.0)
|
||||
return false;
|
||||
|
@ -160,7 +160,8 @@ public:
|
||||
// transform.
|
||||
bool Setup2DTransform()
|
||||
{
|
||||
const gfx3DMatrix& effectiveTransform = mLayer->GetEffectiveTransform();
|
||||
gfx3DMatrix effectiveTransform;
|
||||
To3DMatrix(mLayer->GetEffectiveTransform(), effectiveTransform);
|
||||
// Will return an identity matrix for 3d transforms.
|
||||
return effectiveTransform.CanDraw2D(&mTransform);
|
||||
}
|
||||
@ -403,7 +404,9 @@ MarkLayersHidden(Layer* aLayer, const nsIntRect& aClipRect,
|
||||
// global coordinate system.
|
||||
if (aLayer->GetParent()) {
|
||||
gfxMatrix tr;
|
||||
if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) {
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aLayer->GetParent()->GetEffectiveTransform(), effectiveTransform);
|
||||
if (effectiveTransform.CanDraw2D(&tr)) {
|
||||
// Clip rect is applied after aLayer's transform, i.e., in the coordinate
|
||||
// system of aLayer's parent.
|
||||
TransformIntRect(cr, tr, ToInsideIntRect);
|
||||
@ -422,7 +425,9 @@ MarkLayersHidden(Layer* aLayer, const nsIntRect& aClipRect,
|
||||
|
||||
if (!aLayer->AsContainerLayer()) {
|
||||
gfxMatrix transform;
|
||||
if (!aLayer->GetEffectiveTransform().CanDraw2D(&transform)) {
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), effectiveTransform);
|
||||
if (!effectiveTransform.CanDraw2D(&transform)) {
|
||||
data->SetHidden(false);
|
||||
return;
|
||||
}
|
||||
@ -483,7 +488,9 @@ ApplyDoubleBuffering(Layer* aLayer, const nsIntRect& aVisibleRect)
|
||||
// global coordinate system.
|
||||
if (aLayer->GetParent()) {
|
||||
gfxMatrix tr;
|
||||
if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) {
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aLayer->GetParent()->GetEffectiveTransform(), effectiveTransform);
|
||||
if (effectiveTransform.CanDraw2D(&tr)) {
|
||||
NS_ASSERTION(!tr.HasNonIntegerTranslation(),
|
||||
"Parent can only have an integer translation");
|
||||
cr += nsIntPoint(int32_t(tr.x0), int32_t(tr.y0));
|
||||
@ -983,7 +990,8 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
||||
temp->Paint();
|
||||
}
|
||||
#endif
|
||||
const gfx3DMatrix& effectiveTransform = aLayer->GetEffectiveTransform();
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), effectiveTransform);
|
||||
nsRefPtr<gfxASurface> result =
|
||||
Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
|
||||
effectiveTransform, destRect);
|
||||
|
@ -71,8 +71,9 @@ GetMaskData(Layer* aMaskLayer, AutoMaskData* aMaskData)
|
||||
->GetAsSurface(getter_AddRefs(surface), &descriptor) &&
|
||||
(surface || IsSurfaceDescriptorValid(descriptor))) {
|
||||
gfxMatrix transform;
|
||||
DebugOnly<bool> maskIs2D =
|
||||
aMaskLayer->GetEffectiveTransform().CanDraw2D(&transform);
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aMaskLayer->GetEffectiveTransform(), effectiveTransform);
|
||||
DebugOnly<bool> maskIs2D = effectiveTransform.CanDraw2D(&transform);
|
||||
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
||||
if (surface) {
|
||||
aMaskData->Construct(transform, surface);
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
if (!BasicManager()->IsRetained()) {
|
||||
// Don't do any snapping of our transform, since we're just going to
|
||||
// draw straight through without intermediate buffers.
|
||||
mEffectiveTransform = GetLocalTransform()*aTransformToSurface;
|
||||
gfx::ToMatrix4x4(GetLocalTransform() * aTransformToSurface, mEffectiveTransform);
|
||||
if (gfxPoint(0,0) != mResidualTranslation) {
|
||||
mResidualTranslation = gfxPoint(0,0);
|
||||
mValidRegion.SetEmpty();
|
||||
|
@ -55,7 +55,8 @@ public:
|
||||
if (GetEffectiveVisibleRegion().GetNumRects() != 1 ||
|
||||
!(GetContentFlags() & Layer::CONTENT_OPAQUE))
|
||||
{
|
||||
const gfx3DMatrix& transform3D = GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), transform3D);
|
||||
gfxMatrix transform;
|
||||
if (HasOpaqueAncestorLayer(this) &&
|
||||
transform3D.Is2D(&transform) &&
|
||||
|
@ -82,12 +82,14 @@ ClientTiledThebesLayer::BeginPaint()
|
||||
|
||||
// Calculate the transform required to convert screen space into transformed
|
||||
// layout device space.
|
||||
gfx3DMatrix layoutToScreen = GetEffectiveTransform();
|
||||
gfx::Matrix4x4 effectiveTransform = GetEffectiveTransform();
|
||||
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
|
||||
if (parent->UseIntermediateSurface()) {
|
||||
layoutToScreen *= parent->GetEffectiveTransform();
|
||||
effectiveTransform = effectiveTransform * parent->GetEffectiveTransform();
|
||||
}
|
||||
}
|
||||
gfx3DMatrix layoutToScreen;
|
||||
gfx::To3DMatrix(effectiveTransform, layoutToScreen);
|
||||
layoutToScreen.ScalePost(metrics.mCumulativeResolution.scale,
|
||||
metrics.mCumulativeResolution.scale,
|
||||
1.f);
|
||||
|
@ -81,7 +81,9 @@ CanvasLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
// Using the LINEAR filter we get unexplained artifacts.
|
||||
// Use NEAREST when no scaling is required.
|
||||
gfxMatrix matrix;
|
||||
bool is2D = GetEffectiveTransform().Is2D(&matrix);
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), effectiveTransform);
|
||||
bool is2D = effectiveTransform.Is2D(&matrix);
|
||||
if (is2D && !matrix.HasNonTranslationOrFlip()) {
|
||||
filter = GraphicsFilter::FILTER_NEAREST;
|
||||
}
|
||||
@ -90,13 +92,11 @@ CanvasLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
EffectChain effectChain(this);
|
||||
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(GetEffectiveTransform(), transform);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
|
||||
mImageHost->Composite(effectChain,
|
||||
GetEffectiveOpacity(),
|
||||
transform,
|
||||
GetEffectiveTransform(),
|
||||
gfx::ToFilter(filter),
|
||||
clipRect);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ColorLayerComposite.h"
|
||||
#include "gfx2DGlue.h" // for ToMatrix4x4
|
||||
#include "gfxColor.h" // for gfxRGBA
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
@ -42,9 +41,7 @@ ColorLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
|
||||
float opacity = GetEffectiveOpacity();
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(GetEffectiveTransform(), transform);
|
||||
|
||||
const gfx::Matrix4x4& transform = GetEffectiveTransform();
|
||||
mCompositor->DrawQuad(rect, clipRect, effects, opacity, transform);
|
||||
mCompositor->DrawDiagnostics(DIAGNOSTIC_COLOR,
|
||||
rect, clipRect,
|
||||
|
@ -167,8 +167,7 @@ static void DrawVelGraph(const nsIntRect& aClipRect,
|
||||
|
||||
aManager->SetDebugOverlayWantsNextFrame(true);
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(aLayer->GetEffectiveTransform(), transform);
|
||||
const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform();
|
||||
nsIntRect bounds = aLayer->GetEffectiveVisibleRegion().GetBounds();
|
||||
gfx::Rect graphBounds = gfx::Rect(bounds.x, bounds.y,
|
||||
bounds.width, bounds.height);
|
||||
@ -243,7 +242,8 @@ ContainerRender(ContainerT* aContainer,
|
||||
aContainer->mSupportsComponentAlphaChildren = true;
|
||||
mode = INIT_MODE_NONE;
|
||||
} else {
|
||||
const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(aContainer->GetEffectiveTransform(), transform3D);
|
||||
gfxMatrix transform;
|
||||
// If we have an opaque ancestor layer, then we can be sure that
|
||||
// all the pixels we draw into are either opaque already or will be
|
||||
@ -352,26 +352,20 @@ ContainerRender(ContainerT* aContainer,
|
||||
|
||||
effectChain.mPrimaryEffect = new EffectRenderTarget(surface);
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(aContainer->GetEffectiveTransform(), transform);
|
||||
|
||||
gfx::Rect rect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
aManager->GetCompositor()->DrawQuad(rect, clipRect, effectChain, opacity,
|
||||
transform);
|
||||
aContainer->GetEffectiveTransform());
|
||||
}
|
||||
|
||||
if (aContainer->GetFrameMetrics().IsScrollable()) {
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(aContainer->GetEffectiveTransform(), transform);
|
||||
|
||||
const FrameMetrics& frame = aContainer->GetFrameMetrics();
|
||||
LayerRect layerBounds = ScreenRect(frame.mCompositionBounds) * ScreenToLayerScale(1.0);
|
||||
gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
aManager->GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTAINER,
|
||||
rect, clipRect,
|
||||
transform);
|
||||
aContainer->GetEffectiveTransform());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,13 +94,11 @@ ImageLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
EffectChain effectChain;
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(GetEffectiveTransform(), transform);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
mImageHost->Composite(effectChain,
|
||||
GetEffectiveOpacity(),
|
||||
transform,
|
||||
GetEffectiveTransform(),
|
||||
gfx::ToFilter(mFilter),
|
||||
clipRect);
|
||||
}
|
||||
@ -131,9 +129,10 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToS
|
||||
// This makes our snapping equivalent to what would happen if our content
|
||||
// was drawn into a ThebesLayer (gfxContext would snap using the local
|
||||
// transform, then we'd snap again when compositing the ThebesLayer).
|
||||
mEffectiveTransform =
|
||||
gfx3DMatrix snappedTransform =
|
||||
SnapTransform(local, sourceRect, nullptr) *
|
||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
||||
gfx::ToMatrix4x4(snappedTransform, mEffectiveTransform);
|
||||
ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
|
||||
// Accumulate the transform of intermediate surfaces
|
||||
gfx3DMatrix transform = aTransform;
|
||||
if (container->UseIntermediateSurface()) {
|
||||
transform = aLayer->GetEffectiveTransform();
|
||||
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), transform);
|
||||
transform.PreMultiply(aTransform);
|
||||
}
|
||||
for (Layer* child = aLayer->GetFirstChild(); child;
|
||||
@ -499,7 +499,8 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
|
||||
|
||||
if (!incompleteRegion.IsEmpty()) {
|
||||
// Calculate the transform to get between screen and layer space
|
||||
gfx3DMatrix transformToScreen = aLayer->GetEffectiveTransform();
|
||||
gfx3DMatrix transformToScreen;
|
||||
To3DMatrix(aLayer->GetEffectiveTransform(), transformToScreen);
|
||||
transformToScreen.PreMultiply(aTransform);
|
||||
|
||||
SubtractTransformedRegion(aScreenRegion, incompleteRegion, transformToScreen);
|
||||
@ -577,7 +578,8 @@ LayerManagerComposite::ComputeRenderIntegrity()
|
||||
// This is derived from the code in
|
||||
// AsyncCompositionManager::TransformScrollableLayer
|
||||
const FrameMetrics& metrics = primaryScrollable->AsContainerLayer()->GetFrameMetrics();
|
||||
gfx3DMatrix transform = primaryScrollable->GetEffectiveTransform();
|
||||
gfx3DMatrix transform;
|
||||
gfx::To3DMatrix(primaryScrollable->GetEffectiveTransform(), transform);
|
||||
transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1);
|
||||
|
||||
// Clip the screen rect to the document bounds
|
||||
@ -720,9 +722,7 @@ LayerManagerComposite::AutoAddMaskEffect::AutoAddMaskEffect(Layer* aMaskLayer,
|
||||
return;
|
||||
}
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(aMaskLayer->GetEffectiveTransform(), transform);
|
||||
if (!mCompositable->AddMaskEffect(aEffects, transform, aIs3D)) {
|
||||
if (!mCompositable->AddMaskEffect(aEffects, aMaskLayer->GetEffectiveTransform(), aIs3D)) {
|
||||
mCompositable = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,6 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
mBuffer->GetLayer() == this,
|
||||
"buffer is corrupted");
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(GetEffectiveTransform(), transform);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
@ -134,7 +132,7 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
||||
|
||||
mBuffer->Composite(effectChain,
|
||||
GetEffectiveOpacity(),
|
||||
transform,
|
||||
GetEffectiveTransform(),
|
||||
gfx::Filter::LINEAR,
|
||||
clipRect,
|
||||
&visibleRegion,
|
||||
|
@ -35,8 +35,8 @@ ColorLayerD3D10::RenderLayer()
|
||||
color[2] = (float)(mColor.b * opacity);
|
||||
color[3] = opacity;
|
||||
|
||||
const gfx3DMatrix& transform = GetEffectiveTransform();
|
||||
void* raw = &const_cast<gfx3DMatrix&>(transform)._11;
|
||||
const gfx::Matrix4x4& transform = GetEffectiveTransform();
|
||||
void* raw = &const_cast<gfx::Matrix4x4&>(transform)._11;
|
||||
effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
|
||||
effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color);
|
||||
|
||||
|
@ -106,7 +106,8 @@ ContainerLayerD3D10::RenderLayer()
|
||||
previousViewportSize = mD3DManager->GetViewport();
|
||||
|
||||
if (mVisibleRegion.GetNumRects() != 1 || !(GetContentFlags() & CONTENT_OPAQUE)) {
|
||||
const gfx3DMatrix& transform3D = GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), transform3D);
|
||||
gfxMatrix transform;
|
||||
// If we have an opaque ancestor layer, then we can be sure that
|
||||
// all the pixels we draw into are either opaque already or will be
|
||||
@ -247,7 +248,8 @@ ContainerLayerD3D10::Validate()
|
||||
mSupportsComponentAlphaChildren = false;
|
||||
|
||||
if (UseIntermediateSurface()) {
|
||||
const gfx3DMatrix& transform3D = GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), transform3D);
|
||||
gfxMatrix transform;
|
||||
|
||||
if (mVisibleRegion.GetNumRects() == 1 && (GetContentFlags() & CONTENT_OPAQUE)) {
|
||||
|
@ -860,7 +860,9 @@ LayerD3D10::LoadMaskTexture()
|
||||
}
|
||||
|
||||
gfxMatrix maskTransform;
|
||||
bool maskIs2D = maskLayer->GetEffectiveTransform().CanDraw2D(&maskTransform);
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(maskLayer->GetEffectiveTransform(), effectiveTransform);
|
||||
bool maskIs2D = effectiveTransform.CanDraw2D(&maskTransform);
|
||||
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
||||
gfxRect bounds = gfxRect(gfxPoint(), ThebesIntSize(size));
|
||||
bounds = maskTransform.TransformBounds(bounds);
|
||||
|
@ -238,8 +238,8 @@ public:
|
||||
void SetEffectTransformAndOpacity()
|
||||
{
|
||||
Layer* layer = GetLayer();
|
||||
const gfx3DMatrix& transform = layer->GetEffectiveTransform();
|
||||
void* raw = &const_cast<gfx3DMatrix&>(transform)._11;
|
||||
const gfx::Matrix4x4& transform = layer->GetEffectiveTransform();
|
||||
void* raw = &const_cast<gfx::Matrix4x4&>(transform)._11;
|
||||
effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
|
||||
effect()->GetVariableByName("fLayerOpacity")->AsScalar()->SetFloat(layer->GetEffectiveOpacity());
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager)
|
||||
bounds.height),
|
||||
1);
|
||||
|
||||
const gfx3DMatrix& transform = aLayer->GetEffectiveTransform();
|
||||
const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform();
|
||||
aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4);
|
||||
|
||||
gfxRGBA layerColor(aLayer->GetColor());
|
||||
|
@ -89,7 +89,8 @@ ContainerLayerD3D9::RenderLayer()
|
||||
// don't need a background, we're going to paint all opaque stuff
|
||||
mSupportsComponentAlphaChildren = true;
|
||||
} else {
|
||||
const gfx3DMatrix& transform3D = GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(GetEffectiveTransform(), transform3D);
|
||||
gfxMatrix transform;
|
||||
// If we have an opaque ancestor layer, then we can be sure that
|
||||
// all the pixels we draw into are either opaque already or will be
|
||||
|
@ -552,18 +552,20 @@ LoadMaskTexture(Layer* aMask, IDirect3DDevice9* aDevice,
|
||||
gfx::IntSize size;
|
||||
nsRefPtr<IDirect3DTexture9> texture =
|
||||
static_cast<LayerD3D9*>(aMask->ImplData())->GetAsTexture(&size);
|
||||
|
||||
|
||||
if (!texture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
gfxMatrix maskTransform;
|
||||
bool maskIs2D = aMask->GetEffectiveTransform().CanDraw2D(&maskTransform);
|
||||
gfx3DMatrix effectiveTransform;
|
||||
gfx::To3DMatrix(aMask->GetEffectiveTransform(), effectiveTransform);
|
||||
bool maskIs2D = effectiveTransform.CanDraw2D(&maskTransform);
|
||||
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
||||
gfxRect bounds = gfxRect(gfxPoint(), gfx::ThebesIntSize(size));
|
||||
bounds = maskTransform.TransformBounds(bounds);
|
||||
|
||||
aDevice->SetVertexShaderConstantF(DeviceManagerD3D9::sMaskQuadRegister,
|
||||
aDevice->SetVertexShaderConstantF(DeviceManagerD3D9::sMaskQuadRegister,
|
||||
ShaderConstantRect((float)bounds.x,
|
||||
(float)bounds.y,
|
||||
(float)bounds.width,
|
||||
|
@ -225,7 +225,7 @@ public:
|
||||
void SetShaderTransformAndOpacity()
|
||||
{
|
||||
Layer* layer = GetLayer();
|
||||
const gfx3DMatrix& transform = layer->GetEffectiveTransform();
|
||||
const gfx::Matrix4x4& transform = layer->GetEffectiveTransform();
|
||||
device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4);
|
||||
|
||||
float opacity[4];
|
||||
|
@ -191,7 +191,9 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
|
||||
// A 2D transform with PreservesAxisAlignedRectangles() has all the attributes
|
||||
// above
|
||||
gfxMatrix transform;
|
||||
const gfx3DMatrix& transform3D = aLayer->GetEffectiveTransform();
|
||||
gfx3DMatrix transform3D;
|
||||
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), transform3D);
|
||||
|
||||
if (!transform3D.Is2D(&transform) || !transform.PreservesAxisAlignedRectangles()) {
|
||||
LOGD("Layer has a 3D transform or a non-square angle rotation");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user