[AD] Logic in al_draw_bitmap_region

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I think the logic in al_draw_bitmap_region might be wrong (function
reproduced below). To paraphrase:
If either the target or the destination is a memory bitmap, then call
the display driver function if there is one, otherwise call the
generic memory function.
If they're both display bitmaps, call the display driver function if
they are compatible, otherwise do nothing.

As far as I can see, there are two problems:
1. If the target is memory, it should call the generic function, not
the display driver
2. If the bitmaps are from incompatible displays, it should fall back
to using a memory-to-display blit, not do nothing.

Is this correct? I can make a patch if so. Otherwise I've understood
it wrong, sorry!

Pete

/* Function: al_draw_bitmap_region
 *
 * Draws a region of the given bitmap to the target bitmap.
 *
 * sx - source x
 * sy - source y
 * sw - source width (width of region to blit)
 * sh - source height (height of region to blit)
 * dx - destination x
 * dy - destination y
 * flags - same as for <al_draw_bitmap>
 */
void al_draw_bitmap_region(ALLEGRO_BITMAP *bitmap, float sx, float sy,
	float sw, float sh, float dx, float dy, int flags)
{
   ALLEGRO_BITMAP *dest = al_get_target_bitmap();

   /* If one is a memory bitmap, do memory blit */
   if ((bitmap->flags & ALLEGRO_MEMORY_BITMAP) ||
       (dest->flags & ALLEGRO_MEMORY_BITMAP))
   {
      if (_al_current_display &&
          _al_current_display->vt->draw_memory_bitmap_region)
      {
         _al_current_display->vt->draw_memory_bitmap_region(_al_current_display,
	    bitmap, sx, sy, sw, sh, dx, dy, flags);
      }
      else {
         _al_draw_bitmap_region_memory(bitmap, sx, sy, sw, sh, dx, dy, flags);
      }
   }
   else if (al_is_compatible_bitmap(bitmap)) {
      bitmap->vt->draw_bitmap_region(bitmap, sx, sy, sw, sh, dx, dy, flags);
   }
}




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/