Bug 1342833 - WebRenderBridgeParent::ClearResources() does not clear DisplayList r=jrmuizel
authorsotaro <sotaro.ikeda.g@gmail.com>
Mon, 06 Mar 2017 10:42:17 +0900
changeset 397747 83bb36588e3a40d46ffff0cc4928488a4e22bcc3
parent 394778 aafcba25dee399d3390ea1fb4c2121e4e62b8b0d
child 397748 8a8e6c760d73aa03d9464043476c01803cbac6a4
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1342833
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1342833 - WebRenderBridgeParent::ClearResources() does not clear DisplayList r=jrmuizel
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -565,16 +565,20 @@ WebRenderBridgeParent::ScheduleCompositi
   if (mCompositorScheduler) {
     mCompositorScheduler->ScheduleComposition();
   }
 }
 
 void
 WebRenderBridgeParent::ClearResources()
 {
+  if (mApi) {
+    ++mWrEpoch; // Update webrender epoch
+    mApi->ClearRootDisplayList(wr::NewEpoch(mWrEpoch), mPipelineId);
+  }
   DeleteOldImages();
   if (mCompositableHolder) {
     for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
       uint64_t externalImageId = iter.Key();
       mCompositableHolder->RemoveExternalImageId(externalImageId);
     }
   }
   mExternalImageIds.Clear();
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -180,16 +180,23 @@ WebRenderAPI::SetRootDisplayList(gfx::Co
                                  dl_data,
                                  dl_size,
                                  aux_descriptor,
                                  aux_data,
                                  aux_size);
 }
 
 void
+WebRenderAPI::ClearRootDisplayList(Epoch aEpoch,
+                                   WrPipelineId pipeline_id)
+{
+  wr_api_clear_root_display_list(mWrApi, aEpoch, pipeline_id);
+}
+
+void
 WebRenderAPI::Readback(gfx::IntSize size,
                        uint8_t *buffer,
                        uint32_t buffer_size)
 {
     class Readback : public RendererEvent
     {
         public:
             explicit Readback(layers::SynchronousTask* aTask,
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -51,16 +51,19 @@ public:
                           WrPipelineId pipeline_id,
                           WrBuiltDisplayListDescriptor dl_descriptor,
                           uint8_t *dl_data,
                           size_t dl_size,
                           WrAuxiliaryListsDescriptor aux_descriptor,
                           uint8_t *aux_data,
                           size_t aux_size);
 
+  void ClearRootDisplayList(Epoch aEpoch,
+                            WrPipelineId pipeline_id);
+
   void SetRootPipeline(wr::PipelineId aPipeline);
 
   void AddImage(wr::ImageKey aKey,
                 const ImageDescriptor& aDescriptor,
                 Range<uint8_t> aBytes);
 
   void AddExternalImageHandle(ImageKey key,
                               gfx::IntSize aSize,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -254,16 +254,32 @@ pub unsafe extern fn wr_api_set_root_dis
     api.set_root_display_list(Some(root_background_color),
                               epoch,
                               LayoutSize::new(viewport_width, viewport_height),
                               (pipeline_id, dl, aux),
                               preserve_frame_state);
 }
 
 #[no_mangle]
+pub unsafe extern fn wr_api_clear_root_display_list(api: &mut RenderApi,
+                                                    epoch: Epoch,
+                                                    pipeline_id: PipelineId) {
+    let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);
+    let preserve_frame_state = true;
+    let frame_builder = WebRenderFrameBuilder::new(pipeline_id);
+
+    api.set_root_display_list(Some(root_background_color),
+                              epoch,
+                              LayoutSize::new(0.0, 0.0),
+                              frame_builder.dl_builder.finalize(),
+                              preserve_frame_state);
+}
+
+
+#[no_mangle]
 pub extern fn wr_api_generate_frame(api: &mut RenderApi) {
   api.generate_frame(None);
 }
 
 // Call MakeCurrent before this.
 #[no_mangle]
 pub extern fn wr_window_new(window_id: WrWindowId,
                             gl_context: *mut c_void,
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -472,16 +472,20 @@ wr_api_set_root_display_list(WrAPI* api,
                              uint8_t *dl_data,
                              size_t dl_size,
                              WrAuxiliaryListsDescriptor aux_descriptor,
                              uint8_t *aux_data,
                              size_t aux_size)
 WR_FUNC;
 
 WR_INLINE void
+wr_api_clear_root_display_list(WrAPI* api, WrEpoch epoch, WrPipelineId pipeline_id)
+WR_FUNC;
+
+WR_INLINE void
 wr_api_generate_frame(WrAPI* api)
 WR_FUNC;
 
 WR_INLINE void
 wr_api_send_external_event(WrAPI* api, uintptr_t evt)
 WR_DESTRUCTOR_SAFE_FUNC;
 
 WR_INLINE void