Bug 718465 - Part 2: Clear background color when selected tab changes. r=kats

This commit is contained in:
Brian Nicholson 2012-10-18 00:01:20 -07:00
parent c4c2d5233d
commit ad37712739
3 changed files with 30 additions and 5 deletions

View File

@ -497,6 +497,12 @@ public class GeckoLayerClient
// a full viewport update, which is fine because if browser.js has somehow moved to
// be out of sync with this first-paint viewport, then we force them back in sync.
abortPanZoomAnimation();
// Indicate that the document is about to be composited so the
// LayerView background can be removed.
if (mView.getPaintState() == LayerView.PAINT_START) {
mView.setPaintState(LayerView.PAINT_BEFORE_FIRST);
}
}
DisplayPortCalculator.resetPageState();
mDrawTimingQueue.reset();

View File

@ -6,6 +6,8 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.gfx.Layer.RenderContext;
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
@ -32,7 +34,7 @@ import javax.microedition.khronos.egl.EGLConfig;
/**
* The layer renderer implements the rendering logic for a layer view.
*/
public class LayerRenderer {
public class LayerRenderer implements Tabs.OnTabsChangedListener {
private static final String LOGTAG = "GeckoLayerRenderer";
private static final String PROFTAG = "GeckoLayerRendererProf";
@ -166,6 +168,8 @@ public class LayerRenderer {
mCoordByteBuffer = DirectBufferAllocator.allocate(COORD_BUFFER_SIZE * 4);
mCoordByteBuffer.order(ByteOrder.nativeOrder());
mCoordBuffer = mCoordByteBuffer.asFloatBuffer();
Tabs.registerOnTabsChangedListener(this);
}
@Override
@ -683,7 +687,9 @@ public class LayerRenderer {
}
}
// Remove white screen once we've painted
// Remove background color once we've painted. GeckoLayerClient is
// responsible for setting this flag before current document is
// composited.
if (mView.getPaintState() == LayerView.PAINT_BEFORE_FIRST) {
mView.post(new Runnable() {
public void run() {
@ -694,4 +700,16 @@ public class LayerRenderer {
}
}
}
@Override
public void onTabChanged(final Tab tab, Tabs.TabEvents msg, Object data) {
// Sets the background of the newly selected tab. This background color
// gets cleared in endDrawing(). This function runs on the UI thread,
// but other code that touches the paint state is run on the compositor
// thread, so this may need to be changed if any problems appear.
if (msg == Tabs.TabEvents.SELECTED) {
mView.getChildAt(0).setBackgroundColor(tab.getCheckerboardColor());
mView.setPaintState(LayerView.PAINT_START);
}
}
}

View File

@ -60,8 +60,9 @@ public class LayerView extends FrameLayout {
private Listener mListener;
/* Flags used to determine when to show the painted surface. */
public static final int PAINT_BEFORE_FIRST = 0;
public static final int PAINT_AFTER_FIRST = 1;
public static final int PAINT_START = 0;
public static final int PAINT_BEFORE_FIRST = 1;
public static final int PAINT_AFTER_FIRST = 2;
public boolean shouldUseTextureView() {
// Disable TextureView support for now as it causes panning/zooming
@ -90,7 +91,7 @@ public class LayerView extends FrameLayout {
super(context, attrs);
mGLController = new GLController(this);
mPaintState = PAINT_BEFORE_FIRST;
mPaintState = PAINT_START;
mCheckerboardColor = Color.WHITE;
mCheckerboardShouldShowChecks = true;
}