Bug 1379628 - Ensure pixels for Android dynamic toolbar snapshot get processed even if the toolbar is not visible so pending animations may run r=kats
authorRandall Barker <rbarker@mozilla.com>
Wed, 12 Jul 2017 12:54:59 -0700
changeset 368602 e6e712904806da25a9c8f48ea4533abe7c6ea8f4
parent 368601 1023371e0802e3a22cfac58f1f7f3968a6112cfe
child 368603 48f19f8bc8ba126fd28b8f3e90bd25610814fc09
push id92507
push userrbarker@mozilla.com
push dateThu, 13 Jul 2017 01:54:12 +0000
treeherdermozilla-inbound@e6e712904806 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1379628
milestone56.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 1379628 - Ensure pixels for Android dynamic toolbar snapshot get processed even if the toolbar is not visible so pending animations may run r=kats MozReview-Commit-ID: 9iMFN2gdfKl
gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
gfx/layers/apz/src/AndroidDynamicToolbarAnimator.h
gfx/layers/composite/LayerManagerComposite.cpp
--- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
+++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
@@ -494,23 +494,23 @@ AndroidDynamicToolbarAnimator::NotifyLay
 void
 AndroidDynamicToolbarAnimator::AdoptToolbarPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   mCompositorToolbarPixels = Some(Move(aMem));
   mCompositorToolbarPixelsSize = aSize;
 }
 
-Effect*
-AndroidDynamicToolbarAnimator::GetToolbarEffect(CompositorOGL* gl)
+void
+AndroidDynamicToolbarAnimator::UpdateToolbarSnapshotTexture(CompositorOGL* gl)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   // if the compositor has shutdown, do not create any new rendering objects.
   if (mCompositorShutdown) {
-    return nullptr;
+    return;
   }
 
   if (mCompositorToolbarPixels) {
     RefPtr<DataSourceSurface> surface = Factory::CreateWrappingDataSourceSurface(
         mCompositorToolbarPixels.ref().get<uint8_t>(),
         mCompositorToolbarPixelsSize.width * 4,
         IntSize(mCompositorToolbarPixelsSize.width, mCompositorToolbarPixelsSize.height),
         gfx::SurfaceFormat::B8G8R8A8);
@@ -530,16 +530,26 @@ AndroidDynamicToolbarAnimator::GetToolba
     mCompositorToolbarPixels.reset();
     // Send notification that texture is ready after the current composition has completed.
     if (mCompositorToolbarTexture && mCompositorSendResponseForSnapshotUpdate) {
       mCompositorSendResponseForSnapshotUpdate = false;
       CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod("AndroidDynamicToolbarAnimator::PostToolbarReady",
                                                                  this, &AndroidDynamicToolbarAnimator::PostToolbarReady));
     }
   }
+}
+
+Effect*
+AndroidDynamicToolbarAnimator::GetToolbarEffect()
+{
+  MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
+  // if the compositor has shutdown, do not create any new rendering objects.
+  if (mCompositorShutdown) {
+    return nullptr;
+  }
 
   if (mCompositorToolbarTexture) {
     if (!mCompositorToolbarEffect) {
       mCompositorToolbarEffect = new EffectRGB(mCompositorToolbarTexture, true, SamplingFilter::LINEAR);
     }
 
     float ratioVisible = (float)mCompositorToolbarHeight / (float)mCompositorMaxToolbarHeight;
     mCompositorToolbarEffect->mTextureCoords.y = 1.0f - ratioVisible;
--- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.h
+++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.h
@@ -99,18 +99,21 @@ public:
   // be notified when the layer tree  has been updated. Enabled currently by robocop tests.
   void EnableLayersUpdateNotifications(bool aEnable);
   // Called when a layer has been updated so the UI thread may be notified if necessary.
   void NotifyLayersUpdated();
   // Adopts the Shmem containing the toolbar snapshot sent from the UI thread.
   // The AndroidDynamicToolbarAnimator is responsible for deallocating the Shmem when
   // it is done being used.
   void AdoptToolbarPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize);
+  // Updates the toolbar snapshot texture and notifies the UI thread that the static toolbar is
+  // now ready to be displayed.
+  void UpdateToolbarSnapshotTexture(CompositorOGL* gl);
   // Returns the Effect object used by the compositor to render the toolbar snapshot.
-  Effect* GetToolbarEffect(CompositorOGL* gl);
+  Effect* GetToolbarEffect();
   void Shutdown();
 
 protected:
   enum StaticToolbarState {
     eToolbarVisible,
     eToolbarUpdated,
     eToolbarUnlocked,
     eToolbarAnimating
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -1184,23 +1184,26 @@ LayerManagerComposite::RenderToolbar()
   if (mCompositor->GetTargetContext() != nullptr) {
     return;
   }
 
   if (CompositorBridgeParent* bridge = mCompositor->GetCompositorBridgeParent()) {
     AndroidDynamicToolbarAnimator* animator = bridge->GetAPZCTreeManager()->GetAndroidDynamicToolbarAnimator();
     MOZ_RELEASE_ASSERT(animator);
 
+    animator->UpdateToolbarSnapshotTexture(mCompositor->AsCompositorOGL());
+
     int32_t toolbarHeight = animator->GetCurrentToolbarHeight();
     if (toolbarHeight == 0) {
       return;
     }
 
     EffectChain effects;
-    effects.mPrimaryEffect = animator->GetToolbarEffect(mCompositor->AsCompositorOGL());
+    effects.mPrimaryEffect = animator->GetToolbarEffect();
+
     // If GetToolbarEffect returns null, nothing is rendered for the static snapshot of the toolbar.
     // If the real toolbar chrome is not covering this portion of the surface, the clear color
     // of the surface will be visible. On Android the clear color is the background color of the page.
     if (effects.mPrimaryEffect) {
       ScopedCompositorRenderOffset toolbarOffset(mCompositor->AsCompositorOGL(),
                                                  ScreenPoint(0.0f, -animator->GetCurrentContentOffset()));
       mCompositor->DrawQuad(gfx::Rect(0, 0, mRenderBounds.width, toolbarHeight),
                             IntRect(0, 0, mRenderBounds.width, toolbarHeight), effects, 1.0, gfx::Matrix4x4());