2013-04-28 06:46:30 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=2 et tw=80 : */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/layers/AsyncCompositionManager.h"
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
# include <android/log.h>
|
|
|
|
# include "AndroidBridge.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "CompositorParent.h"
|
|
|
|
#include "LayerManagerComposite.h"
|
|
|
|
|
|
|
|
#include "nsStyleAnimation.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "AnimationCommon.h"
|
|
|
|
#include "nsAnimationManager.h"
|
|
|
|
#include "mozilla/layers/AsyncPanZoomController.h"
|
|
|
|
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
enum Op { Resolve, Detach };
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsSameDimension(ScreenOrientation o1, ScreenOrientation o2)
|
|
|
|
{
|
|
|
|
bool isO1portrait = (o1 == eScreenOrientation_PortraitPrimary || o1 == eScreenOrientation_PortraitSecondary);
|
|
|
|
bool isO2portrait = (o2 == eScreenOrientation_PortraitPrimary || o2 == eScreenOrientation_PortraitSecondary);
|
|
|
|
return !(isO1portrait ^ isO2portrait);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ContentMightReflowOnOrientationChange(const nsIntRect& rect)
|
|
|
|
{
|
|
|
|
return rect.width != rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<Op OP>
|
|
|
|
static void
|
|
|
|
WalkTheTree(Layer* aLayer,
|
|
|
|
bool& aReady,
|
|
|
|
const TargetConfig& aTargetConfig)
|
|
|
|
{
|
|
|
|
if (RefLayer* ref = aLayer->AsRefLayer()) {
|
|
|
|
if (const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(ref->GetReferentId())) {
|
|
|
|
if (Layer* referent = state->mRoot) {
|
2013-07-02 16:01:46 +00:00
|
|
|
ContainerLayer *referentAsContainer = referent->AsContainerLayer();
|
2013-04-28 06:46:30 +00:00
|
|
|
if (!ref->GetVisibleRegion().IsEmpty()) {
|
|
|
|
ScreenOrientation chromeOrientation = aTargetConfig.orientation();
|
|
|
|
ScreenOrientation contentOrientation = state->mTargetConfig.orientation();
|
|
|
|
if (!IsSameDimension(chromeOrientation, contentOrientation) &&
|
|
|
|
ContentMightReflowOnOrientationChange(aTargetConfig.clientBounds())) {
|
|
|
|
aReady = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OP == Resolve) {
|
|
|
|
ref->ConnectReferentLayer(referent);
|
2013-07-02 16:01:46 +00:00
|
|
|
if (referentAsContainer) {
|
|
|
|
if (AsyncPanZoomController* apzc = state->mController) {
|
|
|
|
referentAsContainer->SetAsyncPanZoomController(apzc);
|
|
|
|
}
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ref->DetachReferentLayer(referent);
|
2013-07-02 16:01:46 +00:00
|
|
|
if (referentAsContainer) {
|
|
|
|
referentAsContainer->SetAsyncPanZoomController(nullptr);
|
|
|
|
}
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
2013-06-29 18:53:49 +00:00
|
|
|
WalkTheTree<OP>(child, aReady, aTargetConfig);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AsyncCompositionManager::ResolveRefLayers()
|
|
|
|
{
|
|
|
|
WalkTheTree<Resolve>(mLayerManager->GetRoot(),
|
|
|
|
mReadyForCompose,
|
|
|
|
mTargetConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AsyncCompositionManager::DetachRefLayers()
|
|
|
|
{
|
|
|
|
WalkTheTree<Detach>(mLayerManager->GetRoot(),
|
|
|
|
mReadyForCompose,
|
|
|
|
mTargetConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AsyncCompositionManager::ComputeRotation()
|
|
|
|
{
|
|
|
|
if (!mTargetConfig.naturalBounds().IsEmpty()) {
|
|
|
|
mLayerManager->SetWorldTransform(
|
|
|
|
ComputeTransformForRotation(mTargetConfig.naturalBounds(),
|
|
|
|
mTargetConfig.rotation()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-24 01:34:33 +00:00
|
|
|
static bool
|
|
|
|
GetBaseTransform2D(Layer* aLayer, gfxMatrix* aTransform)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
2013-06-24 01:34:33 +00:00
|
|
|
// Start with the animated transform if there is one
|
|
|
|
return (aLayer->AsLayerComposite()->GetShadowTransformSetByAnimation() ?
|
|
|
|
aLayer->GetLocalTransform() : aLayer->GetTransform()).Is2D(aTransform);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
|
2013-07-22 08:50:05 +00:00
|
|
|
static void
|
|
|
|
TranslateShadowLayer2D(Layer* aLayer,
|
|
|
|
const gfxPoint& aTranslation)
|
|
|
|
{
|
|
|
|
gfxMatrix layerTransform;
|
|
|
|
if (!GetBaseTransform2D(aLayer, &layerTransform)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply the 2D translation to the layer transform.
|
|
|
|
layerTransform.x0 += aTranslation.x;
|
|
|
|
layerTransform.y0 += aTranslation.y;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
gfx3DMatrix layerTransform3D = gfx3DMatrix::From2D(layerTransform);
|
|
|
|
if (ContainerLayer* c = aLayer->AsContainerLayer()) {
|
|
|
|
layerTransform3D.Scale(1.0f/c->GetPreXScale(),
|
|
|
|
1.0f/c->GetPreYScale(),
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
layerTransform3D.ScalePost(1.0f/aLayer->GetPostXScale(),
|
|
|
|
1.0f/aLayer->GetPostYScale(),
|
|
|
|
1);
|
|
|
|
|
|
|
|
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
|
|
|
layerComposite->SetShadowTransform(layerTransform3D);
|
|
|
|
layerComposite->SetShadowTransformSetByAnimation(false);
|
|
|
|
|
|
|
|
const nsIntRect* clipRect = aLayer->GetClipRect();
|
|
|
|
if (clipRect) {
|
|
|
|
nsIntRect transformedClipRect(*clipRect);
|
|
|
|
transformedClipRect.MoveBy(aTranslation.x, aTranslation.y);
|
|
|
|
layerComposite->SetShadowClipRect(&transformedClipRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
AccumulateLayerTransforms2D(Layer* aLayer,
|
|
|
|
Layer* aAncestor,
|
|
|
|
gfxMatrix& aMatrix)
|
|
|
|
{
|
|
|
|
// Accumulate the transforms between this layer and the subtree root layer.
|
|
|
|
for (Layer* l = aLayer; l && l != aAncestor; l = l->GetParent()) {
|
|
|
|
gfxMatrix l2D;
|
|
|
|
if (!GetBaseTransform2D(l, &l2D)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aMatrix.Multiply(l2D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-22 08:50:09 +00:00
|
|
|
static LayerPoint
|
2013-07-22 08:50:05 +00:00
|
|
|
GetLayerFixedMarginsOffset(Layer* aLayer,
|
2013-07-22 08:50:13 +00:00
|
|
|
const LayerMargin& aFixedLayerMargins)
|
2013-07-22 08:50:05 +00:00
|
|
|
{
|
|
|
|
// Work out the necessary translation, in root scrollable layer space.
|
|
|
|
// Because fixed layer margins are stored relative to the root scrollable
|
|
|
|
// layer, we can just take the difference between these values.
|
2013-07-22 08:50:09 +00:00
|
|
|
LayerPoint translation;
|
|
|
|
const LayerPoint& anchor = aLayer->GetFixedPositionAnchor();
|
2013-07-22 08:50:13 +00:00
|
|
|
const LayerMargin& fixedMargins = aLayer->GetFixedPositionMargins();
|
2013-07-22 08:50:05 +00:00
|
|
|
|
|
|
|
if (fixedMargins.left >= 0) {
|
|
|
|
if (anchor.x > 0) {
|
|
|
|
translation.x -= aFixedLayerMargins.right - fixedMargins.right;
|
|
|
|
} else {
|
|
|
|
translation.x += aFixedLayerMargins.left - fixedMargins.left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fixedMargins.top >= 0) {
|
|
|
|
if (anchor.y > 0) {
|
|
|
|
translation.y -= aFixedLayerMargins.bottom - fixedMargins.bottom;
|
|
|
|
} else {
|
|
|
|
translation.y += aFixedLayerMargins.top - fixedMargins.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return translation;
|
|
|
|
}
|
|
|
|
|
2013-04-28 06:46:30 +00:00
|
|
|
void
|
2013-06-24 01:34:33 +00:00
|
|
|
AsyncCompositionManager::AlignFixedLayersForAnchorPoint(Layer* aLayer,
|
|
|
|
Layer* aTransformedSubtreeRoot,
|
2013-07-22 08:50:05 +00:00
|
|
|
const gfx3DMatrix& aPreviousTransformForRoot,
|
2013-07-22 08:50:13 +00:00
|
|
|
const LayerMargin& aFixedLayerMargins)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
2013-06-24 01:34:33 +00:00
|
|
|
if (aLayer != aTransformedSubtreeRoot && aLayer->GetIsFixedPosition() &&
|
2013-04-28 06:46:30 +00:00
|
|
|
!aLayer->GetParent()->GetIsFixedPosition()) {
|
2013-06-24 01:34:33 +00:00
|
|
|
// Insert a translation so that the position of the anchor point is the same
|
|
|
|
// before and after the change to the transform of aTransformedSubtreeRoot.
|
|
|
|
// This currently only works for fixed layers with 2D transforms.
|
|
|
|
|
|
|
|
// Accumulate the transforms between this layer and the subtree root layer.
|
|
|
|
gfxMatrix ancestorTransform;
|
2013-07-22 08:50:05 +00:00
|
|
|
if (!AccumulateLayerTransforms2D(aLayer->GetParent(), aTransformedSubtreeRoot,
|
|
|
|
ancestorTransform)) {
|
|
|
|
return;
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 01:34:33 +00:00
|
|
|
gfxMatrix oldRootTransform;
|
|
|
|
gfxMatrix newRootTransform;
|
|
|
|
if (!aPreviousTransformForRoot.Is2D(&oldRootTransform) ||
|
|
|
|
!aTransformedSubtreeRoot->GetLocalTransform().Is2D(&newRootTransform)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the cumulative transforms between the subtree root with the
|
|
|
|
// old transform and the current transform.
|
|
|
|
gfxMatrix oldCumulativeTransform = ancestorTransform * oldRootTransform;
|
|
|
|
gfxMatrix newCumulativeTransform = ancestorTransform * newRootTransform;
|
|
|
|
if (newCumulativeTransform.IsSingular()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gfxMatrix newCumulativeTransformInverse = newCumulativeTransform;
|
|
|
|
newCumulativeTransformInverse.Invert();
|
|
|
|
|
2013-07-22 08:50:09 +00:00
|
|
|
// Now work out the translation necessary to make sure the layer doesn't
|
|
|
|
// move given the new sub-tree root transform.
|
|
|
|
gfxMatrix layerTransform;
|
|
|
|
if (!GetBaseTransform2D(aLayer, &layerTransform)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-22 08:50:05 +00:00
|
|
|
// Calculate any offset necessary, in previous transform sub-tree root
|
|
|
|
// space. This is used to make sure fixed position content respects
|
|
|
|
// content document fixed position margins.
|
2013-07-22 08:50:09 +00:00
|
|
|
LayerPoint offsetInOldSubtreeLayerSpace = GetLayerFixedMarginsOffset(aLayer, aFixedLayerMargins);
|
|
|
|
|
|
|
|
// Add the above offset to the anchor point so we can offset the layer by
|
|
|
|
// and amount that's specified in old subtree layer space.
|
|
|
|
const LayerPoint& anchorInOldSubtreeLayerSpace = aLayer->GetFixedPositionAnchor();
|
|
|
|
LayerPoint offsetAnchorInOldSubtreeLayerSpace = anchorInOldSubtreeLayerSpace + offsetInOldSubtreeLayerSpace;
|
|
|
|
|
|
|
|
// Add the local layer transform to the two points to make the equation
|
|
|
|
// below this section more convenient.
|
|
|
|
gfxPoint anchor(anchorInOldSubtreeLayerSpace.x, anchorInOldSubtreeLayerSpace.y);
|
|
|
|
gfxPoint offsetAnchor(offsetAnchorInOldSubtreeLayerSpace.x, offsetAnchorInOldSubtreeLayerSpace.y);
|
|
|
|
gfxPoint locallyTransformedAnchor = layerTransform.Transform(anchor);
|
|
|
|
gfxPoint locallyTransformedOffsetAnchor = layerTransform.Transform(offsetAnchor);
|
2013-07-22 08:50:05 +00:00
|
|
|
|
2013-06-24 01:34:33 +00:00
|
|
|
// Transforming the locallyTransformedAnchor by oldCumulativeTransform
|
|
|
|
// returns the layer's anchor point relative to the parent of
|
|
|
|
// aTransformedSubtreeRoot, before the new transform was applied.
|
|
|
|
// Then, applying newCumulativeTransformInverse maps that point relative
|
|
|
|
// to the layer's parent, which is the same coordinate space as
|
|
|
|
// locallyTransformedAnchor again, allowing us to subtract them and find
|
|
|
|
// out the offset necessary to make sure the layer stays stationary.
|
|
|
|
gfxPoint oldAnchorPositionInNewSpace =
|
|
|
|
newCumulativeTransformInverse.Transform(
|
2013-07-22 08:50:05 +00:00
|
|
|
oldCumulativeTransform.Transform(locallyTransformedOffsetAnchor));
|
2013-06-24 01:34:33 +00:00
|
|
|
gfxPoint translation = oldAnchorPositionInNewSpace - locallyTransformedAnchor;
|
|
|
|
|
|
|
|
// Finally, apply the 2D translation to the layer transform.
|
2013-07-22 08:50:05 +00:00
|
|
|
TranslateShadowLayer2D(aLayer, translation);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
// The transform has now been applied, so there's no need to iterate over
|
|
|
|
// child layers.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
2013-07-22 08:50:05 +00:00
|
|
|
AlignFixedLayersForAnchorPoint(child, aTransformedSubtreeRoot,
|
|
|
|
aPreviousTransformForRoot, aFixedLayerMargins);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SampleValue(float aPortion, Animation& aAnimation, nsStyleAnimation::Value& aStart,
|
|
|
|
nsStyleAnimation::Value& aEnd, Animatable* aValue)
|
|
|
|
{
|
|
|
|
nsStyleAnimation::Value interpolatedValue;
|
|
|
|
NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() ||
|
|
|
|
aStart.GetUnit() == nsStyleAnimation::eUnit_None ||
|
|
|
|
aEnd.GetUnit() == nsStyleAnimation::eUnit_None, "Must have same unit");
|
|
|
|
nsStyleAnimation::Interpolate(aAnimation.property(), aStart, aEnd,
|
|
|
|
aPortion, interpolatedValue);
|
|
|
|
if (aAnimation.property() == eCSSProperty_opacity) {
|
|
|
|
*aValue = interpolatedValue.GetFloatValue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSValueList* interpolatedList = interpolatedValue.GetCSSValueListValue();
|
|
|
|
|
|
|
|
TransformData& data = aAnimation.data().get_TransformData();
|
|
|
|
nsPoint origin = data.origin();
|
|
|
|
// we expect all our transform data to arrive in css pixels, so here we must
|
|
|
|
// adjust to dev pixels.
|
|
|
|
double cssPerDev = double(nsDeviceContext::AppUnitsPerCSSPixel())
|
|
|
|
/ double(data.appUnitsPerDevPixel());
|
|
|
|
gfxPoint3D mozOrigin = data.mozOrigin();
|
|
|
|
mozOrigin.x = mozOrigin.x * cssPerDev;
|
|
|
|
mozOrigin.y = mozOrigin.y * cssPerDev;
|
|
|
|
gfxPoint3D perspectiveOrigin = data.perspectiveOrigin();
|
|
|
|
perspectiveOrigin.x = perspectiveOrigin.x * cssPerDev;
|
|
|
|
perspectiveOrigin.y = perspectiveOrigin.y * cssPerDev;
|
|
|
|
nsDisplayTransform::FrameTransformProperties props(interpolatedList,
|
|
|
|
mozOrigin,
|
|
|
|
perspectiveOrigin,
|
|
|
|
data.perspective());
|
|
|
|
gfx3DMatrix transform =
|
|
|
|
nsDisplayTransform::GetResultingTransformMatrix(props, origin,
|
|
|
|
data.appUnitsPerDevPixel(),
|
|
|
|
&data.bounds());
|
|
|
|
gfxPoint3D scaledOrigin =
|
|
|
|
gfxPoint3D(NS_round(NSAppUnitsToFloatPixels(origin.x, data.appUnitsPerDevPixel())),
|
|
|
|
NS_round(NSAppUnitsToFloatPixels(origin.y, data.appUnitsPerDevPixel())),
|
|
|
|
0.0f);
|
|
|
|
|
|
|
|
transform.Translate(scaledOrigin);
|
|
|
|
|
|
|
|
InfallibleTArray<TransformFunction> functions;
|
|
|
|
functions.AppendElement(TransformMatrix(transform));
|
|
|
|
*aValue = functions;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
SampleAnimations(Layer* aLayer, TimeStamp aPoint)
|
|
|
|
{
|
|
|
|
AnimationArray& animations = aLayer->GetAnimations();
|
|
|
|
InfallibleTArray<AnimData>& animationData = aLayer->GetAnimationData();
|
|
|
|
|
|
|
|
bool activeAnimations = false;
|
|
|
|
|
|
|
|
for (uint32_t i = animations.Length(); i-- !=0; ) {
|
|
|
|
Animation& animation = animations[i];
|
|
|
|
AnimData& animData = animationData[i];
|
|
|
|
|
|
|
|
double numIterations = animation.numIterations() != -1 ?
|
|
|
|
animation.numIterations() : NS_IEEEPositiveInfinity();
|
|
|
|
double positionInIteration =
|
|
|
|
ElementAnimations::GetPositionInIteration(aPoint - animation.startTime(),
|
|
|
|
animation.duration(),
|
|
|
|
numIterations,
|
|
|
|
animation.direction());
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(0.0 <= positionInIteration &&
|
|
|
|
positionInIteration <= 1.0,
|
|
|
|
"position should be in [0-1]");
|
|
|
|
|
|
|
|
int segmentIndex = 0;
|
|
|
|
AnimationSegment* segment = animation.segments().Elements();
|
|
|
|
while (segment->endPortion() < positionInIteration) {
|
|
|
|
++segment;
|
|
|
|
++segmentIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
double positionInSegment = (positionInIteration - segment->startPortion()) /
|
|
|
|
(segment->endPortion() - segment->startPortion());
|
|
|
|
|
|
|
|
double portion = animData.mFunctions[segmentIndex]->GetValue(positionInSegment);
|
|
|
|
|
|
|
|
activeAnimations = true;
|
|
|
|
|
|
|
|
// interpolate the property
|
|
|
|
Animatable interpolatedValue;
|
|
|
|
SampleValue(portion, animation, animData.mStartValues[segmentIndex],
|
|
|
|
animData.mEndValues[segmentIndex], &interpolatedValue);
|
|
|
|
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
|
|
|
switch (animation.property()) {
|
|
|
|
case eCSSProperty_opacity:
|
|
|
|
{
|
|
|
|
layerComposite->SetShadowOpacity(interpolatedValue.get_float());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eCSSProperty_transform:
|
|
|
|
{
|
|
|
|
gfx3DMatrix matrix = interpolatedValue.get_ArrayOfTransformFunction()[0].get_TransformMatrix().value();
|
|
|
|
if (ContainerLayer* c = aLayer->AsContainerLayer()) {
|
|
|
|
matrix.ScalePost(c->GetInheritedXScale(),
|
|
|
|
c->GetInheritedYScale(),
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
layerComposite->SetShadowTransform(matrix);
|
2013-05-16 12:34:24 +00:00
|
|
|
layerComposite->SetShadowTransformSetByAnimation(true);
|
2013-04-28 06:46:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_WARNING("Unhandled animated property");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Layer* child = aLayer->GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
activeAnimations |= SampleAnimations(child, aPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
return activeAnimations;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame,
|
|
|
|
Layer *aLayer,
|
|
|
|
bool* aWantNextFrame)
|
|
|
|
{
|
|
|
|
bool appliedTransform = false;
|
|
|
|
for (Layer* child = aLayer->GetFirstChild();
|
|
|
|
child; child = child->GetNextSibling()) {
|
|
|
|
appliedTransform |=
|
|
|
|
ApplyAsyncContentTransformToTree(aCurrentFrame, child, aWantNextFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
if (!container) {
|
|
|
|
return appliedTransform;
|
|
|
|
}
|
|
|
|
|
2013-07-02 16:01:46 +00:00
|
|
|
if (AsyncPanZoomController* controller = container->GetAsyncPanZoomController()) {
|
2013-04-28 06:46:30 +00:00
|
|
|
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
2013-06-24 01:34:33 +00:00
|
|
|
gfx3DMatrix oldTransform = aLayer->GetTransform();
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
ViewTransform treeTransform;
|
2013-06-14 20:11:29 +00:00
|
|
|
ScreenPoint scrollOffset;
|
2013-04-28 06:46:30 +00:00
|
|
|
*aWantNextFrame |=
|
|
|
|
controller->SampleContentTransformForFrame(aCurrentFrame,
|
|
|
|
container,
|
|
|
|
&treeTransform,
|
2013-05-01 14:49:27 +00:00
|
|
|
scrollOffset);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
2013-05-01 14:49:27 +00:00
|
|
|
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
|
|
|
|
const FrameMetrics& metrics = container->GetFrameMetrics();
|
2013-07-04 13:13:52 +00:00
|
|
|
// XXX We use rootTransform instead of metrics.mResolution here because on
|
|
|
|
// Fennec the resolution is set on the root layer rather than the scrollable layer.
|
|
|
|
// The SyncFrameMetrics call and the paintScale variable are used on Fennec only
|
|
|
|
// so it doesn't affect any other platforms. See bug 732971.
|
2013-06-21 21:03:56 +00:00
|
|
|
CSSToLayerScale paintScale = metrics.mDevPixelsPerCSSPixel
|
|
|
|
/ LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale());
|
2013-06-10 13:05:42 +00:00
|
|
|
CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ?
|
|
|
|
metrics.mDisplayPort : metrics.mCriticalDisplayPort);
|
2013-07-22 08:50:13 +00:00
|
|
|
LayerMargin fixedLayerMargins(0, 0, 0, 0);
|
2013-06-03 14:00:02 +00:00
|
|
|
ScreenPoint offset(0, 0);
|
2013-06-14 20:11:31 +00:00
|
|
|
SyncFrameMetrics(scrollOffset, treeTransform.mScale.scale, metrics.mScrollableRect,
|
2013-06-21 21:03:55 +00:00
|
|
|
mLayersUpdated, displayPort, paintScale,
|
2013-05-01 18:12:08 +00:00
|
|
|
mIsFirstPaint, fixedLayerMargins, offset);
|
2013-05-01 14:49:27 +00:00
|
|
|
|
2013-04-28 06:46:30 +00:00
|
|
|
mIsFirstPaint = false;
|
|
|
|
mLayersUpdated = false;
|
|
|
|
|
|
|
|
// Apply the render offset
|
2013-05-01 18:12:08 +00:00
|
|
|
mLayerManager->GetCompositor()->SetScreenRenderOffset(offset);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
gfx3DMatrix transform(gfx3DMatrix(treeTransform) * aLayer->GetTransform());
|
|
|
|
// 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.
|
|
|
|
transform.Scale(1.0f/container->GetPreXScale(),
|
|
|
|
1.0f/container->GetPreYScale(),
|
|
|
|
1);
|
|
|
|
transform.ScalePost(1.0f/aLayer->GetPostXScale(),
|
|
|
|
1.0f/aLayer->GetPostYScale(),
|
|
|
|
1);
|
|
|
|
layerComposite->SetShadowTransform(transform);
|
2013-05-16 12:34:24 +00:00
|
|
|
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
|
|
|
|
"overwriting animated transform!");
|
2013-04-28 06:46:30 +00:00
|
|
|
|
2013-06-24 01:34:33 +00:00
|
|
|
// Apply resolution scaling to the old transform - the layer tree as it is
|
|
|
|
// doesn't have the necessary transform to display correctly.
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// XXX We use rootTransform instead of the resolution on the individual layer's
|
|
|
|
// FrameMetrics on Fennec because the resolution is set on the root layer rather
|
|
|
|
// than the scrollable layer. See bug 732971. On non-Fennec we do the right thing.
|
|
|
|
LayoutDeviceToLayerScale resolution(1.0 / rootTransform.GetXScale(),
|
|
|
|
1.0 / rootTransform.GetYScale());
|
|
|
|
#else
|
|
|
|
LayoutDeviceToLayerScale resolution = metrics.mResolution;
|
|
|
|
#endif
|
|
|
|
oldTransform.Scale(resolution.scale, resolution.scale, 1);
|
|
|
|
|
2013-07-22 08:50:05 +00:00
|
|
|
AlignFixedLayersForAnchorPoint(aLayer, aLayer, oldTransform, fixedLayerMargins);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
appliedTransform = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return appliedTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-04 13:13:52 +00:00
|
|
|
AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDeviceToLayerScale& aResolution)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
|
|
|
LayerComposite* layerComposite = aLayer->AsLayerComposite();
|
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
|
|
|
|
const FrameMetrics& metrics = container->GetFrameMetrics();
|
|
|
|
// We must apply the resolution scale before a pan/zoom transform, so we call
|
|
|
|
// GetTransform here.
|
|
|
|
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
|
2013-06-24 01:34:33 +00:00
|
|
|
gfx3DMatrix oldTransform = currentTransform;
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
gfx3DMatrix treeTransform;
|
|
|
|
|
2013-07-04 13:13:52 +00:00
|
|
|
CSSToLayerScale geckoZoom = metrics.mDevPixelsPerCSSPixel * aResolution;
|
2013-06-03 13:58:07 +00:00
|
|
|
|
2013-06-14 20:11:31 +00:00
|
|
|
LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.mScrollOffset * geckoZoom);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
if (mIsFirstPaint) {
|
2013-06-11 13:46:51 +00:00
|
|
|
mContentRect = metrics.mScrollableRect;
|
2013-06-03 13:58:07 +00:00
|
|
|
SetFirstPaintViewport(scrollOffsetLayerPixels,
|
2013-06-21 21:03:56 +00:00
|
|
|
geckoZoom,
|
2013-06-11 13:46:51 +00:00
|
|
|
mContentRect);
|
2013-04-28 06:46:30 +00:00
|
|
|
mIsFirstPaint = false;
|
2013-06-11 13:46:51 +00:00
|
|
|
} else if (!metrics.mScrollableRect.IsEqualEdges(mContentRect)) {
|
|
|
|
mContentRect = metrics.mScrollableRect;
|
|
|
|
SetPageRect(mContentRect);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2013-06-14 20:11:31 +00:00
|
|
|
LayerIntRect displayPort = RoundedToInt(
|
|
|
|
(metrics.mCriticalDisplayPort.IsEmpty()
|
|
|
|
? metrics.mDisplayPort
|
|
|
|
: metrics.mCriticalDisplayPort
|
|
|
|
) * geckoZoom);
|
2013-06-10 13:05:42 +00:00
|
|
|
displayPort += scrollOffsetLayerPixels;
|
2013-04-28 06:46:30 +00:00
|
|
|
|
2013-07-22 08:50:13 +00:00
|
|
|
LayerMargin fixedLayerMargins(0, 0, 0, 0);
|
2013-06-03 14:00:02 +00:00
|
|
|
ScreenPoint offset(0, 0);
|
2013-06-21 21:03:57 +00:00
|
|
|
|
|
|
|
// 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.scale * metrics.mResolution.scale);
|
|
|
|
ScreenPoint userScroll = metrics.mScrollOffset * userZoom;
|
2013-06-21 21:03:56 +00:00
|
|
|
SyncViewportInfo(displayPort, geckoZoom, mLayersUpdated,
|
|
|
|
userScroll, userZoom, fixedLayerMargins,
|
2013-05-01 18:12:08 +00:00
|
|
|
offset);
|
2013-04-28 06:46:30 +00:00
|
|
|
mLayersUpdated = false;
|
|
|
|
|
|
|
|
// Apply the render offset
|
2013-05-01 18:12:08 +00:00
|
|
|
mLayerManager->GetCompositor()->SetScreenRenderOffset(offset);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
// 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
|
2013-06-14 20:11:31 +00:00
|
|
|
// primary scrollable layer. We compare this to the user zoom and scroll
|
2013-04-28 06:46:30 +00:00
|
|
|
// offset in the view transform we obtained from Java in order to compute the
|
|
|
|
// transformation we need to apply.
|
2013-06-14 20:11:31 +00:00
|
|
|
LayerToScreenScale zoomAdjust = userZoom / geckoZoom;
|
2013-04-28 06:46:30 +00:00
|
|
|
|
2013-06-14 20:11:31 +00:00
|
|
|
LayerIntPoint geckoScroll(0, 0);
|
2013-04-28 06:46:30 +00:00
|
|
|
if (metrics.IsScrollable()) {
|
2013-06-14 20:11:31 +00:00
|
|
|
geckoScroll = scrollOffsetLayerPixels;
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 20:11:31 +00:00
|
|
|
LayerPoint translation = (userScroll / zoomAdjust) - geckoScroll;
|
2013-06-21 21:03:57 +00:00
|
|
|
treeTransform = gfx3DMatrix(ViewTransform(-translation, userZoom / metrics.mDevPixelsPerCSSPixel));
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
gfx3DMatrix computedTransform = treeTransform * currentTransform;
|
|
|
|
computedTransform.Scale(1.0f/container->GetPreXScale(),
|
|
|
|
1.0f/container->GetPreYScale(),
|
|
|
|
1);
|
|
|
|
computedTransform.ScalePost(1.0f/container->GetPostXScale(),
|
|
|
|
1.0f/container->GetPostYScale(),
|
|
|
|
1);
|
|
|
|
layerComposite->SetShadowTransform(computedTransform);
|
2013-05-16 12:34:24 +00:00
|
|
|
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
|
|
|
|
"overwriting animated transform!");
|
2013-06-24 01:34:33 +00:00
|
|
|
|
|
|
|
// Apply resolution scaling to the old transform - the layer tree as it is
|
|
|
|
// doesn't have the necessary transform to display correctly.
|
|
|
|
oldTransform.Scale(aResolution.scale, aResolution.scale, 1);
|
|
|
|
|
2013-07-22 08:50:07 +00:00
|
|
|
// 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
|
|
|
|
// AlignFixedLayersForAnchorPoint.
|
|
|
|
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() -
|
|
|
|
(userScroll.x + metrics.mCompositionBounds.width);
|
|
|
|
}
|
|
|
|
if (userScroll.y < contentScreenRect.y) {
|
|
|
|
overscrollTranslation.y = contentScreenRect.y - userScroll.y;
|
|
|
|
} else if (userScroll.y + metrics.mCompositionBounds.height > contentScreenRect.YMost()) {
|
|
|
|
overscrollTranslation.y = contentScreenRect.YMost() -
|
|
|
|
(userScroll.y + metrics.mCompositionBounds.height);
|
|
|
|
}
|
|
|
|
oldTransform.Translate(overscrollTranslation);
|
|
|
|
|
|
|
|
gfxSize underZoomScale(1.0f, 1.0f);
|
|
|
|
if (mContentRect.width * userZoom.scale < metrics.mCompositionBounds.width) {
|
|
|
|
underZoomScale.width = (mContentRect.width * userZoom.scale) /
|
|
|
|
metrics.mCompositionBounds.width;
|
|
|
|
}
|
|
|
|
if (mContentRect.height * userZoom.scale < metrics.mCompositionBounds.height) {
|
|
|
|
underZoomScale.height = (mContentRect.height * userZoom.scale) /
|
|
|
|
metrics.mCompositionBounds.height;
|
|
|
|
}
|
|
|
|
oldTransform.Scale(underZoomScale.width, underZoomScale.height, 1);
|
|
|
|
|
2013-06-24 01:34:33 +00:00
|
|
|
// Make sure fixed position layers don't move away from their anchor points
|
|
|
|
// when we're asynchronously panning or zooming
|
2013-07-22 08:50:05 +00:00
|
|
|
AlignFixedLayersForAnchorPoint(aLayer, aLayer, oldTransform, fixedLayerMargins);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
|
|
|
|
{
|
|
|
|
Layer* root = mLayerManager->GetRoot();
|
|
|
|
|
|
|
|
// NB: we must sample animations *before* sampling pan/zoom
|
|
|
|
// transforms.
|
2013-05-27 23:47:45 +00:00
|
|
|
bool wantNextFrame = SampleAnimations(root, aCurrentFrame);
|
2013-04-28 06:46:30 +00:00
|
|
|
|
|
|
|
// FIXME/bug 775437: unify this interface with the ~native-fennec
|
|
|
|
// derived code
|
|
|
|
//
|
|
|
|
// Attempt to apply an async content transform to any layer that has
|
|
|
|
// an async pan zoom controller (which means that it is rendered
|
|
|
|
// async using Gecko). If this fails, fall back to transforming the
|
|
|
|
// primary scrollable layer. "Failing" here means that we don't
|
|
|
|
// find a frame that is async scrollable. Note that the fallback
|
|
|
|
// code also includes Fennec which is rendered async. Fennec uses
|
|
|
|
// its own platform-specific async rendering that is done partially
|
|
|
|
// in Gecko and partially in Java.
|
|
|
|
if (!ApplyAsyncContentTransformToTree(aCurrentFrame, root, &wantNextFrame)) {
|
|
|
|
nsAutoTArray<Layer*,1> scrollableLayers;
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
scrollableLayers.AppendElement(mLayerManager->GetPrimaryScrollableLayer());
|
|
|
|
#else
|
|
|
|
mLayerManager->GetScrollableLayers(scrollableLayers);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < scrollableLayers.Length(); i++) {
|
|
|
|
if (scrollableLayers[i]) {
|
2013-07-04 13:13:52 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// XXX We use rootTransform instead of the resolution on the individual layer's
|
|
|
|
// FrameMetrics on Fennec because the resolution is set on the root layer rather
|
|
|
|
// than the scrollable layer. See bug 732971. On non-Fennec we do the right thing.
|
|
|
|
const gfx3DMatrix& rootTransform = root->GetTransform();
|
|
|
|
LayoutDeviceToLayerScale resolution(1.0 / rootTransform.GetXScale(),
|
|
|
|
1.0 / rootTransform.GetYScale());
|
|
|
|
#else
|
|
|
|
LayoutDeviceToLayerScale resolution =
|
|
|
|
scrollableLayers[i]->AsContainerLayer()->GetFrameMetrics().mResolution;
|
|
|
|
#endif
|
|
|
|
TransformScrollableLayer(scrollableLayers[i], resolution);
|
2013-04-28 06:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return wantNextFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-03 13:58:07 +00:00
|
|
|
AsyncCompositionManager::SetFirstPaintViewport(const LayerIntPoint& aOffset,
|
2013-06-21 21:03:56 +00:00
|
|
|
const CSSToLayerScale& aZoom,
|
2013-06-03 13:52:44 +00:00
|
|
|
const CSSRect& aCssPageRect)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-06-11 13:46:51 +00:00
|
|
|
AndroidBridge::Bridge()->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
2013-04-28 06:46:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-03 13:52:44 +00:00
|
|
|
AsyncCompositionManager::SetPageRect(const CSSRect& aCssPageRect)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
AndroidBridge::Bridge()->SetPageRect(aCssPageRect);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-03 13:58:07 +00:00
|
|
|
AsyncCompositionManager::SyncViewportInfo(const LayerIntRect& aDisplayPort,
|
2013-06-21 21:03:56 +00:00
|
|
|
const CSSToLayerScale& aDisplayResolution,
|
2013-04-28 06:46:30 +00:00
|
|
|
bool aLayersUpdated,
|
2013-06-03 13:53:32 +00:00
|
|
|
ScreenPoint& aScrollOffset,
|
2013-06-21 21:03:56 +00:00
|
|
|
CSSToScreenScale& aScale,
|
2013-07-22 08:50:13 +00:00
|
|
|
LayerMargin& aFixedLayerMargins,
|
2013-06-03 14:00:02 +00:00
|
|
|
ScreenPoint& aOffset)
|
2013-04-28 06:46:30 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
AndroidBridge::Bridge()->SyncViewportInfo(aDisplayPort,
|
|
|
|
aDisplayResolution,
|
|
|
|
aLayersUpdated,
|
|
|
|
aScrollOffset,
|
2013-06-21 21:03:56 +00:00
|
|
|
aScale,
|
2013-04-28 06:46:30 +00:00
|
|
|
aFixedLayerMargins,
|
2013-05-01 18:12:08 +00:00
|
|
|
aOffset);
|
2013-04-28 06:46:30 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-05-01 14:49:27 +00:00
|
|
|
void
|
2013-06-14 20:11:29 +00:00
|
|
|
AsyncCompositionManager::SyncFrameMetrics(const ScreenPoint& aScrollOffset,
|
2013-05-01 14:49:27 +00:00
|
|
|
float aZoom,
|
2013-06-03 13:52:44 +00:00
|
|
|
const CSSRect& aCssPageRect,
|
2013-05-01 14:49:27 +00:00
|
|
|
bool aLayersUpdated,
|
2013-06-10 13:05:42 +00:00
|
|
|
const CSSRect& aDisplayPort,
|
2013-06-21 21:03:56 +00:00
|
|
|
const CSSToLayerScale& aDisplayResolution,
|
2013-05-01 14:49:27 +00:00
|
|
|
bool aIsFirstPaint,
|
2013-07-22 08:50:13 +00:00
|
|
|
LayerMargin& aFixedLayerMargins,
|
2013-06-03 14:00:02 +00:00
|
|
|
ScreenPoint& aOffset)
|
2013-05-01 14:49:27 +00:00
|
|
|
{
|
2013-05-01 20:10:17 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2013-05-01 18:12:08 +00:00
|
|
|
AndroidBridge::Bridge()->SyncFrameMetrics(aScrollOffset, aZoom, aCssPageRect,
|
2013-05-01 14:49:27 +00:00
|
|
|
aLayersUpdated, aDisplayPort,
|
|
|
|
aDisplayResolution, aIsFirstPaint,
|
2013-05-01 18:12:08 +00:00
|
|
|
aFixedLayerMargins, aOffset);
|
2013-05-01 14:49:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-28 06:46:30 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|