--- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
+++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp
@@ -9,16 +9,20 @@
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/UiCompositorControllerParent.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/Move.h"
#include "mozilla/Unused.h"
+#include <android/log.h>
+#define RLOG(format, ...) __android_log_print(ANDROID_LOG_INFO, "reb", format, ##__VA_ARGS__);
+#define RLINE RLOG("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__)
+
namespace {
//
// NOTE: These values are also defined in mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
// and must be kept in sync. Any new message added here must also be added there to the AnimatorMessageType enum.
//
static const int32_t STATIC_TOOLBAR_NEEDS_UPDATE = 0; // Sent from compositor when the static toolbar wants to hide.
static const int32_t STATIC_TOOLBAR_READY = 1; // Sent from compositor when the static toolbar image has been updated and is ready to animate.
static const int32_t TOOLBAR_HIDDEN = 2; // Sent to compositor when the real toolbar has been hidden.
@@ -205,44 +209,50 @@ AndroidDynamicToolbarAnimator::ToolbarAn
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
switch(aMessage) {
case STATIC_TOOLBAR_NEEDS_UPDATE:
break;
case STATIC_TOOLBAR_READY:
break;
case TOOLBAR_HIDDEN:
+RLOG("Compositor: TOOLBAR_HIDDEN");
// If the toolbar is animating, then it is already unlocked.
if (mToolbarState != ToolbarAnimating) {
mToolbarState = ToolbarUnlocked;
if (mCompositorAnimationDeferred) {
StartCompositorAnimation(mCompositorAnimationDirection, mCompositorAnimationImmediate, mCompositorToolbarHeight);
}
} else {
// The compositor is already animating the toolbar so no need to defer.
mCompositorAnimationDeferred = false;
}
break;
case TOOLBAR_VISIBLE:
+RLOG("Compositor: TOOLBAR_VISIBLE");
mToolbarState = ToolbarVisible;
break;
case TOOLBAR_SHOW:
break;
case FIRST_PAINT:
break;
case REQUEST_SHOW_TOOLBAR_IMMEDIATELY:
+RLOG("Compositor: REQUEST_SHOW_TOOLBAR_IMMEDIATELY");
NotifyControllerPendingAnimation(MOVE_TOOLBAR_DOWN, VISIBLE_IMMEDIATE);
break;
case REQUEST_SHOW_TOOLBAR_ANIMATED:
+RLOG("Compositor: REQUEST_SHOW_TOOLBAR_ANIMATED");
NotifyControllerPendingAnimation(MOVE_TOOLBAR_DOWN, VISIBLE_ANIMATE);
break;
case REQUEST_HIDE_TOOLBAR_IMMEDIATELY:
+RLOG("Compositor: REQUEST_HIDE_TOOLBAR_IMMEDIATELY");
NotifyControllerPendingAnimation(MOVE_TOOLBAR_UP, VISIBLE_IMMEDIATE);
break;
case REQUEST_HIDE_TOOLBAR_ANIMATED:
+RLOG("Compositor: REQUEST_HIDE_TOOLBAR_ANIMATED");
NotifyControllerPendingAnimation(MOVE_TOOLBAR_UP, VISIBLE_ANIMATE);
break;
default:
break;
}
}
bool
@@ -489,43 +499,48 @@ AndroidDynamicToolbarAnimator::HandleTou
mControllerPreviousTouch = 0;
mControllerTotalDistance = 0;
mControllerDragThresholdReached = false;
mControllerLastEventTimeStamp = 0;
// Received a UI thread request to show or hide the snap shot during a touch.
// This overrides the touch event so just return
if (mControllerCancelTouchTracking) {
+RLOG("Got show request during a touch event.");
mControllerCancelTouchTracking = false;
return;
}
// Don't animate up if not scrolling root content.
if (!isRoot &&
((direction == MOVE_TOOLBAR_UP) && (mControllerToolbarHeight == mControllerMaxToolbarHeight))) {
+RLOG("Not scrolling root content. Make visible");
ShowToolbarIfNotVisible(aCurrentToolbarState);
return;
}
// The page is either too small or too close to the end to animate
if (!CanHideToolbar(direction)) {
if (mControllerToolbarHeight == mControllerMaxToolbarHeight) {
+RLOG("Can not hide toolbar. Make visible");
ShowToolbarIfNotVisible(aCurrentToolbarState);
return;
} else if (mControllerToolbarHeight != 0) {
+RLOG("Can not hide toolbar. But partial scrolled. Move it Down.");
// The snapshot is partially visible but there is not enough page
// to hide the snapshot so make it visible by moving it down
direction = MOVE_TOOLBAR_DOWN;
}
}
// This makes sure the snapshot is not left partially visible at the end of a touch.
if ((aCurrentToolbarState != ToolbarAnimating) && dragThresholdReached) {
if (((direction == MOVE_TOOLBAR_DOWN) && (mControllerToolbarHeight != mControllerMaxToolbarHeight)) ||
((direction == MOVE_TOOLBAR_UP) && (mControllerToolbarHeight != 0))) {
+RLOG("Animate the toolbar after touch end: %s",(direction == MOVE_TOOLBAR_DOWN?"DOWN":"UP"));
StartCompositorAnimation(direction, VISIBLE_ANIMATE, mControllerToolbarHeight);
}
}
}
void
AndroidDynamicToolbarAnimator::PostMessage(int32_t aMessage) {
RefPtr<UiCompositorControllerParent> uiController = UiCompositorControllerParent::GetFromRootLayerTreeId(mRootLayerTreeId);
@@ -587,21 +602,24 @@ AndroidDynamicToolbarAnimator::UpdateFix
void
AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation(int32_t aDirection, bool aImmediate)
{
if (!APZThreadUtils::IsControllerThread()) {
APZThreadUtils::RunOnControllerThread(NewRunnableMethod<int32_t,bool>(this, &AndroidDynamicToolbarAnimator::NotifyControllerPendingAnimation, aDirection, aImmediate));
return;
}
+RLOG("StartCompositorAnimation %s %s height=%d",(aDirection == MOVE_TOOLBAR_UP ? "UP" : "DOWN"),(aImmediate ? "IMMEDIATE":"ANIMATE"),mControllerToolbarHeight);
+
mControllerCancelTouchTracking = true;
// If the toolbar is already where it needs to be, just abort the request.
if (((mControllerToolbarHeight == mControllerMaxToolbarHeight) && (aDirection == MOVE_TOOLBAR_DOWN)) ||
((mControllerToolbarHeight == 0) && (aDirection == MOVE_TOOLBAR_UP))) {
+RLOG("ABORT PENDING ANIMATION");
// We received a show request but the real toolbar is hidden, so tell it to show now.
if ((aDirection == MOVE_TOOLBAR_DOWN) && (mToolbarState == ToolbarUnlocked)) {
PostMessage(TOOLBAR_SHOW);
}
return;
}
// NOTE: StartCompositorAnimation will set mControllerState to AnimationStartPending
@@ -770,16 +788,26 @@ AndroidDynamicToolbarAnimator::FrameMetr
{
if (!FuzzyEqualsMultiplicative(aScrollOffset.x, mScrollOffset.x) ||
!FuzzyEqualsMultiplicative(aScrollOffset.y, mScrollOffset.y) ||
!FuzzyEqualsMultiplicative(aScale.scale, mScale.scale) ||
!FuzzyEqualsMultiplicative(aCssPageRect.width, aCssPageRect.width) ||
!FuzzyEqualsMultiplicative(aCssPageRect.height, aCssPageRect.height) ||
!FuzzyEqualsMultiplicative(aCssPageRect.x, aCssPageRect.x) ||
!FuzzyEqualsMultiplicative(aCssPageRect.y, aCssPageRect.y)) {
+
+RLOG("scrollX=%s scrollY=%s scale=%s width=%s height=%s x=%s y=%s",
+(!FuzzyEqualsMultiplicative(aScrollOffset.x, mScrollOffset.x) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aScrollOffset.y, mScrollOffset.y) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aScale.scale, mScale.scale) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aCssPageRect.width, aCssPageRect.width) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aCssPageRect.height, aCssPageRect.height) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aCssPageRect.x, aCssPageRect.x) ? "YES":"NO"),
+(!FuzzyEqualsMultiplicative(aCssPageRect.y, aCssPageRect.y) ? "YES":"NO"));
+
mScrollOffset = aScrollOffset;
mScale = aScale;
mCssPageRect = aCssPageRect;
mPageRect = mCssPageRect * mScale;
return true;
}
return false;