Bug 709492 - Part 3: Implement expose events. r=kats

This commit is contained in:
Patrick Walton 2011-12-29 15:10:28 -08:00
parent a09787cb39
commit 9f4fa76ed7
3 changed files with 17 additions and 7 deletions

View File

@ -78,6 +78,7 @@ public class GeckoEvent {
public static final int ACTIVITY_START = 17;
public static final int BROADCAST = 19;
public static final int VIEWPORT = 20;
public static final int EXPOSE = 21;
public static final int IME_COMPOSITION_END = 0;
public static final int IME_COMPOSITION_BEGIN = 1;

View File

@ -532,6 +532,7 @@ public:
ACTIVITY_START = 17,
BROADCAST = 19,
VIEWPORT = 20,
EXPOSE = 21,
dummy_java_enum_list_end
};

View File

@ -978,6 +978,7 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
break;
case AndroidGeckoEvent::DRAW:
case AndroidGeckoEvent::EXPOSE:
win->OnDraw(ae);
break;
@ -1168,15 +1169,16 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0)
return;
/*
* Check to see whether browser.js wants us to draw. This will be false during page
* transitions, in which case we immediately bail out.
*/
nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
AndroidBridge::Bridge()->GetDrawMetadataProvider();
/*
* If this is a DRAW event (not an EXPOSE event), check to see whether browser.js wants us to
* draw. This will be false during page transitions, in which case we immediately bail out.
*/
bool shouldDraw = true;
if (metadataProvider) {
if (metadataProvider && ae->Type() == AndroidGeckoEvent::DRAW) {
metadataProvider->DrawingAllowed(&shouldDraw);
}
if (!shouldDraw) {
@ -1187,6 +1189,12 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
AndroidBridge::Bridge()->GetSoftwareLayerClient();
client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height);
// Redraw the entire tile on an EXPOSE event. Otherwise (on a DRAW event), redraw only the
// portion specified by the event.
nsIntRect rect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
if (ae->Type() == AndroidGeckoEvent::DRAW)
rect = ae->Rect();
nsAutoString metadata;
unsigned char *bits = NULL;
if (sHasDirectTexture) {
@ -1219,7 +1227,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
// XXX: lock only the dirty rect above and pass it in here
DrawTo(targetSurface);
} else {
DrawTo(targetSurface, ae->Rect());
DrawTo(targetSurface, rect);
}
if (metadataProvider) {
@ -1232,7 +1240,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
client.UnlockBuffer();
}
}
client.EndDrawing(ae->Rect(), metadata);
client.EndDrawing(rect, metadata);
return;
#endif