Bug 720613 - Prevent resizing before the surface has been created. r=pcwalton

Prevent trying to resize the buffer before the surface has been created. At
that point, we wouldn't know our maximum texture size, so we would've thrown a
RuntimeException.
This commit is contained in:
Chris Lord 2012-01-31 09:36:00 +00:00
parent ab9f951d91
commit 3e51ec6c57
2 changed files with 12 additions and 2 deletions

View File

@ -61,6 +61,10 @@ public class FloatSize {
@Override @Override
public String toString() { return "(" + width + "," + height + ")"; } public String toString() { return "(" + width + "," + height + ")"; }
public boolean isPositive() {
return (width > 0 && height > 0);
}
public boolean fuzzyEquals(FloatSize size) { public boolean fuzzyEquals(FloatSize size) {
return (FloatUtils.fuzzyEquals(size.width, width) && return (FloatUtils.fuzzyEquals(size.width, width) &&
FloatUtils.fuzzyEquals(size.height, height)); FloatUtils.fuzzyEquals(size.height, height));

View File

@ -429,8 +429,14 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (!force && metrics.widthPixels == mScreenSize.width && // Return immediately if the screen size hasn't changed or the viewport
metrics.heightPixels == mScreenSize.height) { // size is zero (which indicates that the rendering surface hasn't been
// allocated yet).
boolean screenSizeChanged = (metrics.widthPixels != mScreenSize.width ||
metrics.heightPixels != mScreenSize.height);
boolean viewportSizeValid = (getLayerController() != null &&
getLayerController().getViewportSize().isPositive());
if (!(force || (screenSizeChanged && viewportSizeValid))) {
return; return;
} }