Hm. That might work. My patch moves the burden of recreating the texture
to user, which is probably what he deserves, by using NO_PRESERVE flag,
but it may be less error-prone to re-create the texture inside Allegro.
I've attached a patch that removes NO_PRESERVE checks from both halt and
resume functions, and adds a null pointer check in upload_bitmap_memory.
Not sure about the last one - maybe we should just call
ogl_create_bitmap instead?
Yeah I think I'd prefer calling ogl_create_bitmap rather than add mysterious
behaviour to _al_ogl_upload_bitmap_memory.
Except I missed the fact that we don't want to create a new bitmap, but rather replace inner 'texture' member in bitmap->extra, so _al_ogl_create_bitmap won't do. We can, however, copy relevant (small) part of code from upload_bitmap_memory. Patch attached.
 src/android/android_display.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/android/android_display.c b/src/android/android_display.c
index 9f65880..b50d0e9 100644
--- a/src/android/android_display.c
+++ b/src/android/android_display.c
@@ -790,8 +790,7 @@ static void 
android_acknowledge_drawing_halt(ALLEGRO_DISPLAY *dpy)
       int bitmap_flags = al_get_bitmap_flags(bmp);
 
       if (!bmp->parent &&
-         !(bitmap_flags & ALLEGRO_MEMORY_BITMAP) &&
-         !(bitmap_flags & ALLEGRO_NO_PRESERVE_TEXTURE))
+         !(bitmap_flags & ALLEGRO_MEMORY_BITMAP))
       {
          ALLEGRO_BITMAP_EXTRA_OPENGL *extra = bmp->extra;
          al_remove_opengl_fbo(bmp);
@@ -851,12 +850,21 @@ static void 
android_acknowledge_drawing_resume(ALLEGRO_DISPLAY *dpy)
       int bitmap_flags = al_get_bitmap_flags(bmp);
 
       if (!bmp->parent &&
-         !(bitmap_flags & ALLEGRO_MEMORY_BITMAP) &&
-         !(bitmap_flags & ALLEGRO_NO_PRESERVE_TEXTURE))
+         !(bitmap_flags & ALLEGRO_MEMORY_BITMAP))
       {
          int format = al_get_bitmap_format(bmp);
          format = _al_pixel_format_is_compressed(format) ? 
ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE : format;
-         _al_ogl_upload_bitmap_memory(bmp, format, bmp->memory);
+                if ( !(bitmap_flags & ALLEGRO_NO_PRESERVE_TEXTURE) ) {
+                       _al_ogl_upload_bitmap_memory(bmp, format, bmp->memory);
+                }
+                else {
+                        ALLEGRO_BITMAP *tmp = 
_al_create_bitmap_params(_al_get_bitmap_display(bmp), bmp->w, bmp->h, format,
+                                al_get_bitmap_flags(bmp));
+                        ((ALLEGRO_BITMAP_EXTRA_OPENGL *)bmp->extra)->texture =
+                                ((ALLEGRO_BITMAP_EXTRA_OPENGL 
*)tmp->extra)->texture;
+                        ((ALLEGRO_BITMAP_EXTRA_OPENGL *)tmp->extra)->texture = 
0;
+                        al_destroy_bitmap(tmp);
+                }
          bmp->dirty = false;
       }
    }
_______________________________________________
Allegro-developers mailing list
[email protected]
https://mail.gna.org/listinfo/allegro-developers

Reply via email to