Bug 1956124 - Rename GeckoViewMetrics to CompositorScrollUpdate. r=hiro
This makes it clearer that the CompositorScrollDelegate API implementation is using this type to represent an *update* to the relevant metrics, of which there may be more than one per composite (in future patches). The patch also moves the type to its own header, to help minimize header dependencies. Differential Revision: https://phabricator.services.mozilla.com/D242834
This commit is contained in:
29
gfx/layers/apz/public/CompositorScrollUpdate.h
Normal file
29
gfx/layers/apz/public/CompositorScrollUpdate.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 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/. */
|
||||
|
||||
#ifndef mozilla_layers_CompositorScrollUpdate_h
|
||||
#define mozilla_layers_CompositorScrollUpdate_h
|
||||
|
||||
#include "Units.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* An update sent by APZ to interesting consumers (e.g. GeckoView)
|
||||
* to inform them, on every composite, about the effective visual
|
||||
* scroll offset and zoom level of the root content APZC at
|
||||
* composition time.
|
||||
*/
|
||||
struct CompositorScrollUpdate {
|
||||
CSSPoint mVisualScrollOffset;
|
||||
CSSToParentLayerScale mZoom;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layers_CompositorScrollUpdate_h
|
||||
@@ -896,8 +896,8 @@ void APZCTreeManager::SampleForWebRender(const Maybe<VsyncId>& aVsyncId,
|
||||
RefPtr<UiCompositorControllerParent> uiController =
|
||||
UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayersId);
|
||||
if (uiController &&
|
||||
apzc->UpdateRootFrameMetricsIfChanged(mLastRootMetrics)) {
|
||||
uiController->NotifyUpdateScreenMetrics(mLastRootMetrics);
|
||||
apzc->UpdateRootFrameMetricsIfChanged(mLastCompositorScrollUpdate)) {
|
||||
uiController->NotifyCompositorScrollUpdate(mLastCompositorScrollUpdate);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||
#include "mozilla/layers/APZInputBridge.h" // for APZInputBridge
|
||||
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
||||
#include "mozilla/layers/APZUtils.h" // for GeckoViewMetrics
|
||||
#include "mozilla/layers/APZUtils.h" // for AsyncTransformComponents
|
||||
#include "mozilla/layers/CompositorScrollUpdate.h" // for CompositorScrollUpdate
|
||||
#include "mozilla/layers/IAPZCTreeManager.h" // for IAPZCTreeManager
|
||||
#include "mozilla/layers/ScrollbarData.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
@@ -1147,8 +1148,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
private:
|
||||
// Last Frame metrics sent to java through UIController.
|
||||
GeckoViewMetrics mLastRootMetrics;
|
||||
// Last compositor scroll update sent to java through UIController.
|
||||
CompositorScrollUpdate mLastCompositorScrollUpdate;
|
||||
#endif // defined(MOZ_WIDGET_ANDROID)
|
||||
};
|
||||
|
||||
|
||||
@@ -181,16 +181,6 @@ enum class AsyncTransformConsumer {
|
||||
*/
|
||||
enum class HandoffConsumer { Scrolling, PullToRefresh };
|
||||
|
||||
/**
|
||||
* Metrics that GeckoView wants to know at every composite.
|
||||
* These are the effective visual scroll offset and zoom level of
|
||||
* the root content APZC at composition time.
|
||||
*/
|
||||
struct GeckoViewMetrics {
|
||||
CSSPoint mVisualScrollOffset;
|
||||
CSSToParentLayerScale mZoom;
|
||||
};
|
||||
|
||||
namespace apz {
|
||||
|
||||
/**
|
||||
|
||||
@@ -6091,9 +6091,10 @@ const FrameMetrics& AsyncPanZoomController::Metrics() const {
|
||||
return mScrollMetadata.GetMetrics();
|
||||
}
|
||||
|
||||
GeckoViewMetrics AsyncPanZoomController::GetGeckoViewMetrics() const {
|
||||
CompositorScrollUpdate AsyncPanZoomController::GetCompositorScrollUpdate()
|
||||
const {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
return GeckoViewMetrics{GetEffectiveScrollOffset(eForCompositing, lock),
|
||||
return CompositorScrollUpdate{GetEffectiveScrollOffset(eForCompositing, lock),
|
||||
GetEffectiveZoom(eForCompositing, lock)};
|
||||
}
|
||||
|
||||
@@ -6122,14 +6123,14 @@ wr::MinimapData AsyncPanZoomController::GetMinimapData() const {
|
||||
}
|
||||
|
||||
bool AsyncPanZoomController::UpdateRootFrameMetricsIfChanged(
|
||||
GeckoViewMetrics& aMetrics) {
|
||||
CompositorScrollUpdate& aMetrics) {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
|
||||
if (!Metrics().IsRootContent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GeckoViewMetrics newMetrics = GetGeckoViewMetrics();
|
||||
CompositorScrollUpdate newMetrics = GetCompositorScrollUpdate();
|
||||
bool hasChanged = RoundedToInt(aMetrics.mVisualScrollOffset) !=
|
||||
RoundedToInt(newMetrics.mVisualScrollOffset) ||
|
||||
aMetrics.mZoom != newMetrics.mZoom;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define mozilla_layers_AsyncPanZoomController_h
|
||||
|
||||
#include "Units.h"
|
||||
#include "mozilla/layers/CompositorScrollUpdate.h"
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "mozilla/layers/RepaintRequest.h"
|
||||
#include "mozilla/layers/SampleTime.h"
|
||||
@@ -592,15 +593,16 @@ class AsyncPanZoomController {
|
||||
FrameMetrics& Metrics();
|
||||
|
||||
/**
|
||||
* Get the GeckoViewMetrics to be sent to Gecko for the current composite.
|
||||
* Get the CompositorScrollUpdate to be sent to consumers for the current
|
||||
* composite.
|
||||
*/
|
||||
GeckoViewMetrics GetGeckoViewMetrics() const;
|
||||
CompositorScrollUpdate GetCompositorScrollUpdate() const;
|
||||
|
||||
wr::MinimapData GetMinimapData() const;
|
||||
|
||||
// Helper function to compare root frame metrics and update them
|
||||
// Returns true when the metrics have changed and were updated.
|
||||
bool UpdateRootFrameMetricsIfChanged(GeckoViewMetrics& aMetrics);
|
||||
bool UpdateRootFrameMetricsIfChanged(CompositorScrollUpdate& aMetrics);
|
||||
|
||||
// Returns the cached current frame time.
|
||||
SampleTime GetFrameTime() const;
|
||||
|
||||
@@ -205,13 +205,12 @@ void UiCompositorControllerParent::NotifyFirstPaint() {
|
||||
ToolbarAnimatorMessageFromCompositor(FIRST_PAINT);
|
||||
}
|
||||
|
||||
void UiCompositorControllerParent::NotifyUpdateScreenMetrics(
|
||||
const GeckoViewMetrics& aMetrics) {
|
||||
void UiCompositorControllerParent::NotifyCompositorScrollUpdate(
|
||||
const CompositorScrollUpdate& aUpdate) {
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// TODO: Need to handle different x-and y-scales.
|
||||
CSSToScreenScale scale = ViewTargetAs<ScreenPixel>(
|
||||
aMetrics.mZoom, PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||
ScreenPoint scrollOffset = aMetrics.mVisualScrollOffset * scale;
|
||||
aUpdate.mZoom, PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||
ScreenPoint scrollOffset = aUpdate.mVisualScrollOffset * scale;
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
|
||||
"UiCompositorControllerParent::SendRootFrameMetrics", this,
|
||||
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#define include_gfx_ipc_UiCompositorControllerParent_h
|
||||
|
||||
#include "mozilla/layers/PUiCompositorControllerParent.h"
|
||||
#include "mozilla/layers/APZUtils.h"
|
||||
#include "mozilla/layers/CompositorScrollUpdate.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
#include "mozilla/ipc/Shmem.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
@@ -56,7 +57,7 @@ class UiCompositorControllerParent final
|
||||
// necessary.
|
||||
void NotifyLayersUpdated();
|
||||
void NotifyFirstPaint();
|
||||
void NotifyUpdateScreenMetrics(const GeckoViewMetrics& aMetrics);
|
||||
void NotifyCompositorScrollUpdate(const CompositorScrollUpdate& aUpdate);
|
||||
|
||||
private:
|
||||
explicit UiCompositorControllerParent(const LayersId& aRootLayerTreeId);
|
||||
|
||||
@@ -89,6 +89,7 @@ EXPORTS.mozilla.layers += [
|
||||
"apz/public/APZSampler.h",
|
||||
"apz/public/APZUpdater.h",
|
||||
"apz/public/CompositorController.h",
|
||||
"apz/public/CompositorScrollUpdate.h",
|
||||
"apz/public/GeckoContentController.h",
|
||||
"apz/public/GeckoContentControllerTypes.h",
|
||||
"apz/public/IAPZCTreeManager.h",
|
||||
|
||||
Reference in New Issue
Block a user