mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 979658 part 3 - Make LayerTransactionParent::RecvGetTransform convert to CSS pixels; r=dzbarsky
LayerTransactionParent::RecvGetTransform takes care to reverse all the transformations applied by AsyncCompositionManager::SampleValue to the CSS values calculated so that it can return CSS values for testing. However, it fails to revert the conversion from CSS pixels to device pixels applied to the translation components of the transform by nsStyleTransformMatrix::ProcessTranslatePart as called by nsDisplayTransform::GetResultingTransformMatrix. This patch converts the resulting transform's translation components from device pixels back to CSS pixels. It also adds documentation for the other operations in LayerTransactionParent::RecvGetTransform.
This commit is contained in:
parent
41336d20b3
commit
e3b4d6f388
@ -32,6 +32,7 @@
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "nsCoord.h" // for NSAppUnitsToFloatPixels
|
||||
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
||||
#include "nsDeviceContext.h" // for AppUnitsPerCSSPixel
|
||||
#include "nsISupportsImpl.h" // for Layer::Release, etc
|
||||
#include "nsLayoutUtils.h" // for nsLayoutUtils
|
||||
#include "nsMathUtils.h" // for NS_round
|
||||
@ -578,12 +579,14 @@ LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
||||
// The following code recovers the untranslated transform
|
||||
// from the shadow transform by undoing the translations in
|
||||
// AsyncCompositionManager::SampleValue.
|
||||
|
||||
Layer* layer = cast(aParent)->AsLayer();
|
||||
if (!layer) {
|
||||
return false;
|
||||
}
|
||||
gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform(), *aTransform);
|
||||
if (ContainerLayer* c = layer->AsContainerLayer()) {
|
||||
// Undo the scale transform applied by AsyncCompositionManager::SampleValue
|
||||
aTransform->ScalePost(1.0f/c->GetInheritedXScale(),
|
||||
1.0f/c->GetInheritedYScale(),
|
||||
1.0f);
|
||||
@ -599,13 +602,32 @@ LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
||||
gfxPoint3D(NS_round(NSAppUnitsToFloatPixels(data.origin().x, scale)),
|
||||
NS_round(NSAppUnitsToFloatPixels(data.origin().y, scale)),
|
||||
0.0f);
|
||||
transformOrigin = data.transformOrigin();
|
||||
double cssPerDev =
|
||||
double(nsDeviceContext::AppUnitsPerCSSPixel()) / double(scale);
|
||||
transformOrigin = data.transformOrigin() * cssPerDev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Undo the translation to the origin of the reference frame applied by
|
||||
// AsyncCompositionManager::SampleValue
|
||||
aTransform->Translate(-scaledOrigin);
|
||||
*aTransform = nsLayoutUtils::ChangeMatrixBasis(-scaledOrigin - transformOrigin, *aTransform);
|
||||
|
||||
// Undo the rebasing applied by
|
||||
// nsDisplayTransform::GetResultingTransformMatrixInternal
|
||||
*aTransform =
|
||||
nsLayoutUtils::ChangeMatrixBasis(-scaledOrigin - transformOrigin,
|
||||
*aTransform);
|
||||
|
||||
// Convert to CSS pixels (this undoes the operations performed by
|
||||
// nsStyleTransformMatrix::ProcessTranslatePart which is called from
|
||||
// nsDisplayTransform::GetResultingTransformMatrix)
|
||||
double devPerCss =
|
||||
double(scale) / double(nsDeviceContext::AppUnitsPerCSSPixel());
|
||||
aTransform->_41 *= devPerCss;
|
||||
aTransform->_42 *= devPerCss;
|
||||
aTransform->_43 *= devPerCss;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user