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 =
|
RefPtr<UiCompositorControllerParent> uiController =
|
||||||
UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayersId);
|
UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayersId);
|
||||||
if (uiController &&
|
if (uiController &&
|
||||||
apzc->UpdateRootFrameMetricsIfChanged(mLastRootMetrics)) {
|
apzc->UpdateRootFrameMetricsIfChanged(mLastCompositorScrollUpdate)) {
|
||||||
uiController->NotifyUpdateScreenMetrics(mLastRootMetrics);
|
uiController->NotifyCompositorScrollUpdate(mLastCompositorScrollUpdate);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,13 @@
|
|||||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||||
#include "mozilla/DataMutex.h" // for DataMutex
|
#include "mozilla/DataMutex.h" // for DataMutex
|
||||||
#include "mozilla/gfx/CompositorHitTestInfo.h"
|
#include "mozilla/gfx/CompositorHitTestInfo.h"
|
||||||
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
|
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
|
||||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
|
||||||
#include "mozilla/layers/APZInputBridge.h" // for APZInputBridge
|
#include "mozilla/layers/APZInputBridge.h" // for APZInputBridge
|
||||||
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
#include "mozilla/layers/APZTestData.h" // for APZTestData
|
||||||
#include "mozilla/layers/APZUtils.h" // for GeckoViewMetrics
|
#include "mozilla/layers/APZUtils.h" // for AsyncTransformComponents
|
||||||
#include "mozilla/layers/IAPZCTreeManager.h" // for IAPZCTreeManager
|
#include "mozilla/layers/CompositorScrollUpdate.h" // for CompositorScrollUpdate
|
||||||
|
#include "mozilla/layers/IAPZCTreeManager.h" // for IAPZCTreeManager
|
||||||
#include "mozilla/layers/ScrollbarData.h"
|
#include "mozilla/layers/ScrollbarData.h"
|
||||||
#include "mozilla/layers/LayersTypes.h"
|
#include "mozilla/layers/LayersTypes.h"
|
||||||
#include "mozilla/layers/KeyboardMap.h" // for KeyboardMap
|
#include "mozilla/layers/KeyboardMap.h" // for KeyboardMap
|
||||||
@@ -1147,8 +1148,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
|
|||||||
|
|
||||||
#if defined(MOZ_WIDGET_ANDROID)
|
#if defined(MOZ_WIDGET_ANDROID)
|
||||||
private:
|
private:
|
||||||
// Last Frame metrics sent to java through UIController.
|
// Last compositor scroll update sent to java through UIController.
|
||||||
GeckoViewMetrics mLastRootMetrics;
|
CompositorScrollUpdate mLastCompositorScrollUpdate;
|
||||||
#endif // defined(MOZ_WIDGET_ANDROID)
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -181,16 +181,6 @@ enum class AsyncTransformConsumer {
|
|||||||
*/
|
*/
|
||||||
enum class HandoffConsumer { Scrolling, PullToRefresh };
|
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 {
|
namespace apz {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6091,10 +6091,11 @@ const FrameMetrics& AsyncPanZoomController::Metrics() const {
|
|||||||
return mScrollMetadata.GetMetrics();
|
return mScrollMetadata.GetMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoViewMetrics AsyncPanZoomController::GetGeckoViewMetrics() const {
|
CompositorScrollUpdate AsyncPanZoomController::GetCompositorScrollUpdate()
|
||||||
|
const {
|
||||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||||
return GeckoViewMetrics{GetEffectiveScrollOffset(eForCompositing, lock),
|
return CompositorScrollUpdate{GetEffectiveScrollOffset(eForCompositing, lock),
|
||||||
GetEffectiveZoom(eForCompositing, lock)};
|
GetEffectiveZoom(eForCompositing, lock)};
|
||||||
}
|
}
|
||||||
|
|
||||||
wr::MinimapData AsyncPanZoomController::GetMinimapData() const {
|
wr::MinimapData AsyncPanZoomController::GetMinimapData() const {
|
||||||
@@ -6122,14 +6123,14 @@ wr::MinimapData AsyncPanZoomController::GetMinimapData() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AsyncPanZoomController::UpdateRootFrameMetricsIfChanged(
|
bool AsyncPanZoomController::UpdateRootFrameMetricsIfChanged(
|
||||||
GeckoViewMetrics& aMetrics) {
|
CompositorScrollUpdate& aMetrics) {
|
||||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||||
|
|
||||||
if (!Metrics().IsRootContent()) {
|
if (!Metrics().IsRootContent()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoViewMetrics newMetrics = GetGeckoViewMetrics();
|
CompositorScrollUpdate newMetrics = GetCompositorScrollUpdate();
|
||||||
bool hasChanged = RoundedToInt(aMetrics.mVisualScrollOffset) !=
|
bool hasChanged = RoundedToInt(aMetrics.mVisualScrollOffset) !=
|
||||||
RoundedToInt(newMetrics.mVisualScrollOffset) ||
|
RoundedToInt(newMetrics.mVisualScrollOffset) ||
|
||||||
aMetrics.mZoom != newMetrics.mZoom;
|
aMetrics.mZoom != newMetrics.mZoom;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#define mozilla_layers_AsyncPanZoomController_h
|
#define mozilla_layers_AsyncPanZoomController_h
|
||||||
|
|
||||||
#include "Units.h"
|
#include "Units.h"
|
||||||
|
#include "mozilla/layers/CompositorScrollUpdate.h"
|
||||||
#include "mozilla/layers/GeckoContentController.h"
|
#include "mozilla/layers/GeckoContentController.h"
|
||||||
#include "mozilla/layers/RepaintRequest.h"
|
#include "mozilla/layers/RepaintRequest.h"
|
||||||
#include "mozilla/layers/SampleTime.h"
|
#include "mozilla/layers/SampleTime.h"
|
||||||
@@ -592,15 +593,16 @@ class AsyncPanZoomController {
|
|||||||
FrameMetrics& Metrics();
|
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;
|
wr::MinimapData GetMinimapData() const;
|
||||||
|
|
||||||
// Helper function to compare root frame metrics and update them
|
// Helper function to compare root frame metrics and update them
|
||||||
// Returns true when the metrics have changed and were updated.
|
// Returns true when the metrics have changed and were updated.
|
||||||
bool UpdateRootFrameMetricsIfChanged(GeckoViewMetrics& aMetrics);
|
bool UpdateRootFrameMetricsIfChanged(CompositorScrollUpdate& aMetrics);
|
||||||
|
|
||||||
// Returns the cached current frame time.
|
// Returns the cached current frame time.
|
||||||
SampleTime GetFrameTime() const;
|
SampleTime GetFrameTime() const;
|
||||||
|
|||||||
@@ -205,13 +205,12 @@ void UiCompositorControllerParent::NotifyFirstPaint() {
|
|||||||
ToolbarAnimatorMessageFromCompositor(FIRST_PAINT);
|
ToolbarAnimatorMessageFromCompositor(FIRST_PAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiCompositorControllerParent::NotifyUpdateScreenMetrics(
|
void UiCompositorControllerParent::NotifyCompositorScrollUpdate(
|
||||||
const GeckoViewMetrics& aMetrics) {
|
const CompositorScrollUpdate& aUpdate) {
|
||||||
#if defined(MOZ_WIDGET_ANDROID)
|
#if defined(MOZ_WIDGET_ANDROID)
|
||||||
// TODO: Need to handle different x-and y-scales.
|
|
||||||
CSSToScreenScale scale = ViewTargetAs<ScreenPixel>(
|
CSSToScreenScale scale = ViewTargetAs<ScreenPixel>(
|
||||||
aMetrics.mZoom, PixelCastJustification::ScreenIsParentLayerForRoot);
|
aUpdate.mZoom, PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||||
ScreenPoint scrollOffset = aMetrics.mVisualScrollOffset * scale;
|
ScreenPoint scrollOffset = aUpdate.mVisualScrollOffset * scale;
|
||||||
CompositorThread()->Dispatch(NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
|
CompositorThread()->Dispatch(NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
|
||||||
"UiCompositorControllerParent::SendRootFrameMetrics", this,
|
"UiCompositorControllerParent::SendRootFrameMetrics", this,
|
||||||
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
|
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
#define include_gfx_ipc_UiCompositorControllerParent_h
|
#define include_gfx_ipc_UiCompositorControllerParent_h
|
||||||
|
|
||||||
#include "mozilla/layers/PUiCompositorControllerParent.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/ipc/Shmem.h"
|
||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ class UiCompositorControllerParent final
|
|||||||
// necessary.
|
// necessary.
|
||||||
void NotifyLayersUpdated();
|
void NotifyLayersUpdated();
|
||||||
void NotifyFirstPaint();
|
void NotifyFirstPaint();
|
||||||
void NotifyUpdateScreenMetrics(const GeckoViewMetrics& aMetrics);
|
void NotifyCompositorScrollUpdate(const CompositorScrollUpdate& aUpdate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit UiCompositorControllerParent(const LayersId& aRootLayerTreeId);
|
explicit UiCompositorControllerParent(const LayersId& aRootLayerTreeId);
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ EXPORTS.mozilla.layers += [
|
|||||||
"apz/public/APZSampler.h",
|
"apz/public/APZSampler.h",
|
||||||
"apz/public/APZUpdater.h",
|
"apz/public/APZUpdater.h",
|
||||||
"apz/public/CompositorController.h",
|
"apz/public/CompositorController.h",
|
||||||
|
"apz/public/CompositorScrollUpdate.h",
|
||||||
"apz/public/GeckoContentController.h",
|
"apz/public/GeckoContentController.h",
|
||||||
"apz/public/GeckoContentControllerTypes.h",
|
"apz/public/GeckoContentControllerTypes.h",
|
||||||
"apz/public/IAPZCTreeManager.h",
|
"apz/public/IAPZCTreeManager.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user