ANDROID: Always use the surface size for the overlay

When coming back from standby, there might be an indermediate surface
change
This commit is contained in:
dhewg 2011-04-03 20:26:27 +02:00
parent fba1c6360c
commit ea4223d941
2 changed files with 15 additions and 29 deletions

View file

@ -696,12 +696,9 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
if (pthread_self() == _main_thread) {
if (_screen_changeid != JNI::surface_changeid) {
if (JNI::egl_surface_width > 0 && JNI::egl_surface_height > 0) {
if (_egl_surface_width > 0 && _egl_surface_height > 0) {
// surface still alive but changed
_screen_changeid = JNI::surface_changeid;
_egl_surface_width = JNI::egl_surface_width;
_egl_surface_height = JNI::egl_surface_height;
// surface changed
JNI::deinitSurface();
initSurface();
initViewport();
updateScreenRect();
updateEventScale();
@ -712,19 +709,6 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
event.type = Common::EVENT_SCREEN_CHANGED;
return true;
} else {
// new surface
initSurface();
updateScreenRect();
updateEventScale();
// double buffered, flip twice
clearScreen(kClearUpdate, 2);
event.type = Common::EVENT_SCREEN_CHANGED;
return true;
}
} else {
// surface lost
deinitSurface();

View file

@ -235,8 +235,10 @@ void OSystem_Android::initViewport() {
}
void OSystem_Android::initOverlay() {
int overlay_width = _egl_surface_width;
int overlay_height = _egl_surface_height;
// minimum of 320x200
// (surface can get smaller when opening the virtual keyboard on *QVGA*)
int overlay_width = MAX(_egl_surface_width, 320);
int overlay_height = MAX(_egl_surface_height, 200);
// the 'normal' theme layout uses a max height of 400 pixels. if the
// surface is too big we use only a quarter of the size so that the widgets
@ -244,7 +246,7 @@ void OSystem_Android::initOverlay() {
// enforces the 'lowres' layout, which will be scaled back up by factor 2x,
// but this looks way better than the 'normal' layout scaled by some
// calculated factors
if (overlay_height > 480) {
while (overlay_height > 480) {
overlay_width /= 2;
overlay_height /= 2;
}