Bug 1386162 - Implement nsDisplayClearBackground using push_clear_rect. r?kats
MozReview-Commit-ID: DlGA7KuZzm0
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -921,16 +921,24 @@ DisplayListBuilder::PushRect(const wr::L
WRDL_LOG("PushRect b=%s cl=%s c=%s\n", mWrState,
Stringify(aBounds).c_str(),
Stringify(aClip).c_str(),
Stringify(aColor).c_str());
wr_dp_push_rect(mWrState, aBounds, aClip, aIsBackfaceVisible, aColor);
}
void
+DisplayListBuilder::PushClearRect(const wr::LayoutRect& aBounds)
+{
+ WRDL_LOG("PushClearRect b=%s\n", mWrState,
+ Stringify(aBounds).c_str());
+ wr_dp_push_clear_rect(mWrState, aBounds);
+}
+
+void
DisplayListBuilder::PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
bool aIsBackfaceVisible,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -263,16 +263,18 @@ public:
const wr::WrClipId* aClipId);
void PopClipAndScrollInfo();
void PushRect(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
bool aIsBackfaceVisible,
const wr::ColorF& aColor);
+ void PushClearRect(const wr::LayoutRect& aBounds);
+
void PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
bool aIsBackfaceVisible,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1382,16 +1382,25 @@ pub extern "C" fn wr_dp_push_rect(state:
let mut prim_info = LayoutPrimitiveInfo::with_clip_rect(rect, clip.into());
prim_info.is_backface_visible = is_backface_visible;
state.frame_builder.dl_builder.push_rect(&prim_info,
color);
}
#[no_mangle]
+pub extern "C" fn wr_dp_push_clear_rect(state: &mut WrState,
+ rect: LayoutRect) {
+ debug_assert!(unsafe { !is_in_render_thread() });
+
+ let prim_info = LayoutPrimitiveInfo::new(rect);
+ state.frame_builder.dl_builder.push_clear_rect(&prim_info);
+}
+
+#[no_mangle]
pub extern "C" fn wr_dp_push_image(state: &mut WrState,
bounds: LayoutRect,
clip: LayoutRect,
is_backface_visible: bool,
stretch_size: LayoutSize,
tile_spacing: LayoutSize,
image_rendering: ImageRendering,
key: WrImageKey) {
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1139,16 +1139,21 @@ void wr_dp_push_box_shadow(WrState *aSta
ColorF aColor,
float aBlurRadius,
float aSpreadRadius,
BorderRadius aBorderRadius,
BoxShadowClipMode aClipMode)
WR_FUNC;
WR_INLINE
+void wr_dp_push_clear_rect(WrState *aState,
+ LayoutRect aRect)
+WR_FUNC;
+
+WR_INLINE
void wr_dp_push_clip(WrState *aState,
uint64_t aClipId)
WR_FUNC;
WR_INLINE
void wr_dp_push_clip_and_scroll_info(WrState *aState,
uint64_t aScrollId,
const uint64_t *aClipId)
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4658,16 +4658,32 @@ nsDisplayClearBackground::BuildLayer(nsD
bool snap;
nsRect bounds = GetBounds(aBuilder, &snap);
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
layer->SetBounds(bounds.ToNearestPixels(appUnitsPerDevPixel)); // XXX Do we need to respect the parent layer's scale here?
return layer.forget();
}
+bool
+nsDisplayClearBackground::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ mozilla::wr::IpcResourceUpdateQueue& aResources,
+ const StackingContextHelper& aSc,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder)
+{
+ LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
+ nsRect(ToReferenceFrame(), mFrame->GetSize()),
+ mFrame->PresContext()->AppUnitsPerDevPixel());
+
+ aBuilder.PushClearRect(aSc.ToRelativeLayoutRect(bounds));
+
+ return true;
+}
+
nsRect
nsDisplayOutline::GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const
{
*aSnap = false;
return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
}
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -4099,16 +4099,22 @@ public:
{
return mozilla::LAYER_ACTIVE_FORCE;
}
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
+ bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ mozilla::wr::IpcResourceUpdateQueue& aResources,
+ const StackingContextHelper& aSc,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder) override;
+
NS_DISPLAY_DECL_NAME("ClearBackground", TYPE_CLEAR_BACKGROUND)
};
/**
* The standard display item to paint the outer CSS box-shadows of a frame.
*/
class nsDisplayBoxShadowOuter final : public nsDisplayItem {
public: