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
+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;
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;
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__; \
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
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) {
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
if (!t) {
CRITICAL("ewk_tile_matrix_tile_new failed!");
- return NULL;
+ return 0;
}
return t;
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);
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)
{
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
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);
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;
}
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)
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);
}
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;
{
for (; start < end; start++) {
_ewk_tiled_backing_store_view_row_del(priv, *start);
- *start = NULL;
+ *start = 0;
}
}
_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);
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;
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);
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) {
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) {
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;
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 =
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);
}
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);
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;
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",
#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>
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
#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>
/* 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;
/* 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)) {
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)) {
* 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.
* @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)
ERR("no cache of unused tile!");
eina_matrixsparse_free(tm->matrix);
free(tm);
- return NULL;
+ return 0;
}
}
*/
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;
}
* @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.
*/
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;
*/
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;
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;
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;
* 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.
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);
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;
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);
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;
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;
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);
}
}
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!
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;
#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;
};
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)
{
}
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;
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);
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;
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);
cairo_surface_destroy(t->surface);
evas_object_del(t->image);
free(t);
- return NULL;
+ return 0;
}
_ewk_tile_account_allocated(t);
t->stats.full_update = EINA_TRUE;
if (t->updates) {
eina_tiler_free(t->updates);
- t->updates = NULL;
+ t->updates = 0;
}
}
}
t->stats.full_update = EINA_TRUE;
if (t->updates) {
eina_tiler_free(t->updates);
- t->updates = NULL;
+ t->updates = 0;
}
return;
}
#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
t->stats.full_update = 0;
else if (t->updates) {
eina_tiler_free(t->updates);
- t->updates = NULL;
+ t->updates = 0;
}
}
*
* @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;
*/
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);
}
*/
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;
}
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;
* 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;
*/
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;
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;
}
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");
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 ? '*': ' ');