Modified: trunk/Source/WebKit/efl/ChangeLog (110555 => 110556)
--- trunk/Source/WebKit/efl/ChangeLog 2012-03-13 12:28:18 UTC (rev 110555)
+++ trunk/Source/WebKit/efl/ChangeLog 2012-03-13 12:38:37 UTC (rev 110556)
@@ -1,3 +1,24 @@
+2012-03-13 JungJik Lee <[email protected]>
+
+ [EFL] Remove a duplicate allocation of matrix entry.
+ https://bugs.webkit.org/show_bug.cgi?id=79362
+
+ Reviewed by Zoltan Herczeg.
+
+ A matrix entry is created when calling ewk_matrix_new.
+ Another matrix is created inside ewk_tile_matrix_zoom_level_set.
+ This patch is for getting rid of a duplicated creation of the matrix.
+
+ * ewk/ewk_tiled_backing_store.cpp:
+ (_Ewk_Tiled_Backing_Store_Item):
+ (_ewk_tiled_backing_store_zoom_set_internal):
+ * ewk/ewk_tiled_matrix.cpp:
+ (ewk_tile_matrix_new):
+ (ewk_tile_matrix_zoom_level_set):
+ (ewk_tile_matrix_entry_new):
+ (ewk_tile_matrix_size_get):
+ * ewk/ewk_tiled_matrix.h:
+
2012-03-09 Jon Lee <[email protected]>
Rename NotificationPresenter to NotificationClient
Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp (110555 => 110556)
--- trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp 2012-03-13 12:28:18 UTC (rev 110555)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp 2012-03-13 12:38:37 UTC (rev 110556)
@@ -1501,7 +1501,11 @@
priv->view.offset.zoomCenter.x = currentX;
priv->view.offset.zoomCenter.y = currentY;
- ewk_tile_matrix_zoom_level_set(priv->model.matrix, *zoom);
+ unsigned long columns, rows;
+ ewk_tile_matrix_size_get(priv->model.matrix, &columns, &rows);
+ if (!ewk_tile_matrix_zoom_level_set(priv->model.matrix, *zoom))
+ ewk_tile_matrix_entry_new(priv->model.matrix, *zoom);
+ ewk_tile_matrix_resize(priv->model.matrix, columns, rows);
if (!priv->view.width || !priv->view.height) {
priv->view.offset.base.x = 0;
Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp (110555 => 110556)
--- trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp 2012-03-13 12:28:18 UTC (rev 110555)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp 2012-03-13 12:38:37 UTC (rev 110556)
@@ -201,14 +201,10 @@
{
OwnPtr<Ewk_Tile_Matrix> tileMatrix = adoptPtr(new Ewk_Tile_Matrix);
- tileMatrix->matrix = eina_matrixsparse_new(rows, columns, _ewk_tile_matrix_cell_free, tileMatrix.get());
- if (!tileMatrix->matrix) {
- ERR("could not create sparse matrix.");
- return 0;
- }
-
tileMatrix->matrices = 0;
- ewk_tile_matrix_zoom_level_set(tileMatrix.get(), zoomLevel);
+ if (!ewk_tile_matrix_zoom_level_set(tileMatrix.get(), zoomLevel))
+ ewk_tile_matrix_entry_new(tileMatrix.get(), zoomLevel);
+ ewk_tile_matrix_resize(tileMatrix.get(), columns, rows);
if (tileUnusedCache)
tileMatrix->tileUnusedCache = ewk_tile_unused_cache_ref(tileUnusedCache);
@@ -238,38 +234,48 @@
return tileMatrix.leakPtr();
}
-void ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix* tileMatrix, float zoom)
+/**
+ * Find the matrix with the same zoom and set it as current matrix.
+ *
+ * @param tileMatrix tile matrix to search the matrix in.
+ * @param zoom zoom factor to find the same matrix with it in matrices.
+ *
+ * @return @c true if found, @c false otherwise.
+ */
+bool ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix* tileMatrix, float zoom)
{
- EINA_SAFETY_ON_NULL_RETURN(tileMatrix);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tileMatrix, false);
Ewk_Tile_Matrix_Entry* iterator = 0;
Ewk_Tile_Matrix_Entry* entry = 0;
- unsigned long rows = 0, columns = 0;
- eina_matrixsparse_size_get(tileMatrix->matrix, &rows, &columns);
-
EINA_INLIST_FOREACH(tileMatrix->matrices, iterator) {
if (iterator->zoom != zoom)
continue;
entry = iterator;
tileMatrix->matrices = eina_inlist_promote(tileMatrix->matrices, EINA_INLIST_GET(entry));
- eina_matrixsparse_size_set(entry->matrix, rows, columns);
+ tileMatrix->matrix = entry->matrix;
+ return true;
}
+ return false;
+}
- if (!entry) {
- entry = new Ewk_Tile_Matrix_Entry;
- memset(entry, 0, sizeof(Ewk_Tile_Matrix_Entry));
- entry->matrix = eina_matrixsparse_new(rows, columns, _ewk_tile_matrix_cell_free, tileMatrix);
+void ewk_tile_matrix_entry_new(Ewk_Tile_Matrix* tileMatrix, float zoom)
+{
+ EINA_SAFETY_ON_NULL_RETURN(tileMatrix);
+
+ Ewk_Tile_Matrix_Entry* entry = new Ewk_Tile_Matrix_Entry;
+ if (entry) {
+ entry->zoom = zoom;
entry->count = 0;
- entry->zoom = zoom;
+ entry->matrix = eina_matrixsparse_new(1, 1, _ewk_tile_matrix_cell_free, tileMatrix);
if (!entry->matrix) {
ERR("could not create sparse matrix.");
delete entry;
return;
}
tileMatrix->matrices = eina_inlist_prepend(tileMatrix->matrices, EINA_INLIST_GET(entry));
+ tileMatrix->matrix = entry->matrix;
}
-
- tileMatrix->matrix = entry->matrix;
}
void ewk_tile_matrix_invalidate(Ewk_Tile_Matrix* tileMatrix)
@@ -356,6 +362,12 @@
eina_matrixsparse_size_set(tileMatrix->matrix, rows, cols);
}
+void ewk_tile_matrix_size_get(Ewk_Tile_Matrix* tileMatrix, unsigned long* columns, unsigned long* rows)
+{
+ EINA_SAFETY_ON_NULL_RETURN(tileMatrix);
+ eina_matrixsparse_size_get(tileMatrix->matrix, rows, columns);
+}
+
/**
* Get the cache of unused tiles in use by given matrix.
*
Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.h (110555 => 110556)
--- trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.h 2012-03-13 12:28:18 UTC (rev 110555)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.h 2012-03-13 12:38:37 UTC (rev 110556)
@@ -27,10 +27,12 @@
/* matrix of tiles */
Ewk_Tile_Matrix *ewk_tile_matrix_new(Ewk_Tile_Unused_Cache *tuc, unsigned long cols, unsigned long rows, float zoom_level, Evas_Colorspace color_space, void (*render_callback)(void *data, Ewk_Tile *t, const Eina_Rectangle *update), const void *render_data);
+void ewk_tile_matrix_entry_new(Ewk_Tile_Matrix *tm, float zoom);
void ewk_tile_matrix_free(Ewk_Tile_Matrix *tm);
void ewk_tile_matrix_resize(Ewk_Tile_Matrix *tm, unsigned long cols, unsigned long rows);
-void ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix *tm, float zoom);
+void ewk_tile_matrix_size_get(Ewk_Tile_Matrix *tm, unsigned long *cols, unsigned long *rows);
+bool ewk_tile_matrix_zoom_level_set(Ewk_Tile_Matrix *tm, float zoom);
void ewk_tile_matrix_invalidate(Ewk_Tile_Matrix *tm);
Ewk_Tile_Unused_Cache *ewk_tile_matrix_unused_cache_get(const Ewk_Tile_Matrix *tm);