Bug 725428 - Draw white background in LayerView until Gecko has painted. r=kats

This commit is contained in:
Brian Nicholson 2012-03-22 15:07:00 -07:00
Родитель 8712e90338
Коммит bc42131258
5 изменённых файлов: 53 добавлений и 22 удалений

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

@ -1743,9 +1743,15 @@ abstract public class GeckoApp
* run experience, perhaps?
*/
mLayerController = new LayerController(this);
mPlaceholderLayerClient = new PlaceholderLayerClient(mLayerController, mLastViewport);
View v = mLayerController.getView();
mGeckoLayout.addView(mLayerController.getView(), 0);
mPlaceholderLayerClient = new PlaceholderLayerClient(mLayerController, mLastViewport);
if (!mPlaceholderLayerClient.loadScreenshot()) {
// Instead of flickering the checkerboard, show a white screen until Gecko paints
v.setBackgroundColor(Color.WHITE);
}
mGeckoLayout.addView(v, 0);
}
mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);

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

@ -367,6 +367,7 @@ public class GeckoLayerClient implements GeckoEventResponder,
// 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.
mLayerController.abortPanZoomAnimation();
mLayerController.getView().setPaintState(LayerView.PAINT_BEFORE_FIRST);
}
}

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

@ -680,6 +680,16 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
pixelBuffer.notify();
}
}
// Remove white screen once we've painted
if (mView.getPaintState() == LayerView.PAINT_BEFORE_FIRST) {
GeckoAppShell.getMainHandler().postAtFrontOfQueue(new Runnable() {
public void run() {
mView.setBackgroundColor(android.graphics.Color.TRANSPARENT);
}
});
mView.setPaintState(LayerView.PAINT_AFTER_FIRST);
}
}
}
}

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

@ -38,6 +38,7 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoInputConnection;
import org.mozilla.gecko.gfx.FloatSize;
import org.mozilla.gecko.gfx.InputConnectionHandler;
@ -77,6 +78,14 @@ public class LayerView extends FlexibleGLSurfaceView {
private static String LOGTAG = "GeckoLayerView";
/* List of events to be processed if the page does not prevent them. Should only be touched on the main thread */
private LinkedList<MotionEvent> mEventQueue = new LinkedList<MotionEvent>();
/* Must be a PAINT_xxx constant */
private int mPaintState = PAINT_NONE;
/* Flags used to determine when to show the painted surface. The integer
* order must correspond to the order in which these states occur. */
public static final int PAINT_NONE = 0;
public static final int PAINT_BEFORE_FIRST = 1;
public static final int PAINT_AFTER_FIRST = 2;
public LayerView(Context context, LayerController controller) {
@ -237,5 +246,17 @@ public class LayerView extends FlexibleGLSurfaceView {
public LayerRenderer getLayerRenderer() {
return mRenderer;
}
/* paintState must be a PAINT_xxx constant. The state will only be changed
* if paintState represents a state that occurs after the current state. */
public void setPaintState(int paintState) {
if (paintState > mPaintState) {
mPaintState = paintState;
}
}
public int getPaintState() {
return mPaintState;
}
}

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

@ -79,25 +79,6 @@ public class PlaceholderLayerClient {
} else {
mViewport = new ViewportMetrics();
}
loadScreenshot();
if (mViewportUnknown)
mViewport.setViewport(mLayerController.getViewport());
mLayerController.setViewportMetrics(mViewport);
BufferedCairoImage image = new BufferedCairoImage(mBuffer, mWidth, mHeight, mFormat);
SingleTileLayer tileLayer = new SingleTileLayer(image);
tileLayer.beginTransaction(); // calling thread irrelevant; nobody else has a ref to tileLayer yet
try {
Point origin = PointUtils.round(mViewport.getOrigin());
tileLayer.setPosition(new Rect(origin.x, origin.y, origin.x + mWidth, origin.y + mHeight));
} finally {
tileLayer.endTransaction();
}
mLayerController.setRoot(tileLayer);
}
public void destroy() {
@ -107,7 +88,7 @@ public class PlaceholderLayerClient {
}
}
boolean loadScreenshot() {
public boolean loadScreenshot() {
if (GeckoApp.mAppContext.mLastScreen == null)
return false;
@ -131,6 +112,18 @@ public class PlaceholderLayerClient {
mLayerController.setPageSize(mViewport.getPageSize());
}
BufferedCairoImage image = new BufferedCairoImage(mBuffer, mWidth, mHeight, mFormat);
SingleTileLayer tileLayer = new SingleTileLayer(image);
tileLayer.beginTransaction(); // calling thread irrelevant; nobody else has a ref to tileLayer yet
try {
Point origin = PointUtils.round(mViewport.getOrigin());
tileLayer.setPosition(new Rect(origin.x, origin.y, origin.x + mWidth, origin.y + mHeight));
} finally {
tileLayer.endTransaction();
}
mLayerController.setRoot(tileLayer);
return true;
}
}