Bug 783368 - Send the correct display port when rendering low precision. r=kats,bgirard

When doing a low precision update, send the display-port instead of the
critical display port so that more appropriate cancelling decisions can be
made.
This commit is contained in:
Chris Lord 2012-11-21 22:34:19 +00:00
Родитель 17b0c18452
Коммит d85f10cccd
8 изменённых файлов: 41 добавлений и 28 удалений

Просмотреть файл

@ -1299,7 +1299,8 @@ bool
BasicShadowLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
gfx::Rect& aViewport,
float& aScaleX,
float& aScaleY)
float& aScaleY,
bool aDrawingCritical)
{
#ifdef MOZ_WIDGET_ANDROID
Layer* primaryScrollable = GetPrimaryScrollableLayer();
@ -1311,15 +1312,16 @@ BasicShadowLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesCont
const gfx3DMatrix& rootTransform = GetRoot()->GetTransform();
float devPixelRatioX = 1 / rootTransform.GetXScale();
float devPixelRatioY = 1 / rootTransform.GetYScale();
const gfx::Rect& metricsDisplayPort = metrics.mCriticalDisplayPort.IsEmpty() ?
metrics.mDisplayPort : metrics.mCriticalDisplayPort;
const gfx::Rect& metricsDisplayPort =
(aDrawingCritical && !metrics.mCriticalDisplayPort.IsEmpty()) ?
metrics.mCriticalDisplayPort : metrics.mDisplayPort;
gfx::Rect displayPort((metricsDisplayPort.x + metrics.mScrollOffset.x) * devPixelRatioX,
(metricsDisplayPort.y + metrics.mScrollOffset.y) * devPixelRatioY,
metricsDisplayPort.width * devPixelRatioX,
metricsDisplayPort.height * devPixelRatioY);
return AndroidBridge::Bridge()->ProgressiveUpdateCallback(
aHasPendingNewThebesContent, displayPort, devPixelRatioX,
aHasPendingNewThebesContent, displayPort, devPixelRatioX, aDrawingCritical,
aViewport, aScaleX, aScaleY);
}
#endif

Просмотреть файл

@ -284,7 +284,8 @@ public:
* Called for each iteration of a progressive tile update. Fills
* aViewport, aScaleX and aScaleY with the current scale and viewport
* being used to composite the layers in this manager, to determine what area
* intersects with the target render rectangle.
* intersects with the target render rectangle. aDrawingCritical will be
* true if the current drawing operation is using the critical displayport.
* Returns true if the update should continue, or false if it should be
* cancelled.
* This is only called if gfxPlatform::UseProgressiveTilePainting() returns
@ -293,7 +294,8 @@ public:
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
gfx::Rect& aViewport,
float& aScaleX,
float& aScaleY);
float& aScaleY,
bool aDrawingCritical);
private:
/**

Просмотреть файл

@ -278,7 +278,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
// If this is a low precision buffer, we force progressive updates. The
// assumption is that the contents is less important, so visual coherency
// is lower priority than speed.
bool forceProgressive = aTiledBuffer.IsLowPrecision();
bool drawingLowPrecision = aTiledBuffer.IsLowPrecision();
// Find out if we have any non-stale content to update.
nsIntRegion freshRegion;
@ -292,7 +292,8 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
// caused by there being an incoming, more relevant paint.
gfx::Rect viewport;
float scaleX, scaleY;
if (BasicManager()->ProgressiveUpdateCallback(!freshRegion.IsEmpty(), viewport, scaleX, scaleY)) {
if (BasicManager()->ProgressiveUpdateCallback(!freshRegion.IsEmpty(), viewport,
scaleX, scaleY, !drawingLowPrecision)) {
SAMPLE_MARKER("Abort painting");
aRegionToPaint.SetEmpty();
return aIsRepeated;
@ -367,7 +368,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
// in one go by repeating this work without calling the painted
// callback. The remaining content is then drawn tile-by-tile in
// multiple transactions.
if (!forceProgressive && paintVisible && drawingStale) {
if (!drawingLowPrecision && paintVisible && drawingStale) {
repeatImmediately = true;
} else {
BasicManager()->SetRepeatTransaction();

Просмотреть файл

@ -76,6 +76,7 @@ public class GeckoLayerClient
/* Used as the return value of progressiveUpdateCallback */
private final ProgressiveUpdateData mProgressiveUpdateData;
private boolean mProgressiveUpdateIsCurrent;
/* This is written by the compositor thread and read by the UI thread. */
private volatile boolean mCompositorCreated;
@ -359,7 +360,8 @@ public class GeckoLayerClient
// is useful for slow-to-render pages when the display-port starts lagging
// behind enough that continuing to draw it is wasted effort.
public ProgressiveUpdateData progressiveUpdateCallback(boolean aHasPendingNewThebesContent,
float x, float y, float width, float height, float resolution) {
float x, float y, float width, float height,
float resolution, boolean lowPrecision) {
// Grab a local copy of the last display-port sent to Gecko and the
// current viewport metrics to avoid races when accessing them.
DisplayPortMetrics displayPort = mDisplayPort;
@ -367,14 +369,6 @@ public class GeckoLayerClient
mProgressiveUpdateData.setViewport(viewportMetrics);
mProgressiveUpdateData.abort = false;
// Always abort updates if the resolution has changed. There's no use
// in drawing at the incorrect resolution.
if (!FloatUtils.fuzzyEquals(resolution, displayPort.resolution)) {
Log.d(LOGTAG, "Aborting draw due to resolution change");
mProgressiveUpdateData.abort = true;
return mProgressiveUpdateData;
}
// XXX All sorts of rounding happens inside Gecko that becomes hard to
// account exactly for. Given we align the display-port to tile
// boundaries (and so they rarely vary by sub-pixel amounts), just
@ -385,10 +379,22 @@ public class GeckoLayerClient
// display-port. If we abort updating when we shouldn't, we can end up
// with blank regions on the screen and we open up the risk of entering
// an endless updating cycle.
if (Math.abs(displayPort.getLeft() - x) <= 2 &&
Math.abs(displayPort.getTop() - y) <= 2 &&
Math.abs(displayPort.getBottom() - (y + height)) <= 2 &&
Math.abs(displayPort.getRight() - (x + width)) <= 2) {
if (!lowPrecision) {
mProgressiveUpdateIsCurrent =
Math.abs(displayPort.getLeft() - x) <= 2 &&
Math.abs(displayPort.getTop() - y) <= 2 &&
Math.abs(displayPort.getBottom() - (y + height)) <= 2 &&
Math.abs(displayPort.getRight() - (x + width)) <= 2;
}
if (mProgressiveUpdateIsCurrent) {
return mProgressiveUpdateData;
}
// Always abort updates if the resolution has changed. There's no use
// in drawing at the incorrect resolution.
if (!FloatUtils.fuzzyEquals(resolution, displayPort.resolution)) {
Log.d(LOGTAG, "Aborting draw due to resolution change");
mProgressiveUpdateData.abort = true;
return mProgressiveUpdateData;
}

Просмотреть файл

@ -2593,13 +2593,13 @@ AndroidBridge::GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDispla
}
bool
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, gfx::Rect& aViewport, float& aScaleX, float& aScaleY)
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY)
{
AndroidGeckoLayerClient *client = mLayerClient;
if (!client)
return false;
return client->ProgressiveUpdateCallback(aHasPendingNewThebesContent, aDisplayPort, aDisplayResolution, aViewport, aScaleX, aScaleY);
return client->ProgressiveUpdateCallback(aHasPendingNewThebesContent, aDisplayPort, aDisplayResolution, aDrawingCritical, aViewport, aScaleX, aScaleY);
}
void

Просмотреть файл

@ -160,7 +160,7 @@ public:
nsresult TakeScreenshot(nsIDOMWindow *window, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t dstY, int32_t dstX, int32_t dstW, int32_t dstH, int32_t bufW, int32_t bufH, int32_t tabId, int32_t token, jobject buffer);
nsresult GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
static void NotifyPaintedRect(float top, float left, float bottom, float right);

Просмотреть файл

@ -364,7 +364,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
jDisplayportPosition = GetFieldID(jEnv, jDisplayportClass, "mPosition", "Landroid/graphics/RectF;");
jDisplayportResolution = GetFieldID(jEnv, jDisplayportClass, "resolution", "F");
jProgressiveUpdateCallbackMethod = getMethod("progressiveUpdateCallback",
"(ZFFFFF)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
"(ZFFFFFZ)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
#endif
}
@ -853,6 +853,7 @@ bool
AndroidGeckoLayerClient::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
const gfx::Rect& aDisplayPort,
float aDisplayResolution,
bool aDrawingCritical,
gfx::Rect& aViewport,
float& aScaleX,
float& aScaleY)
@ -868,7 +869,8 @@ AndroidGeckoLayerClient::ProgressiveUpdateCallback(bool aHasPendingNewThebesCont
(float)aDisplayPort.y,
(float)aDisplayPort.width,
(float)aDisplayPort.height,
aDisplayResolution));
aDisplayResolution,
!aDrawingCritical));
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();

Просмотреть файл

@ -259,7 +259,7 @@ public:
void SetPageRect(const gfx::Rect& aCssPageRect);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const gfx::Rect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
bool DeactivateProgram(AutoLocalJNIFrame *jniFrame);