mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1055760 - Replace GetPrimaryScrollableLayer with functions that are more appropriate. r=BenWa
This commit is contained in:
parent
c11c63c527
commit
39794bb5b4
@ -286,13 +286,6 @@ public:
|
||||
return gfx::Matrix4x4();
|
||||
}
|
||||
|
||||
const gfx::Matrix4x4& GetEffectiveTransform() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
return mLayer->GetEffectiveTransform();
|
||||
}
|
||||
|
||||
RefLayer* AsRefLayer() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
@ -54,11 +54,11 @@ using namespace mozilla::gfx;
|
||||
|
||||
//--------------------------------------------------
|
||||
// LayerManager
|
||||
LayerMetricsWrapper
|
||||
LayerManager::GetPrimaryScrollableLayer()
|
||||
FrameMetrics::ViewID
|
||||
LayerManager::GetRootScrollableLayerId()
|
||||
{
|
||||
if (!mRoot) {
|
||||
return LayerMetricsWrapper();
|
||||
return FrameMetrics::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
nsTArray<LayerMetricsWrapper> queue;
|
||||
@ -69,7 +69,7 @@ LayerManager::GetPrimaryScrollableLayer()
|
||||
|
||||
const FrameMetrics& frameMetrics = layer.Metrics();
|
||||
if (frameMetrics.IsScrollable()) {
|
||||
return layer;
|
||||
return frameMetrics.GetScrollId();
|
||||
}
|
||||
|
||||
LayerMetricsWrapper child = layer.GetFirstChild();
|
||||
@ -79,7 +79,37 @@ LayerManager::GetPrimaryScrollableLayer()
|
||||
}
|
||||
}
|
||||
|
||||
return LayerMetricsWrapper(mRoot);
|
||||
return FrameMetrics::NULL_SCROLL_ID;
|
||||
}
|
||||
|
||||
void
|
||||
LayerManager::GetRootScrollableLayers(nsTArray<Layer*>& aArray)
|
||||
{
|
||||
if (!mRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
FrameMetrics::ViewID rootScrollableId = GetRootScrollableLayerId();
|
||||
if (rootScrollableId == FrameMetrics::NULL_SCROLL_ID) {
|
||||
aArray.AppendElement(mRoot);
|
||||
return;
|
||||
}
|
||||
|
||||
nsTArray<Layer*> queue;
|
||||
queue.AppendElement(mRoot);
|
||||
while (queue.Length()) {
|
||||
Layer* layer = queue[0];
|
||||
queue.RemoveElementAt(0);
|
||||
|
||||
if (LayerMetricsWrapper::TopmostScrollableMetrics(layer).GetScrollId() == rootScrollableId) {
|
||||
aArray.AppendElement(layer);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Layer* child = layer->GetFirstChild(); child; child = child->GetNextSibling()) {
|
||||
queue.AppendElement(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -337,10 +337,20 @@ public:
|
||||
|
||||
/**
|
||||
* Does a breadth-first search from the root layer to find the first
|
||||
* scrollable layer.
|
||||
* scrollable layer, and returns its ViewID. Note that there may be
|
||||
* other layers in the tree which share the same ViewID.
|
||||
* Can be called any time.
|
||||
*/
|
||||
LayerMetricsWrapper GetPrimaryScrollableLayer();
|
||||
FrameMetrics::ViewID GetRootScrollableLayerId();
|
||||
|
||||
/**
|
||||
* Does a breadth-first search from the root layer to find the first
|
||||
* scrollable layer, and returns all the layers that have that ViewID
|
||||
* as the first scrollable metrics in their ancestor chain. If no
|
||||
* scrollable layers are found it just returns the root of the tree if
|
||||
* there is one.
|
||||
*/
|
||||
void GetRootScrollableLayers(nsTArray<Layer*>& aArray);
|
||||
|
||||
/**
|
||||
* Returns a list of all descendant layers for which
|
||||
|
@ -642,30 +642,26 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
||||
bool aDrawingCritical)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
const LayerMetricsWrapper& primaryScrollable = GetPrimaryScrollableLayer();
|
||||
if (primaryScrollable) {
|
||||
const FrameMetrics& metrics = primaryScrollable.Metrics();
|
||||
|
||||
// This is derived from the code in
|
||||
// gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree.
|
||||
CSSToLayerScale paintScale = metrics.LayersPixelsPerCSSPixel();
|
||||
const CSSRect& metricsDisplayPort =
|
||||
(aDrawingCritical && !metrics.mCriticalDisplayPort.IsEmpty()) ?
|
||||
metrics.mCriticalDisplayPort : metrics.mDisplayPort;
|
||||
LayerRect displayPort = (metricsDisplayPort + metrics.GetScrollOffset()) * paintScale;
|
||||
|
||||
ScreenPoint scrollOffset;
|
||||
CSSToScreenScale zoom;
|
||||
bool ret = AndroidBridge::Bridge()->ProgressiveUpdateCallback(
|
||||
aHasPendingNewThebesContent, displayPort, paintScale.scale, aDrawingCritical,
|
||||
scrollOffset, zoom);
|
||||
aMetrics.SetScrollOffset(scrollOffset / zoom);
|
||||
aMetrics.SetZoom(zoom);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
MOZ_ASSERT(aMetrics.IsScrollable());
|
||||
// This is derived from the code in
|
||||
// gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree.
|
||||
CSSToLayerScale paintScale = aMetrics.LayersPixelsPerCSSPixel();
|
||||
const CSSRect& metricsDisplayPort =
|
||||
(aDrawingCritical && !aMetrics.mCriticalDisplayPort.IsEmpty()) ?
|
||||
aMetrics.mCriticalDisplayPort : aMetrics.mDisplayPort;
|
||||
LayerRect displayPort = (metricsDisplayPort + aMetrics.GetScrollOffset()) * paintScale;
|
||||
|
||||
ScreenPoint scrollOffset;
|
||||
CSSToScreenScale zoom;
|
||||
bool ret = AndroidBridge::Bridge()->ProgressiveUpdateCallback(
|
||||
aHasPendingNewThebesContent, displayPort, paintScale.scale, aDrawingCritical,
|
||||
scrollOffset, zoom);
|
||||
aMetrics.SetScrollOffset(scrollOffset / zoom);
|
||||
aMetrics.SetZoom(zoom);
|
||||
return ret;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ClientLayer::~ClientLayer()
|
||||
|
@ -1426,16 +1426,18 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval
|
||||
// caused by there being an incoming, more relevant paint.
|
||||
ViewTransform viewTransform;
|
||||
#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_ANDROID_APZ)
|
||||
FrameMetrics compositorMetrics = scrollAncestor.Metrics();
|
||||
FrameMetrics contentMetrics = scrollAncestor.Metrics();
|
||||
bool abortPaint = false;
|
||||
// On Android, only the primary scrollable layer is async-scrolled, and the only one
|
||||
// that the Java-side code can provide details about. If we're tiling some other layer
|
||||
// then we already have all the information we need about it.
|
||||
if (scrollAncestor == mManager->GetPrimaryScrollableLayer()) {
|
||||
if (contentMetrics.GetScrollId() == mManager->GetRootScrollableLayerId()) {
|
||||
FrameMetrics compositorMetrics = contentMetrics;
|
||||
// The ProgressiveUpdateCallback updates the compositorMetrics
|
||||
abortPaint = mManager->ProgressiveUpdateCallback(!staleRegion.Contains(aInvalidRegion),
|
||||
compositorMetrics,
|
||||
!drawingLowPrecision);
|
||||
viewTransform = ComputeViewTransform(scrollAncestor.Metrics(), compositorMetrics);
|
||||
viewTransform = ComputeViewTransform(contentMetrics, compositorMetrics);
|
||||
}
|
||||
#else
|
||||
MOZ_ASSERT(mSharedFrameMetricsHelper);
|
||||
|
@ -943,15 +943,7 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame)
|
||||
if (!ApplyAsyncContentTransformToTree(root)) {
|
||||
nsAutoTArray<Layer*,1> scrollableLayers;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
const LayerMetricsWrapper& primaryScrollable = mLayerManager->GetPrimaryScrollableLayer();
|
||||
if (primaryScrollable) {
|
||||
// Extracting the Layer* from the LayerMetricsWrapper here is ugly but
|
||||
// should be only temporary. It is needed here because Fennec doesn't
|
||||
// support async scrolling of nested scrollable layers (i.e. sub-APZ).
|
||||
// Once Fennec switches to native APZ (bug 776030) this code will be
|
||||
// eliminated entirely.
|
||||
scrollableLayers.AppendElement((Layer*)primaryScrollable.GetLayer());
|
||||
}
|
||||
mLayerManager->GetRootScrollableLayers(scrollableLayers);
|
||||
#else
|
||||
mLayerManager->GetScrollableLayers(scrollableLayers);
|
||||
#endif
|
||||
|
@ -810,12 +810,14 @@ LayerManagerComposite::ComputeRenderIntegrity()
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Use the transform on the primary scrollable layer and its FrameMetrics
|
||||
// to find out how much of the viewport the current displayport covers
|
||||
const LayerMetricsWrapper& primaryScrollable = GetPrimaryScrollableLayer();
|
||||
if (primaryScrollable) {
|
||||
nsTArray<Layer*> rootScrollableLayers;
|
||||
GetRootScrollableLayers(rootScrollableLayers);
|
||||
if (rootScrollableLayers.Length() > 0) {
|
||||
// This is derived from the code in
|
||||
// AsyncCompositionManager::TransformScrollableLayer
|
||||
const FrameMetrics& metrics = primaryScrollable.Metrics();
|
||||
Matrix4x4 transform = primaryScrollable.GetEffectiveTransform();
|
||||
Layer* rootScrollable = rootScrollableLayers[0];
|
||||
const FrameMetrics& metrics = LayerMetricsWrapper::TopmostScrollableMetrics(rootScrollable);
|
||||
Matrix4x4 transform = rootScrollable->GetEffectiveTransform();
|
||||
transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1);
|
||||
|
||||
// Clip the screen rect to the document bounds
|
||||
|
Loading…
Reference in New Issue
Block a user