[EFL] Rename ewk_tiled_*.c to ewk_tiled_*.cpp
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:13:19 +0000 (14:13 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Oct 2011 14:13:19 +0000 (14:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68599

Use a C++ compiler for these files and fix compile issues and coding style.

Reviewed by Hajime Morita.

* CMakeListsEfl.txt:
* ewk/ewk_tiled_backing_store.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_backing_store.c.
* ewk/ewk_tiled_backing_store.h:
* ewk/ewk_tiled_matrix.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_matrix.c.
* ewk/ewk_tiled_model.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_model.c.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96495 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/efl/CMakeListsEfl.txt
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp [moved from Source/WebKit/efl/ewk/ewk_tiled_backing_store.c with 97% similarity]
Source/WebKit/efl/ewk/ewk_tiled_backing_store.h
Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp [moved from Source/WebKit/efl/ewk/ewk_tiled_matrix.c with 90% similarity]
Source/WebKit/efl/ewk/ewk_tiled_model.cpp [moved from Source/WebKit/efl/ewk/ewk_tiled_model.c with 93% similarity]

index f9db35c..76dcdd9 100644 (file)
@@ -74,9 +74,9 @@ LIST(APPEND WebKit_SOURCES
     efl/ewk/ewk_network.cpp
     efl/ewk/ewk_settings.cpp
     efl/ewk/ewk_protocol_handler.cpp
-    efl/ewk/ewk_tiled_backing_store.c
-    efl/ewk/ewk_tiled_matrix.c
-    efl/ewk/ewk_tiled_model.c
+    efl/ewk/ewk_tiled_backing_store.cpp
+    efl/ewk/ewk_tiled_matrix.cpp
+    efl/ewk/ewk_tiled_model.cpp
     efl/ewk/ewk_util.cpp
     efl/ewk/ewk_view.cpp
     efl/ewk/ewk_view_single.cpp
index b342632..64739c9 100755 (executable)
@@ -1,3 +1,18 @@
+2011-10-03  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL] Rename ewk_tiled_*.c to ewk_tiled_*.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=68599
+
+        Use a C++ compiler for these files and fix compile issues and coding style.
+
+        Reviewed by Hajime Morita.
+
+        * CMakeListsEfl.txt:
+        * ewk/ewk_tiled_backing_store.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_backing_store.c.
+        * ewk/ewk_tiled_backing_store.h:
+        * ewk/ewk_tiled_matrix.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_matrix.c.
+        * ewk/ewk_tiled_model.cpp: Renamed from Source/WebKit/efl/ewk/ewk_tiled_model.c.
+
 2011-09-29  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Use C++ type cast instead of C style type cast
 #include "config.h"
 #include "ewk_tiled_backing_store.h"
 
-#define _GNU_SOURCE
+#include "ewk_tiled_matrix.h"
 #include "ewk_tiled_private.h"
 #include <Ecore.h>
 #include <Eina.h>
+#include <algorithm>
 #include <errno.h>
 #include <math.h>
 #include <stdio.h> // XXX REMOVE ME LATER
 
 #define IDX(col, row, rowspan) (col + (row * rowspan))
 
-#if !defined(MIN)
-# define MIN(a, b) ((a < b) ? a : b)
-#endif
-
-#if !defined(MAX)
-# define MAX(a, b) ((a > b) ? a : b)
-#endif
-
-typedef enum _Ewk_Tiled_Backing_Store_Pre_Render_Priority Ewk_Tiled_Backing_Store_Pre_Render_Priority;
 typedef struct _Ewk_Tiled_Backing_Store_Data Ewk_Tiled_Backing_Store_Data;
 typedef struct _Ewk_Tiled_Backing_Store_Item Ewk_Tiled_Backing_Store_Item;
 typedef struct _Ewk_Tiled_Backing_Store_Pre_Render_Request Ewk_Tiled_Backing_Store_Pre_Render_Request;
@@ -50,6 +42,7 @@ enum _Ewk_Tiled_Backing_Store_Pre_Render_Priority {
     PRE_RENDER_PRIORITY_LOW = 0, /**< Append the request to the list */
     PRE_RENDER_PRIORITY_HIGH     /**< Prepend the request to the list */
 };
+typedef enum _Ewk_Tiled_Backing_Store_Pre_Render_Priority Ewk_Tiled_Backing_Store_Pre_Render_Priority;
 
 struct _Ewk_Tiled_Backing_Store_Item {
     EINA_INLIST;
@@ -126,7 +119,7 @@ static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
 int _ewk_tiled_log_dom = -1;
 
 #define PRIV_DATA_GET_OR_RETURN(obj, ptr, ...)                       \
-    Ewk_Tiled_Backing_Store_Data *ptr = evas_object_smart_data_get(obj); \
+    Ewk_Tiled_Backing_Store_Data* ptr = static_cast<Ewk_Tiled_Backing_Store_Data*>(evas_object_smart_data_get(obj)); \
     if (!ptr) {                                                      \
         CRITICAL("no private data in obj=%p", obj);                  \
         return __VA_ARGS__;                                          \
@@ -138,7 +131,7 @@ static inline void _ewk_tiled_backing_store_changed(Ewk_Tiled_Backing_Store_Data
 
 static inline void _ewk_tiled_backing_store_updates_process(Ewk_Tiled_Backing_Store_Data *priv)
 {
-    void *data = NULL;
+    void *data = 0;
 
     /* Do not process updates. Note that we still want to get updates requests
      * in the queue in order to not miss any updates after the render is
@@ -158,7 +151,7 @@ static inline void _ewk_tiled_backing_store_updates_process(Ewk_Tiled_Backing_St
 
 static int _ewk_tiled_backing_store_flush(void *data)
 {
-    Ewk_Tiled_Backing_Store_Data *priv = data;
+    Ewk_Tiled_Backing_Store_Data* priv = static_cast<Ewk_Tiled_Backing_Store_Data*>(data);
     Ewk_Tile_Unused_Cache *tuc = ewk_tile_matrix_unused_cache_get(priv->model.matrix);
 
     if (tuc) {
@@ -176,7 +169,7 @@ static Ewk_Tile *_ewk_tiled_backing_store_tile_new(Ewk_Tiled_Backing_Store_Data
     Evas *evas = evas_object_evas_get(priv->self);
     if (!evas) {
         CRITICAL("evas_object_evas_get failed!");
-        return NULL;
+        return 0;
     }
 
     t = ewk_tile_matrix_tile_new
@@ -184,7 +177,7 @@ static Ewk_Tile *_ewk_tiled_backing_store_tile_new(Ewk_Tiled_Backing_Store_Data
 
     if (!t) {
         CRITICAL("ewk_tile_matrix_tile_new failed!");
-        return NULL;
+        return 0;
     }
 
     return t;
@@ -213,7 +206,7 @@ static void _ewk_tiled_backing_store_item_resize(Ewk_Tiled_Backing_Store_Item *i
 static void _ewk_tiled_backing_store_tile_associate(Ewk_Tiled_Backing_Store_Data *priv, Ewk_Tile *t, Ewk_Tiled_Backing_Store_Item *it)
 {
     if (it->tile)
-        CRITICAL("it->tile=%p, but it should be NULL!", it->tile);
+        CRITICAL("it->tile=%p, but it should be 0!", it->tile);
     it->tile = t;
     evas_object_move(it->tile->image, it->geometry.x, it->geometry.y);
     evas_object_resize(it->tile->image, it->geometry.w, it->geometry.h);
@@ -237,7 +230,7 @@ static void _ewk_tiled_backing_store_tile_dissociate(Ewk_Tiled_Backing_Store_Dat
     tuc = ewk_tile_matrix_unused_cache_get(priv->model.matrix);
     ewk_tile_unused_cache_auto_flush(tuc);
 
-    it->tile = NULL;
+    it->tile = 0;
 }
 
 static void _ewk_tiled_backing_store_tile_dissociate_all(Ewk_Tiled_Backing_Store_Data *priv)
@@ -259,7 +252,9 @@ static inline Eina_Bool _ewk_tiled_backing_store_pre_render_request_add(Ewk_Tile
 {
     Ewk_Tiled_Backing_Store_Pre_Render_Request *r;
 
-    MALLOC_OR_OOM_RET(r, sizeof(*r), EINA_FALSE);
+    r = static_cast<Ewk_Tiled_Backing_Store_Pre_Render_Request*>(malloc(sizeof(*r)));
+    if (!r)
+        return EINA_FALSE;
 
     if (priority == PRE_RENDER_PRIORITY_HIGH)
         priv->render.pre_render_requests = eina_inlist_prepend
@@ -365,7 +360,7 @@ end:
 
 static Eina_Bool _ewk_tiled_backing_store_item_process_idler_cb(void *data)
 {
-    Ewk_Tiled_Backing_Store_Data *priv = data;
+    Ewk_Tiled_Backing_Store_Data* priv = static_cast<Ewk_Tiled_Backing_Store_Data*>(data);
 
     if (priv->process.pre_cb)
         data = priv->process.pre_cb(priv->process.pre_data, priv->self);
@@ -376,7 +371,7 @@ static Eina_Bool _ewk_tiled_backing_store_item_process_idler_cb(void *data)
         priv->process.post_cb(priv->process.post_data, data, priv->self);
 
     if (!priv->render.pre_render_requests) {
-        priv->render.idler = NULL;
+        priv->render.idler = 0;
         return EINA_FALSE;
     }
 
@@ -389,7 +384,7 @@ static inline void _ewk_tiled_backing_store_item_process_idler_stop(Ewk_Tiled_Ba
         return;
 
     ecore_idler_del(priv->render.idler);
-    priv->render.idler = NULL;
+    priv->render.idler = 0;
 }
 
 static inline void _ewk_tiled_backing_store_item_process_idler_start(Ewk_Tiled_Backing_Store_Data *priv)
@@ -447,9 +442,9 @@ static inline Eina_Bool _ewk_tiled_backing_store_item_fill(Ewk_Tiled_Backing_Sto
         t = ewk_tile_matrix_tile_exact_get(priv->model.matrix, m_col, m_row, zoom);
 
         if (!t) {
-            /* NOTE: it never returns NULL if it->tile was set! */
+            /* NOTE: it never returns 0 if it->tile was set! */
             if (it->tile) {
-                CRITICAL("it->tile=%p, but it should be NULL!", it->tile);
+                CRITICAL("it->tile=%p, but it should be 0!", it->tile);
                 _ewk_tiled_backing_store_tile_dissociate(priv, it,
                                                          last_used);
             }
@@ -483,21 +478,23 @@ static Ewk_Tiled_Backing_Store_Item *_ewk_tiled_backing_store_item_add(Ewk_Tiled
 
     DBG("o=%p", priv->self);
 
-    MALLOC_OR_OOM_RET(it, sizeof(*it), NULL);
+    it = static_cast<Ewk_Tiled_Backing_Store_Item*>(malloc(sizeof(*it)));
+    if (!it)
+        return 0;
 
     tw = priv->view.tile.w;
     th = priv->view.tile.h;
     x = priv->view.offset.base.x + priv->view.x + tw  *col;
     y = priv->view.offset.base.y + priv->view.y + th  *row;
 
-    it->tile = NULL;
+    it->tile = 0;
 
     it->smooth_scale = priv->view.tile.zoom_weak_smooth_scale;
     _ewk_tiled_backing_store_item_move(it, x, y);
     _ewk_tiled_backing_store_item_resize(it, tw, th);
     if (!_ewk_tiled_backing_store_item_fill(priv, it, col, row)) {
         free(it);
-        return NULL;
+        return 0;
     }
 
     return it;
@@ -582,7 +579,7 @@ static void _ewk_tiled_backing_store_view_rows_range_del(Ewk_Tiled_Backing_Store
 {
     for (; start < end; start++) {
         _ewk_tiled_backing_store_view_row_del(priv, *start);
-        *start = NULL;
+        *start = 0;
     }
 }
 
@@ -596,14 +593,14 @@ static void _ewk_tiled_backing_store_view_rows_all_del(Ewk_Tiled_Backing_Store_D
     _ewk_tiled_backing_store_view_rows_range_del(priv, start, end);
 
     free(priv->view.items);
-    priv->view.items = NULL;
+    priv->view.items = 0;
     priv->view.cols = 0;
     priv->view.rows = 0;
 }
 
 static void _ewk_tiled_backing_store_render(void *data, Ewk_Tile *t, const Eina_Rectangle *area)
 {
-    Ewk_Tiled_Backing_Store_Data *priv = data;
+    Ewk_Tiled_Backing_Store_Data* priv = static_cast<Ewk_Tiled_Backing_Store_Data*>(data);
 
     INF("TODO %p (visible? %d) [%lu,%lu] %d,%d + %dx%d",
         t, t->visible, t->col, t->row, area->x, area->y, area->w, area->h);
@@ -696,7 +693,9 @@ static void _ewk_tiled_backing_store_smart_add(Evas_Object *o)
 
     DBG("o=%p", o);
 
-    CALLOC_OR_OOM_RET(priv, sizeof(*priv));
+    priv = static_cast<Ewk_Tiled_Backing_Store_Data*>(calloc(1, sizeof(*priv)));
+    if (!priv)
+        return;
 
     priv->self = o;
     priv->view.tile.zoom = 1.0;
@@ -732,7 +731,7 @@ static void _ewk_tiled_backing_store_smart_add(Evas_Object *o)
     evas_object_show(priv->contents_clipper);
     evas_object_smart_member_add(priv->contents_clipper, o);
 
-    _ewk_tiled_backing_store_model_matrix_create(priv, NULL);
+    _ewk_tiled_backing_store_model_matrix_create(priv, 0);
     evas_object_move(priv->base.clipper, 0, 0);
     evas_object_resize(priv->base.clipper, 0, 0);
     evas_object_clip_set(priv->contents_clipper, priv->base.clipper);
@@ -831,7 +830,12 @@ static void _ewk_tiled_backing_store_recalc_renderers(Ewk_Tiled_Backing_Store_Da
         end = priv->view.items + old_rows;
         _ewk_tiled_backing_store_view_rows_range_del(priv, start, end);
     }
-    REALLOC_OR_OOM_RET(priv->view.items, sizeof(Eina_Inlist*) * (int)rows);
+
+    void* newItems = realloc(priv->view.items, sizeof(Eina_Inlist*) * rows);
+    if (!newItems)
+        return;
+
+    priv->view.items = static_cast<Eina_Inlist**>(newItems);
     priv->view.rows = rows;
     priv->view.cols = cols;
     if (rows > old_rows) {
@@ -840,7 +844,7 @@ static void _ewk_tiled_backing_store_recalc_renderers(Ewk_Tiled_Backing_Store_Da
         end = priv->view.items + rows;
         for (; start < end; start++) {
             Eina_Bool r;
-            *start = NULL;
+            *start = 0;
             r = _ewk_tiled_backing_store_view_cols_end_add
                 (priv, start, 0, cols);
             if (!r) {
@@ -857,7 +861,7 @@ static void _ewk_tiled_backing_store_recalc_renderers(Ewk_Tiled_Backing_Store_Da
         Eina_Inlist **start, **end;
         int todo = cols - old_cols;
         start = priv->view.items;
-        end = start + MIN(old_rows, rows);
+        end = start + std::min(old_rows, rows);
         if (todo > 0) {
             for (; start < end; start++) {
                 Eina_Bool r;
@@ -1375,10 +1379,10 @@ static void _ewk_tiled_backing_store_smart_calculate(Evas_Object *o)
 
 Evas_Object *ewk_tiled_backing_store_add(Evas *e)
 {
-    static Evas_Smart *smart = NULL;
+    static Evas_Smart *smart = 0;
 
     if (_ewk_tiled_log_dom < 0)
-        _ewk_tiled_log_dom = eina_log_domain_register("Ewk_Tiled_Backing_Store", NULL);
+        _ewk_tiled_log_dom = eina_log_domain_register("Ewk_Tiled_Backing_Store", 0);
 
     if (!smart) {
         static Evas_Smart_Class sc =
@@ -1411,7 +1415,7 @@ void ewk_tiled_backing_store_render_cb_set(Evas_Object *o, Eina_Bool (*cb)(void
 
 Ewk_Tile_Unused_Cache *ewk_tiled_backing_store_tile_unused_cache_get(const Evas_Object *o)
 {
-    PRIV_DATA_GET_OR_RETURN(o, priv, NULL);
+    PRIV_DATA_GET_OR_RETURN(o, priv, 0);
     return ewk_tile_matrix_unused_cache_get(priv->model.matrix);
 }
 
@@ -1613,7 +1617,7 @@ Eina_Bool ewk_tiled_backing_store_zoom_weak_set(Evas_Object *o, float zoom, Evas
 
     if (recalc) {
         Evas_Coord w, h;
-        evas_object_geometry_get(o, NULL, NULL, &w, &h);
+        evas_object_geometry_get(o, 0, 0, &w, &h);
         _ewk_tiled_backing_store_recalc_renderers(priv, w, h, tw, th);
         _ewk_tiled_backing_store_fill_renderers(priv);
         _ewk_tiled_backing_store_updates_process(priv);
@@ -1789,7 +1793,7 @@ void ewk_tiled_backing_store_disabled_update_set(Evas_Object *o, Eina_Bool value
 void ewk_tiled_backing_store_flush(Evas_Object *o)
 {
     PRIV_DATA_GET_OR_RETURN(o, priv);
-    Ewk_Tile_Unused_Cache *tuc = NULL;
+    Ewk_Tile_Unused_Cache *tuc = 0;
 
     priv->view.offset.cur.x = 0;
     priv->view.offset.cur.y = 0;
@@ -1863,9 +1867,9 @@ Eina_Bool ewk_tiled_backing_store_pre_render_relative_radius(Evas_Object *o, uns
             priv->model.base.row, n, priv->view.rows);
     start_row = (long)priv->model.base.row - n;
     start_col = (long)priv->model.base.col - n;
-    end_row = MIN(priv->model.cur.rows - 1,
+    end_row = std::min(priv->model.cur.rows - 1,
                   priv->model.base.row + priv->view.rows + n - 1);
-    end_col = MIN(priv->model.cur.cols - 1,
+    end_col = std::min(priv->model.cur.cols - 1,
                   priv->model.base.col + priv->view.cols + n - 1);
 
     INF("start_row=%lu, end_row=%lu, start_col=%lu, end_col=%lu",
index 46aaa83..30103ed 100644 (file)
 #define TILE_ZOOM_AT_SIZE(SIZE, ORIG_TILE) ((float)(SIZE) / (float)(ORIG_TILE))
 #define ROUNDED_ZOOM(SIZE, ZOOM) ((float)(SIZE) / (float)(((int)roundf((SIZE) / (ZOOM)))))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <Evas.h>
 #include <cairo.h>
 
@@ -123,7 +119,4 @@ void ewk_tiled_backing_store_pre_render_cancel(Evas_Object* o);
 
 Eina_Bool ewk_tiled_backing_store_disable_render(Evas_Object* o);
 Eina_Bool ewk_tiled_backing_store_enable_render(Evas_Object* o);
-#ifdef __cplusplus
-}
-#endif
 #endif // ewk_tiled_backing_store_h
similarity index 90%
rename from Source/WebKit/efl/ewk/ewk_tiled_matrix.c
rename to Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp
index c2f9c84..ff4c41c 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "ewk_tiled_matrix.h"
 
-#define _GNU_SOURCE
 #include "ewk_tiled_backing_store.h"
 #include "ewk_tiled_private.h"
 #include <Eina.h>
@@ -62,8 +61,8 @@ static uint64_t bytes_leaked = 0;
 /* called when matrixsparse is resized or freed */
 static void _ewk_tile_matrix_cell_free(void *user_data, void *cell_data)
 {
-    Ewk_Tile_Matrix *tm = user_data;
-    Ewk_Tile *t = cell_data;
+    Ewk_Tile_Matrix* tm = static_cast<Ewk_Tile_Matrix*>(user_data);
+    Ewk_Tile* t = static_cast<Ewk_Tile*>(cell_data);
 
     if (!t)
         return;
@@ -94,7 +93,7 @@ static void _ewk_tile_matrix_cell_free(void *user_data, void *cell_data)
 /* called when cache of unused tile is flushed */
 static void _ewk_tile_matrix_tile_free(void *data, Ewk_Tile *t)
 {
-    Ewk_Tile_Matrix *tm = data;
+    Ewk_Tile_Matrix* tm = static_cast<Ewk_Tile_Matrix*>(data);
     Eina_Matrixsparse_Cell *cell;
  
     if (!eina_matrixsparse_cell_idx_get(tm->matrix, t->row, t->col, &cell)) {
@@ -111,7 +110,7 @@ static void _ewk_tile_matrix_tile_free(void *data, Ewk_Tile *t)
         tm->updates = eina_list_remove(tm->updates, t);
 
     /* set to null to avoid double free */
-    eina_matrixsparse_cell_data_replace(cell, NULL, NULL);
+    eina_matrixsparse_cell_data_replace(cell, 0, 0);
     eina_matrixsparse_cell_clear(cell);
 
     if (EINA_UNLIKELY(!!t->visible)) {
@@ -136,7 +135,7 @@ static void _ewk_tile_matrix_tile_free(void *data, Ewk_Tile *t)
  * existing tiles and give them back, allowing them to be
  * freed/replaced by the cache.
  *
- * @param tuc cache of unused tiles or @c NULL to create one
+ * @param tuc cache of unused tiles or @c 0 to create one
  *        automatically.
  * @param cols number of columns in the matrix.
  * @param rows number of rows in the matrix.
@@ -144,19 +143,19 @@ static void _ewk_tile_matrix_tile_free(void *data, Ewk_Tile *t)
  * @param render_cb function used to render given tile update.
  * @param render_data context to give back to @a render_cb.
  *
- * @return newly allocated instance on success, @c NULL on failure.
+ * @return newly allocated instance on success, @c 0 on failure.
  */
 Ewk_Tile_Matrix *ewk_tile_matrix_new(Ewk_Tile_Unused_Cache *tuc, unsigned long cols, unsigned long rows, Evas_Colorspace cspace, void (*render_cb)(void *data, Ewk_Tile *t, const Eina_Rectangle *update), const void *render_data)
 {
-    Ewk_Tile_Matrix *tm;
-
-    CALLOC_OR_OOM_RET(tm, sizeof(Ewk_Tile_Matrix), NULL);
+    Ewk_Tile_Matrix* tm = static_cast<Ewk_Tile_Matrix*>(calloc(1, sizeof(Ewk_Tile_Matrix)));
+    if (!tm)
+        return 0;
 
     tm->matrix = eina_matrixsparse_new(rows, cols, _ewk_tile_matrix_cell_free, tm);
     if (!tm->matrix) {
         ERR("could not create sparse matrix.");
         free(tm);
-        return NULL;
+        return 0;
     }
 
     if (tuc)
@@ -167,7 +166,7 @@ Ewk_Tile_Matrix *ewk_tile_matrix_new(Ewk_Tile_Unused_Cache *tuc, unsigned long c
             ERR("no cache of unused tile!");
             eina_matrixsparse_free(tm->matrix);
             free(tm);
-            return NULL;
+            return 0;
         }
     }
 
@@ -244,7 +243,7 @@ void ewk_tile_matrix_resize(Ewk_Tile_Matrix *tm, unsigned long cols, unsigned lo
  */
 Ewk_Tile_Unused_Cache *ewk_tile_matrix_unused_cache_get(const Ewk_Tile_Matrix *tm)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(tm, NULL);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(tm, 0);
     return tm->tuc;
 }
 
@@ -262,7 +261,7 @@ Ewk_Tile_Unused_Cache *ewk_tile_matrix_unused_cache_get(const Ewk_Tile_Matrix *t
  * @param row the row number.
  * @param zoom the exact zoom to use.
  *
- * @return The tile instance or @c NULL if none is found. If the tile
+ * @return The tile instance or @c 0 if none is found. If the tile
  *         was in the unused cache it will be @b removed (thus
  *         considered used) and one should give it back with
  *         ewk_tile_matrix_tile_put() afterwards.
@@ -271,10 +270,9 @@ Ewk_Tile_Unused_Cache *ewk_tile_matrix_unused_cache_get(const Ewk_Tile_Matrix *t
  */
 Ewk_Tile *ewk_tile_matrix_tile_exact_get(Ewk_Tile_Matrix *tm, unsigned long col, unsigned long row, float zoom)
 {
-    Ewk_Tile *t;
-    t = eina_matrixsparse_data_idx_get(tm->matrix, row, col);
+    Ewk_Tile* t = static_cast<Ewk_Tile*>(eina_matrixsparse_data_idx_get(tm->matrix, row, col));
     if (!t)
-        return NULL;
+        return 0;
 
     if (t->zoom == zoom)
         goto end;
@@ -302,10 +300,7 @@ Ewk_Tile *ewk_tile_matrix_tile_exact_get(Ewk_Tile_Matrix *tm, unsigned long col,
  */
 Eina_Bool ewk_tile_matrix_tile_exact_exists(Ewk_Tile_Matrix *tm, unsigned long col, unsigned long row, float zoom)
 {
-    Ewk_Tile *t;
-
-    t = eina_matrixsparse_data_idx_get(tm->matrix, row, col);
-    if (!t)
+    if (!eina_matrixsparse_data_idx_get(tm->matrix, row, col))
         return EINA_FALSE;
 
     return EINA_TRUE;
@@ -328,8 +323,8 @@ Ewk_Tile *ewk_tile_matrix_tile_new(Ewk_Tile_Matrix *tm, Evas *evas, unsigned lon
     Evas_Coord tw, th;
     Ewk_Tile *t;
 
-    EINA_SAFETY_ON_NULL_RETURN_VAL(tm, NULL);
-    EINA_SAFETY_ON_FALSE_RETURN_VAL(zoom > 0.0, NULL);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(tm, 0);
+    EINA_SAFETY_ON_FALSE_RETURN_VAL(zoom > 0.0, 0);
 
     tw = tm->tile.w;
     th = tm->tile.h;
@@ -337,13 +332,13 @@ Ewk_Tile *ewk_tile_matrix_tile_new(Ewk_Tile_Matrix *tm, Evas *evas, unsigned lon
     t = ewk_tile_new(evas, tw, th, zoom, tm->cspace);
     if (!t) {
         ERR("could not create tile %dx%d at %f, cspace=%d", tw, th, (double)zoom, tm->cspace);
-        return NULL;
+        return 0;
     }
 
     if (!eina_matrixsparse_data_idx_set(tm->matrix, row, col, t)) {
         ERR("could not set matrix cell, row/col outside matrix dimensions!");
         ewk_tile_free(t);
-        return NULL;
+        return 0;
     }
 
     t->col = col;
@@ -376,7 +371,7 @@ Ewk_Tile *ewk_tile_matrix_tile_new(Ewk_Tile_Matrix *tm, Evas *evas, unsigned lon
  * unused cache.
  *
  * @param tm the tile matrix to return tile to.
- * @param t the tile instance to return, must @b not be @c NULL.
+ * @param t the tile instance to return, must @b not be @c 0.
  * @param last_used time in which tile was last used.
  *
  * @return #EINA_TRUE on success or #EINA_FALSE on failure.
@@ -395,7 +390,6 @@ Eina_Bool ewk_tile_matrix_tile_put(Ewk_Tile_Matrix *tm, Ewk_Tile *t, double last
 
 Eina_Bool ewk_tile_matrix_tile_update(Ewk_Tile_Matrix *tm, unsigned long col, unsigned long row, const Eina_Rectangle *update)
 {
-    Ewk_Tile *t;
     Eina_Rectangle new_update;
     EINA_SAFETY_ON_NULL_RETURN_VAL(tm, EINA_FALSE);
     EINA_SAFETY_ON_NULL_RETURN_VAL(update, EINA_FALSE);
@@ -412,8 +406,7 @@ Eina_Bool ewk_tile_matrix_tile_update(Ewk_Tile_Matrix *tm, unsigned long col, un
     if (update->y + update->h - 1 >= tm->tile.h)
         new_update.h = tm->tile.h - update->y;
 
-    t = eina_matrixsparse_data_idx_get(tm->matrix, row, col);
-
+    Ewk_Tile* t = static_cast<Ewk_Tile*>(eina_matrixsparse_data_idx_get(tm->matrix, row, col));
     if (!t)
         return EINA_TRUE;
 
@@ -426,7 +419,6 @@ Eina_Bool ewk_tile_matrix_tile_update(Ewk_Tile_Matrix *tm, unsigned long col, un
 
 Eina_Bool ewk_tile_matrix_tile_update_full(Ewk_Tile_Matrix *tm, unsigned long col, unsigned long row)
 {
-    Ewk_Tile *t;
     Eina_Matrixsparse_Cell *cell;
     EINA_SAFETY_ON_NULL_RETURN_VAL(tm, EINA_FALSE);
 
@@ -436,7 +428,7 @@ Eina_Bool ewk_tile_matrix_tile_update_full(Ewk_Tile_Matrix *tm, unsigned long co
     if (!cell)
         return EINA_TRUE;
 
-    t = eina_matrixsparse_cell_data_get(cell);
+    Ewk_Tile* t = static_cast<Ewk_Tile*>(eina_matrixsparse_cell_data_get(cell));
     if (!t) {
         CRITICAL("matrix cell with no tile!");
         return EINA_TRUE;
@@ -518,11 +510,10 @@ Eina_Bool ewk_tile_matrix_update(Ewk_Tile_Matrix *tm, const Eina_Rectangle *upda
 
     while (eina_tile_grid_slicer_next(&slicer, &info)) {
         unsigned long col, row;
-        Ewk_Tile *t;
         col = info->col;
         row = info->row;
 
-        t = eina_matrixsparse_data_idx_get(tm->matrix, row, col);
+        Ewk_Tile* t = static_cast<Ewk_Tile*>(eina_matrixsparse_data_idx_get(tm->matrix, row, col));
         if (!t)
             continue;
 
@@ -541,14 +532,15 @@ Eina_Bool ewk_tile_matrix_update(Ewk_Tile_Matrix *tm, const Eina_Rectangle *upda
 void ewk_tile_matrix_updates_process(Ewk_Tile_Matrix *tm)
 {
     Eina_List *l, *l_next;
-    Ewk_Tile *t;
+    void* item;
     EINA_SAFETY_ON_NULL_RETURN(tm);
 
     // process updates, unflag tiles
-    EINA_LIST_FOREACH_SAFE(tm->updates, l, l_next, t) {
-        ewk_tile_updates_process(t, tm->render.cb, tm->render.data);
-        if (t->visible) {
-            ewk_tile_updates_clear(t);
+    EINA_LIST_FOREACH_SAFE(tm->updates, l, l_next, item) {
+        Ewk_Tile* tile = static_cast<Ewk_Tile*>(item);
+        ewk_tile_updates_process(tile, tm->render.cb, tm->render.data);
+        if (tile->visible) {
+            ewk_tile_updates_clear(tile);
             tm->updates = eina_list_remove_list(tm->updates, l);
         }
     }
@@ -556,12 +548,12 @@ void ewk_tile_matrix_updates_process(Ewk_Tile_Matrix *tm)
 
 void ewk_tile_matrix_updates_clear(Ewk_Tile_Matrix *tm)
 {
-    Ewk_Tile *t;
+    void* item;
     EINA_SAFETY_ON_NULL_RETURN(tm);
 
-    EINA_LIST_FREE(tm->updates, t)
-        ewk_tile_updates_clear(t);
-    tm->updates = NULL;
+    EINA_LIST_FREE(tm->updates, item)
+        ewk_tile_updates_clear(static_cast<Ewk_Tile*>(item));
+    tm->updates = 0;
 }
 
 // remove me later!
@@ -584,10 +576,9 @@ void ewk_tile_matrix_dbg(const Ewk_Tile_Matrix *tm)
 
     EINA_ITERATOR_FOREACH(it, cell) {
         unsigned long row, col;
-        Ewk_Tile *t;
         eina_matrixsparse_cell_position_get(cell, &row, &col);
-        t = eina_matrixsparse_cell_data_get(cell);
 
+        Ewk_Tile* t = static_cast<Ewk_Tile*>(eina_matrixsparse_cell_data_get(cell));
         if (!t) {
             if (!last_empty) {
                 last_empty = EINA_TRUE;
similarity index 93%
rename from Source/WebKit/efl/ewk/ewk_tiled_model.c
rename to Source/WebKit/efl/ewk/ewk_tiled_model.cpp
index d2e9479..6168572 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "ewk_tiled_model.h"
 
-#define _GNU_SOURCE
 #include "ewk_tiled_backing_store.h"
 #include "ewk_tiled_private.h"
 #include <Ecore_Evas.h>
 #include <sys/time.h>
 #endif
 
-#ifndef CAIRO_FORMAT_RGB16_565
-#define CAIRO_FORMAT_RGB16_565 4
-#endif
-
 #define IDX(col, row, rowspan) (col + (row * rowspan))
-#define MIN(a, b) ((a < b) ? a : b)
-#define MAX(a, b) ((a > b) ? a : b)
 
 #ifdef DEBUG_MEM_LEAKS
 static uint64_t tiles_allocated = 0;
@@ -60,7 +53,7 @@ struct tile_account {
 };
 
 static size_t accounting_len = 0;
-static struct tile_account *accounting = NULL;
+static struct tile_account *accounting = 0;
 
 static inline struct tile_account *_ewk_tile_account_get(const Ewk_Tile *t)
 {
@@ -73,7 +66,7 @@ static inline struct tile_account *_ewk_tile_account_get(const Ewk_Tile *t)
     }
 
     i = (accounting_len + 1) * sizeof(struct tile_account);
-    REALLOC_OR_OOM_RET(accounting, i, NULL);
+    REALLOC_OR_OOM_RET(accounting, i, 0);
 
     acc = accounting + accounting_len;
     acc->size = t->w;
@@ -266,12 +259,15 @@ Ewk_Tile *ewk_tile_new(Evas *evas, Evas_Coord w, Evas_Coord h, float zoom, Evas_
         format = CAIRO_FORMAT_RGB16_565;
     } else {
         ERR("unknown color space: %d", cspace);
-        return NULL;
+        return 0;
     }
 
     DBG("size: %dx%d (%d), zoom: %f, cspace=%d", w, h, area, (double)zoom, cspace);
 
-    MALLOC_OR_OOM_RET(t, sizeof(Ewk_Tile), NULL);
+    t = static_cast<Ewk_Tile*>(malloc(sizeof(Ewk_Tile)));
+    if (!t)
+        return 0;
+
     t->image = evas_object_image_add(evas);
 
     ee = ecore_evas_ecore_evas_get(evas);
@@ -280,7 +276,7 @@ Ewk_Tile *ewk_tile_new(Evas *evas, Evas_Coord w, Evas_Coord h, float zoom, Evas_
         evas_object_image_content_hint_set(t->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
 
     t->visible = 0;
-    t->updates = NULL;
+    t->updates = 0;
 
     memset(&t->stats, 0, sizeof(Ewk_Tile_Stats));
     t->stats.area = area;
@@ -303,14 +299,14 @@ Ewk_Tile *ewk_tile_new(Evas *evas, Evas_Coord w, Evas_Coord h, float zoom, Evas_
 
     evas_object_image_size_set(t->image, t->w, t->h);
     evas_object_image_colorspace_set(t->image, t->cspace);
-    t->pixels = evas_object_image_data_get(t->image, EINA_TRUE);
+    t->pixels = static_cast<uint8_t*>(evas_object_image_data_get(t->image, EINA_TRUE));
     t->surface = cairo_image_surface_create_for_data(t->pixels, format, w, h, stride);
     status = cairo_surface_status(t->surface);
     if (status != CAIRO_STATUS_SUCCESS) {
         ERR("failed to create cairo surface: %s",
             cairo_status_to_string(status));
         free(t);
-        return NULL;
+        return 0;
     }
 
     t->cairo = cairo_create(t->surface);
@@ -320,7 +316,7 @@ Ewk_Tile *ewk_tile_new(Evas *evas, Evas_Coord w, Evas_Coord h, float zoom, Evas_
         cairo_surface_destroy(t->surface);
         evas_object_del(t->image);
         free(t);
-        return NULL;
+        return 0;
     }
 
     _ewk_tile_account_allocated(t);
@@ -383,7 +379,7 @@ void ewk_tile_update_full(Ewk_Tile *t)
         t->stats.full_update = EINA_TRUE;
         if (t->updates) {
             eina_tiler_free(t->updates);
-            t->updates = NULL;
+            t->updates = 0;
         }
     }
 }
@@ -403,7 +399,7 @@ void ewk_tile_update_area(Ewk_Tile *t, const Eina_Rectangle *r)
         t->stats.full_update = EINA_TRUE;
         if (t->updates) {
             eina_tiler_free(t->updates);
-            t->updates = NULL;
+            t->updates = 0;
         }
         return;
     }
@@ -436,13 +432,13 @@ void ewk_tile_updates_process(Ewk_Tile *t, void (*cb)(void *data, Ewk_Tile *t, c
 #ifdef TILE_STATS_ACCOUNT_RENDER_TIME
         struct timeval timev;
         double render_start;
-        gettimeofday(&timev, NULL);
+        gettimeofday(&timev, 0);
         render_start = (double)timev.tv_sec +
             (((double)timev.tv_usec) / 1000000);
 #endif
         cb((void *)data, t, &r);
 #ifdef TILE_STATS_ACCOUNT_RENDER_TIME
-        gettimeofday(&timev, NULL);
+        gettimeofday(&timev, 0);
         t->stats.render_time = (double)timev.tv_sec +
             (((double)timev.tv_usec) / 1000000) - render_start;
 #endif
@@ -478,7 +474,7 @@ void ewk_tile_updates_clear(Ewk_Tile *t)
         t->stats.full_update = 0;
     else if (t->updates) {
         eina_tiler_free(t->updates);
-        t->updates = NULL;
+        t->updates = 0;
     }
 }
 
@@ -524,13 +520,15 @@ static const size_t TILE_UNUSED_CACHE_MAX_FREE = 32;
  *
  * @return newly allocated cache of unused tiles, use
  *         ewk_tile_unused_cache_free() to release resources. If not
- *         possible to allocate memory, @c NULL is returned.
+ *         possible to allocate memory, @c 0 is returned.
  */
 Ewk_Tile_Unused_Cache *ewk_tile_unused_cache_new(size_t max)
 {
     Ewk_Tile_Unused_Cache *tuc;
 
-    CALLOC_OR_OOM_RET(tuc, sizeof(Ewk_Tile_Unused_Cache), NULL);
+    tuc = static_cast<Ewk_Tile_Unused_Cache*>(calloc(1, sizeof(Ewk_Tile_Unused_Cache)));
+    if (!tuc)
+        return 0;
 
     DBG("tuc=%p", tuc);
     tuc->memory.max = max;
@@ -591,13 +589,14 @@ static void _ewk_tile_unused_cache_free(Ewk_Tile_Unused_Cache *tuc)
  */
 void ewk_tile_unused_cache_clear(Ewk_Tile_Unused_Cache *tuc)
 {
-    Ewk_Tile_Unused_Cache_Entry *itr;
     EINA_SAFETY_ON_NULL_RETURN(tuc);
 
     if (!tuc->entries.count)
         return;
 
-    EINA_LIST_FREE(tuc->entries.list, itr) {
+    void* item;
+    EINA_LIST_FREE(tuc->entries.list, item) {
+        Ewk_Tile_Unused_Cache_Entry* itr = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item);
         itr->tile_free.cb(itr->tile_free.data, itr->tile);
         free(itr);
     }
@@ -615,7 +614,7 @@ void ewk_tile_unused_cache_clear(Ewk_Tile_Unused_Cache *tuc)
  */
 Ewk_Tile_Unused_Cache *ewk_tile_unused_cache_ref(Ewk_Tile_Unused_Cache *tuc)
 {
-    EINA_SAFETY_ON_NULL_RETURN_VAL(tuc, NULL);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(tuc, 0);
     tuc->references++;
     return tuc;
 }
@@ -654,7 +653,6 @@ size_t ewk_tile_unused_cache_used_get(const Ewk_Tile_Unused_Cache *tuc)
 
 size_t ewk_tile_unused_cache_flush(Ewk_Tile_Unused_Cache *tuc, size_t bytes)
 {
-    Ewk_Tile_Unused_Cache_Entry *itr;
     Eina_List *l, *l_next;
     EINA_SAFETY_ON_NULL_RETURN_VAL(tuc, 0);
     size_t done;
@@ -670,9 +668,11 @@ size_t ewk_tile_unused_cache_flush(Ewk_Tile_Unused_Cache *tuc, size_t bytes)
      * Don't need to sort any more.
      */
 
+    void* item;
     done = 0;
     count = 0;
-    EINA_LIST_FOREACH_SAFE(tuc->entries.list, l, l_next, itr) {
+    EINA_LIST_FOREACH_SAFE(tuc->entries.list, l, l_next, item) {
+        Ewk_Tile_Unused_Cache_Entry* itr = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item);
         Ewk_Tile *t = itr->tile;
         if (done > bytes)
             break;
@@ -752,12 +752,12 @@ void ewk_tile_unused_cache_thaw(Ewk_Tile_Unused_Cache *tuc)
  */
 Eina_Bool ewk_tile_unused_cache_tile_get(Ewk_Tile_Unused_Cache *tuc, Ewk_Tile *t)
 {
-    Ewk_Tile_Unused_Cache_Entry *entry;
     Eina_List *e, *l;
 
-    e = NULL;
-    EINA_LIST_FOREACH(tuc->entries.list, l, entry)
-    {
+    void* item;
+    e = 0;
+    EINA_LIST_FOREACH(tuc->entries.list, l, item) {
+        Ewk_Tile_Unused_Cache_Entry* entry = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item);
         if (entry->tile == t) {
             e = l;
             break;
@@ -771,7 +771,7 @@ Eina_Bool ewk_tile_unused_cache_tile_get(Ewk_Tile_Unused_Cache *tuc, Ewk_Tile *t
     tuc->entries.count--;
     tuc->memory.used -= sizeof(Ewk_Tile) + t->bytes;
     tuc->entries.list = eina_list_remove_list(tuc->entries.list, e);
-    free(entry);
+    free(item);
 
     return EINA_TRUE;
 }
@@ -807,7 +807,10 @@ Eina_Bool ewk_tile_unused_cache_tile_put(Ewk_Tile_Unused_Cache *tuc, Ewk_Tile *t
         return EINA_FALSE;
     }
 
-    MALLOC_OR_OOM_RET(e, sizeof(Ewk_Tile_Unused_Cache_Entry), EINA_FALSE);
+    e = static_cast<Ewk_Tile_Unused_Cache_Entry*>(malloc(sizeof(Ewk_Tile_Unused_Cache_Entry)));
+    if (!e)
+        return EINA_FALSE;
+
     tuc->entries.list = eina_list_append(tuc->entries.list, e);
     if (eina_error_get()) {
         ERR("List allocation failed");
@@ -827,15 +830,15 @@ Eina_Bool ewk_tile_unused_cache_tile_put(Ewk_Tile_Unused_Cache *tuc, Ewk_Tile *t
 
 void ewk_tile_unused_cache_dbg(const Ewk_Tile_Unused_Cache *tuc)
 {
-    Ewk_Tile_Unused_Cache_Entry *itr;
+    void* item;
     Eina_List *l;
     int count = 0;
     printf("Cache of unused tiles: entries: %zu/%zu, memory: %zu/%zu\n",
            tuc->entries.count, tuc->entries.allocated,
            tuc->memory.used, tuc->memory.max);
 
-    EINA_LIST_FOREACH(tuc->entries.list, l, itr) {
-        const Ewk_Tile *t = itr->tile;
+    EINA_LIST_FOREACH(tuc->entries.list, l, item) {
+        const Ewk_Tile *t = static_cast<Ewk_Tile_Unused_Cache_Entry*>(item)->tile;
         printf(" [%3lu,%3lu + %dx%d @ %0.3f]%c",
                t->col, t->row, t->w, t->h, t->zoom,
                t->visible ? '*': ' ');