Bug 1021085 - Fix up the Fennec code path as well. r=Cwiiis

This commit is contained in:
Kartikaya Gupta 2014-06-23 08:42:53 -04:00
parent 2fd9c31921
commit e1ac0ad31b
9 changed files with 44 additions and 76 deletions

View File

@ -615,11 +615,9 @@ ClientLayerManager::GetBackendName(nsAString& aName)
bool
ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
ParentLayerRect& aCompositionBounds,
CSSToParentLayerScale& aZoom,
FrameMetrics& aMetrics,
bool aDrawingCritical)
{
aZoom.scale = 1.0;
#ifdef MOZ_WIDGET_ANDROID
Layer* primaryScrollable = GetPrimaryScrollableLayer();
if (primaryScrollable) {
@ -633,9 +631,14 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
metrics.mCriticalDisplayPort : metrics.mDisplayPort;
LayerRect displayPort = (metricsDisplayPort + metrics.GetScrollOffset()) * paintScale;
return AndroidBridge::Bridge()->ProgressiveUpdateCallback(
ScreenPoint scrollOffset;
CSSToScreenScale zoom;
bool ret = AndroidBridge::Bridge()->ProgressiveUpdateCallback(
aHasPendingNewThebesContent, displayPort, paintScale.scale, aDrawingCritical,
aCompositionBounds, aZoom);
scrollOffset, zoom);
aMetrics.SetScrollOffset(scrollOffset / zoom);
aMetrics.SetZoom(zoom);
return ret;
}
#endif

View File

@ -143,9 +143,9 @@ public:
CompositorChild* GetCompositorChild();
/**
* Called for each iteration of a progressive tile update. Fills
* aCompositionBounds and aZoom with the current scale and composition bounds
* being used to composite the layers in this manager, to determine what area
* Called for each iteration of a progressive tile update. Updates
* aMetrics with the current scroll offset and scale being used to composite
* the primary scrollable layer in this manager, to determine what area
* intersects with the target composition bounds.
* aDrawingCritical will be true if the current drawing operation is using
* the critical displayport.
@ -155,8 +155,7 @@ public:
* true.
*/
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
ParentLayerRect& aCompositionBounds,
CSSToParentLayerScale& aZoom,
FrameMetrics& aMetrics,
bool aDrawingCritical);
bool InConstruction() { return mPhase == PHASE_CONSTRUCTION; }

View File

@ -141,6 +141,21 @@ FuzzyEquals(float a, float b) {
return (fabsf(a - b) < 1e-6);
}
static ViewTransform
ComputeViewTransform(const FrameMetrics& aContentMetrics, const FrameMetrics& aCompositorMetrics)
{
// This is basically the same code as AsyncPanZoomController::GetCurrentAsyncTransform
// but with aContentMetrics used in place of mLastContentPaintMetrics, because they
// should be equivalent, modulo race conditions while transactions are inflight.
LayerPoint translation = (aCompositorMetrics.GetScrollOffset() - aContentMetrics.GetScrollOffset())
* aContentMetrics.LayersPixelsPerCSSPixel();
return ViewTransform(-translation,
aCompositorMetrics.GetZoom()
/ aContentMetrics.mDevPixelsPerCSSPixel
/ aCompositorMetrics.GetParentResolution());
}
bool
SharedFrameMetricsHelper::UpdateFromCompositorFrameMetrics(
ContainerLayer* aLayer,
@ -214,22 +229,6 @@ SharedFrameMetricsHelper::UpdateFromCompositorFrameMetrics(
return false;
}
ViewTransform
SharedFrameMetricsHelper::ComputeViewTransform(const FrameMetrics& aContentMetrics,
const FrameMetrics& aCompositorMetrics)
{
// This is basically the same code as AsyncPanZoomController::GetCurrentAsyncTransform
// but with aContentMetrics used in place of mLastContentPaintMetrics, because they
// should be equivalent, modulo race conditions while transactions are inflight.
LayerPoint translation = (aCompositorMetrics.GetScrollOffset() - aContentMetrics.GetScrollOffset())
* aContentMetrics.LayersPixelsPerCSSPixel();
return ViewTransform(-translation,
aCompositorMetrics.GetZoom()
/ aContentMetrics.mDevPixelsPerCSSPixel
/ aCompositorMetrics.GetParentResolution());
}
bool
SharedFrameMetricsHelper::AboutToCheckerboard(const FrameMetrics& aContentMetrics,
const FrameMetrics& aCompositorMetrics)
@ -1015,9 +1014,17 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval
// caused by there being an incoming, more relevant paint.
ViewTransform viewTransform;
#if defined(MOZ_WIDGET_ANDROID)
bool abortPaint = mManager->ProgressiveUpdateCallback(!staleRegion.Contains(aInvalidRegion),
viewTransform,
!drawingLowPrecision);
FrameMetrics compositorMetrics = scrollAncestor->GetFrameMetrics();
bool abortPaint = false;
// On Android, only the primary scrollable layer is async-scrolled, and the only one
// that the Java-side code can provide details about. If we're tiling some other layer
// then we already have all the information we need about it.
if (scrollAncestor == mManager->GetPrimaryScrollableLayer()) {
abortPaint = mManager->ProgressiveUpdateCallback(!staleRegion.Contains(aInvalidRegion),
compositorMetrics,
!drawingLowPrecision);
viewTransform = ComputeViewTransform(scrollAncestor->GetFrameMetrics(), compositorMetrics);
}
#else
MOZ_ASSERT(mSharedFrameMetricsHelper);

View File

@ -326,13 +326,6 @@ public:
bool aLowPrecision,
ViewTransform& aViewTransform);
/**
* Compute the APZ's async transform given the content-side and
* compositor-side metrics for the layer.
*/
ViewTransform ComputeViewTransform(const FrameMetrics& aContentMetrics,
const FrameMetrics& aCompositorMetrics);
/**
* Determines if the compositor's upcoming composition bounds has fallen
* outside of the contents display port. If it has then the compositor

View File

@ -17,16 +17,12 @@ import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
public class ProgressiveUpdateData {
public float x;
public float y;
public float width;
public float height;
public float scale;
public boolean abort;
public void setViewport(ImmutableViewportMetrics viewport) {
this.x = viewport.viewportRectLeft;
this.y = viewport.viewportRectTop;
this.width = viewport.viewportRectRight - this.x;
this.height = viewport.viewportRectBottom - this.y;
this.scale = viewport.zoomFactor;
}
}

View File

@ -1951,7 +1951,8 @@ AndroidBridge::IsContentDocumentDisplayed()
}
bool
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, ParentLayerRect& aCompositionBounds, CSSToParentLayerScale& aZoom)
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution,
bool aDrawingCritical, ScreenPoint& aScrollOffset, CSSToScreenScale& aZoom)
{
mozilla::widget::android::GeckoLayerClient *client = mLayerClient;
if (!client) {
@ -1971,10 +1972,8 @@ AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const
ProgressiveUpdateData* progressiveUpdateData = ProgressiveUpdateData::Wrap(progressiveUpdateDataJObj);
aCompositionBounds.x = progressiveUpdateData->getx();
aCompositionBounds.y = progressiveUpdateData->gety();
aCompositionBounds.width = progressiveUpdateData->getwidth();
aCompositionBounds.height = progressiveUpdateData->getheight();
aScrollOffset.x = progressiveUpdateData->getx();
aScrollOffset.y = progressiveUpdateData->gety();
aZoom.scale = progressiveUpdateData->getscale();
bool ret = progressiveUpdateData->getabort();

View File

@ -200,7 +200,8 @@ public:
void ContentDocumentChanged();
bool IsContentDocumentDisplayed();
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, mozilla::ParentLayerRect& aCompositionBounds, mozilla::CSSToParentLayerScale& aZoom);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical,
mozilla::ScreenPoint& aScrollOffset, mozilla::CSSToScreenScale& aZoom);
void SetLayerClient(JNIEnv* env, jobject jobj);
mozilla::widget::android::GeckoLayerClient* GetLayerClient() { return mLayerClient; }

View File

@ -2031,9 +2031,7 @@ jclass ProgressiveUpdateData::mProgressiveUpdateDataClass = 0;
jmethodID ProgressiveUpdateData::jProgressiveUpdateData = 0;
jmethodID ProgressiveUpdateData::jsetViewport = 0;
jfieldID ProgressiveUpdateData::jabort = 0;
jfieldID ProgressiveUpdateData::jheight = 0;
jfieldID ProgressiveUpdateData::jscale = 0;
jfieldID ProgressiveUpdateData::jwidth = 0;
jfieldID ProgressiveUpdateData::jx = 0;
jfieldID ProgressiveUpdateData::jy = 0;
void ProgressiveUpdateData::InitStubs(JNIEnv *jEnv) {
@ -2043,9 +2041,7 @@ void ProgressiveUpdateData::InitStubs(JNIEnv *jEnv) {
jProgressiveUpdateData = getMethod("<init>", "()V");
jsetViewport = getMethod("setViewport", "(Lorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)V");
jabort = getField("abort", "Z");
jheight = getField("height", "F");
jscale = getField("scale", "F");
jwidth = getField("width", "F");
jx = getField("x", "F");
jy = getField("y", "F");
}
@ -2090,16 +2086,6 @@ void ProgressiveUpdateData::setabort(bool a0) {
env->SetBooleanField(wrapped_obj, jabort, a0);
}
jfloat ProgressiveUpdateData::getheight() {
JNIEnv *env = GetJNIForThread();
return env->GetFloatField(wrapped_obj, jheight);
}
void ProgressiveUpdateData::setheight(jfloat a0) {
JNIEnv *env = GetJNIForThread();
env->SetFloatField(wrapped_obj, jheight, a0);
}
jfloat ProgressiveUpdateData::getscale() {
JNIEnv *env = GetJNIForThread();
return env->GetFloatField(wrapped_obj, jscale);
@ -2110,16 +2096,6 @@ void ProgressiveUpdateData::setscale(jfloat a0) {
env->SetFloatField(wrapped_obj, jscale, a0);
}
jfloat ProgressiveUpdateData::getwidth() {
JNIEnv *env = GetJNIForThread();
return env->GetFloatField(wrapped_obj, jwidth);
}
void ProgressiveUpdateData::setwidth(jfloat a0) {
JNIEnv *env = GetJNIForThread();
env->SetFloatField(wrapped_obj, jwidth, a0);
}
jfloat ProgressiveUpdateData::getx() {
JNIEnv *env = GetJNIForThread();
return env->GetFloatField(wrapped_obj, jx);

View File

@ -380,12 +380,8 @@ public:
void setViewport(jobject a0);
bool getabort();
void setabort(bool a0);
jfloat getheight();
void setheight(jfloat a0);
jfloat getscale();
void setscale(jfloat a0);
jfloat getwidth();
void setwidth(jfloat a0);
jfloat getx();
void setx(jfloat a0);
jfloat gety();
@ -395,9 +391,7 @@ protected:
static jmethodID jProgressiveUpdateData;
static jmethodID jsetViewport;
static jfieldID jabort;
static jfieldID jheight;
static jfieldID jscale;
static jfieldID jwidth;
static jfieldID jx;
static jfieldID jy;
};