I use 'working bitmaps' for quite a lot of my effects - for example, merging overlapping primitives before drawing them with reduced opacity:
al_set_target_bitmap(tmp); al_draw_filled_rectangle( 0, 0, 20, 20, al_map_rgb_f(1,0,0)); al_draw_filled_rectangle( 0, 10, 20, 30, al_map_rgb_f(0,1,0)); al_draw_filled_rectangle(10, 0, 30, 20, al_map_rgb_f(0,0,1)); al_set_target_backbuffer(disp); al_draw_tinted_bitmap(tmp, al_map_rgba_f(1,1,1,0.5), 0, 0);
Here, tmp needs to be cleared to 100% transparency before each draw. The most trivial way of doing this would be:
al_clear_to_color(al_map_rgba_f(0,0,0,0));
Alternatively, I could blank the area needed with a rectangle:
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_filled_rectangle(0, 0, 30, 30, al_map_rgba_f(0,0,0,0));
So, let's say I made the (perhaps poor) decision to clear a working area many times in my draw code. Given that al_clear_to_color ignores blending and transforms, I'm wondering whether it might be better-optimised than the primitives, despite the larger fill area.
Could someone with knowledge of Allegro's internals give me a hint as to what might be universally faster?
Do yourself a favor and get out gdb. Set a breakpoint in al_clear_to_color and al_draw_filled_rectangle and step into the function and see what it does on the OpenGL / DX layer.
I suspect clear is significantly faster given how much is necessary to accomplish the primitive drawing from Allegro's side.
I doubt there's any faster way than just to use glClear.
"just getting out gdb" would be fine for my specific case, but 'universal' is the operative word here; I had no idea whether some internals would run faster/slower on specific backends, OSes, or cards. For whatever reason.
From what SiegeLord is saying, though, clear sounds like it's always going to be faster. Ta
I'd go for al_clear_to_color - the code looks fairly straightforward:
https://github.com/liballeg/allegro5/blob/d7757184d335d400460808eff8e0d19c9f557673/src/drawing.c#L26-L41
Which calls out to this in OpenGL:
https://github.com/liballeg/allegro5/blob/af83c358bbd3b074705151760ebb7b351907cae2/src/opengl/ogl_draw.c#L228-L252
This in DirectX
https://github.com/liballeg/allegro5/blob/af83c358bbd3b074705151760ebb7b351907cae2/src/win/d3d_disp.cpp#L1980-L1994
And this for memory bitmaps (and also locked OpenGL bitmaps)
https://github.com/liballeg/allegro5/blob/d7757184d335d400460808eff8e0d19c9f557673/src/memdraw.c#L54-L160
You could do the same for al_draw_filled_rectangle 
TBH I doubt either would be disastrously slow...
Nice leg work Peter!