Bug 1181240 - Part 3: Replace gfx3DMatrix with Matrix4x4 in gfx,r=vlad

- Refactored code to use Matrix4x4 instead of gfx3DMatrix.
- There is not expected to be any functional effect.
This commit is contained in:
Kearwood (Kip) Gilbert 2015-07-10 17:06:35 -07:00
parent c06afa1c7f
commit 5b2ac66a0c
15 changed files with 44 additions and 93 deletions

View File

@ -337,7 +337,7 @@ public:
return mLayer->GetVisibleRegion();
}
nsIntRegion region = mLayer->GetVisibleRegion();
region.Transform(gfx::To3DMatrix(mLayer->GetTransform()));
region.Transform(mLayer->GetTransform());
return region;
}

View File

@ -10,7 +10,6 @@
#include <stdlib.h> // for getenv
#include "DirectedGraph.h" // for DirectedGraph
#include "Layers.h" // for Layer
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxLineSegment.h" // for gfxLineSegment
#include "gfxPoint.h" // for gfxPoint
#include "gfxQuad.h" // for gfxQuad
@ -41,11 +40,11 @@ enum LayerSortOrder {
*
* point = normal . (p0 - l0) / normal . l
*/
static gfxFloat RecoverZDepth(const gfx3DMatrix& aTransform, const gfxPoint& aPoint)
static gfxFloat RecoverZDepth(const Matrix4x4& aTransform, const gfxPoint& aPoint)
{
const Point3D l(0, 0, 1);
Point3D l0 = Point3D(aPoint.x, aPoint.y, 0);
Point3D p0 = aTransform.Transform3D(Point3D(0, 0, 0));
Point3D p0 = aTransform * Point3D(0, 0, 0);
Point3D normal = aTransform.GetNormalVector();
gfxFloat n = normal.DotProduct(p0 - l0);
@ -79,12 +78,12 @@ static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
gfxRect ourRect = aOne->GetEffectiveVisibleRegion().GetBounds();
gfxRect otherRect = aTwo->GetEffectiveVisibleRegion().GetBounds();
gfx3DMatrix ourTransform = To3DMatrix(aOne->GetTransform());
gfx3DMatrix otherTransform = To3DMatrix(aTwo->GetTransform());
Matrix4x4 ourTransform = aOne->GetTransform();
Matrix4x4 otherTransform = aTwo->GetTransform();
// Transform both rectangles and project into 2d space.
gfxQuad ourTransformedRect = ourTransform.TransformRect(ourRect);
gfxQuad otherTransformedRect = otherTransform.TransformRect(otherRect);
gfxQuad ourTransformedRect = ourRect.TransformToQuad(ourTransform);
gfxQuad otherTransformedRect = otherRect.TransformToQuad(otherTransform);
gfxRect ourBounds = ourTransformedRect.GetBounds();
gfxRect otherBounds = otherTransformedRect.GetBounds();

View File

@ -344,7 +344,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
container->SetChildrenChanged(true);
}
result.Transform(gfx::To3DMatrix(mLayer->GetLocalTransform()));
result.Transform(mLayer->GetLocalTransform());
return result;
}

View File

@ -214,7 +214,7 @@ struct EventRegions {
mVerticalPanRegion.MoveBy(aXTrans, aYTrans);
}
void Transform(const gfx3DMatrix& aTransform)
void Transform(const gfx::Matrix4x4& aTransform)
{
mHitRegion.Transform(aTransform);
mDispatchToContentHitRegion.Transform(aTransform);

View File

@ -188,7 +188,7 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest,
#ifdef MOZ_ENABLE_SKIA
static SkMatrix
Matrix3DToSkia(const gfx3DMatrix& aMatrix)
Matrix3DToSkia(const Matrix4x4& aMatrix)
{
SkMatrix transform;
transform.setAll(aMatrix._11,
@ -207,7 +207,7 @@ Matrix3DToSkia(const gfx3DMatrix& aMatrix)
static void
Transform(DataSourceSurface* aDest,
DataSourceSurface* aSource,
const gfx3DMatrix& aTransform,
const Matrix4x4& aTransform,
const Point& aDestOffset)
{
if (aTransform.IsSingular()) {
@ -233,8 +233,8 @@ Transform(DataSourceSurface* aDest,
src.setInfo(srcInfo, aSource->Stride());
src.setPixels((uint32_t*)aSource->GetData());
gfx3DMatrix transform = aTransform;
transform.TranslatePost(Point3D(-aDestOffset.x, -aDestOffset.y, 0));
Matrix4x4 transform = aTransform;
transform.PostTranslate(Point3D(-aDestOffset.x, -aDestOffset.y, 0));
destCanvas.setMatrix(Matrix3DToSkia(transform));
SkPaint paint;
@ -246,7 +246,7 @@ Transform(DataSourceSurface* aDest,
}
#else
static pixman_transform
Matrix3DToPixman(const gfx3DMatrix& aMatrix)
Matrix3DToPixman(const Matrix4x4& aMatrix)
{
pixman_f_transform transform;
@ -269,7 +269,7 @@ Matrix3DToPixman(const gfx3DMatrix& aMatrix)
static void
Transform(DataSourceSurface* aDest,
DataSourceSurface* aSource,
const gfx3DMatrix& aTransform,
const Matrix4x4& aTransform,
const Point& aDestOffset)
{
IntSize destSize = aDest->GetSize();
@ -343,7 +343,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
Matrix newTransform;
Rect transformBounds;
gfx3DMatrix new3DTransform;
Matrix4x4 new3DTransform;
IntPoint offset = mRenderTarget->GetOrigin();
if (aTransform.Is2D()) {
@ -358,8 +358,9 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
dest->SetTransform(Matrix::Translation(-aRect.x, -aRect.y));
// Get the bounds post-transform.
new3DTransform = To3DMatrix(aTransform);
gfxRect bounds = new3DTransform.TransformBounds(ThebesRect(aRect));
new3DTransform = aTransform;
gfxRect bounds = ThebesRect(aRect);
bounds.TransformBounds(new3DTransform);
bounds.IntersectRect(bounds, gfxRect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
transformBounds = ToRect(bounds);
@ -370,7 +371,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 = gfx3DMatrix::Translation(aRect.x, aRect.y, 0) * new3DTransform;
new3DTransform = Matrix4x4::Translation(aRect.x, aRect.y, 0) * new3DTransform;
}
newTransform.PostTranslate(-offset.x, -offset.y);

View File

@ -16,7 +16,6 @@
#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
@ -613,7 +612,7 @@ BasicLayerManager::SetRoot(Layer* aLayer)
#ifdef MOZ_ENABLE_SKIA
static SkMatrix
BasicLayerManager_Matrix3DToSkia(const gfx3DMatrix& aMatrix)
BasicLayerManager_Matrix3DToSkia(const Matrix4x4& aMatrix)
{
SkMatrix transform;
transform.setAll(aMatrix._11,
@ -632,7 +631,7 @@ BasicLayerManager_Matrix3DToSkia(const gfx3DMatrix& aMatrix)
static void
Transform(const gfxImageSurface* aDest,
RefPtr<DataSourceSurface> aSrc,
const gfx3DMatrix& aTransform,
const Matrix4x4& aTransform,
gfxPoint aDestOffset)
{
if (aTransform.IsSingular()) {
@ -658,8 +657,8 @@ Transform(const gfxImageSurface* aDest,
src.setInfo(srcInfo, aSrc->Stride());
src.setPixels((uint32_t*)aSrc->GetData());
gfx3DMatrix transform = aTransform;
transform.TranslatePost(Point3D(-aDestOffset.x, -aDestOffset.y, 0));
Matrix4x4 transform = aTransform;
transform.PostTranslate(Point3D(-aDestOffset.x, -aDestOffset.y, 0));
destCanvas.setMatrix(BasicLayerManager_Matrix3DToSkia(transform));
SkPaint paint;
@ -671,7 +670,7 @@ Transform(const gfxImageSurface* aDest,
}
#else
static pixman_transform
BasicLayerManager_Matrix3DToPixman(const gfx3DMatrix& aMatrix)
BasicLayerManager_Matrix3DToPixman(const Matrix4x4& aMatrix)
{
pixman_f_transform transform;
@ -694,7 +693,7 @@ BasicLayerManager_Matrix3DToPixman(const gfx3DMatrix& aMatrix)
static void
Transform(const gfxImageSurface* aDest,
RefPtr<DataSourceSurface> aSrc,
const gfx3DMatrix& aTransform,
const Matrix4x4& aTransform,
gfxPoint aDestOffset)
{
IntSize destSize = aDest->GetSize();
@ -743,7 +742,7 @@ Transform(const gfxImageSurface* aDest,
#endif
/**
* Transform a surface using a gfx3DMatrix and blit to the destination if
* Transform a surface using a Matrix4x4 and blit to the destination if
* it is efficient to do so.
*
* @param aSource Source surface.
@ -759,11 +758,12 @@ static already_AddRefed<gfxASurface>
Transform3D(RefPtr<SourceSurface> aSource,
gfxContext* aDest,
const gfxRect& aBounds,
const gfx3DMatrix& aTransform,
const Matrix4x4& aTransform,
gfxRect& aDestRect)
{
// Find the transformed rectangle of our layer.
gfxRect offsetRect = aTransform.TransformBounds(aBounds);
gfxRect offsetRect = aBounds;
offsetRect.TransformBounds(aTransform);
// Intersect the transformed layer with the destination rectangle.
// This is in device space since we have an identity transform set on aTarget.
@ -779,7 +779,7 @@ Transform3D(RefPtr<SourceSurface> aSource,
gfxPoint offset = aDestRect.TopLeft();
// Include a translation to the correct origin.
gfx3DMatrix translation = gfx3DMatrix::Translation(aBounds.x, aBounds.y, 0);
Matrix4x4 translation = Matrix4x4::Translation(aBounds.x, aBounds.y, 0);
// Transform the content and offset it such that the content begins at the origin.
Transform(destImage, aSource->GetDataSurface(), translation * aTransform, offset);
@ -961,8 +961,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
temp->Paint();
}
#endif
gfx3DMatrix effectiveTransform;
effectiveTransform = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
Matrix4x4 effectiveTransform = aLayer->GetEffectiveTransform();
nsRefPtr<gfxASurface> result =
Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
effectiveTransform, destRect);

View File

@ -5,7 +5,7 @@
#include "CanvasLayerComposite.h"
#include "composite/CompositableHost.h" // for CompositableHost
#include "gfx2DGlue.h" // for ToFilter, ToMatrix4x4
#include "gfx2DGlue.h" // for ToFilter
#include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4

View File

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

View File

@ -6,7 +6,7 @@
#include "ImageLayerComposite.h"
#include "CompositableHost.h" // for CompositableHost
#include "Layers.h" // for WriteSnapshotToDumpFile, etc
#include "gfx2DGlue.h" // for ToFilter, ToMatrix4x4
#include "gfx2DGlue.h" // for ToFilter
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc

View File

@ -22,7 +22,6 @@
#include "TiledContentHost.h"
#include "Units.h" // for ScreenIntRect
#include "UnitTransforms.h" // for ViewAs
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfxPrefs.h" // for gfxPrefs
#ifdef XP_MACOSX
#include "gfxPlatformMac.h"

View File

@ -7,7 +7,6 @@
#include "CompositableHost.h" // for TiledLayerProperties, etc
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for CSSRect, LayerPixel, etc
#include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfxUtils.h" // for gfxUtils, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/gfx/Matrix.h" // for Matrix4x4

View File

@ -19,7 +19,6 @@
#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 "gfxMatrix.h" // for gfxMatrix
#include "GraphicsFilter.h" // for GraphicsFilter

View File

@ -6,7 +6,6 @@
#include "nsRegion.h"
#include "nsPrintfCString.h"
#include "nsTArray.h"
#include "gfx3DMatrix.h"
#include "gfxUtils.h"
bool nsRegion::Contains(const nsRegion& aRgn) const
@ -607,14 +606,14 @@ nsRegion& nsRegion::ScaleInverseRoundOut (float aXScale, float aYScale)
}
static mozilla::gfx::IntRect
TransformRect(const mozilla::gfx::IntRect& aRect, const gfx3DMatrix& aTransform)
TransformRect(const mozilla::gfx::IntRect& aRect, const mozilla::gfx::Matrix4x4& aTransform)
{
if (aRect.IsEmpty()) {
return mozilla::gfx::IntRect();
}
gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height);
rect = aTransform.TransformBounds(rect);
rect.TransformBounds(aTransform);
rect.RoundOut();
mozilla::gfx::IntRect intRect;
@ -625,7 +624,7 @@ TransformRect(const mozilla::gfx::IntRect& aRect, const gfx3DMatrix& aTransform)
return intRect;
}
nsRegion& nsRegion::Transform (const gfx3DMatrix &aTransform)
nsRegion& nsRegion::Transform (const mozilla::gfx::Matrix4x4 &aTransform)
{
int n;
pixman_box32_t *boxes = pixman_region32_rectangles(&mImpl, &n);

View File

@ -21,7 +21,11 @@
#include "mozilla/Move.h" // for mozilla::Move
class nsIntRegion;
class gfx3DMatrix;
namespace mozilla {
namespace gfx {
class Matrix4x4;
} // namespace gfx
} // namespace mozilla
#include "pixman.h"
@ -299,7 +303,7 @@ public:
ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale);
nsRegion& Transform (const gfx3DMatrix &aTransform);
nsRegion& Transform (const mozilla::gfx::Matrix4x4 &aTransform);
nsIntRegion ScaleToOutsidePixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
nsIntRegion ScaleToInsidePixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
nsIntRegion ScaleToNearestPixels (float aXScale, float aYScale, nscoord aAppUnitsPerPixel) const;
@ -721,7 +725,7 @@ public:
return This();
}
Derived& Transform (const gfx3DMatrix &aTransform)
Derived& Transform (const mozilla::gfx::Matrix4x4 &aTransform)
{
mImpl.Transform(aTransform);
return This();

View File

@ -9,7 +9,6 @@
#include "gfxPlatform.h"
#include "gfxRect.h"
#include "gfxMatrix.h"
#include "gfx3DMatrix.h"
#include "gfxContext.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/Rect.h"
@ -310,52 +309,6 @@ inline gfxContext::GraphicsOperator ThebesOp(CompositionOp aOp)
}
}
inline Matrix4x4
ToMatrix4x4(const gfx3DMatrix& aIn)
{
Matrix4x4 m;
m._11 = aIn._11;
m._12 = aIn._12;
m._13 = aIn._13;
m._14 = aIn._14;
m._21 = aIn._21;
m._22 = aIn._22;
m._23 = aIn._23;
m._24 = aIn._24;
m._31 = aIn._31;
m._32 = aIn._32;
m._33 = aIn._33;
m._34 = aIn._34;
m._41 = aIn._41;
m._42 = aIn._42;
m._43 = aIn._43;
m._44 = aIn._44;
return m;
}
inline gfx3DMatrix
To3DMatrix(const Matrix4x4& aIn)
{
gfx3DMatrix m;
m._11 = aIn._11;
m._12 = aIn._12;
m._13 = aIn._13;
m._14 = aIn._14;
m._21 = aIn._21;
m._22 = aIn._22;
m._23 = aIn._23;
m._24 = aIn._24;
m._31 = aIn._31;
m._32 = aIn._32;
m._33 = aIn._33;
m._34 = aIn._34;
m._41 = aIn._41;
m._42 = aIn._42;
m._43 = aIn._43;
m._44 = aIn._44;
return m;
}
} // namespace gfx
} // namespace mozilla