Bug 1498699 - Move the FIRST_PAINT notification from AndroidDynamicToolbarAnimator to UiCompositorControllerParent. r=jnicol
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 15 Oct 2018 13:20:27 +0000
changeset 489644 da505775320b6d209ecac91e25d018b7b7197894
parent 489643 dcd095eb89108d1171c25b9d32ca01a6d317087f
child 489645 8866a66f76593da837ea35dc27ebf5e289735c7f
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjnicol
bugs1498699
milestone64.0a1
Bug 1498699 - Move the FIRST_PAINT notification from AndroidDynamicToolbarAnimator to UiCompositorControllerParent. r=jnicol Depends on D8657 Differential Revision: https://phabricator.services.mozilla.com/D8658
gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/ipc/UiCompositorControllerParent.cpp
gfx/layers/ipc/UiCompositorControllerParent.h
--- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
+++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
@@ -437,17 +437,16 @@ AndroidDynamicToolbarAnimator::UpdateAni
   return continueAnimating;
 }
 
 void
 AndroidDynamicToolbarAnimator::FirstPaint()
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   mCompositorReceivedFirstPaint = true;
-  PostMessage(FIRST_PAINT);
 }
 
 void
 AndroidDynamicToolbarAnimator::UpdateRootFrameMetrics(const FrameMetrics& aMetrics)
 {
   CSSToScreenScale scale = ViewTargetAs<ScreenPixel>(aMetrics.GetZoom().ToScaleFactor(),
                                                      PixelCastJustification::ScreenIsParentLayerForRoot);
   ScreenPoint scrollOffset = aMetrics.GetScrollOffset() * scale;
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -1015,16 +1015,20 @@ AsyncCompositionManager::ApplyAsyncConte
                 mRootScrollableId = metrics.GetScrollId();
                 Compositor* compositor = mLayerManager->GetCompositor();
                 if (CompositorBridgeParent* bridge = compositor->GetCompositorBridgeParent()) {
                   AndroidDynamicToolbarAnimator* animator = bridge->GetAndroidDynamicToolbarAnimator();
                   MOZ_ASSERT(animator);
                   if (mIsFirstPaint) {
                     animator->UpdateRootFrameMetrics(metrics);
                     animator->FirstPaint();
+                    LayersId rootLayerTreeId = bridge->RootLayerTreeId();
+                    if (RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(rootLayerTreeId)) {
+                      uiController->NotifyFirstPaint();
+                    }
                     mIsFirstPaint = false;
                   }
                   if (mLayersUpdated) {
                     LayersId rootLayerTreeId = bridge->RootLayerTreeId();
                     if (RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(rootLayerTreeId)) {
                       uiController->NotifyLayersUpdated();
                     }
                     mLayersUpdated = false;
--- a/gfx/layers/ipc/UiCompositorControllerParent.cpp
+++ b/gfx/layers/ipc/UiCompositorControllerParent.cpp
@@ -241,16 +241,23 @@ UiCompositorControllerParent::NotifyLaye
 {
 #ifdef MOZ_WIDGET_ANDROID
   if (mCompositorLayersUpdateEnabled) {
     ToolbarAnimatorMessageFromCompositor(LAYERS_UPDATED);
   }
 #endif
 }
 
+void
+UiCompositorControllerParent::NotifyFirstPaint()
+{
+  ToolbarAnimatorMessageFromCompositor(FIRST_PAINT);
+}
+
+
 UiCompositorControllerParent::UiCompositorControllerParent(const LayersId& aRootLayerTreeId)
   : mRootLayerTreeId(aRootLayerTreeId)
 #ifdef MOZ_WIDGET_ANDROID
   , mCompositorLayersUpdateEnabled(false)
 #endif
   , mMaxToolbarHeight(0)
 {
   MOZ_COUNT_CTOR(UiCompositorControllerParent);
--- a/gfx/layers/ipc/UiCompositorControllerParent.h
+++ b/gfx/layers/ipc/UiCompositorControllerParent.h
@@ -46,16 +46,17 @@ public:
 #if defined(MOZ_WIDGET_ANDROID)
   void RegisterAndroidDynamicToolbarAnimator(AndroidDynamicToolbarAnimator* aAnimator);
 #endif // MOZ_WIDGET_ANDROID
   void ToolbarAnimatorMessageFromCompositor(int32_t aMessage);
   bool AllocPixelBuffer(const int32_t aSize, Shmem* aMem);
 
   // Called when a layer has been updated so the UI thread may be notified if necessary.
   void NotifyLayersUpdated();
+  void NotifyFirstPaint();
 
 private:
   explicit UiCompositorControllerParent(const LayersId& aRootLayerTreeId);
   ~UiCompositorControllerParent();
   void InitializeForSameProcess();
   void InitializeForOutOfProcess();
   void Initialize();
   void Open(Endpoint<PUiCompositorControllerParent>&& aEndpoint);