toaruos/userspace/wallpaper.c
Kevin Lange 4c67b5da84 Completely rewrote compositing engine
The compositor itself still needs work, but the compositing engine
within now does full blitting and is faster than the old method.
Transparency is now supported properly, though telling the compositor to
use it on a window will degrade performance. One terminal is usually
okay, and everything runs faster than it did before; two terminals is
pushing it; three will make you very sad. The stacking logic has also
been updated. Presumably, alpha blitting for transparent windows could
be done with SIMD instructions and be extremely fast.

All graphics libraries have also been updated to (hopefully) work
properly with alpha bits.
2012-09-13 22:12:47 -07:00

71 lines
1.2 KiB
C

/* vim: tabstop=4 shiftwidth=4 noexpandtab
*
* Wallpaper renderer.
*
*/
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include "lib/window.h"
#include "lib/graphics.h"
sprite_t * sprites[128];
sprite_t alpha_tmp;
uint16_t win_width;
uint16_t win_height;
gfx_context_t * ctx;
int center_x(int x) {
return (win_width - x) / 2;
}
int center_y(int y) {
return (win_height - y) / 2;
}
volatile int _continue = 1;
void sig_int(int sig) {
printf("Received shutdown signal in wallpaper!\n");
_continue = 0;
}
int main (int argc, char ** argv) {
setup_windowing();
int width = wins_globals->server_width;
int height = wins_globals->server_height;
win_width = width;
win_height = height;
/* Do something with a window */
window_t * wina = window_create(0,0, width, height);
assert(wina);
window_reorder (wina, 0);
ctx = init_graphics_window_double_buffer(wina);
draw_fill(ctx, rgb(127,127,127));
flip(ctx);
syscall_signal(2, sig_int);
sprites[0] = malloc(sizeof(sprite_t));
sprites[0]->alpha = 0;
if (load_sprite_png(sprites[0], "/usr/share/wallpaper.png")) {
return 0;
}
draw_sprite_scaled(ctx, sprites[0], 0, 0, width, height);
flip(ctx);
while (_continue) {
syscall_yield();
}
teardown_windowing();
return 0;
}