Bug 1486962 - Ensure frame is associated with background images with WebRender. r=mstange
authorAndrew Osmond <aosmond@mozilla.com>
Thu, 30 Aug 2018 18:19:59 -0400
changeset 482456 c5c7d67c2b5b43e08c08e4d592112b4be81af76e
parent 482455 f2b2045a17cee9ed5d7a1dee39afb5062f359a4e
child 482457 3cf0bec611e10d70c41dcd8548559e7f77e2d65c
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
Bug 1486962 - Ensure frame is associated with background images with WebRender. r=mstange The frame for a background image should be associated with the image request. This was done on the non-WebRender path in nsCSSRendering::PaintStyleImageLayerWithSC but otherwise missing for the WebRender path. This is important because the association is what allows the FRAME_UPDATE from imagelib to cause a repaint. Without it, it will manifest as incomplete or missing background images, in particular after the background image SourceSurface has been released to save memory.
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -2921,16 +2921,22 @@ nsCSSRendering::BuildWebRenderDisplayIte
   ImgDrawResult result = ImgDrawResult::SUCCESS;
   nsBackgroundLayerState state =
     PrepareImageLayer(&aParams.presCtx, aParams.frame,
                       aParams.paintFlags, paintBorderArea,
                       clipState.mBGClipArea, layer, nullptr);
   result &= state.mImageRenderer.PrepareResult();
+  // Ensure we get invalidated for loads and animations of the image.
+  // We need to do this here because this might be the only code that
+  // knows about the association of the style data with the frame.
+  aParams.frame->AssociateImage(layer.mImage, &aParams.presCtx, 0);
   if (!state.mFillArea.IsEmpty()) {
     return state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx,
                                      aBuilder, aResources, aSc,
                                      aManager, aItem,
                                      state.mDestArea, state.mFillArea,
                                      state.mAnchor + paintBorderArea.TopLeft(),
                                      state.mRepeatSize, aParams.opacity);