diff options
author | dhewg | 2011-03-14 17:50:19 +0100 |
---|---|---|
committer | dhewg | 2011-03-14 19:35:35 +0100 |
commit | e1575e57f818f57b022531f31161e521869d7483 (patch) | |
tree | fb5db2ab0fff4b5c1a8ed051f6435b2e713a9115 | |
parent | 57635fe75cdf01a654d760efa0528a2aa186a391 (diff) | |
download | scummvm-rg350-e1575e57f818f57b022531f31161e521869d7483.tar.gz scummvm-rg350-e1575e57f818f57b022531f31161e521869d7483.tar.bz2 scummvm-rg350-e1575e57f818f57b022531f31161e521869d7483.zip |
ANDROID: Extend clearScreen to take care of all cases
Hopefully that'll help me to not forget about the double buffering.
This fixes some gfx leftovers when not running games in fullscreen
mode.
-rw-r--r-- | backends/platform/android/android.cpp | 9 | ||||
-rw-r--r-- | backends/platform/android/android.h | 10 | ||||
-rw-r--r-- | backends/platform/android/gfx.cpp | 48 |
3 files changed, 47 insertions, 20 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 85d4817f29..7731c53873 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -438,10 +438,7 @@ bool OSystem_Android::pollEvent(Common::Event &event) { updateScreenRect(); // double buffered, flip twice - _force_redraw = true; - updateScreen(); - _force_redraw = true; - updateScreen(); + clearScreen(kClearUpdate, 2); event.type = Common::EVENT_SCREEN_CHANGED; @@ -451,8 +448,8 @@ bool OSystem_Android::pollEvent(Common::Event &event) { initSurface(); updateScreenRect(); - _force_redraw = true; - updateScreen(); + // double buffered, flip twice + clearScreen(kClearUpdate, 2); event.type = Common::EVENT_SCREEN_CHANGED; diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 8e6d72fad2..db2cb95650 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -186,7 +186,15 @@ public: virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); - void clearScreen(bool swapBuffers); + + enum FixupType { + kClear = 0, // glClear + kClearSwap, // glClear + swapBuffers + kClearUpdate // glClear + updateScreen + }; + + void clearScreen(FixupType type, byte count = 1); + void updateScreenRect(); virtual int getScreenChangeID() const; diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 83ee8ba0f0..191d82efad 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -278,26 +278,47 @@ void OSystem_Android::initSize(uint width, uint height, // size (it's small). _mouse_texture_palette->allocBuffer(20, 20); - clearScreen(true); + clearScreen(kClear); } -void OSystem_Android::clearScreen(bool swapBuffers) { - // clear screen - GLCALL(glClearColorx(0, 0, 0, 1 << 16)); - GLCALL(glClear(GL_COLOR_BUFFER_BIT)); +void OSystem_Android::clearScreen(FixupType type, byte count) { + assert(count > 0); - if (swapBuffers) - JNI::swapBuffers(); + for (byte i = 0; i < count; ++i) { + if (!_show_overlay) + GLCALL(glDisable(GL_SCISSOR_TEST)); + + // clear screen + GLCALL(glClearColorx(0, 0, 0, 1 << 16)); + GLCALL(glClear(GL_COLOR_BUFFER_BIT)); + + if (!_show_overlay) + GLCALL(glEnable(GL_SCISSOR_TEST)); + + switch (type) { + case kClear: + break; + + case kClearSwap: + JNI::swapBuffers(); + break; + + case kClearUpdate: + _force_redraw = true; + updateScreen(); + break; + } + } } void OSystem_Android::updateScreenRect() { - uint16 w = _game_texture->width(); - uint16 h = _game_texture->height(); - Common::Rect rect(0, 0, _egl_surface_width, _egl_surface_height); _overlay_texture->setDrawRect(rect); + uint16 w = _game_texture->width(); + uint16 h = _game_texture->height(); + if (w && h && !_fullscreen) { if (_ar_correction && w == 320 && h == 200) h = 240; @@ -404,7 +425,7 @@ void OSystem_Android::updateScreen() { // clear pointer leftovers in dead areas if (_show_overlay && !_fullscreen) - clearScreen(false); + clearScreen(kClear); GLCALL(glPushMatrix()); @@ -414,7 +435,7 @@ void OSystem_Android::updateScreen() { _game_texture->height()).contains(_focus_rect))) { // These are the only cases where _game_texture doesn't // cover the entire screen. - clearScreen(false); + clearScreen(kClear); // Move everything up by _shake_offset (game) pixels GLCALL(glTranslatex(0, -_shake_offset << 16, 0)); @@ -574,7 +595,8 @@ void OSystem_Android::hideOverlay() { _show_overlay = false; _force_redraw = true; - clearScreen(false); + // double buffered, flip twice + clearScreen(kClearUpdate, 2); GLCALL(glEnable(GL_SCISSOR_TEST)); } |