Skip to content

Commit

Permalink
Backed out 6 changesets (bug 1510030) for webrender bustages CLOSED TREE
Browse files Browse the repository at this point in the history
Backed out changeset 28a2fba71977 (bug 1510030)
Backed out changeset 1700b3a416cd (bug 1510030)
Backed out changeset 087518046b0c (bug 1510030)
Backed out changeset 6b3af91a7ce6 (bug 1510030)
Backed out changeset 737f4bc3afd3 (bug 1510030)
Backed out changeset 921116ca67a5 (bug 1510030)
  • Loading branch information
bogdant-old committed Feb 27, 2020
1 parent ee2bc06 commit a6ca419
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 622 deletions.
11 changes: 11 additions & 0 deletions dom/animation/KeyframeEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,17 @@ KeyframeEffect::MatchForCompositor KeyframeEffect::IsMatchForCompositor(
if (!StaticPrefs::gfx_omta_background_color()) {
return KeyframeEffect::MatchForCompositor::No;
}

if (nsIContent* content = aFrame->GetContent()) {
RefPtr<layers::LayerManager> layerManager =
nsContentUtils::LayerManagerForContent(content);
if (layerManager &&
layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
// Bug 1510030: We don't yet support background-color animations on the
// compositor for WebRender.
return KeyframeEffect::MatchForCompositor::No;
}
}
}

return mAnimation->IsPlaying() ? KeyframeEffect::MatchForCompositor::Yes
Expand Down
22 changes: 18 additions & 4 deletions dom/animation/test/chrome/test_running_on_compositor.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
animation is running on the compositor or not **/

const omtaEnabled = isOMTAEnabled();
const isWebRender =
SpecialPowers.DOMWindowUtils.layerManagerType == 'WebRender';

function assert_animation_is_running_on_compositor(animation, desc) {
assert_equals(animation.isRunningOnCompositor, omtaEnabled,
Expand Down Expand Up @@ -1027,8 +1029,14 @@
await waitForAnimationReadyToRestyle(animation);
await waitForPaints();

assert_animation_is_running_on_compositor(animation,
'background-color animation should be running on the compositor');
if (!isWebRender) {
assert_animation_is_running_on_compositor(animation,
'background-color animation should be running on the compositor');
} else {
assert_animation_is_not_running_on_compositor(animation,
'background-color animation is not yet able to run on the compositor ' +
'on WebRender');
}
}, 'background-color animation runs on the compositor');

promise_test(async t => {
Expand All @@ -1039,8 +1047,14 @@
await waitForAnimationReadyToRestyle(animation);
await waitForPaints();

assert_animation_is_running_on_compositor(animation,
'background-color animation should be running on the compositor');
if (!isWebRender) {
assert_animation_is_running_on_compositor(animation,
'background-color animation should be running on the compositor');
} else {
assert_animation_is_not_running_on_compositor(animation,
'background-color animation is not yet able to run on the compositor ' +
'on WebRender');
}

// Add a red opaque background image covering the background color animation.
div.style.backgroundImage =
Expand Down
6 changes: 0 additions & 6 deletions gfx/layers/AnimationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,6 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage,

// Store the AnimatedValue
switch (lastPropertyAnimationGroup.mProperty) {
case eCSSProperty_background_color: {
aStorage->SetAnimatedValue(
iter.Key(), Servo_AnimationValue_GetColor(animationValues[0],
NS_RGBA(0, 0, 0, 0)));
break;
}
case eCSSProperty_opacity: {
MOZ_ASSERT(animationValues.Length() == 1);
aStorage->SetAnimatedValue(
Expand Down
13 changes: 3 additions & 10 deletions gfx/layers/wr/WebRenderBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,8 +2279,7 @@ bool WebRenderBridgeParent::AdvanceAnimations() {

bool WebRenderBridgeParent::SampleAnimations(
wr::RenderRootArray<nsTArray<wr::WrOpacityProperty>>& aOpacityArrays,
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>>& aTransformArrays,
wr::RenderRootArray<nsTArray<wr::WrColorProperty>>& aColorArrays) {
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>>& aTransformArrays) {
const bool isAnimating = AdvanceAnimations();

// return the animated data if has
Expand All @@ -2291,16 +2290,12 @@ bool WebRenderBridgeParent::SampleAnimations(
wr::RenderRoot renderRoot = mAnimStorage->AnimationRenderRoot(iter.Key());
auto& transformArray = aTransformArrays[renderRoot];
auto& opacityArray = aOpacityArrays[renderRoot];
auto& colorArray = aColorArrays[renderRoot];
if (value->Is<AnimationTransform>()) {
transformArray.AppendElement(wr::ToWrTransformProperty(
iter.Key(), value->Transform().mTransformInDevSpace));
} else if (value->Is<float>()) {
opacityArray.AppendElement(
wr::ToWrOpacityProperty(iter.Key(), value->Opacity()));
} else if (value->Is<nscolor>()) {
colorArray.AppendElement(wr::ToWrColorProperty(
iter.Key(), gfx::Color::FromABGR(value->Color())));
}
}
}
Expand Down Expand Up @@ -2430,9 +2425,8 @@ void WebRenderBridgeParent::MaybeGenerateFrame(VsyncId aId,

wr::RenderRootArray<nsTArray<wr::WrOpacityProperty>> opacityArrays;
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>> transformArrays;
wr::RenderRootArray<nsTArray<wr::WrColorProperty>> colorArrays;

if (SampleAnimations(opacityArrays, transformArrays, colorArrays)) {
if (SampleAnimations(opacityArrays, transformArrays)) {
// TODO we should have a better way of assessing whether we need a content
// or a chrome frame generation.
ScheduleGenerateFrameAllRenderRoots();
Expand All @@ -2445,8 +2439,7 @@ void WebRenderBridgeParent::MaybeGenerateFrame(VsyncId aId,
}
auto renderRoot = api->GetRenderRoot();
fastTxns[renderRoot]->UpdateDynamicProperties(opacityArrays[renderRoot],
transformArrays[renderRoot],
colorArrays[renderRoot]);
transformArrays[renderRoot]);
}

SetAPZSampleTime();
Expand Down
3 changes: 1 addition & 2 deletions gfx/layers/wr/WebRenderBridgeParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ class WebRenderBridgeParent final
bool AdvanceAnimations();
bool SampleAnimations(
wr::RenderRootArray<nsTArray<wr::WrOpacityProperty>>& aOpacityArrays,
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>>& aTransformArrays,
wr::RenderRootArray<nsTArray<wr::WrColorProperty>>& aColorArrays);
wr::RenderRootArray<nsTArray<wr::WrTransformProperty>>& aTransformArrays);

CompositorBridgeParent* GetRootCompositorBridgeParent() const;

Expand Down
21 changes: 2 additions & 19 deletions gfx/webrender_bindings/WebRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,12 @@ void TransactionBuilder::InvalidateRenderedFrame() {

void TransactionBuilder::UpdateDynamicProperties(
const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
const nsTArray<wr::WrTransformProperty>& aTransformArray,
const nsTArray<wr::WrColorProperty>& aColorArray) {
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(),
aColorArray.IsEmpty() ? nullptr : aColorArray.Elements(),
aColorArray.Length());
aTransformArray.Length());
}

bool TransactionBuilder::IsEmpty() const {
Expand Down Expand Up @@ -1142,20 +1139,6 @@ void DisplayListBuilder::PushHitTest(const wr::LayoutRect& aBounds,
&mCurrentSpaceAndClipChain);
}

void DisplayListBuilder::PushRectWithAnimation(
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
bool aIsBackfaceVisible, const wr::ColorF& aColor,
const WrAnimationProperty* aAnimation) {
wr::LayoutRect clip = MergeClipLeaf(aClip);
WRDL_LOG("PushRectWithAnimation b=%s cl=%s c=%s\n", mWrState,
Stringify(aBounds).c_str(), Stringify(clip).c_str(),
Stringify(aColor).c_str());

wr_dp_push_rect_with_animation(mWrState, aBounds, clip, aIsBackfaceVisible,
&mCurrentSpaceAndClipChain, aColor,
aAnimation);
}

void DisplayListBuilder::PushClearRect(const wr::LayoutRect& aBounds) {
wr::LayoutRect clip = MergeClipLeaf(aBounds);
WRDL_LOG("PushClearRect b=%s c=%s\n", mWrState, Stringify(aBounds).c_str(),
Expand Down
7 changes: 1 addition & 6 deletions gfx/webrender_bindings/WebRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class TransactionBuilder final {

void UpdateDynamicProperties(
const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
const nsTArray<wr::WrTransformProperty>& aTransformArray,
const nsTArray<wr::WrColorProperty>& aColorArray);
const nsTArray<wr::WrTransformProperty>& aTransformArray);

void SetDocumentView(const LayoutDeviceIntRect& aDocRect);

Expand Down Expand Up @@ -463,10 +462,6 @@ class DisplayListBuilder final {

void PushRect(const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
bool aIsBackfaceVisible, const wr::ColorF& aColor);
void PushRectWithAnimation(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
bool aIsBackfaceVisible, const wr::ColorF& aColor,
const WrAnimationProperty* aAnimation);
void PushRoundedRect(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip, bool aIsBackfaceVisible,
const wr::ColorF& aColor);
Expand Down
8 changes: 0 additions & 8 deletions gfx/webrender_bindings/WebRenderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,6 @@ static inline wr::WrOpacityProperty ToWrOpacityProperty(uint64_t id,
return prop;
}

static inline wr::WrColorProperty ToWrColorProperty(uint64_t id,
const gfx::Color& color) {
wr::WrColorProperty prop;
prop.id = id;
prop.color = ToColorF(color);
return prop;
}

// Whenever possible, use wr::ExternalImageId instead of manipulating uint64_t.
inline uint64_t AsUint64(const ExternalImageId& aId) {
return static_cast<uint64_t>(aId._0);
Expand Down
98 changes: 11 additions & 87 deletions gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,9 @@ pub struct WrFilterData {
}

#[repr(u32)]
#[derive(Debug)]
pub enum WrAnimationType {
Transform = 0,
Opacity = 1,
BackgroundColor = 2,
}

#[repr(C)]
Expand All @@ -461,13 +459,6 @@ pub struct WrOpacityProperty {
pub opacity: f32,
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct WrColorProperty {
pub id: u64,
pub color: ColorF,
}

/// cbindgen:field-names=[mHandle]
/// cbindgen:derive-lt=true
/// cbindgen:derive-lte=true
Expand Down Expand Up @@ -1714,13 +1705,10 @@ pub extern "C" fn wr_transaction_update_dynamic_properties(
opacity_count: usize,
transform_array: *const WrTransformProperty,
transform_count: usize,
color_array: *const WrColorProperty,
color_count: usize,
) {
let mut properties = DynamicProperties {
transforms: Vec::with_capacity(transform_count),
floats: Vec::with_capacity(opacity_count),
colors: Vec::with_capacity(color_count),
};

if transform_count > 0 {
Expand Down Expand Up @@ -1750,19 +1738,6 @@ pub extern "C" fn wr_transaction_update_dynamic_properties(
}
}

if color_count > 0 {
let color_slice = unsafe { make_slice(color_array, color_count) };

properties.colors.reserve(color_slice.len());
for element in color_slice.iter() {
let prop = PropertyValue {
key: PropertyBindingKey::new(element.id),
value: element.color,
};
properties.colors.push(prop);
}
}

txn.update_dynamic_properties(properties);
}

Expand Down Expand Up @@ -2406,7 +2381,6 @@ pub extern "C" fn wr_dp_push_stacking_context(
// Same as above opacity case.
transform_ref.cloned().unwrap_or(LayoutTransform::identity())));
},
_ => unreachable!("{:?} should not create a stacking context", anim.effect_type),
}
}

Expand Down Expand Up @@ -2639,17 +2613,19 @@ fn prim_flags(
}
}

fn common_item_properties_for_rect(
state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
is_backface_visible: bool,
parent: &WrSpaceAndClipChain
) -> CommonItemProperties {
#[no_mangle]
pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
is_backface_visible: bool,
parent: &WrSpaceAndClipChain,
color: ColorF) {
debug_assert!(unsafe { !is_in_render_thread() });

let space_and_clip = parent.to_webrender(state.pipeline_id);
let clip_rect = clip.intersection(&rect);

CommonItemProperties {
let prim_info = CommonItemProperties {
// NB: the damp-e10s talos-test will frequently crash on startup if we
// early-return here for empty rects. I couldn't figure out why, but
// it's pretty harmless to feed these through, so, uh, we do?
Expand All @@ -2659,66 +2635,14 @@ fn common_item_properties_for_rect(
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
item_key: state.current_item_key,
}
}

#[no_mangle]
pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
is_backface_visible: bool,
parent: &WrSpaceAndClipChain,
color: ColorF) {
debug_assert!(unsafe { !is_in_render_thread() });

let prim_info = common_item_properties_for_rect(
state,
rect,
clip,
is_backface_visible,
parent,
);
};

state.frame_builder.dl_builder.push_rect(
&prim_info,
color,
);
}

#[no_mangle]
pub extern "C" fn wr_dp_push_rect_with_animation(
state: &mut WrState,
rect: LayoutRect,
clip: LayoutRect,
is_backface_visible: bool,
parent: &WrSpaceAndClipChain,
color: ColorF,
animation: *const WrAnimationProperty) {
debug_assert!(unsafe { !is_in_render_thread() });

let prim_info = common_item_properties_for_rect(
state,
rect,
clip,
is_backface_visible,
parent,
);

let anim = unsafe { animation.as_ref() };
if let Some(anim) = anim {
debug_assert!(anim.id > 0);
match anim.effect_type {
WrAnimationType::BackgroundColor => {
state.frame_builder.dl_builder.push_rect_with_animation(
&prim_info,
PropertyBinding::Binding(PropertyBindingKey::new(anim.id), color),
)
},
_ => unreachable!("Didn't expect {:?} animation", anim.effect_type),
}
}
}

#[no_mangle]
pub extern "C" fn wr_dp_push_rect_with_parent_clip(
state: &mut WrState,
Expand Down
5 changes: 2 additions & 3 deletions gfx/wr/webrender/src/box_shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use api::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, PrimitiveKeyKind};
use api::PropertyBinding;
use api::MAX_BLUR_RADIUS;
use api::units::*;
use crate::clip::{ClipItemKey, ClipItemKeyKind};
Expand Down Expand Up @@ -164,7 +163,7 @@ impl<'a> SceneBuilder<'a> {
&LayoutPrimitiveInfo::with_clip_rect(final_prim_rect, prim_info.clip_rect),
clips,
PrimitiveKeyKind::Rectangle {
color: PropertyBinding::Value(color.into()),
color: color.into(),
},
);
} else {
Expand All @@ -190,7 +189,7 @@ impl<'a> SceneBuilder<'a> {
// Draw the box-shadow as a solid rect, using a box-shadow
// clip mask item.
let prim = PrimitiveKeyKind::Rectangle {
color: PropertyBinding::Value(color.into()),
color: color.into(),
};

// Create the box-shadow clip item.
Expand Down
Loading

0 comments on commit a6ca419

Please sign in to comment.