mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1453364 - Update scrollbar transforms separately from OMTA transforms. r=nical
Although they still happen in the same transaction, they are done in two separate frame messages. This results in better encapsulated code on the C++ side since we don't have to pass around an array of properties, and will simplify future changes to update these properties at render time rather than at GenerateFrame time. MozReview-Commit-ID: 9qUkHX7gmD1 --HG-- extra : rebase_source : 15a319ba270eb1783815c514ae05c6a72e323dac
This commit is contained in:
parent
caada858fb
commit
cfd585d234
@ -38,8 +38,7 @@ public:
|
||||
explicit APZSampler(const RefPtr<APZCTreeManager>& aApz);
|
||||
|
||||
bool PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
const TimeStamp& aSampleTime);
|
||||
|
||||
bool SampleAnimations(const LayerMetricsWrapper& aLayer,
|
||||
const TimeStamp& aSampleTime);
|
||||
|
@ -532,8 +532,7 @@ APZCTreeManager::UpdateHitTestingTree(LayersId aRootLayerTreeId,
|
||||
|
||||
bool
|
||||
APZCTreeManager::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
const TimeStamp& aSampleTime)
|
||||
{
|
||||
AssertOnSamplerThread();
|
||||
|
||||
@ -608,6 +607,7 @@ APZCTreeManager::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
// iteration, it's cleaner and more efficient to do it as a separate pass
|
||||
// because now we have a populated httnMap which allows O(log n) lookup here,
|
||||
// resulting in O(n log n) runtime.
|
||||
nsTArray<wr::WrTransformProperty> scrollbarTransforms;
|
||||
ForEachNode<ReverseIterator>(mRootNode.get(),
|
||||
[&](HitTestingTreeNode* aNode)
|
||||
{
|
||||
@ -637,10 +637,11 @@ APZCTreeManager::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
scrollTargetNode->IsAncestorOf(aNode),
|
||||
nullptr);
|
||||
});
|
||||
aTransformArray.AppendElement(wr::ToWrTransformProperty(
|
||||
scrollbarTransforms.AppendElement(wr::ToWrTransformProperty(
|
||||
aNode->GetScrollbarAnimationId(),
|
||||
transform));
|
||||
});
|
||||
aTxn.AppendTransformProperties(scrollbarTransforms);
|
||||
|
||||
return activeAnimations;
|
||||
}
|
||||
|
@ -201,13 +201,12 @@ public:
|
||||
* sample time. In effect it is the webrender equivalent of (part of) the
|
||||
* code in AsyncCompositionManager. If scrollbar transforms need updating
|
||||
* to reflect the async scroll position, the updated transforms are appended
|
||||
* to the provided aTransformArray.
|
||||
* to the provided transaction as well.
|
||||
* Returns true if any APZ animations are in progress and we need to keep
|
||||
* compositing.
|
||||
*/
|
||||
bool PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
const TimeStamp& aSampleTime);
|
||||
|
||||
/**
|
||||
* Walk the tree of APZCs and flushes the repaint requests for all the APZCS
|
||||
|
@ -31,12 +31,11 @@ APZSampler::~APZSampler()
|
||||
|
||||
bool
|
||||
APZSampler::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
const TimeStamp& aSampleTime)
|
||||
{
|
||||
// This function will be removed eventually since we'll have WR pull
|
||||
// the transforms from APZ instead.
|
||||
return mApz->PushStateToWR(aTxn, aSampleTime, aTransformArray);
|
||||
return mApz->PushStateToWR(aTxn, aSampleTime);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -533,8 +533,7 @@ WebRenderBridgeParent::UpdateAPZScrollData(const wr::Epoch& aEpoch,
|
||||
}
|
||||
|
||||
bool
|
||||
WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn)
|
||||
{
|
||||
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
|
||||
if (!cbp) {
|
||||
@ -549,7 +548,7 @@ WebRenderBridgeParent::PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
||||
if (frameInterval != TimeDuration::Forever()) {
|
||||
animationTime += frameInterval;
|
||||
}
|
||||
return apz->PushStateToWR(aTxn, animationTime, aTransformArray);
|
||||
return apz->PushStateToWR(aTxn, animationTime);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1234,6 +1233,8 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
|
||||
return;
|
||||
}
|
||||
|
||||
wr::TransactionBuilder txn;
|
||||
|
||||
nsTArray<wr::WrOpacityProperty> opacityArray;
|
||||
nsTArray<wr::WrTransformProperty> transformArray;
|
||||
|
||||
@ -1241,10 +1242,14 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
|
||||
if (!transformArray.IsEmpty() || !opacityArray.IsEmpty()) {
|
||||
ScheduleGenerateFrame();
|
||||
}
|
||||
// We do this even if the arrays are empty, because it will clear out any
|
||||
// previous properties stored on the WR side, which is desirable. Also, we
|
||||
// must do this before the PushAPZStateToWR call which will append more
|
||||
// properties, If we did this after that call, this would clobber those
|
||||
// properties.
|
||||
txn.UpdateDynamicProperties(opacityArray, transformArray);
|
||||
|
||||
wr::TransactionBuilder txn;
|
||||
|
||||
if (PushAPZStateToWR(txn, transformArray)) {
|
||||
if (PushAPZStateToWR(txn)) {
|
||||
ScheduleGenerateFrame();
|
||||
}
|
||||
|
||||
@ -1255,10 +1260,6 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
|
||||
mApi->SetFrameStartTime(startTime);
|
||||
#endif
|
||||
|
||||
if (!transformArray.IsEmpty() || !opacityArray.IsEmpty()) {
|
||||
txn.UpdateDynamicProperties(opacityArray, transformArray);
|
||||
}
|
||||
|
||||
txn.GenerateFrame();
|
||||
|
||||
mApi->SendTransaction(txn);
|
||||
|
@ -222,10 +222,9 @@ private:
|
||||
|
||||
// Have APZ push the async scroll state to WR. Returns true if an APZ
|
||||
// animation is in effect and we need to schedule another composition.
|
||||
// If scrollbars need their transforms updated, the provided aTransformArray
|
||||
// is populated with the property update details.
|
||||
bool PushAPZStateToWR(wr::TransactionBuilder& aTxn,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
// If scrollbars need their transforms updated, the transaction builder
|
||||
// is populated with the property update details via AppendTransformProperties
|
||||
bool PushAPZStateToWR(wr::TransactionBuilder& aTxn);
|
||||
|
||||
wr::Epoch GetNextWrEpoch();
|
||||
|
||||
|
@ -206,13 +206,21 @@ void
|
||||
TransactionBuilder::UpdateDynamicProperties(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
|
||||
const nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
{
|
||||
wr_transaction_update_dynamic_properties(mTxn,
|
||||
aOpacityArray.IsEmpty() ?
|
||||
nullptr : aOpacityArray.Elements(),
|
||||
aOpacityArray.Length(),
|
||||
aTransformArray.IsEmpty() ?
|
||||
nullptr : aTransformArray.Elements(),
|
||||
aTransformArray.Length());
|
||||
wr_transaction_update_dynamic_properties(
|
||||
mTxn,
|
||||
aOpacityArray.IsEmpty() ? nullptr : aOpacityArray.Elements(),
|
||||
aOpacityArray.Length(),
|
||||
aTransformArray.IsEmpty() ? nullptr : aTransformArray.Elements(),
|
||||
aTransformArray.Length());
|
||||
}
|
||||
|
||||
void
|
||||
TransactionBuilder::AppendTransformProperties(const nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
{
|
||||
wr_transaction_append_transform_properties(
|
||||
mTxn,
|
||||
aTransformArray.IsEmpty() ? nullptr : aTransformArray.Elements(),
|
||||
aTransformArray.Length());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
|
||||
void UpdateDynamicProperties(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
|
||||
const nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
void AppendTransformProperties(const nsTArray<wr::WrTransformProperty>& aTransformArray);
|
||||
|
||||
void SetWindowParameters(const LayoutDeviceIntSize& aWindowSize,
|
||||
const LayoutDeviceIntRect& aDocRect);
|
||||
|
@ -1066,8 +1066,6 @@ pub extern "C" fn wr_transaction_update_dynamic_properties(
|
||||
transform_array: *const WrTransformProperty,
|
||||
transform_count: usize,
|
||||
) {
|
||||
debug_assert!(transform_count > 0 || opacity_count > 0);
|
||||
|
||||
let mut properties = DynamicProperties {
|
||||
transforms: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
@ -1101,6 +1099,35 @@ pub extern "C" fn wr_transaction_update_dynamic_properties(
|
||||
txn.update_dynamic_properties(properties);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_transaction_append_transform_properties(
|
||||
txn: &mut Transaction,
|
||||
transform_array: *const WrTransformProperty,
|
||||
transform_count: usize,
|
||||
) {
|
||||
if transform_count == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut properties = DynamicProperties {
|
||||
transforms: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
};
|
||||
|
||||
let transform_slice = make_slice(transform_array, transform_count);
|
||||
|
||||
for element in transform_slice.iter() {
|
||||
let prop = PropertyValue {
|
||||
key: PropertyBindingKey::new(element.id),
|
||||
value: element.transform.into(),
|
||||
};
|
||||
|
||||
properties.transforms.push(prop);
|
||||
}
|
||||
|
||||
txn.append_dynamic_properties(properties);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_transaction_scroll_layer(
|
||||
txn: &mut Transaction,
|
||||
|
@ -942,6 +942,11 @@ struct FontInstancePlatformOptions {
|
||||
};
|
||||
#endif
|
||||
|
||||
struct WrTransformProperty {
|
||||
uint64_t id;
|
||||
LayoutTransform transform;
|
||||
};
|
||||
|
||||
struct WrOpacityProperty {
|
||||
uint64_t id;
|
||||
float opacity;
|
||||
@ -952,11 +957,6 @@ struct WrOpacityProperty {
|
||||
}
|
||||
};
|
||||
|
||||
struct WrTransformProperty {
|
||||
uint64_t id;
|
||||
LayoutTransform transform;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
|
||||
@ -1597,6 +1597,12 @@ WR_INLINE
|
||||
WrThreadPool *wr_thread_pool_new()
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_transaction_append_transform_properties(Transaction *aTxn,
|
||||
const WrTransformProperty *aTransformArray,
|
||||
uintptr_t aTransformCount)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_transaction_clear_display_list(Transaction *aTxn,
|
||||
WrEpoch aEpoch,
|
||||
|
Loading…
Reference in New Issue
Block a user