mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1077961, part 2 - Stop doing lots of unnecessary and expensive Matrix4x4 multiplication. r=Bas
This commit is contained in:
parent
30c91163ad
commit
c5ae349afc
@ -715,10 +715,10 @@ const Matrix4x4
|
|||||||
Layer::GetTransform() const
|
Layer::GetTransform() const
|
||||||
{
|
{
|
||||||
Matrix4x4 transform = mTransform;
|
Matrix4x4 transform = mTransform;
|
||||||
|
transform.PostScale(mPostXScale, mPostYScale, 1.0f);
|
||||||
if (const ContainerLayer* c = AsContainerLayer()) {
|
if (const ContainerLayer* c = AsContainerLayer()) {
|
||||||
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
||||||
}
|
}
|
||||||
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,10 +730,11 @@ Layer::GetLocalTransform()
|
|||||||
transform = shadow->GetShadowTransform();
|
transform = shadow->GetShadowTransform();
|
||||||
else
|
else
|
||||||
transform = mTransform;
|
transform = mTransform;
|
||||||
|
|
||||||
|
transform.PostScale(mPostXScale, mPostYScale, 1.0f);
|
||||||
if (ContainerLayer* c = AsContainerLayer()) {
|
if (ContainerLayer* c = AsContainerLayer()) {
|
||||||
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
transform.Scale(c->GetPreXScale(), c->GetPreYScale(), 1.0f);
|
||||||
}
|
}
|
||||||
transform = transform * Matrix4x4().Scale(mPostXScale, mPostYScale, 1.0f);
|
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
@ -2498,7 +2498,7 @@ Matrix4x4 AsyncPanZoomController::GetOverscrollTransform() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Combine the transformations into a matrix.
|
// Combine the transformations into a matrix.
|
||||||
return Matrix4x4().Scale(scaleX, scaleY, 1)
|
return Matrix4x4::Scaling(scaleX, scaleY, 1)
|
||||||
.PostTranslate(translation.x, translation.y, 0);
|
.PostTranslate(translation.x, translation.y, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2623,9 +2623,9 @@ ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() const {
|
|||||||
|
|
||||||
Matrix4x4 AsyncPanZoomController::GetNontransientAsyncTransform() const {
|
Matrix4x4 AsyncPanZoomController::GetNontransientAsyncTransform() const {
|
||||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||||
return Matrix4x4().Scale(mLastContentPaintMetrics.mResolution.scale,
|
return Matrix4x4::Scaling(mLastContentPaintMetrics.mResolution.scale,
|
||||||
mLastContentPaintMetrics.mResolution.scale,
|
mLastContentPaintMetrics.mResolution.scale,
|
||||||
1.0f);
|
1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const {
|
Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const {
|
||||||
@ -2644,8 +2644,8 @@ Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const {
|
|||||||
|
|
||||||
float zoomChange = mLastContentPaintMetrics.GetZoom().scale / mLastDispatchedPaintMetrics.GetZoom().scale;
|
float zoomChange = mLastContentPaintMetrics.GetZoom().scale / mLastDispatchedPaintMetrics.GetZoom().scale;
|
||||||
|
|
||||||
return Matrix4x4().Translate(scrollChange.x, scrollChange.y, 0) *
|
return Matrix4x4::Translation(scrollChange.x, scrollChange.y, 0).
|
||||||
Matrix4x4().Scale(zoomChange, zoomChange, 1);
|
PostScale(zoomChange, zoomChange, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsyncPanZoomController::IsCurrentlyCheckerboarding() const {
|
bool AsyncPanZoomController::IsCurrentlyCheckerboarding() const {
|
||||||
|
@ -75,7 +75,7 @@ GetTransformToAncestorsParentLayer(Layer* aStart, const LayerMetricsWrapper& aAn
|
|||||||
// If the layer has a non-transient async transform then we need to apply it here
|
// If the layer has a non-transient async transform then we need to apply it here
|
||||||
// because it will get applied by the APZ in the compositor as well
|
// because it will get applied by the APZ in the compositor as well
|
||||||
const FrameMetrics& metrics = iter.Metrics();
|
const FrameMetrics& metrics = iter.Metrics();
|
||||||
transform = transform * gfx::Matrix4x4().Scale(metrics.mResolution.scale, metrics.mResolution.scale, 1.f);
|
transform.PostScale(metrics.mResolution.scale, metrics.mResolution.scale, 1.f);
|
||||||
}
|
}
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
@ -1366,7 +1366,7 @@ GetCompositorSideCompositionBounds(const LayerMetricsWrapper& aScrollAncestor,
|
|||||||
const Matrix4x4& aTransformToCompBounds,
|
const Matrix4x4& aTransformToCompBounds,
|
||||||
const ViewTransform& aAPZTransform)
|
const ViewTransform& aAPZTransform)
|
||||||
{
|
{
|
||||||
Matrix4x4 nonTransientAPZUntransform = Matrix4x4().Scale(
|
Matrix4x4 nonTransientAPZUntransform = Matrix4x4::Scaling(
|
||||||
aScrollAncestor.Metrics().mResolution.scale,
|
aScrollAncestor.Metrics().mResolution.scale,
|
||||||
aScrollAncestor.Metrics().mResolution.scale,
|
aScrollAncestor.Metrics().mResolution.scale,
|
||||||
1.f);
|
1.f);
|
||||||
|
@ -178,17 +178,16 @@ TranslateShadowLayer2D(Layer* aLayer,
|
|||||||
1.0f/c->GetPreYScale(),
|
1.0f/c->GetPreYScale(),
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
layerTransform3D = layerTransform3D *
|
layerTransform3D.PostScale(1.0f/aLayer->GetPostXScale(),
|
||||||
Matrix4x4().Scale(1.0f/aLayer->GetPostXScale(),
|
1.0f/aLayer->GetPostYScale(),
|
||||||
1.0f/aLayer->GetPostYScale(),
|
1);
|
||||||
1);
|
|
||||||
|
|
||||||
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
||||||
layerComposite->SetShadowTransform(layerTransform3D);
|
layerComposite->SetShadowTransform(layerTransform3D);
|
||||||
layerComposite->SetShadowTransformSetByAnimation(false);
|
layerComposite->SetShadowTransformSetByAnimation(false);
|
||||||
|
|
||||||
if (aAdjustClipRect) {
|
if (aAdjustClipRect) {
|
||||||
TransformClipRect(aLayer, Matrix4x4().Translate(aTranslation.x, aTranslation.y, 0));
|
TransformClipRect(aLayer, Matrix4x4::Translation(aTranslation.x, aTranslation.y, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,9 +499,7 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
|
|||||||
{
|
{
|
||||||
Matrix4x4 matrix = interpolatedValue.get_ArrayOfTransformFunction()[0].get_TransformMatrix().value();
|
Matrix4x4 matrix = interpolatedValue.get_ArrayOfTransformFunction()[0].get_TransformMatrix().value();
|
||||||
if (ContainerLayer* c = aLayer->AsContainerLayer()) {
|
if (ContainerLayer* c = aLayer->AsContainerLayer()) {
|
||||||
matrix = matrix * Matrix4x4().Scale(c->GetInheritedXScale(),
|
matrix.PostScale(c->GetInheritedXScale(), c->GetInheritedYScale(), 1);
|
||||||
c->GetInheritedYScale(),
|
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
layerComposite->SetShadowTransform(matrix);
|
layerComposite->SetShadowTransform(matrix);
|
||||||
layerComposite->SetShadowTransformSetByAnimation(true);
|
layerComposite->SetShadowTransformSetByAnimation(true);
|
||||||
@ -627,9 +624,9 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer)
|
|||||||
1.0f/container->GetPreYScale(),
|
1.0f/container->GetPreYScale(),
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
transform = transform * Matrix4x4().Scale(1.0f/aLayer->GetPostXScale(),
|
transform.PostScale(1.0f/aLayer->GetPostXScale(),
|
||||||
1.0f/aLayer->GetPostYScale(),
|
1.0f/aLayer->GetPostYScale(),
|
||||||
1);
|
1);
|
||||||
layerComposite->SetShadowTransform(transform);
|
layerComposite->SetShadowTransform(transform);
|
||||||
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
|
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
|
||||||
"overwriting animated transform!");
|
"overwriting animated transform!");
|
||||||
@ -715,13 +712,13 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
|
|||||||
Matrix4x4 scrollbarTransform;
|
Matrix4x4 scrollbarTransform;
|
||||||
if (aScrollbar->GetScrollbarDirection() == Layer::VERTICAL) {
|
if (aScrollbar->GetScrollbarDirection() == Layer::VERTICAL) {
|
||||||
float scale = metrics.CalculateCompositedSizeInCssPixels().height / metrics.mScrollableRect.height;
|
float scale = metrics.CalculateCompositedSizeInCssPixels().height / metrics.mScrollableRect.height;
|
||||||
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f, 1.f / transientTransform._22, 1.f);
|
scrollbarTransform.PostScale(1.f, 1.f / transientTransform._22, 1.f);
|
||||||
scrollbarTransform = scrollbarTransform * Matrix4x4().Translate(0, -transientTransform._42 * scale, 0);
|
scrollbarTransform.PostTranslate(0, -transientTransform._42 * scale, 0);
|
||||||
}
|
}
|
||||||
if (aScrollbar->GetScrollbarDirection() == Layer::HORIZONTAL) {
|
if (aScrollbar->GetScrollbarDirection() == Layer::HORIZONTAL) {
|
||||||
float scale = metrics.CalculateCompositedSizeInCssPixels().width / metrics.mScrollableRect.width;
|
float scale = metrics.CalculateCompositedSizeInCssPixels().width / metrics.mScrollableRect.width;
|
||||||
scrollbarTransform = scrollbarTransform * Matrix4x4().Scale(1.f / transientTransform._11, 1.f, 1.f);
|
scrollbarTransform.PostScale(1.f / transientTransform._11, 1.f, 1.f);
|
||||||
scrollbarTransform = scrollbarTransform * Matrix4x4().Translate(-transientTransform._41 * scale, 0, 0);
|
scrollbarTransform.PostTranslate(-transientTransform._41 * scale, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 transform = scrollbarTransform * aScrollbar->GetTransform();
|
Matrix4x4 transform = scrollbarTransform * aScrollbar->GetTransform();
|
||||||
@ -760,9 +757,9 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
|
|||||||
1.0f/container->GetPreYScale(),
|
1.0f/container->GetPreYScale(),
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
transform = transform * Matrix4x4().Scale(1.0f/aScrollbar->GetPostXScale(),
|
transform.PostScale(1.0f/aScrollbar->GetPostXScale(),
|
||||||
1.0f/aScrollbar->GetPostYScale(),
|
1.0f/aScrollbar->GetPostYScale(),
|
||||||
1);
|
1);
|
||||||
aScrollbar->AsLayerComposite()->SetShadowTransform(transform);
|
aScrollbar->AsLayerComposite()->SetShadowTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ struct ViewTransform {
|
|||||||
operator gfx::Matrix4x4() const
|
operator gfx::Matrix4x4() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
gfx::Matrix4x4().Scale(mScale.scale, mScale.scale, 1)
|
gfx::Matrix4x4::Scaling(mScale.scale, mScale.scale, 1)
|
||||||
.PostTranslate(mTranslation.x, mTranslation.y, 0);
|
.PostTranslate(mTranslation.x, mTranslation.y, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,7 +1701,7 @@ protected:
|
|||||||
Matrix4x4 transforms[] = {
|
Matrix4x4 transforms[] = {
|
||||||
Matrix4x4(),
|
Matrix4x4(),
|
||||||
Matrix4x4(),
|
Matrix4x4(),
|
||||||
Matrix4x4().Scale(2, 1, 1),
|
Matrix4x4::Scaling(2, 1, 1),
|
||||||
Matrix4x4(),
|
Matrix4x4(),
|
||||||
};
|
};
|
||||||
root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers);
|
root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, lm, layers);
|
||||||
|
@ -3735,7 +3735,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
|
|||||||
nsIntPoint offset;
|
nsIntPoint offset;
|
||||||
|
|
||||||
Matrix4x4 transform =
|
Matrix4x4 transform =
|
||||||
Matrix4x4().Scale(aIncomingScale.mXScale, aIncomingScale.mYScale, 1.0);
|
Matrix4x4::Scaling(aIncomingScale.mXScale, aIncomingScale.mYScale, 1.0);
|
||||||
if (aTransform) {
|
if (aTransform) {
|
||||||
// aTransform is applied first, then the scale is applied to the result
|
// aTransform is applied first, then the scale is applied to the result
|
||||||
transform = (*aTransform)*transform;
|
transform = (*aTransform)*transform;
|
||||||
@ -3764,7 +3764,9 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
|
|||||||
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.x, appUnitsPerDevPixel)*aIncomingScale.mXScale),
|
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.x, appUnitsPerDevPixel)*aIncomingScale.mXScale),
|
||||||
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.y, appUnitsPerDevPixel)*aIncomingScale.mYScale));
|
NS_lround(NSAppUnitsToDoublePixels(appUnitOffset.y, appUnitsPerDevPixel)*aIncomingScale.mYScale));
|
||||||
}
|
}
|
||||||
transform = transform * Matrix4x4().Translate(offset.x + aIncomingScale.mOffset.x, offset.y + aIncomingScale.mOffset.y, 0);
|
transform.PostTranslate(offset.x + aIncomingScale.mOffset.x,
|
||||||
|
offset.y + aIncomingScale.mOffset.y,
|
||||||
|
0);
|
||||||
|
|
||||||
if (transform.IsSingular()) {
|
if (transform.IsSingular()) {
|
||||||
return false;
|
return false;
|
||||||
@ -4137,7 +4139,7 @@ static gfxSize
|
|||||||
PredictScaleForContent(nsIFrame* aFrame, nsIFrame* aAncestorWithScale,
|
PredictScaleForContent(nsIFrame* aFrame, nsIFrame* aAncestorWithScale,
|
||||||
const gfxSize& aScale)
|
const gfxSize& aScale)
|
||||||
{
|
{
|
||||||
Matrix4x4 transform = Matrix4x4().Scale(aScale.width, aScale.height, 1.0);
|
Matrix4x4 transform = Matrix4x4::Scaling(aScale.width, aScale.height, 1.0);
|
||||||
if (aFrame != aAncestorWithScale) {
|
if (aFrame != aAncestorWithScale) {
|
||||||
// aTransform is applied first, then the scale is applied to the result
|
// aTransform is applied first, then the scale is applied to the result
|
||||||
transform = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestorWithScale)*transform;
|
transform = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestorWithScale)*transform;
|
||||||
|
@ -4785,10 +4785,9 @@ nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor,
|
|||||||
// XXXjwatt: seems like this will double count offsets in the face of preserve-3d:
|
// XXXjwatt: seems like this will double count offsets in the face of preserve-3d:
|
||||||
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
||||||
/* Combine the raw transform with a translation to our parent. */
|
/* Combine the raw transform with a translation to our parent. */
|
||||||
result = result * Matrix4x4().Translate
|
result.PostTranslate(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
||||||
(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
||||||
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
0.0f);
|
||||||
0.0f);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4864,10 +4863,9 @@ nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor,
|
|||||||
*/
|
*/
|
||||||
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
||||||
int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
|
int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
|
||||||
return Matrix4x4().Translate
|
return Matrix4x4::Translation(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
||||||
(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
||||||
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
0.0f);
|
||||||
0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = true)
|
static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = true)
|
||||||
|
@ -463,7 +463,7 @@ static void PaintHeaderFooter(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
|||||||
static gfx::Matrix4x4 ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
|
static gfx::Matrix4x4 ComputePageTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
|
||||||
{
|
{
|
||||||
float scale = aFrame->PresContext()->GetPageScale();
|
float scale = aFrame->PresContext()->GetPageScale();
|
||||||
return gfx::Matrix4x4().Scale(scale, scale, 1);
|
return gfx::Matrix4x4::Scaling(scale, scale, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -824,7 +824,7 @@ inline gfx::Matrix4x4
|
|||||||
ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
|
ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel)
|
||||||
{
|
{
|
||||||
float scale = aFrame->PresContext()->GetPrintPreviewScale();
|
float scale = aFrame->PresContext()->GetPrintPreviewScale();
|
||||||
return gfx::Matrix4x4().Scale(scale, scale, 1);
|
return gfx::Matrix4x4::Scaling(scale, scale, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2515,8 +2515,8 @@ nsChildView::MaybeDrawRoundedCorners(GLManager* aManager, const nsIntRect& aRect
|
|||||||
aManager->gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA,
|
aManager->gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA,
|
||||||
LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA);
|
LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA);
|
||||||
|
|
||||||
Matrix4x4 flipX = Matrix4x4().Scale(-1, 1, 1);
|
Matrix4x4 flipX = Matrix4x4::Scaling(-1, 1, 1);
|
||||||
Matrix4x4 flipY = Matrix4x4().Scale(1, -1, 1);
|
Matrix4x4 flipY = Matrix4x4::Scaling(1, -1, 1);
|
||||||
|
|
||||||
if (mIsCoveringTitlebar && !mIsFullscreen) {
|
if (mIsCoveringTitlebar && !mIsFullscreen) {
|
||||||
// Mask the top corners.
|
// Mask the top corners.
|
||||||
@ -2928,7 +2928,7 @@ RectTextureImage::Draw(GLManager* aManager,
|
|||||||
|
|
||||||
program->Activate();
|
program->Activate();
|
||||||
program->SetProjectionMatrix(aManager->GetProjMatrix());
|
program->SetProjectionMatrix(aManager->GetProjMatrix());
|
||||||
program->SetLayerTransform(aTransform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0));
|
program->SetLayerTransform(Matrix4x4(aTransform).PostTranslate(aLocation.x, aLocation.y, 0));
|
||||||
program->SetTextureTransform(gfx::Matrix4x4());
|
program->SetTextureTransform(gfx::Matrix4x4());
|
||||||
program->SetRenderOffset(nsIntPoint(0, 0));
|
program->SetRenderOffset(nsIntPoint(0, 0));
|
||||||
program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height);
|
program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height);
|
||||||
|
Loading…
Reference in New Issue
Block a user