Bug 717283 - Use tiles on-demand. r=pcwalton, snorp

Instead of tying the tile-buffer in MultiTileLayer directly to the back-buffer
of the page, make sure rendering is always aligned to the tile grid and use
tiles on-demand. This makes better use of tiles when panning/zooming, and opens
up the route for further optimisations.
This commit is contained in:
Chris Lord
2012-01-24 15:39:53 +00:00
parent 88b2a113c8
commit 0438500908
13 changed files with 655 additions and 319 deletions

View File

@@ -46,6 +46,7 @@ jfieldID AndroidGeckoEvent::jTypeField = 0;
jfieldID AndroidGeckoEvent::jTimeField = 0;
jfieldID AndroidGeckoEvent::jP0Field = 0;
jfieldID AndroidGeckoEvent::jP1Field = 0;
jfieldID AndroidGeckoEvent::jP2Field = 0;
jfieldID AndroidGeckoEvent::jAlphaField = 0;
jfieldID AndroidGeckoEvent::jBetaField = 0;
jfieldID AndroidGeckoEvent::jGammaField = 0;
@@ -107,6 +108,7 @@ jmethodID AndroidAddress::jGetThoroughfareMethod;
jclass AndroidGeckoSoftwareLayerClient::jGeckoSoftwareLayerClientClass = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jLockBufferMethod = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jUnlockBufferMethod = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jGetRenderOffsetMethod = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jBeginDrawingMethod = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jEndDrawingMethod = 0;
jclass AndroidGeckoSurfaceView::jGeckoSurfaceViewClass = 0;
@@ -157,6 +159,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jTimeField = getField("mTime", "J");
jP0Field = getField("mP0", "Landroid/graphics/Point;");
jP1Field = getField("mP1", "Landroid/graphics/Point;");
jP2Field = getField("mP2", "Landroid/graphics/Point;");
jAlphaField = getField("mAlpha", "D");
jBetaField = getField("mBeta", "D");
jGammaField = getField("mGamma", "D");
@@ -323,8 +326,9 @@ AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv)
jLockBufferMethod = getMethod("lockBuffer", "()Ljava/nio/ByteBuffer;");
jUnlockBufferMethod = getMethod("unlockBuffer", "()V");
jBeginDrawingMethod = getMethod("beginDrawing", "(II)V");
jEndDrawingMethod = getMethod("endDrawing", "(IIIILjava/lang/String;Z)V");
jGetRenderOffsetMethod = getMethod("getRenderOffset", "()Landroid/graphics/Point;");
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Z");
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
#endif
}
@@ -349,6 +353,14 @@ AndroidGeckoEvent::ReadP1Field(JNIEnv *jenv)
mP1.y = p1.Y();
}
void
AndroidGeckoEvent::ReadP2Field(JNIEnv *jenv)
{
AndroidPoint p2(jenv, jenv->GetObjectField(wrappedObject(), jP2Field));
mP2.x = p2.X();
mP2.y = p2.Y();
}
void
AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
{
@@ -412,13 +424,10 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
mType = jenv->GetIntField(jobj, jTypeField);
switch (mType) {
case TILE_SIZE:
ReadP0Field(jenv);
break;
case SIZE_CHANGED:
ReadP0Field(jenv);
ReadP1Field(jenv);
ReadP2Field(jenv);
break;
case KEY_EVENT:
@@ -623,21 +632,28 @@ AndroidGeckoSoftwareLayerClient::UnlockBuffer()
}
void
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight)
AndroidGeckoSoftwareLayerClient::GetRenderOffset(nsIntPoint &aOffset)
{
AndroidPoint offset(JNI(), JNI()->CallObjectMethod(wrapped_obj, jGetRenderOffsetMethod));
aOffset.x = offset.X();
aOffset.y = offset.Y();
}
bool
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, const nsAString &aMetadata, bool aHasDirectTexture)
{
NS_ASSERTION(!isNull(), "BeginDrawing() called on null software layer client!");
AndroidBridge::AutoLocalJNIFrame(1);
return JNI()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight);
jstring jMetadata = JNI()->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
return JNI()->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, aTileWidth, aTileHeight, jMetadata, aHasDirectTexture);
}
void
AndroidGeckoSoftwareLayerClient::EndDrawing(const nsIntRect &aRect, const nsAString &aMetadata, bool aHasDirectTexture)
AndroidGeckoSoftwareLayerClient::EndDrawing(const nsIntRect &aRect)
{
NS_ASSERTION(!isNull(), "EndDrawing() called on null software layer client!");
AndroidBridge::AutoLocalJNIFrame(1);
jstring jMetadata = JNI()->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
return JNI()->CallVoidMethod(wrapped_obj, jEndDrawingMethod, aRect.x, aRect.y, aRect.width,
aRect.height, jMetadata, aHasDirectTexture);
return JNI()->CallVoidMethod(wrapped_obj, jEndDrawingMethod, aRect.x, aRect.y, aRect.width, aRect.height);
}
jobject