Bug 805028 - Use ComputeRenderIntegrity to calculate accurate checkerboard. r=kats

Use ComputeRenderIntegrity so that checkerboarding values remain accurate when
progressive tiles are enabled.
This commit is contained in:
Chris Lord 2012-10-25 17:23:47 +01:00
parent 0206c993d6
commit ae4d4e2f4d
6 changed files with 43 additions and 15 deletions

View File

@ -249,6 +249,7 @@ public class GeckoAppShell
public static native void scheduleComposite();
public static native void schedulePauseComposition();
public static native void scheduleResumeComposition(int width, int height);
public static native float computeRenderIntegrity();
public static native SurfaceBits getSurfaceBits(Surface surface);

View File

@ -410,12 +410,18 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
// Whether a layer was updated.
private boolean mUpdated;
private final Rect mPageRect;
private final Rect mAbsolutePageRect;
public Frame(ImmutableViewportMetrics metrics) {
mFrameMetrics = metrics;
mPageContext = createPageContext(metrics);
mScreenContext = createScreenContext(metrics);
mPageRect = getPageRect();
Point origin = PointUtils.round(mFrameMetrics.getOrigin());
Rect pageRect = RectUtils.round(mFrameMetrics.getPageRect());
mAbsolutePageRect = new Rect(pageRect);
pageRect.offset(-origin.x, -origin.y);
mPageRect = pageRect;
}
private void setScissorRect() {
@ -437,13 +443,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
(screenSize.height - bottom) + (bottom - top));
}
private Rect getPageRect() {
Point origin = PointUtils.round(mFrameMetrics.getOrigin());
Rect pageRect = RectUtils.round(mFrameMetrics.getPageRect());
pageRect.offset(-origin.x, -origin.y);
return pageRect;
}
/** This function is invoked via JNI; be careful when modifying signature. */
public void beginDrawing() {
mFrameStartTime = SystemClock.uptimeMillis();
@ -543,9 +542,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
mBackgroundLayer.draw(mScreenContext);
/* Draw the drop shadow, if we need to. */
RectF untransformedPageRect = new RectF(0.0f, 0.0f, mPageRect.width(),
mPageRect.height());
if (!untransformedPageRect.contains(mFrameMetrics.getViewport()))
if (!new RectF(mAbsolutePageRect).contains(mFrameMetrics.getViewport()))
mShadowLayer.draw(mPageContext);
/* Draw the 'checkerboard'. We use gfx.show_checkerboard_pattern to
@ -607,7 +604,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
/* restrict the viewport to page bounds so we don't
* count overscroll as checkerboard */
if (!viewport.intersect(mPageRect)) {
if (!viewport.intersect(mAbsolutePageRect)) {
/* if the rectangles don't intersect
intersect() doesn't change viewport
so we set it to empty by hand */
@ -615,10 +612,14 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
validRegion.op(viewport, Region.Op.INTERSECT);
float checkerboard = 0.0f;
// Check if we have total checkerboarding (there's visible
// page area and the valid region doesn't intersect with the
// viewport).
int screenArea = viewport.width() * viewport.height();
if (screenArea > 0 && !(validRegion.isRect() && validRegion.getBounds().equals(viewport))) {
float checkerboard = (screenArea > 0 &&
validRegion.quickReject(viewport)) ? 1.0f : 0.0f;
if (screenArea > 0 && checkerboard < 1.0f) {
validRegion.op(viewport, Region.Op.REVERSE_DIFFERENCE);
// XXX The assumption here is that a Region never has overlapping
@ -633,6 +634,9 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
}
checkerboard = checkerboardArea / (float)screenArea;
// Add any incomplete rendering in the screen area
checkerboard += (1.0 - checkerboard) * (1.0 - GeckoAppShell.computeRenderIntegrity());
}
PanningPerfAPI.recordCheckerboard(checkerboard);

View File

@ -306,6 +306,7 @@ SHELL_WRAPPER0(bindWidgetTexture)
SHELL_WRAPPER0(scheduleComposite)
SHELL_WRAPPER0(schedulePauseComposition)
SHELL_WRAPPER2(scheduleResumeComposition, jint, jint)
SHELL_WRAPPER0_WITH_RETURN(computeRenderIntegrity, jfloat)
SHELL_WRAPPER3_WITH_RETURN(saveMessageInSentbox, jint, jstring, jstring, jlong)
SHELL_WRAPPER6(notifySmsSent, jint, jstring, jstring, jlong, jint, jlong)
SHELL_WRAPPER4(notifySmsDelivered, jint, jstring, jstring, jlong)
@ -729,6 +730,7 @@ loadGeckoLibs(const char *apkName)
GETFUNC(scheduleComposite);
GETFUNC(schedulePauseComposition);
GETFUNC(scheduleResumeComposition);
GETFUNC(computeRenderIntegrity);
GETFUNC(saveMessageInSentbox);
GETFUNC(notifySmsSent);
GETFUNC(notifySmsDelivered);

View File

@ -834,6 +834,12 @@ Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv*, jclass,
nsWindow::ScheduleResumeComposition(width, height);
}
NS_EXPORT float JNICALL
Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity(JNIEnv*, jclass)
{
return nsWindow::ComputeRenderIntegrity();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifyFilePickerResult(JNIEnv* jenv, jclass, jstring filePath, jlong callback)
{

View File

@ -2283,6 +2283,20 @@ nsWindow::ScheduleResumeComposition(int width, int height)
}
}
float
nsWindow::ComputeRenderIntegrity()
{
if (sCompositorParent) {
mozilla::layers::LayerManagerOGL* manager =
static_cast<mozilla::layers::LayerManagerOGL*>(sCompositorParent->GetLayerManager());
if (manager) {
return manager->ComputeRenderIntegrity();
}
}
return 1.f;
}
bool
nsWindow::WidgetPaintsBackground()
{

View File

@ -156,6 +156,7 @@ public:
static void ScheduleComposite();
static void SchedulePauseComposition();
static void ScheduleResumeComposition(int width, int height);
static float ComputeRenderIntegrity();
virtual bool WidgetPaintsBackground();
#endif