Title: [104021] trunk/Source/WebKit/efl
Revision
104021
Author
[email protected]
Date
2012-01-04 01:26:16 -0800 (Wed, 04 Jan 2012)

Log Message

[EFL] Refactor the way using cairo in ewk_tiled_backing_store.
https://bugs.webkit.org/show_bug.cgi?id=74993

Patch by KwangHyuk Kim <[email protected]> on 2012-01-04
Reviewed by Nikolas Zimmermann.

For now there are cairo related code scattered around the ewk_tiled_backing_store.
>From the point of code complexity view, it doesn't look good and I couldn't notice any benefit of it.
So, this patch will let cairo related code be used only for painting operation.

* ewk/ewk_tiled_backing_store.h:
* ewk/ewk_tiled_matrix.cpp:
(ewk_tile_matrix_tile_new):
* ewk/ewk_tiled_model.cpp:
(ewk_tile_new):
(ewk_tile_free):
* ewk/ewk_view_tiled.cpp:
(_ewk_view_tiled_render_cb):

Modified Paths

Diff

Modified: trunk/Source/WebKit/efl/ChangeLog (104020 => 104021)


--- trunk/Source/WebKit/efl/ChangeLog	2012-01-04 09:17:45 UTC (rev 104020)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-01-04 09:26:16 UTC (rev 104021)
@@ -1,3 +1,23 @@
+2012-01-04  KwangHyuk Kim  <[email protected]>
+
+        [EFL] Refactor the way using cairo in ewk_tiled_backing_store.
+        https://bugs.webkit.org/show_bug.cgi?id=74993
+
+        Reviewed by Nikolas Zimmermann.
+
+        For now there are cairo related code scattered around the ewk_tiled_backing_store.
+        From the point of code complexity view, it doesn't look good and I couldn't notice any benefit of it.
+        So, this patch will let cairo related code be used only for painting operation.
+
+        * ewk/ewk_tiled_backing_store.h:
+        * ewk/ewk_tiled_matrix.cpp:
+        (ewk_tile_matrix_tile_new):
+        * ewk/ewk_tiled_model.cpp:
+        (ewk_tile_new):
+        (ewk_tile_free):
+        * ewk/ewk_view_tiled.cpp:
+        (_ewk_view_tiled_render_cb):
+
 2012-01-03  Jon Lee  <[email protected]>
 
         Leak of WebNotificationClient when page is destroyed

Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h (104020 => 104021)


--- trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h	2012-01-04 09:17:45 UTC (rev 104020)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h	2012-01-04 09:26:16 UTC (rev 104021)
@@ -67,10 +67,6 @@
     unsigned long col, row; /**< tile tile position */
     Evas_Coord x, y;        /**< tile coordinate position */
 
-    /* TODO: does it worth to keep those or create on demand? */
-    cairo_surface_t* surface;
-    cairo_t* cairo;
-
     /** Never ever change those after tile is created (respect const!) */
     const Evas_Coord width, height;        /**< tile size (see TILE_SIZE_AT_ZOOM()) */
     const Evas_Colorspace cspace; /**< colorspace */

Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp (104020 => 104021)


--- trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp	2012-01-04 09:17:45 UTC (rev 104020)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp	2012-01-04 09:26:16 UTC (rev 104021)
@@ -463,9 +463,6 @@
     tile->row = row;
     tile->x = column * tileWidth;
     tile->y = row * tileHeight;
-
-    cairo_translate(tile->cairo, -tile->x, -tile->y);
-
     tile->stats.full_update = true;
     tileMatrix->updates = eina_list_append(tileMatrix->updates, tile);
 

Modified: trunk/Source/WebKit/efl/ewk/ewk_tiled_model.cpp (104020 => 104021)


--- trunk/Source/WebKit/efl/ewk/ewk_tiled_model.cpp	2012-01-04 09:17:45 UTC (rev 104020)
+++ trunk/Source/WebKit/efl/ewk/ewk_tiled_model.cpp	2012-01-04 09:26:16 UTC (rev 104021)
@@ -237,23 +237,16 @@
     Ewk_Tile* tile;
     unsigned int area;
     size_t bytes;
-    cairo_format_t format;
-    cairo_status_t status;
-    int stride;
     Ecore_Evas* ecoreEvas;
     const char* engine;
 
     area = width * height;
 
-    if (colorSpace == EVAS_COLORSPACE_ARGB8888) {
+    if (colorSpace == EVAS_COLORSPACE_ARGB8888)
         bytes = area * 4;
-        stride = width * 4;
-        format = CAIRO_FORMAT_ARGB32;
-    } else if (colorSpace == EVAS_COLORSPACE_RGB565_A5P) {
+    else if (colorSpace == EVAS_COLORSPACE_RGB565_A5P)
         bytes = area * 2;
-        stride = width * 2;
-        format = CAIRO_FORMAT_RGB16_565;
-    } else {
+    else {
         ERR("unknown color space: %d", colorSpace);
         return 0;
     }
@@ -296,25 +289,6 @@
     evas_object_image_size_set(tile->image, tile->width, tile->height);
     evas_object_image_colorspace_set(tile->image, tile->cspace);
     tile->pixels = static_cast<uint8_t*>(evas_object_image_data_get(tile->image, true));
-    tile->surface = cairo_image_surface_create_for_data(tile->pixels, format, width, height, stride);
-    status = cairo_surface_status(tile->surface);
-    if (status != CAIRO_STATUS_SUCCESS) {
-        ERR("failed to create cairo surface: %s",
-            cairo_status_to_string(status));
-        free(tile);
-        return 0;
-    }
-
-    tile->cairo = cairo_create(tile->surface);
-    status = cairo_status(tile->cairo);
-    if (status != CAIRO_STATUS_SUCCESS) {
-        ERR("failed to create cairo: %s", cairo_status_to_string(status));
-        cairo_surface_destroy(tile->surface);
-        evas_object_del(tile->image);
-        free(tile);
-        return 0;
-    }
-
     _ewk_tile_account_allocated(tile);
 
     return tile;
@@ -330,8 +304,6 @@
     if (tile->updates)
         eina_tiler_free(tile->updates);
 
-    cairo_surface_destroy(tile->surface);
-    cairo_destroy(tile->cairo);
     evas_object_del(tile->image);
     free(tile);
 }

Modified: trunk/Source/WebKit/efl/ewk/ewk_view_tiled.cpp (104020 => 104021)


--- trunk/Source/WebKit/efl/ewk/ewk_view_tiled.cpp	2012-01-04 09:17:45 UTC (rev 104020)
+++ trunk/Source/WebKit/efl/ewk/ewk_view_tiled.cpp	2012-01-04 09:26:16 UTC (rev 104021)
@@ -25,6 +25,7 @@
 #include "ewk_private.h"
 
 #include <Evas.h>
+#include <RefPtrCairo.h>
 #include <eina_safety_checks.h>
 #include <ewk_tiled_backing_store.h>
 
@@ -33,9 +34,38 @@
 static Eina_Bool _ewk_view_tiled_render_cb(void* data, Ewk_Tile* tile, const Eina_Rectangle* area)
 {
     Ewk_View_Private_Data* priv = static_cast<Ewk_View_Private_Data*>(data);
-    Eina_Rectangle rect = {area->x + tile->x, area->y + tile->y, area->w, area->h};
+    Eina_Rectangle rect = {area->x + tile->x, area->y + tile->y, area->w, area->h};    
+    int stride;
+    cairo_format_t format;
 
-    return ewk_view_paint_contents(priv, tile->cairo, &rect);
+    if (tile->cspace == EVAS_COLORSPACE_ARGB8888) {
+        stride = tile->width * 4;
+        format = CAIRO_FORMAT_ARGB32;
+    } else if (tile->cspace == EVAS_COLORSPACE_RGB565_A5P) {
+        stride = tile->width * 2;
+        format = CAIRO_FORMAT_RGB16_565;
+    } else {
+        ERR("unknown color space: %d", tile->cspace);
+        return false;
+    }
+
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(tile->pixels, format, tile->width, tile->height, stride));
+    cairo_status_t status = cairo_surface_status(surface.get());
+    if (status != CAIRO_STATUS_SUCCESS) {
+        ERR("failed to create cairo surface: %s", cairo_status_to_string(status));
+        return false;
+    }
+
+    RefPtr<cairo_t> cairo = adoptRef(cairo_create(surface.get()));
+    status = cairo_status(cairo.get());
+    if (status != CAIRO_STATUS_SUCCESS) {
+        ERR("failed to create cairo: %s", cairo_status_to_string(status));
+        return false;
+    }
+
+    cairo_translate(cairo.get(), -tile->x, -tile->y);
+
+    return ewk_view_paint_contents(priv, cairo.get(), &rect);
 }
 
 static void* _ewk_view_tiled_updates_process_pre(void* data, Evas_Object* ewkView)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to