forked from enlightenment/efl
153 lines
5.7 KiB
C
153 lines
5.7 KiB
C
#ifndef EVAS_SOFT16_H
|
|
#define EVAS_SOFT16_H
|
|
|
|
#include "Evas.h"
|
|
#include "evas_common.h"
|
|
#include "evas_private.h"
|
|
|
|
#define RGB_565_UNPACKED_MASK 0x07e0f81f
|
|
#define RGB_565_UNPACK(rgb) \
|
|
(((rgb) | ((rgb) << 16)) & RGB_565_UNPACKED_MASK)
|
|
#define RGB_565_PACK(rgb) \
|
|
((((rgb) & RGB_565_UNPACKED_MASK) | \
|
|
((rgb) & RGB_565_UNPACKED_MASK) >> 16) & 0xffff)
|
|
#define RGB_565_UNPACKED_BLEND(a, b, alpha) \
|
|
((b) + (a) - ((((b) * (alpha)) >> 5) & RGB_565_UNPACKED_MASK))
|
|
#define RGB_565_UNPACKED_BLEND_UNMUL(a, b, alpha) \
|
|
((b) + ((((a) - (b)) * (alpha)) >> 5))
|
|
|
|
#define RGB_565_FROM_COMPONENTS(r, g, b) \
|
|
(((((r) >> 3) & 0x1f) << 11) | \
|
|
((((g) >> 2) & 0x3f) << 5) | \
|
|
(((b) >> 3) & 0x1f))
|
|
|
|
#define UNROLL2(op...) op op
|
|
#define UNROLL4(op...) UNROLL2(op) UNROLL2(op)
|
|
#define UNROLL8(op...) UNROLL4(op) UNROLL4(op)
|
|
#define UNROLL16(op...) UNROLL8(op) UNROLL8(op)
|
|
|
|
#if defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__) || \
|
|
defined(__ARM_ARCH_4T__)
|
|
# define __ARM_ARCH__ 4
|
|
#endif
|
|
|
|
#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
|
|
defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
|
|
defined(__ARM_ARCH_5TEJ__)
|
|
# define __ARM_ARCH__ 5
|
|
#endif
|
|
|
|
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
|
|
defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
|
|
defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
|
|
# define __ARM_ARCH__ 6
|
|
#endif
|
|
|
|
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
|
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)
|
|
# define __ARM_ARCH__ 7
|
|
#endif
|
|
|
|
|
|
#if defined(__ARM_ARCH__) && (__ARM_ARCH__ >= 5)
|
|
/* tested on ARMv6 (arm1136j-s), Nokia N800 CPU */
|
|
#define pld(addr, off) \
|
|
__asm__("pld [%[address], %[offset]]":: \
|
|
[address] "r" (addr), [offset] "i" (off))
|
|
#else
|
|
#define pld(addr, off)
|
|
#endif /* __ARMEL__ */
|
|
|
|
#ifndef always_inline
|
|
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
|
# define always_inline __attribute__((always_inline)) inline
|
|
#else
|
|
# define always_inline inline
|
|
#endif
|
|
#endif
|
|
|
|
#define IMG_BYTE_SIZE(stride, height, has_alpha) \
|
|
((stride) * (height) * (!(has_alpha) ? 2 : 3))
|
|
|
|
typedef struct _Soft16_Image Soft16_Image;
|
|
|
|
struct _Soft16_Image
|
|
{
|
|
const char *file; // file source - optional
|
|
const char *key; // key within file source - optional
|
|
time_t timestamp; // file modified timestamp
|
|
time_t laststat; // last time this file was statted
|
|
int w, h; // width and height in pixels
|
|
int stride; // pixel stride - likely a multiple of 2
|
|
DATA16 *pixels; // 16bpp pixels rgb565
|
|
DATA8 *alpha; // 8bit alpha mask - optional. points into pixels
|
|
int references; // refcount
|
|
RGBA_Image *source_im; // original source rgba image - if still reffed
|
|
|
|
Evas_Image_Load_Opts lo; // load options
|
|
|
|
const char *cache_key;
|
|
|
|
unsigned char have_alpha : 1; // 1 if we have halpha
|
|
unsigned char free_pixels : 1; // 1 if pixels should be freed
|
|
};
|
|
|
|
/**
|
|
* Image (evas_soft16_main.c)
|
|
*/
|
|
Soft16_Image *soft16_image_new(int w, int h, int stride, int have_alpha, DATA16 *pixels, int copy);
|
|
void soft16_image_free(Soft16_Image *im);
|
|
void soft16_image_destroy(Soft16_Image *im);
|
|
Soft16_Image *soft16_image_load(const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo);
|
|
void soft16_image_load_data(Soft16_Image *im);
|
|
void soft16_image_draw(Soft16_Image *src, Soft16_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h, int smooth);
|
|
Soft16_Image *soft16_image_alpha_set(Soft16_Image *im, int have_alpha);
|
|
Soft16_Image *soft16_image_size_set(Soft16_Image *im, int w, int h);
|
|
|
|
|
|
void soft16_image_draw_unscaled(Soft16_Image *src, Soft16_Image *dst, RGBA_Draw_Context *dc, const Evas_Rectangle sr, const Evas_Rectangle dr, const Evas_Rectangle cr);
|
|
void soft16_image_draw_scaled_sampled(Soft16_Image *src, Soft16_Image *dst, RGBA_Draw_Context *dc, const Evas_Rectangle sr, const Evas_Rectangle dr, const Evas_Rectangle cr);
|
|
|
|
/* convert/dither functions */
|
|
void soft16_image_convert_from_rgb(Soft16_Image *im, const DATA32 *src);
|
|
void soft16_image_convert_from_rgba(Soft16_Image *im, const DATA32 *src);
|
|
|
|
/**
|
|
* Image cache (evas_soft16_image_cache.c)
|
|
*/
|
|
void soft16_image_cache_flush(void);
|
|
int soft16_image_cache_size_get(void);
|
|
void soft16_image_cache_size_set(int limit);
|
|
|
|
Soft16_Image *soft16_image_cache_get(const char *cache_key);
|
|
void soft16_image_cache_put(Soft16_Image *im);
|
|
void soft16_image_cache_add(Soft16_Image *im, const char *cache_key);
|
|
void soft16_image_cache_del(Soft16_Image *im);
|
|
|
|
/**
|
|
* Rectangle (evas_soft16_rectangle.c)
|
|
*/
|
|
void soft16_rectangle_draw(Soft16_Image *dst, RGBA_Draw_Context *dc, int x, int y, int w, int h);
|
|
|
|
/**
|
|
* Polygon (evas_soft16_polygon.c)
|
|
*/
|
|
void
|
|
soft16_polygon_draw(Soft16_Image *dst, RGBA_Draw_Context *dc, RGBA_Polygon_Point *points);
|
|
|
|
/**
|
|
* Line (evas_soft16_line.c)
|
|
*/
|
|
void
|
|
soft16_line_draw(Soft16_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1);
|
|
|
|
|
|
/**
|
|
* Font (evas_soft16_font.c)
|
|
*/
|
|
void *soft16_font_glyph_new(void *data, RGBA_Font_Glyph *fg);
|
|
void soft16_font_glyph_free(void *ext_dat);
|
|
void soft16_font_glyph_draw(void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y);
|
|
|
|
#endif
|