Re: [AD] Logic in al_draw_bitmap_region |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Patch attached.
Pete
On Tue, Feb 26, 2008 at 11:29 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> On Tue, February 26, 2008 2:26 pm, Peter Hull said:
> [snip]
>
> > 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
>
>
> I think you're right. The display driver memory blit is supposed to
> draw memory bitmaps to the target, but if the target is a memory
> bitmap, it can be done by the generic function. And as for 2, yes,
> it should fall back on the generic function I would think.
>
> Trent
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
>
Index: src/bitmap_new.c
===================================================================
--- src/bitmap_new.c (revision 10045)
+++ src/bitmap_new.c (working copy)
@@ -274,18 +274,34 @@
void al_draw_bitmap(ALLEGRO_BITMAP *bitmap, 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->vt->draw_memory_bitmap_region)
- _al_current_display->vt->draw_memory_bitmap_region(_al_current_display,
- bitmap, 0, 0, bitmap->w, bitmap->h, dx, dy, flags);
- else
- _al_draw_bitmap_memory(bitmap, dx, dy, flags);
+ ALLEGRO_DISPLAY* display = _al_current_display;
+
+ /* If destination is memory, do a memory bitmap */
+ if (dest->flags & ALLEGRO_MEMORY_BITMAP)
+ {
+ _al_draw_bitmap_memory(bitmap, dx, dy, flags);
}
- else if (al_is_compatible_bitmap(bitmap))
- bitmap->vt->draw_bitmap(bitmap, dx, dy, flags);
+ else
+ {
+ /* if source is memory or incompatible */
+ if ((bitmap->flags & ALLEGRO_MEMORY_BITMAP) || (!al_is_compatible_bitmap(bitmap)))
+ {
+ if (display && display->vt->draw_memory_bitmap_region)
+ {
+ display->vt->draw_memory_bitmap_region(display,
+ bitmap, 0, 0, bitmap->w, bitmap->h, dx, dy, flags);
+ }
+ else
+ {
+ _al_draw_bitmap_memory(bitmap, dx, dy, flags);
+ }
+ }
+ else
+ {
+ /* Compatible display bitmap, use full acceleration */
+ bitmap->vt->draw_bitmap(bitmap, dx, dy, flags);
+ }
+ }
}
@@ -306,24 +322,34 @@
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))
+ ALLEGRO_DISPLAY* display = _al_current_display;
+
+ /* If destination is memory, do a memory bitmap */
+ if (dest->flags & ALLEGRO_MEMORY_BITMAP)
{
- if (_al_current_display &&
- _al_current_display->vt->draw_memory_bitmap_region)
+ _al_draw_bitmap_region_memory(bitmap, sx, sy, sw, sh, dx, dy, flags);
+ }
+ else
+ {
+ /* if source is memory or incompatible */
+ if ((bitmap->flags & ALLEGRO_MEMORY_BITMAP) || (!al_is_compatible_bitmap(bitmap)))
{
- _al_current_display->vt->draw_memory_bitmap_region(_al_current_display,
- bitmap, sx, sy, sw, sh, dx, dy, flags);
+ if (display && display->vt->draw_memory_bitmap_region)
+ {
+ display->vt->draw_memory_bitmap_region(display,
+ bitmap, sx, sy, sw, sh, dx, dy, flags);
+ }
+ else
+ {
+ _al_draw_bitmap_region_memory(bitmap, sx, sy, sw, sh, dx, dy, flags);
+ }
}
- else {
- _al_draw_bitmap_region_memory(bitmap, sx, sy, sw, sh, dx, dy, flags);
+ else
+ {
+ /* Compatible display bitmap, use full acceleration */
+ bitmap->vt->draw_bitmap_region(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);
- }
}