jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b114f8c66db549362a8e9aa0bf0c7101f8090979

commit b114f8c66db549362a8e9aa0bf0c7101f8090979
Author: Jean-Philippe Andre <[email protected]>
Date:   Wed May 24 15:07:21 2017 +0900

    evas/elm: Add Efl.Image.image_size read-only property
    
    Following a remark in the mailing list, it is pretty clear that
    Efl.Gfx.View.view_size is not as simple as "image_size".
    
    I have defined this new image_size as being the size of the
    image file, and not what's currently loaded. So it will not
    apply to proxies, gl views, 3d scenes, etc... but only to
    standard image files loaded with file_set or mmap_set.
    Supported objects:
     - Efl.Canvas.Image (evas image)
     - Efl.Ui.Image (elm image)
     - Elm.Photocam (note: still needs some interface work)
    
    @feature
---
 src/lib/efl/interfaces/efl_image.eo              | 17 +++++++++++++++++
 src/lib/elementary/efl_ui_image.c                | 12 ++++++++++++
 src/lib/elementary/efl_ui_image.eo               |  1 +
 src/lib/elementary/elm_photocam.c                |  7 +++++++
 src/lib/elementary/elm_photocam.eo               |  3 ++-
 src/lib/evas/canvas/efl_canvas_image.c           |  4 ++++
 src/lib/evas/canvas/efl_canvas_image_internal.eo |  1 +
 src/lib/evas/canvas/evas_image_private.h         |  4 ++++
 src/lib/evas/canvas/evas_object_image.c          |  9 +++++++++
 9 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/src/lib/efl/interfaces/efl_image.eo 
b/src/lib/efl/interfaces/efl_image.eo
index a8b2337..0af0116 100644
--- a/src/lib/efl/interfaces/efl_image.eo
+++ b/src/lib/efl/interfaces/efl_image.eo
@@ -112,6 +112,23 @@ interface Efl.Image ()
             fill: Efl.Gfx.Border_Fill_Mode; [[Fill mode of the center region.]]
          }
       }
+      @property image_size {
+         [[This represents the size of the original image in pixels.
+
+           This may be different from the actual geometry on screen or even
+           the size of the loaded pixel buffer. This is the size of the image
+           as stored in the original file.
+
+           This is a read-only property, and may return 0x0.
+
+           @since 1.20
+         ]]
+         get {}
+         values {
+            w: int; [[The image width.]]
+            h: int; [[The image height.]]
+         }
+      }
 
       /* Note: those are obscure features of evas image. Expose in Efl.Image? 
*/
       @property content_hint {
diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index a41a835..6a9b91c 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -1232,6 +1232,18 @@ _efl_ui_image_efl_gfx_view_view_size_get(Eo *obj 
EINA_UNUSED, Efl_Ui_Image_Data
    if (h) *h = th;
 }
 
+EOLIAN static void
+_efl_ui_image_efl_image_image_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data 
*sd, int *w, int *h)
+{
+   if (sd->edje)
+     {
+        if (w) *w = 0;
+        if (h) *h = 0;
+        return;
+     }
+
+   efl_image_size_get(sd->img, w, h);
+}
 
 EAPI void
 elm_image_prescale_set(Evas_Object *obj,
diff --git a/src/lib/elementary/efl_ui_image.eo 
b/src/lib/elementary/efl_ui_image.eo
index f5f5930..566640d 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -128,6 +128,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, 
Efl.Ui.Draggable,
       Efl.Gfx.position { set; }
       Efl.Gfx.size { set; }
       Efl.Gfx.View.view_size { get; }
+      Efl.Image.image_size { get; }
       Efl.Image.Load.load_size { get; set; }
       Efl.Image.smooth_scale { get; set; }
       Efl.Orientation.orientation { get; set; }
diff --git a/src/lib/elementary/elm_photocam.c 
b/src/lib/elementary/elm_photocam.c
index 34f6d02..40ac8e6 100644
--- a/src/lib/elementary/elm_photocam.c
+++ b/src/lib/elementary/elm_photocam.c
@@ -1559,6 +1559,13 @@ _elm_photocam_efl_object_constructor(Eo *obj, 
Elm_Photocam_Data *_pd EINA_UNUSED
    return obj;
 }
 
+EOLIAN static void
+_elm_photocam_efl_image_image_size_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data 
*pd, int *w, int *h)
+{
+   if (w) *w = pd->size.imw;
+   if (h) *h = pd->size.imh;
+}
+
 static void
 _internal_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, Eina_File 
*f, Evas_Load_Error *ret)
 {
diff --git a/src/lib/elementary/elm_photocam.eo 
b/src/lib/elementary/elm_photocam.eo
index 1f18499..1d0ddc5 100644
--- a/src/lib/elementary/elm_photocam.eo
+++ b/src/lib/elementary/elm_photocam.eo
@@ -1,7 +1,7 @@
 class Elm.Photocam (Elm.Widget, Elm.Interface_Scrollable,
                     Elm.Interface.Atspi_Widget_Action, Efl.File,
                     Efl.Ui.Clickable, Efl.Ui.Scrollable, Efl.Gfx.View,
-                    Efl.Ui.Zoom, Efl.Orientation, Efl.Flipable)
+                    Efl.Ui.Zoom, Efl.Orientation, Efl.Flipable, Efl.Image)
 {
    [[Elementary photocam class]]
    legacy_prefix: elm_photocam;
@@ -53,6 +53,7 @@ class Elm.Photocam (Elm.Widget, Elm.Interface_Scrollable,
       Efl.Gfx.position { set; }
       Efl.Gfx.size { set; }
       Efl.Gfx.View.view_size { get; }
+      Efl.Image.image_size { get; }
       Efl.Ui.Zoom.zoom_animation { set; get; }
       Efl.Ui.Zoom.zoom { set; get; }
       Efl.Ui.Zoom.zoom_mode { set; get; }
diff --git a/src/lib/evas/canvas/efl_canvas_image.c 
b/src/lib/evas/canvas/efl_canvas_image.c
index 05b05b3..f6f0456 100644
--- a/src/lib/evas/canvas/efl_canvas_image.c
+++ b/src/lib/evas/canvas/efl_canvas_image.c
@@ -23,6 +23,8 @@ _evas_image_mmap_set(Eo *eo_obj, const Eina_File *f, const 
char *key)
    o->engine_data = ENFN->image_mmap(ENDT, o->cur->u.f, o->cur->key, 
&o->load_error, &lo);
    o->buffer_data_set = EINA_FALSE;
    _evas_image_done_set(eo_obj, obj, o);
+   o->file_size.w = o->cur->image.w;
+   o->file_size.h = o->cur->image.h;
 
    return EINA_TRUE;
 }
@@ -84,6 +86,8 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char 
*key)
    o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, 
&lo);
    o->buffer_data_set = EINA_FALSE;
    _evas_image_done_set(eo_obj, obj, o);
+   o->file_size.w = o->cur->image.w;
+   o->file_size.h = o->cur->image.h;
    if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
      {
         efl_del(o->file_obj);
diff --git a/src/lib/evas/canvas/efl_canvas_image_internal.eo 
b/src/lib/evas/canvas/efl_canvas_image_internal.eo
index 1676122..2f65a48 100644
--- a/src/lib/evas/canvas/efl_canvas_image_internal.eo
+++ b/src/lib/evas/canvas/efl_canvas_image_internal.eo
@@ -20,6 +20,7 @@ abstract Efl.Canvas.Image.Internal (Efl.Canvas.Object, 
Efl.Canvas.Filter.Interna
       Efl.Image.border_center_fill { get; set; }
       Efl.Image.scale_hint { get; set; }
       Efl.Image.content_hint { get; set; }
+      Efl.Image.image_size { get; }
       Efl.Gfx.Buffer.alpha { get; set; }
       Efl.Gfx.Buffer.buffer_update_add;
       Efl.Gfx.Buffer.colorspace { get; }
diff --git a/src/lib/evas/canvas/evas_image_private.h 
b/src/lib/evas/canvas/evas_image_private.h
index e21fec3..5c9f79c 100644
--- a/src/lib/evas/canvas/evas_image_private.h
+++ b/src/lib/evas/canvas/evas_image_private.h
@@ -118,6 +118,10 @@ struct _Evas_Image_Data
    Efl_Flip               flip_value;
    Efl_Orient             orient_value;
 
+   struct {
+      short          w, h;
+   } file_size;
+
    Eina_Bool         changed : 1;
    Eina_Bool         dirty_pixels : 1;
    Eina_Bool         filled : 1;
diff --git a/src/lib/evas/canvas/evas_object_image.c 
b/src/lib/evas/canvas/evas_object_image.c
index ceab232..ee32f18 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -395,6 +395,8 @@ _evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data 
*obj, Evas_Image_Dat
           }
         EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
      }
+   o->file_size.w = 0;
+   o->file_size.h = 0;
    o->written = EINA_FALSE;
    o->changed = EINA_TRUE;
    if (resize_call) evas_object_inform_call_image_resize(eo_obj);
@@ -703,6 +705,13 @@ _efl_canvas_image_internal_efl_gfx_fill_fill_get(Eo 
*eo_obj EINA_UNUSED, Evas_Im
 }
 
 EOLIAN static void
+_efl_canvas_image_internal_efl_image_image_size_get(Eo *eo_obj EINA_UNUSED, 
Evas_Image_Data *o, int *w, int *h)
+{
+   if (w) *w = o->file_size.w;
+   if (h) *h = o->file_size.h;
+}
+
+EOLIAN static void
 _efl_canvas_image_internal_efl_gfx_view_view_size_get(Eo *eo_obj, 
Evas_Image_Data *o, int *w, int *h)
 {
    int uvw, uvh;

-- 


Reply via email to