evas/evas3d: clean up camera code.
authorChunEon Park <hermet@hermet.pe.kr>
Wed, 16 Apr 2014 13:29:02 +0000 (22:29 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Fri, 25 Apr 2014 08:35:22 +0000 (17:35 +0900)
rewrite for more efl style.

src/lib/evas/canvas/evas_3d_camera.c

index 6607c04..8e84e68 100644 (file)
@@ -1,8 +1,3 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
 #include "evas_common_private.h"
 #include "evas_private.h"
 
@@ -21,14 +16,14 @@ _camera_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_eo_evas_3d_object_change_notify(Eo *obj, Evas_3D_Camera_Data *pd, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED)
+_eo_evas_3d_camera_eo_evas_3d_object_change_notify(Eo *obj,Evas_3D_Camera_Data *pd, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED)
 {
-   if (pd->nodes)
-     eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj);
+   if (pd->nodes) eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj);
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_eo_evas_3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd EINA_UNUSED)
+_eo_evas_3d_camera_eo_evas_3d_object_update_notify(Eo *obj EINA_UNUSED,
+                                                   Evas_3D_Camera_Data *pd EINA_UNUSED)
 {
 
 }
@@ -36,57 +31,54 @@ _eo_evas_3d_camera_eo_evas_3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_3D_
 void
 evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node)
 {
-   int count = 0;
    Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS);
-   if (pd->nodes == NULL)
+   int count = 0;
+
+   if (!pd->nodes)
      {
         pd->nodes = eina_hash_pointer_new(NULL);
 
-        if (pd->nodes == NULL)
+        if (!pd->nodes)
           {
-             ERR("Failed to create hash table.");
+             ERR("Failed to create hash table. camera(%p)", camera);
              return;
           }
      }
-   else
-     count = (int)eina_hash_find(pd->nodes, &node);
-
+   else count = (int)eina_hash_find(pd->nodes, &node);
    eina_hash_set(pd->nodes, &node, (const void *)(count + 1));
 }
 
 void
 evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node)
 {
-   int count = 0;
    Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS);
+   int count = 0;
 
-   if (pd->nodes == NULL)
+   if (!pd->nodes)
      {
         ERR("No node to delete.");
         return;
      }
 
    count = (int)eina_hash_find(pd->nodes, &node);
-
-   if (count == 1)
-     eina_hash_del(pd->nodes, &node, NULL);
-   else
-     eina_hash_set(pd->nodes, &node, (const void *)(count - 1));
+   if (count == 1) eina_hash_del(pd->nodes, &node, NULL);
+   else eina_hash_set(pd->nodes, &node, (const void *)(count - 1));
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_eo_base_constructor(Eo *obj, Evas_3D_Camera_Data *pd EINA_UNUSED)
+_eo_evas_3d_camera_eo_base_constructor(Eo *obj,
+                                       Evas_3D_Camera_Data *pd EINA_UNUSED)
 {
    eo_do_super(obj, MY_CLASS, eo_constructor());
    eo_do(obj, eo_evas_3d_object_type_set(EVAS_3D_OBJECT_TYPE_CAMERA));
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd)
+_eo_evas_3d_camera_eo_base_destructor(Eo *obj EINA_UNUSED,
+                                      Evas_3D_Camera_Data *pd)
 {
    //evas_3d_object_unreference(&pd->base);
-   if (pd->nodes)
-     eina_hash_free(pd->nodes);
+   if (pd->nodes) eina_hash_free(pd->nodes);
 }
 
 EAPI Evas_3D_Camera *
@@ -98,24 +90,28 @@ evas_3d_camera_add(Evas *e)
    Evas_Object *eo_obj = eo_add(MY_CLASS, e);
    eo_unref(eo_obj);
    return eo_obj;
-   //return evas_3d_camera_new(e);
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_projection_matrix_set(Eo *obj, Evas_3D_Camera_Data *pd, const Evas_Real *matrix)
+_eo_evas_3d_camera_projection_matrix_set(Eo *obj, Evas_3D_Camera_Data *pd,
+                                         const Evas_Real *matrix)
 {
    evas_mat4_array_set(&pd->projection, matrix);
    evas_3d_object_change(obj, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_projection_matrix_get(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real *matrix)
+_eo_evas_3d_camera_projection_matrix_get(Eo *obj EINA_UNUSED,
+                                         Evas_3D_Camera_Data *pd,
+                                         Evas_Real *matrix)
 {
    memcpy(matrix, &pd->projection.m[0], sizeof(Evas_Real) * 16);
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_projection_perspective_set(Eo *obj, Evas_3D_Camera_Data *pd, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far)
+_eo_evas_3d_camera_projection_perspective_set(Eo *obj, Evas_3D_Camera_Data *pd,
+                                              Evas_Real fovy, Evas_Real aspect,
+                                              Evas_Real near, Evas_Real far)
 {
    Evas_Real   xmax;
    Evas_Real   ymax;
@@ -128,14 +124,20 @@ _eo_evas_3d_camera_projection_perspective_set(Eo *obj, Evas_3D_Camera_Data *pd,
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_projection_frustum_set(Eo *obj, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
+_eo_evas_3d_camera_projection_frustum_set(Eo *obj, Evas_3D_Camera_Data *pd,
+                                          Evas_Real left, Evas_Real right,
+                                          Evas_Real bottom, Evas_Real top,
+                                          Evas_Real near, Evas_Real far)
 {
    evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, near, far);
    evas_3d_object_change(obj, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
 }
 
 EOLIAN static void
-_eo_evas_3d_camera_projection_ortho_set(Eo *obj, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
+_eo_evas_3d_camera_projection_ortho_set(Eo *obj, Evas_3D_Camera_Data *pd,
+                                        Evas_Real left, Evas_Real right,
+                                        Evas_Real bottom, Evas_Real top,
+                                        Evas_Real near, Evas_Real far)
 {
    evas_mat4_ortho_set(&pd->projection, left, right, bottom, top, near, far);
    evas_3d_object_change(obj, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);