Bug 724928 - Tell Gecko not to draw areas we aren't interested in. r=kats

Alter GeckoSoftwareLayerClient.beginDrawing so that it can return a rectangle
of the buffer that it's interested in. Gecko then uses this to clip the dirty
region, which often saves on unnecessary drawing during flings.
This commit is contained in:
Chris Lord
2012-02-09 17:28:10 +00:00
parent f9df3a2799
commit 4febd751ee
5 changed files with 91 additions and 29 deletions

View File

@@ -331,7 +331,7 @@ AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv)
jLockBufferMethod = getMethod("lockBuffer", "()Ljava/nio/ByteBuffer;");
jUnlockBufferMethod = getMethod("unlockBuffer", "()V");
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Z");
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Landroid/graphics/Rect;");
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
#endif
}
@@ -392,8 +392,8 @@ AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
if (!r.isNull()) {
mRect.SetRect(r.Left(),
r.Top(),
r.Right() - r.Left(),
r.Bottom() - r.Top());
r.Width(),
r.Height());
} else {
mRect.SetEmpty();
}
@@ -690,7 +690,7 @@ AndroidGeckoSoftwareLayerClient::UnlockBuffer()
}
bool
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, const nsAString &aMetadata, bool aHasDirectTexture)
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture)
{
NS_ASSERTION(!isNull(), "BeginDrawing() called on null software layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
@@ -699,7 +699,20 @@ AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTile
AndroidBridge::AutoLocalJNIFrame(env, 1);
jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
return env->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, aTileWidth, aTileHeight, jMetadata, aHasDirectTexture);
jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
aWidth, aHeight, aTileWidth, aTileHeight,
jMetadata, aHasDirectTexture);
if (rectObject == nsnull)
return false;
AndroidRect rect(env, rectObject);
nsIntRect newDirtyRect = aDirtyRect.Intersect(nsIntRect(rect.Top(), rect.Left(),
rect.Width(), rect.Height()));
aDirtyRect.SetRect(newDirtyRect.x, newDirtyRect.y, newDirtyRect.width, newDirtyRect.height);
return true;
}
void