Take out the code that allows Java to further clip the invalid rect based on visible area.

This code is never used because the invalid rect we pass to DrawTo is ignored;
the nsLayoutUtils::PaintFrame uses the display port as the visible region to
paint instead. (http://mxr.mozilla.org/mozilla-central/source/layout/base/nsLayoutUtils.cpp#1603)
This commit is contained in:
Kartikaya Gupta 2012-02-26 10:47:45 -05:00
Родитель 1fbfd77a69
Коммит d18f53fccd
4 изменённых файлов: 10 добавлений и 59 удалений

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

@ -126,21 +126,21 @@ public class GeckoLayerClient implements GeckoEventListener,
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
public Rect beginDrawing(int width, int height, String metadata) {
public boolean beginDrawing(int width, int height, String metadata) {
Log.e(LOGTAG, "### beginDrawing " + width + " " + height);
// If the viewport has changed but we still don't have the latest viewport
// from Gecko, ignore the viewport passed to us from Gecko since that is going
// to be wrong.
if (!mFirstPaint && mIgnorePaintsPendingViewportSizeChange) {
return null;
return false;
}
mFirstPaint = false;
// If we've changed surface types, cancel this draw
if (initializeVirtualLayer()) {
Log.e(LOGTAG, "### Cancelling draw due to virtual layer initialization");
return null;
return false;
}
try {
@ -157,50 +157,14 @@ public class GeckoLayerClient implements GeckoEventListener,
}
} catch (JSONException e) {
Log.e(LOGTAG, "Aborting draw, bad viewport description: " + metadata);
return null;
}
// Make sure we don't spend time painting areas we aren't interested in.
// Only do this if the Gecko viewport isn't going to override our viewport.
Rect bufferRect = new Rect(0, 0, width, height);
if (!mUpdateViewportOnEndDraw) {
// First, find out our ideal displayport. This would be what we would
// send to Gecko if adjustViewport were called now.
ViewportMetrics currentMetrics = mLayerController.getViewportMetrics();
PointF currentBestOrigin = RectUtils.getOrigin(currentMetrics.getClampedViewport());
Rect currentRect = RectUtils.round(new RectF(currentBestOrigin.x, currentBestOrigin.y,
currentBestOrigin.x + width, currentBestOrigin.y + height));
// Second, store Gecko's displayport.
PointF currentOrigin = mNewGeckoViewport.getOrigin();
bufferRect = RectUtils.round(new RectF(currentOrigin.x, currentOrigin.y,
currentOrigin.x + width, currentOrigin.y + height));
int area = width * height;
// Take the intersection of the two as the area we're interested in rendering.
if (!bufferRect.intersect(currentRect)) {
Log.w(LOGTAG, "Prediction would avoid useless paint of " + area + " pixels (100.0%)");
// If there's no intersection, we have no need to render anything,
// but make sure to update the page size.
updateViewport(true);
return null;
}
int wasted = area - (bufferRect.width() * bufferRect.height());
Log.w(LOGTAG, "Prediction would avoid useless paint of " + wasted + " pixels (" + ((float)wasted * 100.0f / area) + "%)");
bufferRect.offset(Math.round(-currentOrigin.x), Math.round(-currentOrigin.y));
return false;
}
if (mBufferSize.width != width || mBufferSize.height != height) {
mBufferSize = new IntSize(width, height);
}
return bufferRect;
return true;
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */

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

@ -347,7 +347,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
jBeginDrawingMethod = getMethod("beginDrawing", "(IILjava/lang/String;)Landroid/graphics/Rect;");
jBeginDrawingMethod = getMethod("beginDrawing", "(IILjava/lang/String;)Z");
jEndDrawingMethod = getMethod("endDrawing", "()V");
jGetViewTransformMethod = getMethod("getViewTransform",
"()Lorg/mozilla/gecko/gfx/ViewTransform;");
@ -764,7 +764,7 @@ AndroidGeckoSurfaceView::Draw2D(jobject buffer, int stride)
}
bool
AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata)
AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, const nsAString &aMetadata)
{
NS_ASSERTION(!isNull(), "BeginDrawing() called on null layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
@ -774,19 +774,7 @@ AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, nsIntRect &aDirty
AndroidBridge::AutoLocalJNIFrame(env, 1);
jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
aWidth, aHeight,
jMetadata);
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;
return env->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, jMetadata);
}
void

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

@ -224,7 +224,7 @@ public:
AndroidGeckoLayerClient(jobject jobj)
: mViewTransformGetter(*this) { Init(jobj); }
bool BeginDrawing(int aWidth, int aHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata);
bool BeginDrawing(int aWidth, int aHeight, const nsAString &aMetadata);
void EndDrawing();
void GetViewTransform(AndroidViewTransform& aViewTransform);
void CreateFrame(AndroidLayerRendererFrame& aFrame);

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

@ -1190,8 +1190,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
nsIntRect dirtyRect = ae->Rect().Intersect(nsIntRect(0, 0, gAndroidBounds.width, gAndroidBounds.height));
AndroidGeckoLayerClient &client = AndroidBridge::Bridge()->GetLayerClient();
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height,
dirtyRect, metadata)) {
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height, metadata)) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### BeginDrawing returned false!");
return;
}