From 1541b0e97e39487ac8d1a0af4fc832c9ba02e5c4 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 21 Oct 2011 08:17:14 +0000 Subject: [PATCH] add call to get maximum image size (eg max texture size) SVN revision: 64244 --- legacy/evas/src/lib/Evas.h | 22 ++++++++++++++++--- .../evas/src/lib/canvas/evas_object_image.c | 17 ++++++++++++++ legacy/evas/src/lib/include/evas_private.h | 3 +++ .../src/modules/engines/gl_x11/evas_engine.c | 10 +++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h index 5b6bc86099..7134031efc 100644 --- a/legacy/evas/src/lib/Evas.h +++ b/legacy/evas/src/lib/Evas.h @@ -2653,21 +2653,37 @@ EAPI void evas_image_cache_reload (Evas *e) EINA_ARG_NONN * @param e The given evas pointer. * @param size The cache size. * - * This function sets the image cache of canvas. + * This function sets the image cache of canvas in bytes. * */ EAPI void evas_image_cache_set (Evas *e, int size) EINA_ARG_NONNULL(1); /** - * Set the image cache + * Get the image cache * * @param e The given evas pointer. * - * This function returns the image cache of canvas. + * This function returns the image cache size of canvas in bytes. * */ EAPI int evas_image_cache_get (const Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE; +/** + * Get the maximum image size evas can possibly handle + * + * @param e The given evas pointer. + * @param maxw Pointer to hold the return value in pixels of the maxumum width + * @param maxh Pointer to hold the return value in pixels of the maximum height + * + * This function returns the larges image or surface size that evas can handle + * in pixels, and if there is one, returns EINA_TRUE. It returns EINA_FALSE + * if no extra constraint on maximum image size exists. You still should + * check the return values of @p maxw and @p maxh as there may still be a + * limit, just a much higher one. + * + */ +EAPI Eina_Bool evas_image_max_size_get (const Evas *e, int *maxw, int *maxh) EINA_ARG_NONNULL(1) EINA_PURE; + /** * @} */ diff --git a/legacy/evas/src/lib/canvas/evas_object_image.c b/legacy/evas/src/lib/canvas/evas_object_image.c index a5d857f673..d12392af02 100644 --- a/legacy/evas/src/lib/canvas/evas_object_image.c +++ b/legacy/evas/src/lib/canvas/evas_object_image.c @@ -2139,6 +2139,23 @@ evas_image_cache_get(const Evas *e) return e->engine.func->image_cache_get(e->engine.data.output); } +EAPI Eina_Bool +evas_image_max_size_get(const Evas *e, int *maxw, int *maxh) +{ + int w = 0, h = 0; + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return EINA_FALSE; + MAGIC_CHECK_END(); + + if (maxw) *maxw = 0xffff; + if (maxh) *maxh = 0xffff; + if (!e->engine.func->image_max_size_get) return EINA_FALSE; + e->engine.func->image_max_size_get(e->engine.data.output, &w, &h); + if (maxw) *maxw = w; + if (maxh) *maxh = h; + return EINA_TRUE; +} + /* all nice and private */ static void _proxy_unset(Evas_Object *proxy) diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index 304f8a5473..22dae7d243 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -834,6 +834,9 @@ struct _Evas_Func int (*image_animated_loop_count_get) (void *data, void *image); double (*image_animated_frame_duration_get) (void *data, void *image, int start_frame, int frame_num); Eina_Bool (*image_animated_frame_set) (void *data, void *image, int frame_index); + + /* max size query */ + void (*image_max_size_get) (void *data, int *maxw, int *maxh); }; struct _Evas_Image_Load_Func diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c index c929b0a311..acd5911391 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -3764,6 +3764,14 @@ eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index return EINA_TRUE; } +static void +eng_image_max_size_get(void *data, int *maxw, int *maxh) +{ + Render_Engine *re = (Render_Engine *)data; + if (maxw) *maxw = re->win->gl_context->shared->info.max_texture_size; + if (maxh) *maxh = re->win->gl_context->shared->info.max_texture_size; +} + static int module_open(Evas_Module *em) { @@ -3880,6 +3888,8 @@ module_open(Evas_Module *em) ORD(image_animated_frame_duration_get); ORD(image_animated_frame_set); + ORD(image_max_size_get); + /* now advertise out own api */ em->functions = (void *)(&func); return 1;