forked from enlightenment/efl
added the ability to set load scaledown, dpi or load size - the svg loader
uses these to know what to render and how (or has defaults if these are not set) SVN revision: 24868
This commit is contained in:
parent
efdd0bf4fa
commit
0889c589f2
|
@ -450,6 +450,12 @@ tile_mode);
|
|||
EAPI void evas_object_image_pixels_get_callback_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *o), void *data);
|
||||
EAPI void evas_object_image_pixels_dirty_set (Evas_Object *obj, Evas_Bool dirty);
|
||||
EAPI Evas_Bool evas_object_image_pixels_dirty_get (Evas_Object *obj);
|
||||
EAPI void evas_object_image_load_dpi_set (Evas_Object *obj, double dpi);
|
||||
EAPI double evas_object_image_load_dpi_get (Evas_Object *obj);
|
||||
EAPI void evas_object_image_load_size_set (Evas_Object *obj, int w, int h);
|
||||
EAPI void evas_object_image_load_size_get (Evas_Object *obj, int *w, int *h);
|
||||
EAPI void evas_object_image_load_scale_down_set (Evas_Object *obj, int scale_down);
|
||||
EAPI int evas_object_image_load_scale_down_get (Evas_Object *obj);
|
||||
|
||||
EAPI void evas_image_cache_flush (Evas *e);
|
||||
EAPI void evas_image_cache_reload (Evas *e);
|
||||
|
|
|
@ -36,6 +36,12 @@ struct _Evas_Object_Image
|
|||
int pixels_checked_out;
|
||||
int load_error;
|
||||
Evas_List *pixel_updates;
|
||||
|
||||
struct {
|
||||
unsigned char scale_down_by;
|
||||
double dpi;
|
||||
short w, h;
|
||||
} load_opts;
|
||||
|
||||
struct {
|
||||
void (*get_pixels) (void *data, Evas_Object *o);
|
||||
|
@ -123,6 +129,7 @@ EAPI void
|
|||
evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
Evas_Image_Load_Opts lo;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return;
|
||||
|
@ -150,10 +157,15 @@ evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
|
|||
obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
|
||||
o->engine_data);
|
||||
o->load_error = EVAS_LOAD_ERROR_NONE;
|
||||
lo.scale_down_by = o->load_opts.scale_down_by;
|
||||
lo.dpi = o->load_opts.dpi;
|
||||
lo.w = o->load_opts.w;
|
||||
lo.h = o->load_opts.h;
|
||||
o->engine_data = obj->layer->evas->engine.func->image_load(obj->layer->evas->engine.data.output,
|
||||
o->cur.file,
|
||||
o->cur.key,
|
||||
&o->load_error);
|
||||
&o->load_error,
|
||||
&lo);
|
||||
if (o->engine_data)
|
||||
{
|
||||
int w, h;
|
||||
|
@ -1062,6 +1074,155 @@ evas_object_image_pixels_dirty_get(Evas_Object *obj)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI void
|
||||
evas_object_image_load_dpi_set(Evas_Object *obj, double dpi)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o->load_opts.dpi = dpi;
|
||||
if (o->cur.file)
|
||||
{
|
||||
evas_object_image_unload(obj);
|
||||
evas_object_image_load(obj);
|
||||
o->changed = 1;
|
||||
evas_object_change(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI double
|
||||
evas_object_image_load_dpi_get(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return 0.0;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return 0.0;
|
||||
MAGIC_CHECK_END();
|
||||
return o->load_opts.dpi;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI void
|
||||
evas_object_image_load_size_set(Evas_Object *obj, int w, int h)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o->load_opts.w = w;
|
||||
o->load_opts.h = h;
|
||||
if (o->cur.file)
|
||||
{
|
||||
evas_object_image_unload(obj);
|
||||
evas_object_image_load(obj);
|
||||
o->changed = 1;
|
||||
evas_object_change(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI void
|
||||
evas_object_image_load_size_get(Evas_Object *obj, int *w, int *h)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
if (w) *w = o->load_opts.w;
|
||||
if (h) *h = o->load_opts.h;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI void
|
||||
evas_object_image_load_scale_down_set(Evas_Object *obj, int scale_down)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return;
|
||||
MAGIC_CHECK_END();
|
||||
o->load_opts.scale_down_by = scale_down;
|
||||
if (o->cur.file)
|
||||
{
|
||||
evas_object_image_unload(obj);
|
||||
evas_object_image_load(obj);
|
||||
o->changed = 1;
|
||||
evas_object_change(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
* FIXME: To be fixed.
|
||||
*
|
||||
*/
|
||||
EAPI int
|
||||
evas_object_image_load_scale_down_get(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
|
||||
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
||||
return 0;
|
||||
MAGIC_CHECK_END();
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
|
||||
return 0;
|
||||
MAGIC_CHECK_END();
|
||||
return o->load_opts.scale_down_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* To be documented.
|
||||
*
|
||||
|
@ -1209,14 +1370,20 @@ static void
|
|||
evas_object_image_load(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object_Image *o;
|
||||
Evas_Image_Load_Opts lo;
|
||||
|
||||
o = (Evas_Object_Image *)(obj->object_data);
|
||||
if (o->engine_data) return;
|
||||
|
||||
lo.scale_down_by = o->load_opts.scale_down_by;
|
||||
lo.dpi = o->load_opts.dpi;
|
||||
lo.w = o->load_opts.w;
|
||||
lo.h = o->load_opts.h;
|
||||
o->engine_data = obj->layer->evas->engine.func->image_load(obj->layer->evas->engine.data.output,
|
||||
o->cur.file,
|
||||
o->cur.key,
|
||||
&o->load_error);
|
||||
&o->load_error,
|
||||
&lo);
|
||||
if (o->engine_data)
|
||||
{
|
||||
int w, h;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
extern Evas_List *evas_modules;
|
||||
|
||||
RGBA_Image *
|
||||
evas_common_load_image_from_file(const char *file, const char *key)
|
||||
evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_Loadopts *lo)
|
||||
{
|
||||
Evas_Image_Load_Func *evas_image_load_func = NULL;
|
||||
Evas_List *l;
|
||||
|
@ -14,7 +14,7 @@ evas_common_load_image_from_file(const char *file, const char *key)
|
|||
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
im = evas_common_image_find(file, key, 0);
|
||||
im = evas_common_image_find(file, key, 0, lo);
|
||||
if (im)
|
||||
{
|
||||
evas_common_image_ref(im);
|
||||
|
@ -23,6 +23,8 @@ evas_common_load_image_from_file(const char *file, const char *key)
|
|||
im = evas_common_image_new();
|
||||
if (!im) return NULL;
|
||||
|
||||
if (lo) im->load_opts = *lo;
|
||||
|
||||
p = strrchr(file, '.');
|
||||
if (p)
|
||||
{
|
||||
|
|
|
@ -428,7 +428,7 @@ evas_common_image_unstore(RGBA_Image *im)
|
|||
|
||||
|
||||
RGBA_Image *
|
||||
evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
||||
evas_common_image_find(const char *filename, const char *key, DATA64 timestamp, RGBA_Image_Loadopts *lo)
|
||||
{
|
||||
char *real_filename = NULL;
|
||||
Evas_Object_List *l;
|
||||
|
|
|
@ -15,7 +15,7 @@ evas_imaging_image_load(const char *file, const char *key)
|
|||
if (!key) key = "";
|
||||
evas_common_cpu_init();
|
||||
evas_common_image_init();
|
||||
image = evas_common_load_image_from_file(file, key);
|
||||
image = evas_common_load_image_from_file(file, key, NULL);
|
||||
if (!image) return NULL;
|
||||
im = calloc(1, sizeof(Evas_Imaging_Image));
|
||||
if (!im)
|
||||
|
|
|
@ -86,6 +86,7 @@ typedef struct _Evas_Object_List Evas_Object_List;
|
|||
|
||||
typedef struct _Evas_Hash_El Evas_Hash_El;
|
||||
|
||||
typedef struct _RGBA_Image_Loadopts RGBA_Image_Loadopts;
|
||||
typedef struct _RGBA_Image RGBA_Image;
|
||||
typedef struct _RGBA_Surface RGBA_Surface;
|
||||
typedef struct _RGBA_Image_Span RGBA_Image_Span;
|
||||
|
@ -234,6 +235,13 @@ struct _RGBA_Surface
|
|||
RGBA_Image *im;
|
||||
};
|
||||
|
||||
struct _RGBA_Image_Loadopts
|
||||
{
|
||||
int scale_down_by; // if > 1 then use this
|
||||
double dpi; // if > 0.0 use this
|
||||
int w, h; // if > 0 use this
|
||||
};
|
||||
|
||||
struct _RGBA_Image
|
||||
{
|
||||
Evas_Object_List _list_data;
|
||||
|
@ -251,6 +259,7 @@ struct _RGBA_Image
|
|||
int references;
|
||||
// DATA64 timestamp;
|
||||
void *extended_info;
|
||||
RGBA_Image_Loadopts load_opts;
|
||||
};
|
||||
|
||||
struct _RGBA_Gradient_Color
|
||||
|
@ -672,12 +681,12 @@ void evas_common_image_set_cache (int size);
|
|||
int evas_common_image_get_cache (void);
|
||||
void evas_common_image_store (RGBA_Image *im);
|
||||
void evas_common_image_unstore (RGBA_Image *im);
|
||||
RGBA_Image *evas_common_image_find (const char *filename, const char *key, DATA64 timestamp);
|
||||
RGBA_Image *evas_common_image_find (const char *filename, const char *key, DATA64 timestamp, RGBA_Image_Loadopts *lo);
|
||||
int evas_common_image_ram_usage (RGBA_Image *im);
|
||||
void evas_common_image_dirty (RGBA_Image *im);
|
||||
void evas_common_image_cache_free (void);
|
||||
|
||||
RGBA_Image *evas_common_load_image_from_file (const char *file, const char *key);
|
||||
RGBA_Image *evas_common_load_image_from_file (const char *file, const char *key, RGBA_Image_Loadopts *lo);
|
||||
void evas_common_load_image_data_from_file(RGBA_Image *im);
|
||||
int evas_common_save_image_to_file (RGBA_Image *im, const char *file, const char *key, int quality, int compress);
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct _Evas_Font Evas_Font;
|
|||
typedef struct _Evas_Font_Alias Evas_Font_Alias;
|
||||
typedef struct _Evas_Data_Node Evas_Data_Node;
|
||||
typedef struct _Evas_Func_Node Evas_Func_Node;
|
||||
typedef RGBA_Image_Loadopts Evas_Image_Load_Opts;
|
||||
typedef struct _Evas_Func Evas_Func;
|
||||
typedef struct _Evas_Image_Load_Func Evas_Image_Load_Func;
|
||||
typedef struct _Evas_Image_Save_Func Evas_Image_Save_Func;
|
||||
|
@ -559,7 +560,7 @@ struct _Evas_Func
|
|||
void (*gradient_map) (void *data, void *context, void *gradient, int spread);
|
||||
void (*gradient_draw) (void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread);
|
||||
|
||||
void *(*image_load) (void *data, const char *file, const char *key, int *error);
|
||||
void *(*image_load) (void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
void *(*image_new_from_data) (void *data, int w, int h, DATA32 *image_data);
|
||||
void *(*image_new_from_copied_data) (void *data, int w, int h, DATA32 *image_data);
|
||||
void (*image_free) (void *data, void *image);
|
||||
|
|
|
@ -58,7 +58,7 @@ static void *eng_gradient_geometry_init(void *data, void *gradient, int spread);
|
|||
static int eng_gradient_alpha_get(void *data, void *gradient, int spread, int op);
|
||||
static void eng_gradient_map(void *data, void *context, void *gradient, int spread);
|
||||
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void eng_image_free(void *data, void *image);
|
||||
|
@ -862,18 +862,18 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
|
|||
}
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, char *file, char *key, int *error)
|
||||
eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Render_Engine *re;
|
||||
Evas_Cairo_Image *im;
|
||||
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
if (error) *error = 0;
|
||||
|
||||
im = calloc(1, sizeof(Evas_Cairo_Image));
|
||||
if (!im) return NULL;
|
||||
|
||||
im->im = evas_common_load_image_from_file(file, key);
|
||||
im->im = evas_common_load_image_from_file(file, key, lo);
|
||||
if (!im->im)
|
||||
{
|
||||
free(im);
|
||||
|
|
|
@ -28,7 +28,7 @@ static RGBA_Image *_dfb_image_find(const char *filename, const char *key, DATA64
|
|||
*/
|
||||
|
||||
void *
|
||||
evas_engine_directfb_image_load(void *data, char *file, char *key, int *error)
|
||||
evas_engine_directfb_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Render_Engine *re;
|
||||
DFBSurfaceDescription dsc;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef EVAS_ENGINE_DFB_IMAGE_OBJECTS_H
|
||||
#define EVAS_ENGINE_DFB_IMAGE_OBJECTS_H
|
||||
void *evas_engine_directfb_image_load(void *data, char *file,
|
||||
char *key, int *error);
|
||||
char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
void *evas_engine_directfb_image_new_from_data(void *data, int w,
|
||||
int h,
|
||||
DATA32 *
|
||||
|
|
|
@ -108,6 +108,7 @@ struct _Evas_GL_Image
|
|||
Evas_GL_Context *gc;
|
||||
RGBA_Image *im;
|
||||
Evas_GL_Texture *tex;
|
||||
RGBA_Image_Loadopts load_opts;
|
||||
int putcount;
|
||||
int references;
|
||||
char dirty : 1;
|
||||
|
@ -175,7 +176,7 @@ void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image
|
|||
void evas_gl_common_texture_free(Evas_GL_Texture *tex);
|
||||
void evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int smooth);
|
||||
|
||||
Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key);
|
||||
Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key, Evas_Image_Load_Opts *lo);
|
||||
Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data);
|
||||
Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data);
|
||||
Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "evas_gl_private.h"
|
||||
|
||||
Evas_GL_Image *
|
||||
evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key)
|
||||
evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Evas_GL_Image *im;
|
||||
RGBA_Image *im_im;
|
||||
Evas_List *l;
|
||||
|
||||
im_im = evas_common_load_image_from_file(file, key);
|
||||
im_im = evas_common_load_image_from_file(file, key, lo);
|
||||
if (!im_im) return NULL;
|
||||
|
||||
for (l = gc->images; l; l = l->next)
|
||||
|
@ -35,6 +35,7 @@ evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key)
|
|||
im->gc = gc;
|
||||
im->references = 1;
|
||||
im->cached = 1;
|
||||
if (lo) im->load_opts = *lo;
|
||||
gc->images = evas_list_prepend(gc->images, im);
|
||||
return im;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ static void *eng_gradient_geometry_init(void *data, void *gradient, int spread);
|
|||
static int eng_gradient_alpha_get(void *data, void *gradient, int spread, int op);
|
||||
static void eng_gradient_map(void *data, void *context, void *gradient, int spread);
|
||||
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void eng_image_free(void *data, void *image);
|
||||
|
@ -819,14 +819,14 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
|
|||
}
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, char *file, char *key, int *error)
|
||||
eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
*error = 0;
|
||||
eng_window_use(re->win);
|
||||
return evas_gl_common_image_load(re->win->gl_context, file, key);
|
||||
return evas_gl_common_image_load(re->win->gl_context, file, key, Evas_Image_Load_Opts *lo);
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
@ -257,10 +257,10 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
|
|||
}
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, const char *file, const char *key, int *error)
|
||||
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
*error = 0;
|
||||
return evas_common_load_image_from_file(file, key);
|
||||
return evas_common_load_image_from_file(file, key, lo);
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
@ -65,7 +65,7 @@ static void *eng_gradient_geometry_init(void *data, void *gradient, int spread);
|
|||
static int eng_gradient_alpha_get(void *data, void *gradient, int spread, int op);
|
||||
static void eng_gradient_map(void *data, void *context, void *gradient, int spread);
|
||||
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread);
|
||||
static void *eng_image_load(void *data, const char *file, const char *key, int *error);
|
||||
static void *eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void eng_image_free(void *data, void *image);
|
||||
|
@ -476,14 +476,14 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
|
|||
}
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, const char *file, const char *key, int *error)
|
||||
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Render_Engine *re;
|
||||
XR_Image *im;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
*error = 0;
|
||||
im = _xre_image_load(re->xinf, file, key);
|
||||
im = _xre_image_load(re->xinf, file, key, lo);
|
||||
return im;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,12 +99,13 @@ struct _XR_Image
|
|||
char *format;
|
||||
const char *comment;
|
||||
Tilebuf *updates;
|
||||
RGBA_Image_Loadopts load_opts;
|
||||
unsigned char alpha : 1;
|
||||
unsigned char dirty : 1;
|
||||
unsigned char free_data : 1;
|
||||
};
|
||||
|
||||
XR_Image *_xre_image_load(Ximage_Info *xinf, const char *file, const char *key);
|
||||
XR_Image *_xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image_Load_Opts *lo);
|
||||
XR_Image *_xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data);
|
||||
XR_Image *_xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data);
|
||||
XR_Image *_xre_image_new(Ximage_Info *xinf, int w, int h);
|
||||
|
|
|
@ -66,16 +66,26 @@ __xre_image_find(char *fkey)
|
|||
}
|
||||
|
||||
XR_Image *
|
||||
_xre_image_load(Ximage_Info *xinf, const char *file, const char *key)
|
||||
_xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
XR_Image *im;
|
||||
char buf[4096];
|
||||
|
||||
if (!file) return NULL;
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s//://%s", xinf->disp, xinf->root, file, key);
|
||||
if (!lo)
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s//://%s", xinf->disp, xinf->root, file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s", xinf->disp, xinf->root, file);
|
||||
}
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s", xinf->disp, xinf->root, file);
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//@%p@%lx@/%s//://%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, xinf->disp, xinf->root, file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//@%p@%lx@/%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, xinf->disp, xinf->root, file);
|
||||
}
|
||||
im = __xre_image_find(buf);
|
||||
if (im)
|
||||
{
|
||||
|
@ -84,7 +94,7 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key)
|
|||
|
||||
im = calloc(1, sizeof(XR_Image));
|
||||
if (!im) return NULL;
|
||||
im->im = evas_common_load_image_from_file(file, key);
|
||||
im->im = evas_common_load_image_from_file(file, key, lo);
|
||||
if (!im->im)
|
||||
{
|
||||
free(im);
|
||||
|
@ -98,6 +108,7 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key)
|
|||
im->w = im->im->image->w;
|
||||
im->h = im->im->image->h;
|
||||
im->references = 1;
|
||||
if (lo) im->load_opts = *lo;
|
||||
if (im->im->info.comment) im->comment = evas_stringshare_add(im->im->info.comment);
|
||||
// if (im->im->info.format == 1) im->format = evas_stringshare_add("png");
|
||||
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) im->alpha = 1;
|
||||
|
@ -249,7 +260,7 @@ _xre_image_copy(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
@ -372,7 +383,7 @@ _xre_image_data_get(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
@ -503,7 +514,7 @@ _xre_image_surface_gen(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
|
|
@ -68,7 +68,7 @@ static void *eng_gradient_geometry_init(void *data, void *gradient, int spread);
|
|||
static int eng_gradient_alpha_get(void *data, void *gradient, int spread, int op);
|
||||
static void eng_gradient_map(void *data, void *context, void *gradient, int spread);
|
||||
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error);
|
||||
static void *eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo);
|
||||
static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data);
|
||||
static void eng_image_free(void *data, void *image);
|
||||
|
@ -486,14 +486,14 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
|
|||
}
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, char *file, char *key, int *error)
|
||||
eng_image_load(void *data, char *file, char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Render_Engine *re;
|
||||
XR_Image *im;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
*error = 0;
|
||||
im = _xre_image_load(re->xcbinf, file, key);
|
||||
im = _xre_image_load(re->xcbinf, file, key, lo);
|
||||
return im;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ struct _XR_Image
|
|||
unsigned char free_data : 1;
|
||||
};
|
||||
|
||||
XR_Image *_xre_image_load(XCBimage_Info *xcbinf, char *file, char *key);
|
||||
XR_Image *_xre_image_load(XCBimage_Info *xcbinf, char *file, char *key, Evas_Image_Load_Opts *lo);
|
||||
XR_Image *_xre_image_new_from_data(XCBimage_Info *xcbinf, int w, int h, void *data);
|
||||
XR_Image *_xre_image_new_from_copied_data(XCBimage_Info *xcbinf, int w, int h, void *data);
|
||||
XR_Image *_xre_image_new(XCBimage_Info *xcbinf, int w, int h);
|
||||
|
|
|
@ -66,16 +66,26 @@ __xre_image_find(char *fkey)
|
|||
}
|
||||
|
||||
XR_Image *
|
||||
_xre_image_load(XCBimage_Info *xcbinf, char *file, char *key)
|
||||
_xre_image_load(XCBimage_Info *xcbinf, char *file, char *key, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
XR_Image *im;
|
||||
char buf[4096];
|
||||
|
||||
if (!file) return NULL;
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "/@%p@%x@/%s//://%s", xcbinf->conn, xcbinf->root.window.xid, file, key);
|
||||
if (!lo)
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s//://%s", xinf->disp, xinf->root, file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "/@%p@%lx@/%s", xinf->disp, xinf->root, file);
|
||||
}
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "/@%p@%x@/%s", xcbinf->conn, xcbinf->root.window.xid, file);
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//@%p@%lx@/%s//://%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, xinf->disp, xinf->root, file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//@%p@%lx@/%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, xinf->disp, xinf->root, file);
|
||||
}
|
||||
im = __xre_image_find(buf);
|
||||
if (im)
|
||||
{
|
||||
|
@ -84,7 +94,7 @@ _xre_image_load(XCBimage_Info *xcbinf, char *file, char *key)
|
|||
|
||||
im = calloc(1, sizeof(XR_Image));
|
||||
if (!im) return NULL;
|
||||
im->im = evas_common_load_image_from_file(file, key);
|
||||
im->im = evas_common_load_image_from_file(file, key, lo);
|
||||
if (!im->im)
|
||||
{
|
||||
free(im);
|
||||
|
@ -98,6 +108,7 @@ _xre_image_load(XCBimage_Info *xcbinf, char *file, char *key)
|
|||
im->w = im->im->image->w;
|
||||
im->h = im->im->image->h;
|
||||
im->references = 1;
|
||||
if (lo) im->load_opts = *lo;
|
||||
if (im->im->info.comment) im->comment = (char *)evas_stringshare_add(im->im->info.comment);
|
||||
/* if (im->im->info.format == 1) im->format = evas_stringshare_add("png"); */
|
||||
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) im->alpha = 1;
|
||||
|
@ -249,7 +260,7 @@ _xre_image_copy(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
@ -373,7 +384,7 @@ _xre_image_data_get(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
@ -507,7 +518,7 @@ _xre_image_surface_gen(XR_Image *im)
|
|||
if (im->data) data = im->data;
|
||||
else
|
||||
{
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key);
|
||||
if (!im->im) im->im = evas_common_load_image_from_file(im->file, im->key, &(im->load_opts));
|
||||
if (im->im)
|
||||
{
|
||||
evas_common_load_image_data_from_file(im->im);
|
||||
|
|
|
@ -44,6 +44,7 @@ evas_image_load_file_head_svg(RGBA_Image *im, const char *file, const char *key)
|
|||
|
||||
RsvgHandle *rsvg;
|
||||
RsvgDimensionData dim;
|
||||
int w, h;
|
||||
|
||||
if (!file) return 0;
|
||||
|
||||
|
@ -70,11 +71,37 @@ evas_image_load_file_head_svg(RGBA_Image *im, const char *file, const char *key)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
rsvg_handle_set_dpi_x_y(rsvg, 90, 90);
|
||||
|
||||
rsvg_handle_get_dimensions(rsvg, &dim);
|
||||
im->image->w = dim.width;
|
||||
im->image->h = dim.height;
|
||||
w = dim.width;
|
||||
h = dim.height;
|
||||
if (im->load_opts.scale_down_by > 1)
|
||||
{
|
||||
w /= im->load_opts.scale_down_by;
|
||||
h /= im->load_opts.scale_down_by;
|
||||
}
|
||||
else if (im->load_opts.dpi > 0.0)
|
||||
{
|
||||
w = (w * im->load_opts.dpi) / 90.0;
|
||||
h = (h * im->load_opts.dpi) / 90.0;
|
||||
}
|
||||
else if ((im->load_opts.w > 0) &&
|
||||
(im->load_opts.h > 0))
|
||||
{
|
||||
int w2, h2;
|
||||
|
||||
w2 = im->load_opts.w;
|
||||
h2 = (im->load_opts.w * h) / w;
|
||||
if (h2 > im->load_opts.h)
|
||||
{
|
||||
h2 = im->load_opts.h;
|
||||
w2 = (im->load_opts.h * w) / h;
|
||||
}
|
||||
}
|
||||
if (w < 1) w = 1;
|
||||
if (h < 1) h = 1;
|
||||
im->image->w = w;
|
||||
im->image->h = h;
|
||||
im->flags |= RGBA_IMAGE_HAS_ALPHA;
|
||||
rsvg_handle_free(rsvg);
|
||||
chdir(pcwd);
|
||||
|
@ -114,10 +141,34 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
rsvg_handle_set_dpi_x_y(rsvg, 90, 90);
|
||||
rsvg_handle_get_dimensions(rsvg, &dim);
|
||||
w = dim.width;
|
||||
h = dim.height;
|
||||
if (im->load_opts.scale_down_by > 1)
|
||||
{
|
||||
w /= im->load_opts.scale_down_by;
|
||||
h /= im->load_opts.scale_down_by;
|
||||
}
|
||||
else if (im->load_opts.dpi > 0.0)
|
||||
{
|
||||
w = (w * im->load_opts.dpi) / 90.0;
|
||||
h = (h * im->load_opts.dpi) / 90.0;
|
||||
}
|
||||
else if ((im->load_opts.w > 0) &&
|
||||
(im->load_opts.h > 0))
|
||||
{
|
||||
int w2, h2;
|
||||
|
||||
w2 = im->load_opts.w;
|
||||
h2 = (im->load_opts.w * h) / w;
|
||||
if (h2 > im->load_opts.h)
|
||||
{
|
||||
h2 = im->load_opts.h;
|
||||
w2 = (im->load_opts.h * w) / h;
|
||||
}
|
||||
}
|
||||
if (w < 1) w = 1;
|
||||
if (h < 1) h = 1;
|
||||
im->image->w = w;
|
||||
im->image->h = h;
|
||||
im->flags |= RGBA_IMAGE_HAS_ALPHA;
|
||||
|
@ -154,6 +205,7 @@ evas_image_load_file_data_svg(RGBA_Image *im, const char *file, const char *key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
cairo_scale(cr, (double)im->image->w / dim.em, (double)im->image->h / dim.ex);
|
||||
rsvg_handle_render_cairo(rsvg, cr);
|
||||
cairo_surface_destroy(surface);
|
||||
/* need to check if this is required... */
|
||||
|
|
Loading…
Reference in New Issue