Bug 724042 - back out 663892ff23e0 as we have a better solution.

This commit is contained in:
Kartikaya Gupta 2012-02-04 18:48:21 -05:00
parent b84511ce96
commit 244e89d4f2

View File

@ -43,7 +43,7 @@ import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.LayerClient;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.LayerRenderer;
import org.mozilla.gecko.gfx.SingleTileLayer;
import org.mozilla.gecko.gfx.MultiTileLayer;
import org.mozilla.gecko.gfx.PointUtils;
import org.mozilla.gecko.gfx.WidgetTileLayer;
import org.mozilla.gecko.FloatUtils;
@ -182,7 +182,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
mRenderOffset.set(0, 0);
} else {
Log.i(LOGTAG, "Creating MultiTileLayer");
mTileLayer = new SingleTileLayer(mCairoImage);
mTileLayer = new MultiTileLayer(mCairoImage, TILE_SIZE);
}
getLayerController().setRoot(mTileLayer);
@ -197,13 +197,12 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
public boolean beginDrawing(int width, int height, int tileWidth, int tileHeight, String metadata, boolean hasDirectTexture) {
// If we've changed surface types, cancel this draw
if (setHasDirectTexture(hasDirectTexture)) {
Log.i(LOGTAG, "we've changed surface types, cancel this draw");
return false;
}
// Make sure the tile-size matches. If it doesn't, we could crash trying
// to access invalid memory.
if (mHasDirectTexture || mTileLayer instanceof SingleTileLayer) {
if (mHasDirectTexture) {
if (tileWidth != 0 || tileHeight != 0) {
Log.e(LOGTAG, "Aborting draw, incorrect tile size of " + tileWidth + "x" + tileHeight);
return false;
@ -236,24 +235,8 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
// we're using MultiTileLayer. Otherwise, just synchronise the
// buffer size and return.
if (!(mTileLayer instanceof MultiTileLayer)) {
if (mBufferSize.width != width || mBufferSize.height != height) {
if (mBufferSize.width != width || mBufferSize.height != height)
mBufferSize = new IntSize(width, height);
if (mTileLayer instanceof SingleTileLayer) {
int size = mBufferSize.getArea() * 2;
if (mBuffer == null || mBuffer.capacity() != size) {
// Free the old buffer
if (mBuffer != null) {
GeckoAppShell.freeDirectBuffer(mBuffer);
mBuffer = null;
}
mBuffer = GeckoAppShell.allocateDirectBuffer(size);
}
}
}
if (!(mTileLayer instanceof SingleTileLayer)){
Log.i(LOGTAG, "returning early from beginDraw");
}
return true;
}
@ -282,7 +265,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
IntSize realBufferSize = new IntSize(width + TILE_SIZE.width,
height + TILE_SIZE.height);
// Reallocate the buffer if necessary
int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat) / 8;
int size = realBufferSize.getArea() * bpp;
if (mBuffer == null || mBuffer.capacity() != size) {
@ -296,8 +279,6 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
}
}
Log.i(LOGTAG, "beginDraw finishing");
return true;
}
@ -336,13 +317,10 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
try {
updateViewport(!mUpdateViewportOnEndDraw);
mUpdateViewportOnEndDraw = false;
Rect rect = new Rect(x, y, x + width, y + height);
rect.offset(mRenderOffset.x, mRenderOffset.y);
if (mTileLayer instanceof SingleTileLayer)
((SingleTileLayer)mTileLayer).invalidate(rect);
if (mTileLayer instanceof MultiTileLayer) {
Rect rect = new Rect(x, y, x + width, y + height);
rect.offset(mRenderOffset.x, mRenderOffset.y);
((MultiTileLayer)mTileLayer).invalidate(rect);
((MultiTileLayer)mTileLayer).setRenderOffset(mRenderOffset);
}
@ -469,16 +447,10 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
// Round up depending on layer implementation to remove texture wastage
if (!mHasDirectTexture) {
if (mTileLayer instanceof MultiTileLayer) {
// Round to the next multiple of the tile size
bufferSize = new IntSize(((mScreenSize.width + LayerController.MIN_BUFFER.width - 1) / TILE_SIZE.width + 1) * TILE_SIZE.width,
((mScreenSize.height + LayerController.MIN_BUFFER.height - 1) / TILE_SIZE.height + 1) * TILE_SIZE.height);
tileSize = TILE_SIZE;
} else {
bufferSize = new IntSize(IntSize.nextPowerOfTwo(mScreenSize.width + LayerController.MIN_BUFFER.width),
IntSize.nextPowerOfTwo(mScreenSize.height + LayerController.MIN_BUFFER.height));
tileSize = new IntSize(0, 0);
}
// Round to the next multiple of the tile size
bufferSize = new IntSize(((mScreenSize.width + LayerController.MIN_BUFFER.width - 1) / TILE_SIZE.width + 1) * TILE_SIZE.width,
((mScreenSize.height + LayerController.MIN_BUFFER.height - 1) / TILE_SIZE.height + 1) * TILE_SIZE.height);
tileSize = TILE_SIZE;
} else {
int maxSize = getLayerController().getView().getMaxTextureSize();