vxKernel/src/modules/display/image/shader/shadow.c

86 lines
1.6 KiB
C

#include <vhex/display/image.h>
#include <vhex/display/types.h>
#include <vhex/display/stack.h>
#include <vhex/display/shader.h>
//---
// Internal functions
//---
/* dimg_shadow_default_render() : add shadow on image with no alpha */
static void dimg_shadow_default_render(
dsurface_t *surface,
image_t *img,
uint32_t *draw,
uint32_t *shader
) {
(void)surface;
(void)img;
(void)draw;
(void)shader;
}
/* dimg_shadow_alpha_render() : add shadow on image with no alpha */
static void dimg_shadow_alpha_render(
dsurface_t *surface,
image_t *img,
uint32_t *draw,
uint32_t *shader
) {
(void)img;
(void)surface;
(void)draw;
(void)shader;
#if 0
struct imgbox imgbox;
dsubimage_render_box(
&imgbox,
image,
(int)draw[1] + xoff,
(int)draw[2] + yoff,
(int)draw[3],
(int)draw[4],
(int)draw[5],
(int)draw[6]
);
#endif
}
//---
// Dstack-level API
//---
/* dimage_shader_shadow() : add shadows in any image rendered */
static void dimage_shader_shadow_dstack(
dsurface_t *surface,
uint32_t *draw,
uint32_t *shader
) {
image_t *image;
image = (image_t*)(uintptr_t)draw[0];
/* send drawing request in the approriate optimized function */
if (IMAGE_IS_ALPHA(image->format)) {
dimg_shadow_alpha_render(surface, image, draw, shader);
return;
}
dimg_shadow_default_render(surface, image, draw, shader);
}
//---
// User-level API
//---
/* dimage_shader_shadow() : add shadows in any image rendered */
int dimage_shader_shadow(did_t did, int xoff, int yoff)
{
return dstack_add_shader(
did,
DSHADER(&dimage_shader_shadow_dstack, xoff, yoff)
);
}