本文整理汇总了C++中Matrix4x4::ScalePost方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4x4::ScalePost方法的具体用法?C++ Matrix4x4::ScalePost怎么用?C++ Matrix4x4::ScalePost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4::ScalePost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast
bool
LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
MaybeTransform* aTransform)
{
if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
return false;
}
Layer* layer = cast(aParent)->AsLayer();
if (!layer) {
return false;
}
// This method is specific to transforms applied by animation.
// This is because this method uses the information stored with an animation
// such as the origin of the reference frame corresponding to the layer, to
// recover the untranslated transform from the shadow transform. For
// transforms that are not set by animation we don't have this information
// available.
if (!layer->AsLayerComposite()->GetShadowTransformSetByAnimation()) {
*aTransform = mozilla::void_t();
return true;
}
// The following code recovers the untranslated transform
// from the shadow transform by undoing the translations in
// AsyncCompositionManager::SampleValue.
Matrix4x4 transform = layer->AsLayerComposite()->GetShadowTransform();
if (ContainerLayer* c = layer->AsContainerLayer()) {
// Undo the scale transform applied by AsyncCompositionManager::SampleValue
transform.ScalePost(1.0f/c->GetInheritedXScale(),
1.0f/c->GetInheritedYScale(),
1.0f);
}
float scale = 1;
gfxPoint3D scaledOrigin;
gfxPoint3D transformOrigin;
for (uint32_t i=0; i < layer->GetAnimations().Length(); i++) {
if (layer->GetAnimations()[i].data().type() == AnimationData::TTransformData) {
const TransformData& data = layer->GetAnimations()[i].data().get_TransformData();
scale = data.appUnitsPerDevPixel();
scaledOrigin =
gfxPoint3D(NS_round(NSAppUnitsToFloatPixels(data.origin().x, scale)),
NS_round(NSAppUnitsToFloatPixels(data.origin().y, scale)),
0.0f);
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
transform.Translate(-scaledOrigin.x, -scaledOrigin.y, -scaledOrigin.z);
// Undo the rebasing applied by
// nsDisplayTransform::GetResultingTransformMatrixInternal
gfxPoint3D basis = -scaledOrigin - transformOrigin;
transform.ChangeBasis(basis.x, basis.y, basis.z);
// 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());
transform._41 *= devPerCss;
transform._42 *= devPerCss;
transform._43 *= devPerCss;
*aTransform = transform;
return true;
}
示例2: fixedLayerMargins
void
AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
{
LayerComposite* layerComposite = aLayer->AsLayerComposite();
const FrameMetrics& metrics = aLayer->GetFrameMetrics();
// We must apply the resolution scale before a pan/zoom transform, so we call
// GetTransform here.
Matrix4x4 oldTransform = aLayer->GetTransform();
CSSToLayerScale geckoZoom = metrics.LayersPixelsPerCSSPixel();
LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.GetScrollOffset() * geckoZoom);
if (mIsFirstPaint) {
mContentRect = metrics.mScrollableRect;
SetFirstPaintViewport(scrollOffsetLayerPixels,
geckoZoom,
mContentRect);
mIsFirstPaint = false;
} else if (!metrics.mScrollableRect.IsEqualEdges(mContentRect)) {
mContentRect = metrics.mScrollableRect;
SetPageRect(mContentRect);
}
// We synchronise the viewport information with Java after sending the above
// notifications, so that Java can take these into account in its response.
// Calculate the absolute display port to send to Java
LayerIntRect displayPort = RoundedToInt(
(metrics.mCriticalDisplayPort.IsEmpty()
? metrics.mDisplayPort
: metrics.mCriticalDisplayPort
) * geckoZoom);
displayPort += scrollOffsetLayerPixels;
LayerMargin fixedLayerMargins(0, 0, 0, 0);
ScreenPoint offset(0, 0);
// Ideally we would initialize userZoom to AsyncPanZoomController::CalculateResolution(metrics)
// but this causes a reftest-ipc test to fail (see bug 883646 comment 27). The reason for this
// appears to be that metrics.mZoom is poorly initialized in some scenarios. In these scenarios,
// however, we can assume there is no async zooming in progress and so the following statement
// works fine.
CSSToScreenScale userZoom(metrics.mDevPixelsPerCSSPixel * metrics.mCumulativeResolution * LayerToScreenScale(1));
ScreenPoint userScroll = metrics.GetScrollOffset() * userZoom;
SyncViewportInfo(displayPort, geckoZoom, mLayersUpdated,
userScroll, userZoom, fixedLayerMargins,
offset);
mLayersUpdated = false;
// Apply the render offset
mLayerManager->GetCompositor()->SetScreenRenderOffset(offset);
// Handle transformations for asynchronous panning and zooming. We determine the
// zoom used by Gecko from the transformation set on the root layer, and we
// determine the scroll offset used by Gecko from the frame metrics of the
// primary scrollable layer. We compare this to the user zoom and scroll
// offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply.
ScreenPoint geckoScroll(0, 0);
if (metrics.IsScrollable()) {
geckoScroll = metrics.GetScrollOffset() * userZoom;
}
ParentLayerToScreenScale scale = userZoom
/ metrics.mDevPixelsPerCSSPixel
/ metrics.GetParentResolution();
ScreenPoint translation = userScroll - geckoScroll;
Matrix4x4 treeTransform = ViewTransform(scale, -translation);
// The transform already takes the resolution scale into account. Since we
// will apply the resolution scale again when computing the effective
// transform, we must apply the inverse resolution scale here.
Matrix4x4 computedTransform = oldTransform * treeTransform;
if (ContainerLayer* container = aLayer->AsContainerLayer()) {
computedTransform.Scale(1.0f/container->GetPreXScale(),
1.0f/container->GetPreYScale(),
1);
}
computedTransform.ScalePost(1.0f/aLayer->GetPostXScale(),
1.0f/aLayer->GetPostYScale(),
1);
layerComposite->SetShadowTransform(computedTransform);
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");
// Apply resolution scaling to the old transform - the layer tree as it is
// doesn't have the necessary transform to display correctly.
oldTransform.Scale(metrics.mResolution.scale, metrics.mResolution.scale, 1);
// Make sure that overscroll and under-zoom are represented in the old
// transform so that fixed position content moves and scales accordingly.
// These calculations will effectively scale and offset fixed position layers
// in screen space when the compensatory transform is performed in
// AlignFixedAndStickyLayers.
ScreenRect contentScreenRect = mContentRect * userZoom;
gfxPoint3D overscrollTranslation;
if (userScroll.x < contentScreenRect.x) {
overscrollTranslation.x = contentScreenRect.x - userScroll.x;
} else if (userScroll.x + metrics.mCompositionBounds.width > contentScreenRect.XMost()) {
overscrollTranslation.x = contentScreenRect.XMost() -
//.........这里部分代码省略.........