[EFL] Merge ewk_view_single into ewk_view
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jan 2014 00:59:16 +0000 (00:59 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jan 2014 00:59:16 +0000 (00:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126508

Reviewed by Gyuyoung Kim.

Source/WebKit:

* PlatformEfl.cmake: Removed ewk_view_single.cpp.

Source/WebKit/efl:

Since ewk_view_tiled is removed at r161134, we don't need to keep
ewk_view_single out of ewk_view.cpp.

This patch moves the logic of ewk_view_single to ewk_view and refactors it.
In addition, replaces 0.00001 to episilon.

* ewk/ewk_view.cpp:
(_ewk_view_smart_add):
(_ewk_view_smart_resize): Merged with the logic of ewk_view_single.
(_ewk_view_screen_move): Moved from ewk_view_single.cpp.
(_ewk_view_scroll_process): Ditto.
(_ewk_view_smart_scrolls_process): Ditto.
(_ewk_view_smart_repaints_process): Ditto.
(_ewk_view_smart_calculate): Removed unnecessary check routine for scrolls_process.
(_ewk_view_smart_zoom_weak_set):
(_ewk_view_smart_zoom_weak_smooth_scale_set):
(ewk_view_base_smart_set): Merged smart method of ewk_view_single.
(ewk_view_single_smart_set):
(_ewk_view_single_smart_class_new):
(ewk_view_single_add):
(ewk_view_bg_color_set):
(ewk_view_pre_render_region):
(ewk_view_scrolls_process):
* ewk/ewk_view.h:
* ewk/ewk_view_private.h: Removed unncessary functions.
* ewk/ewk_view_single.cpp: Removed.

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

Source/WebKit/ChangeLog
Source/WebKit/PlatformEfl.cmake
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/efl/ewk/ewk_view.h
Source/WebKit/efl/ewk/ewk_view_private.h
Source/WebKit/efl/ewk/ewk_view_single.cpp [deleted file]

index 67b370f..8062637 100644 (file)
@@ -1,3 +1,12 @@
+2014-01-08  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL] Merge ewk_view_single into ewk_view
+        https://bugs.webkit.org/show_bug.cgi?id=126508
+
+        Reviewed by Gyuyoung Kim.
+
+        * PlatformEfl.cmake: Removed ewk_view_single.cpp.
+
 2014-01-08  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Move efl API test binaries to TestWebKitAPI/EWebKit|EWebKit2
index bfbee3b..9941bfd 100644 (file)
@@ -142,7 +142,6 @@ list(APPEND WebKit_SOURCES
     efl/ewk/ewk_settings.cpp
     efl/ewk/ewk_touch_event.cpp
     efl/ewk/ewk_view.cpp
-    efl/ewk/ewk_view_single.cpp
     efl/ewk/ewk_web_database.cpp
     efl/ewk/ewk_window_features.cpp
 )
index f88fdeb..e9bdbd0 100644 (file)
@@ -1,3 +1,37 @@
+2014-01-08  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL] Merge ewk_view_single into ewk_view
+        https://bugs.webkit.org/show_bug.cgi?id=126508
+
+        Reviewed by Gyuyoung Kim.
+
+        Since ewk_view_tiled is removed at r161134, we don't need to keep
+        ewk_view_single out of ewk_view.cpp.
+
+        This patch moves the logic of ewk_view_single to ewk_view and refactors it.
+        In addition, replaces 0.00001 to episilon.
+
+        * ewk/ewk_view.cpp:
+        (_ewk_view_smart_add):
+        (_ewk_view_smart_resize): Merged with the logic of ewk_view_single.
+        (_ewk_view_screen_move): Moved from ewk_view_single.cpp.
+        (_ewk_view_scroll_process): Ditto.
+        (_ewk_view_smart_scrolls_process): Ditto.
+        (_ewk_view_smart_repaints_process): Ditto.
+        (_ewk_view_smart_calculate): Removed unnecessary check routine for scrolls_process.
+        (_ewk_view_smart_zoom_weak_set):
+        (_ewk_view_smart_zoom_weak_smooth_scale_set):
+        (ewk_view_base_smart_set): Merged smart method of ewk_view_single.
+        (ewk_view_single_smart_set):
+        (_ewk_view_single_smart_class_new):
+        (ewk_view_single_add):
+        (ewk_view_bg_color_set):
+        (ewk_view_pre_render_region):
+        (ewk_view_scrolls_process):
+        * ewk/ewk_view.h:
+        * ewk/ewk_view_private.h: Removed unncessary functions.
+        * ewk/ewk_view_single.cpp: Removed.
+
 2014-01-08  Anders Carlsson  <andersca@apple.com>
 
         Add WTF::StringView and use it for grammar checking
index 5562f50..3cf0eec 100644 (file)
@@ -906,7 +906,6 @@ static void _ewk_view_smart_add(Evas_Object* ewkView)
     const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
     const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
     const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
-    EINA_SAFETY_ON_NULL_RETURN(api->backing_store_add);
     EWK_VIEW_SD_GET(ewkView, smartData);
 
     if (!smartData) {
@@ -934,15 +933,22 @@ static void _ewk_view_smart_add(Evas_Object* ewkView)
 
     EWK_VIEW_PRIV_GET(smartData, priv);
 
-    smartData->backing_store = api->backing_store_add(smartData);
-    if (!smartData->backing_store) {
+    smartData->backing_store = evas_object_image_add(smartData->base.evas);
+    if (EINA_UNLIKELY(!smartData->backing_store)) {
         ERR("Could not create backing store object.");
         return;
     }
 
+    const Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
+    const char* engine = ecore_evas_engine_name_get(ecoreEvas);
+    if (!strncmp(engine, "opengl_x11", strlen("opengl_x11")))
+        evas_object_image_content_hint_set(smartData->backing_store, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
+
+    evas_object_image_alpha_set(smartData->backing_store, false);
+    evas_object_image_smooth_scale_set(smartData->backing_store, smartData->zoom_weak_smooth_scale);
+    evas_object_pass_events_set(smartData->backing_store, true);
     evas_object_smart_member_add(smartData->backing_store, ewkView);
     evas_object_show(smartData->backing_store);
-    evas_object_pass_events_set(smartData->backing_store, true);
 
     smartData->events_rect = evas_object_rectangle_add(smartData->base.evas);
     evas_object_color_set(smartData->events_rect, 0, 0, 0, 0);
@@ -998,9 +1004,24 @@ static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord w, Evas_Coor
 
     // these should be queued and processed in calculate as well!
     evas_object_resize(smartData->backing_store, w, h);
+    evas_object_image_size_set(smartData->backing_store, w, h);
 
     smartData->changed.size = true;
     _ewk_view_smart_changed(smartData);
+
+    if (smartData->animated_zoom.zoom.current < std::numeric_limits<float>::epsilon()) {
+        Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
+        Evas_Coord x, y, contentWidth, contentHeight;
+        evas_object_image_fill_set(smartData->backing_store, 0, 0, w, h);
+        evas_object_geometry_get(smartData->backing_store, &x, &y, 0, 0);
+        evas_object_move(clip, x, y);
+        ewk_frame_contents_size_get(smartData->main_frame, &contentWidth, &contentHeight);
+        if (w > contentWidth)
+            w = contentWidth;
+        if (h > contentHeight)
+            h = contentHeight;
+        evas_object_resize(clip, w, h);
+    }
 }
 
 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord /*x*/, Evas_Coord /*y*/)
@@ -1010,12 +1031,212 @@ static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord /*x*/, Evas_Co
     _ewk_view_smart_changed(smartData);
 }
 
+static inline void _ewk_view_screen_move(uint32_t* image, size_t destinationX, size_t destinationY, size_t sourceX, size_t sourceY, size_t copyWidth, size_t copyHeight, size_t imageWidth)
+{
+    uint32_t* sourceBegin = image + (imageWidth * sourceY) + sourceX;
+    uint32_t* destinationBegin = image + (imageWidth * destinationY) + destinationX;
+
+    size_t copyLength = copyWidth * 4;
+
+    int moveLineUpDown;
+    int row;
+
+    if (sourceY >= destinationY) {
+        row = 0;
+        moveLineUpDown = 1;
+    } else {
+        row = copyHeight - 1;
+        moveLineUpDown = -1;
+    }
+
+    uint32_t* source, * destination;
+    if ((destinationX > sourceX && destinationX < sourceX + copyWidth)
+        || (destinationX < sourceX && destinationX + copyWidth > sourceX)) {
+        for (size_t i = 0; i < copyHeight; ++i, row += moveLineUpDown) {
+            source = sourceBegin + (imageWidth * row);
+            destination = destinationBegin + (imageWidth * row);
+            memmove(destination, source, copyLength);
+        }
+    } else {
+        for (size_t i = 0; i < copyHeight; ++i, row += moveLineUpDown) {
+            source = sourceBegin + (imageWidth * row);
+            destination = destinationBegin + (imageWidth * row);
+            memcpy(destination, source, copyLength);
+        }
+    }
+}
+
+static inline void _ewk_view_scroll_process(Ewk_View_Smart_Data* smartData, void* pixels, Evas_Coord width, Evas_Coord height, const WebCore::IntSize& scrollOffset, const WebCore::IntRect& rectToScroll)
+{
+    int scrollX = rectToScroll.x();
+    int scrollY = rectToScroll.y();
+    int scrollWidth = rectToScroll.width();
+    int scrollHeight = rectToScroll.height();
+
+    if (abs(scrollOffset.width()) >= scrollWidth || abs(scrollOffset.height()) >= scrollHeight) {
+        ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
+        return;
+    }
+
+    if (scrollX < 0) {
+        scrollWidth += scrollX;
+        scrollX = 0;
+    }
+    if (scrollY < 0) {
+        scrollHeight += scrollY;
+        scrollY = 0;
+    }
+
+    if (scrollX + scrollWidth > width)
+        scrollWidth = width - scrollX;
+    if (scrollY + scrollHeight > height)
+        scrollHeight = height - scrollY;
+
+    if (scrollWidth <= 0 || scrollHeight <= 0)
+        return;
+
+    int sourceX = scrollOffset.width() < 0 ? abs(scrollOffset.width()) : 0;
+    int sourceY = scrollOffset.height() < 0 ? abs(scrollOffset.height()) : 0;
+    int destinationX = scrollOffset.width() < 0 ? 0 : scrollOffset.width();
+    int destinationY = scrollOffset.height() < 0 ? 0 : scrollOffset.height();
+    int copyWidth = scrollWidth - abs(scrollOffset.width());
+    int copyHeight = scrollHeight - abs(scrollOffset.height());
+    if (scrollOffset.width() || scrollOffset.height()) {
+        _ewk_view_screen_move(static_cast<uint32_t*>(pixels), destinationX, destinationY, sourceX, sourceY, copyWidth, copyHeight, width);
+        evas_object_image_data_update_add(smartData->backing_store, destinationX, destinationY, copyWidth, copyHeight);
+    }
+
+    Eina_Rectangle verticalUpdate;
+    verticalUpdate.x = destinationX ? 0 : copyWidth - 1;
+    verticalUpdate.y = 0;
+    verticalUpdate.w = abs(scrollOffset.width());
+    verticalUpdate.h = scrollHeight;
+    if (verticalUpdate.w && verticalUpdate.h)
+        ewk_view_repaint_add(smartData->_priv, verticalUpdate.x, verticalUpdate.y, verticalUpdate.w, verticalUpdate.h);
+
+    Eina_Rectangle horizontalUpdate;
+    horizontalUpdate.x = destinationX;
+    horizontalUpdate.y = destinationY ? 0 : copyHeight - 1;
+    horizontalUpdate.w = copyWidth;
+    horizontalUpdate.h = abs(scrollOffset.height());
+    if (horizontalUpdate.w && horizontalUpdate.h)
+        ewk_view_repaint_add(smartData->_priv, horizontalUpdate.x, horizontalUpdate.y, horizontalUpdate.w, horizontalUpdate.h);
+}
+
+static void _ewk_view_smart_scrolls_process(Ewk_View_Smart_Data* smartData)
+{
+    Evas_Coord imageWidth, imageHeight;
+    const WTF::Vector<WebCore::IntSize>& scrollOffsets = smartData->_priv->m_scrollOffsets;
+    const WTF::Vector<WebCore::IntRect>& rectsToScroll = smartData->_priv->m_rectsToScroll;
+
+    if (!scrollOffsets.size())
+        return;
+
+    evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight);
+
+    WebCore::IntRect rectToScroll(0, 0, imageWidth, imageHeight);
+    WebCore::IntSize scrollOffset;
+    for (size_t i = 0; i < scrollOffsets.size(); ++i) {
+        rectToScroll.intersect(rectsToScroll[i]);
+        scrollOffset += scrollOffsets[i];
+    }
+
+    if (scrollOffset.isZero())
+        return;
+
+    void* pixels = evas_object_image_data_get(smartData->backing_store, 1);
+    _ewk_view_scroll_process(smartData, pixels, imageWidth, imageHeight, scrollOffset, rectToScroll);
+
+    evas_object_image_data_set(smartData->backing_store, pixels);
+
+    return;
+}
+
+static Eina_Bool _ewk_view_smart_repaints_process(Ewk_View_Smart_Data* smartData)
+{
+    if (smartData->animated_zoom.zoom.current < std::numeric_limits<float>::epsilon()) {
+        Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
+
+        // reset effects of zoom_weak_set()
+        evas_object_image_fill_set(smartData->backing_store, 0, 0, smartData->view.w, smartData->view.h);
+        evas_object_move(clip, smartData->view.x, smartData->view.y);
+
+        Evas_Coord width = smartData->view.w;
+        Evas_Coord height = smartData->view.h;
+
+        Evas_Coord centerWidth, centerHeight;
+        ewk_frame_contents_size_get(smartData->main_frame, &centerWidth, &centerHeight);
+        if (width > centerWidth)
+            width = centerWidth;
+
+        if (height > centerHeight)
+            height = centerHeight;
+
+        evas_object_resize(clip, width, height);
+    }
+
+    Evas_Coord imageWidth, imageHeight;
+    evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight);
+
+    Eina_Tiler* tiler = eina_tiler_new(imageWidth, imageHeight);
+    if (!tiler) {
+        ERR("could not create tiler %dx%d", imageWidth, imageHeight);
+        return false;
+    }
+
+    ewk_view_layout_if_needed_recursive(smartData->_priv);
+
+    size_t count;
+    const Eina_Rectangle* paintRequest = ewk_view_repaints_pop(smartData->_priv, &count);
+    const Eina_Rectangle* paintRequestEnd = paintRequest + count;
+    for (; paintRequest < paintRequestEnd; paintRequest++)
+        eina_tiler_rect_add(tiler, paintRequest);
+
+    Eina_Iterator* iterator = eina_tiler_iterator_new(tiler);
+    if (!iterator) {
+        ERR("could not get iterator for tiler");
+        eina_tiler_free(tiler);
+        return false;
+    }
+
+#if USE(TILED_BACKING_STORE)
+    WebCore::Frame* mainFrame = EWKPrivate::coreFrame(smartData->main_frame);
+    if (mainFrame && mainFrame->tiledBackingStore())
+        mainFrame->tiledBackingStore()->coverWithTilesIfNeeded();
+#endif
+
+    Ewk_Paint_Context* context = ewk_paint_context_from_image_new(smartData->backing_store);
+    ewk_paint_context_save(context);
+
+    Eina_Rectangle* rect;
+    EINA_ITERATOR_FOREACH(iterator, rect) {
+        ewk_view_paint(smartData->_priv, context, rect);
+        evas_object_image_data_update_add(smartData->backing_store, rect->x, rect->y, rect->w, rect->h);
+    }
+
+#if ENABLE(INSPECTOR)
+    WebCore::Page* page = EWKPrivate::corePage(smartData->self);
+    if (page) {
+        WebCore::InspectorController* controller = page->inspectorController();
+        if (controller->highlightedNode())
+            controller->drawHighlight(*context->graphicContext);
+    }
+#endif
+
+    ewk_paint_context_restore(context);
+    ewk_paint_context_free(context);
+
+    eina_tiler_free(tiler);
+    eina_iterator_free(iterator);
+
+    return true;
+}
+
 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
 {
     EWK_VIEW_SD_GET(ewkView, smartData);
     EWK_VIEW_PRIV_GET(smartData, priv);
     EINA_SAFETY_ON_NULL_RETURN(smartData->api->contents_resize);
-    EINA_SAFETY_ON_NULL_RETURN(smartData->api->scrolls_process);
     EINA_SAFETY_ON_NULL_RETURN(smartData->api->repaints_process);
     Evas_Coord x, y, width, height;
 
@@ -1059,8 +1280,7 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
     }
     smartData->changed.position = false;
 
-    if (!smartData->api->scrolls_process(smartData))
-        ERR("failed to process scrolls.");
+    smartData->api->scrolls_process(smartData);
     _ewk_view_scrolls_flush(priv);
 
     if (!smartData->api->repaints_process(smartData))
@@ -1187,6 +1407,48 @@ static float _ewk_view_zoom_animated_current(Ewk_View_Private_Data* priv)
             + priv->animatedZoom.zoom.start);
 }
 
+static Eina_Bool _ewk_view_smart_zoom_weak_set(Ewk_View_Smart_Data* smartData, float zoom, Evas_Coord centerX, Evas_Coord centerY)
+{
+    float scale = zoom / smartData->animated_zoom.zoom.start;
+    Evas_Coord w = smartData->view.w * scale;
+    Evas_Coord h = smartData->view.h * scale;
+    Evas_Coord deltaX, deltaY, contentWidth, contentHeight;
+    Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
+
+    ewk_frame_contents_size_get(smartData->main_frame, &contentWidth, &contentHeight);
+    if (smartData->view.w > 0 && smartData->view.h > 0) {
+        deltaX = (w * (smartData->view.w - centerX)) / smartData->view.w;
+        deltaY = (h * (smartData->view.h - centerY)) / smartData->view.h;
+    } else {
+        deltaX = 0;
+        deltaY = 0;
+    }
+
+    evas_object_image_fill_set(smartData->backing_store, centerX + deltaX, centerY + deltaY, w, h);
+
+    if (smartData->view.w > 0 && smartData->view.h > 0) {
+        deltaX = ((smartData->view.w - w) * centerX) / smartData->view.w;
+        deltaY = ((smartData->view.h - h) * centerY) / smartData->view.h;
+    } else {
+        deltaX = 0;
+        deltaY = 0;
+    }
+    evas_object_move(clip, smartData->view.x + deltaX, smartData->view.y + deltaY);
+
+    if (contentWidth < smartData->view.w)
+        w = contentWidth * scale;
+    if (contentHeight < smartData->view.h)
+        h = contentHeight * scale;
+    evas_object_resize(clip, w, h);
+
+    return true;
+}
+
+static void _ewk_view_smart_zoom_weak_smooth_scale_set(Ewk_View_Smart_Data* smartData, Eina_Bool smooth_scale)
+{
+    evas_object_image_smooth_scale_set(smartData->backing_store, smooth_scale);
+}
+
 static Eina_Bool _ewk_view_zoom_animator_cb(void* data)
 {
     Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
@@ -1288,7 +1550,11 @@ Eina_Bool ewk_view_base_smart_set(Ewk_View_Smart_Class* api)
     api->sc.callbacks = _ewk_view_callback_names;
 
     api->contents_resize = _ewk_view_smart_contents_resize;
+    api->scrolls_process = _ewk_view_smart_scrolls_process;
+    api->repaints_process = _ewk_view_smart_repaints_process;
     api->zoom_set = _ewk_view_smart_zoom_set;
+    api->zoom_weak_set = _ewk_view_smart_zoom_weak_set;
+    api->zoom_weak_smooth_scale_set = _ewk_view_smart_zoom_weak_smooth_scale_set;
     api->flush = _ewk_view_smart_flush;
     api->pre_render_region = _ewk_view_smart_pre_render_region;
     api->pre_render_relative_radius = _ewk_view_smart_pre_render_relative_radius;
@@ -1316,6 +1582,29 @@ Eina_Bool ewk_view_base_smart_set(Ewk_View_Smart_Class* api)
     return true;
 }
 
+Eina_Bool ewk_view_single_smart_set(Ewk_View_Smart_Class* api)
+{
+    return ewk_view_base_smart_set(api);
+}
+
+static inline Evas_Smart* _ewk_view_single_smart_class_new(void)
+{
+    static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(ewkViewSingleName);
+    static Evas_Smart* smart = 0;
+
+    if (EINA_UNLIKELY(!smart)) {
+        ewk_view_base_smart_set(&api);
+        smart = evas_smart_class_new(&api.sc);
+    }
+
+    return smart;
+}
+
+Evas_Object* ewk_view_single_add(Evas* canvas)
+{
+    return evas_object_smart_add(canvas, _ewk_view_single_smart_class_new());
+}
+
 void ewk_view_fixed_layout_size_set(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
@@ -1424,7 +1713,6 @@ void ewk_view_bg_color_set(Evas_Object* ewkView, int red, int green, int blue, i
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
     EINA_SAFETY_ON_NULL_RETURN(smartData->api);
-    EINA_SAFETY_ON_NULL_RETURN(smartData->api->bg_color_set);
 
     if (alpha < 0) {
         WARN("Alpha less than zero (%d).", alpha);
@@ -1453,7 +1741,7 @@ void ewk_view_bg_color_set(Evas_Object* ewkView, int red, int green, int blue, i
     smartData->bg_color.b = blue;
     smartData->bg_color.a = alpha;
 
-    smartData->api->bg_color_set(smartData, red, green, blue, alpha);
+    evas_object_image_alpha_set(smartData->backing_store, alpha < 255);
 
     WebCore::FrameView* view = smartData->_priv->mainFrame->view();
     if (view) {
@@ -1926,7 +2214,6 @@ Eina_Bool ewk_view_pre_render_region(Evas_Object* ewkView, Evas_Coord x, Evas_Co
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->pre_render_region, false);
-    float currentZoom;
     Evas_Coord contentsWidth, contentsHeight;
 
     /* When doing animated zoom it's not possible to call pre-render since it
@@ -1935,10 +2222,10 @@ Eina_Bool ewk_view_pre_render_region(Evas_Object* ewkView, Evas_Coord x, Evas_Co
     if (priv->animatedZoom.animator)
         return false;
 
-    currentZoom = ewk_frame_page_zoom_get(smartData->main_frame);
-
-    if (currentZoom < 0.00001)
+    float currentZoom = ewk_frame_page_zoom_get(smartData->main_frame);
+    if (currentZoom < std::numeric_limits<float>::epsilon())
         return false;
+
     if (!ewk_frame_contents_size_get(smartData->main_frame, &contentsWidth, &contentsHeight))
         return false;
 
@@ -2726,18 +3013,6 @@ const Eina_Rectangle* ewk_view_repaints_pop(Ewk_View_Private_Data* priv, size_t*
     return priv->repaints.array;
 }
 
-const Vector<WebCore::IntSize>& ewk_view_scroll_offsets_get(const Ewk_View_Private_Data* priv)
-{
-    ASSERT(priv);
-    return priv->m_scrollOffsets;
-}
-
-const Vector<WebCore::IntRect>& ewk_view_scroll_rects_get(const Ewk_View_Private_Data* priv)
-{
-    ASSERT(priv);
-    return priv->m_rectsToScroll;
-}
-
 /**
  * Add a new repaint request to queue.
  *
@@ -2782,8 +3057,8 @@ void ewk_view_scrolls_process(Ewk_View_Smart_Data* smartData)
 {
     EINA_SAFETY_ON_NULL_RETURN(smartData);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
-    if (!smartData->api->scrolls_process(smartData))
-        ERR("failed to process scrolls.");
+
+    smartData->api->scrolls_process(smartData);
     _ewk_view_scrolls_flush(priv);
 }
 
index 9c90886..f9cfba7 100644 (file)
@@ -153,15 +153,12 @@ struct _Ewk_View_Smart_Class {
 
     Evas_Object *(*window_create)(Ewk_View_Smart_Data *sd, Eina_Bool javascript, const Ewk_Window_Features *window_features); /**< creates a new window, requested by webkit */
     void (*window_close)(Ewk_View_Smart_Data *sd); /**< closes a window */
-    // hooks to allow different backing stores
-    Evas_Object *(*backing_store_add)(Ewk_View_Smart_Data *sd); /**< must be defined */
-    Eina_Bool (*scrolls_process)(Ewk_View_Smart_Data *sd); /**< must be defined */
+    void (*scrolls_process)(Ewk_View_Smart_Data *sd); /**< must be defined */
     Eina_Bool (*repaints_process)(Ewk_View_Smart_Data *sd); /**< must be defined */
     Eina_Bool (*contents_resize)(Ewk_View_Smart_Data *sd, int w, int h);
     Eina_Bool (*zoom_set)(Ewk_View_Smart_Data *sd, float zoom, Evas_Coord cx, Evas_Coord cy);
     Eina_Bool (*zoom_weak_set)(Ewk_View_Smart_Data *sd, float zoom, Evas_Coord cx, Evas_Coord cy);
     void (*zoom_weak_smooth_scale_set)(Ewk_View_Smart_Data *sd, Eina_Bool smooth_scale);
-    void (*bg_color_set)(Ewk_View_Smart_Data *sd, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
     void (*flush)(Ewk_View_Smart_Data *sd);
     Eina_Bool (*pre_render_region)(Ewk_View_Smart_Data *sd, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, float zoom);
     Eina_Bool (*pre_render_relative_radius)(Ewk_View_Smart_Data *sd, unsigned int n, float zoom);
@@ -203,7 +200,7 @@ struct _Ewk_View_Smart_Class {
  * The version you have to put into the version field
  * in the @a Ewk_View_Smart_Class structure.
  */
-#define EWK_VIEW_SMART_CLASS_VERSION 7UL
+#define EWK_VIEW_SMART_CLASS_VERSION 8UL
 
 /**
  * Initializes a whole @a Ewk_View_Smart_Class structure.
@@ -215,7 +212,7 @@ struct _Ewk_View_Smart_Class {
  * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
  * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
  */
-#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 
 /**
  * Initializes to zero a whole @a Ewk_View_Smart_Class structure.
index 2ddbc24..a5b88ad 100644 (file)
@@ -148,8 +148,6 @@ bool ewk_view_need_touch_events_get(const Evas_Object*);
 #endif
 
 const Eina_Rectangle* ewk_view_repaints_pop(Ewk_View_Private_Data* priv, size_t* count);
-const Vector<WebCore::IntSize>& ewk_view_scroll_offsets_get(const Ewk_View_Private_Data*);
-const Vector<WebCore::IntRect>& ewk_view_scroll_rects_get(const Ewk_View_Private_Data*);
 
 void ewk_view_repaint_add(Ewk_View_Private_Data* priv, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height);
 
diff --git a/Source/WebKit/efl/ewk/ewk_view_single.cpp b/Source/WebKit/efl/ewk/ewk_view_single.cpp
deleted file mode 100644 (file)
index 0c45176..0000000
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
-    Copyright (C) 2009-2010 ProFUSION embedded systems
-    Copyright (C) 2009-2010 Samsung Electronics
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "ewk_view.h"
-
-#include "TiledBackingStore.h"
-#include "ewk_frame_private.h"
-#include "ewk_private.h"
-#include "ewk_view_private.h"
-
-#include <Ecore_Evas.h>
-#include <Evas.h>
-#include <eina_safety_checks.h>
-#include <string.h>
-
-#if ENABLE(INSPECTOR)
-#include "InspectorController.h"
-#include "Page.h"
-#endif
-
-static Ewk_View_Smart_Class _parent_sc = EWK_VIEW_SMART_CLASS_INIT_NULL;
-
-static void _ewk_view_single_on_del(void* data, Evas*, Evas_Object*, void*)
-{
-    Evas_Object* clip = (Evas_Object*)data;
-    evas_object_del(clip);
-}
-
-static void _ewk_view_single_smart_add(Evas_Object* ewkView)
-{
-    Ewk_View_Smart_Data* smartData;
-
-    _parent_sc.sc.add(ewkView);
-
-    smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView));
-    if (!smartData)
-        return;
-
-    Evas_Object* clip = evas_object_rectangle_add(smartData->base.evas);
-    evas_object_show(clip);
-
-    evas_object_event_callback_add
-        (smartData->backing_store, EVAS_CALLBACK_DEL, _ewk_view_single_on_del, clip);
-}
-
-static Evas_Object* _ewk_view_single_smart_backing_store_add(Ewk_View_Smart_Data* smartData)
-{
-    Evas_Object* bs = evas_object_image_add(smartData->base.evas);
-    EINA_SAFETY_ON_NULL_RETURN_VAL(bs, 0);
-    const Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
-    const char* engine = ecore_evas_engine_name_get(ecoreEvas);
-    if (!strncmp(engine, "opengl_x11", strlen("opengl_x11")))
-        evas_object_image_content_hint_set(bs, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
-
-    evas_object_image_alpha_set(bs, false);
-    evas_object_image_smooth_scale_set(bs, smartData->zoom_weak_smooth_scale);
-
-    return bs;
-}
-
-static void _ewk_view_single_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
-{
-    Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView));
-    _parent_sc.sc.resize(ewkView, width, height);
-
-    if (!smartData)
-        return;
-
-    // these should be queued and processed in calculate as well!
-    evas_object_image_size_set(smartData->backing_store, width, height);
-    if (smartData->animated_zoom.zoom.current < 0.00001) {
-        Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
-        Evas_Coord x, y, cw, ch;
-        evas_object_image_fill_set(smartData->backing_store, 0, 0, width, height);
-        evas_object_geometry_get(smartData->backing_store, &x, &y, 0, 0);
-        evas_object_move(clip, x, y);
-        ewk_frame_contents_size_get(smartData->main_frame, &cw, &ch);
-        if (width > cw)
-            width = cw;
-        if (height > ch)
-            height = ch;
-        evas_object_resize(clip, width, height);
-    }
-}
-
-static inline void _ewk_view_screen_move(uint32_t* image, size_t destinationX, size_t destinationY, size_t sourceX, size_t sourceY, size_t copyWidth, size_t copyHeight, size_t imageWidth)
-{
-    uint32_t* sourceBegin = image + (imageWidth * sourceY) + sourceX;
-    uint32_t* destinationBegin = image + (imageWidth * destinationY) + destinationX;
-
-    size_t copyLength = copyWidth * 4;
-    const int moveLineUpDown = sourceY >= destinationY ? 1 : -1;
-    int startHeight = sourceY >= destinationY ? 0 : copyHeight - 1;
-
-    uint32_t* source, * destination;
-    if ((destinationX > sourceX && destinationX < sourceX + copyWidth)
-        || (destinationX < sourceX && destinationX + copyWidth > sourceX)) {
-        for (size_t i = 0; i < copyHeight; i++) {
-            source = sourceBegin + (imageWidth * startHeight);
-            destination = destinationBegin + (imageWidth * startHeight);
-            startHeight = startHeight + moveLineUpDown;
-            memmove(destination, source, copyLength);
-        }
-    } else {
-        for (size_t i = 0; i < copyHeight; i++) {
-            source = sourceBegin + (imageWidth * startHeight);
-            destination = destinationBegin + (imageWidth * startHeight);
-            startHeight = startHeight + moveLineUpDown;
-            memcpy(destination, source, copyLength);
-        }
-    }
-}
-
-static inline void _ewk_view_single_scroll_process_single(Ewk_View_Smart_Data* smartData, void* pixels, Evas_Coord width, Evas_Coord height, const WebCore::IntSize& scrollOffset, const WebCore::IntRect& rectToScroll)
-{
-    int scrollX = rectToScroll.x();
-    int scrollY = rectToScroll.y();
-    int scrollWidth = rectToScroll.width();
-    int scrollHeight = rectToScroll.height();
-
-    DBG("%d,%d + %d,%d %+03d,%+03d, store: %p %dx%d",
-        scrollX, scrollY, scrollWidth, scrollHeight, scrollOffset.width(), scrollOffset.height(), pixels, width, height);
-
-    if (abs(scrollOffset.width()) >= scrollWidth || abs(scrollOffset.height()) >= scrollHeight) {
-        ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
-        return;
-    }
-
-    if (scrollX < 0) {
-        scrollWidth += scrollX;
-        scrollX = 0;
-    }
-    if (scrollY < 0) {
-        scrollHeight += scrollY;
-        scrollY = 0;
-    }
-
-    if (scrollX + scrollWidth > width)
-        scrollWidth = width - scrollX;
-    if (scrollY + scrollHeight > height)
-        scrollHeight = height - scrollY;
-
-    if (scrollWidth <= 0 || scrollHeight <= 0)
-        return;
-
-    int sourceX = scrollOffset.width() < 0 ? abs(scrollOffset.width()) : 0;
-    int sourceY = scrollOffset.height() < 0 ? abs(scrollOffset.height()) : 0;
-    int destinationX = scrollOffset.width() < 0 ? 0 : scrollOffset.width();
-    int destinationY = scrollOffset.height() < 0 ? 0 : scrollOffset.height();
-    int copyWidth = scrollWidth - abs(scrollOffset.width());
-    int copyHeight = scrollHeight - abs(scrollOffset.height());
-    if (scrollOffset.width() || scrollOffset.height()) {
-        _ewk_view_screen_move(static_cast<uint32_t*>(pixels), destinationX, destinationY, sourceX, sourceY, copyWidth, copyHeight, width);
-        evas_object_image_data_update_add(smartData->backing_store, destinationX, destinationY, copyWidth, copyHeight);
-    }
-
-    Eina_Rectangle verticalUpdate;
-    verticalUpdate.x = destinationX ? 0 : copyWidth - 1;
-    verticalUpdate.y = 0;
-    verticalUpdate.w = abs(scrollOffset.width());
-    verticalUpdate.h = scrollHeight;
-    if (verticalUpdate.w && verticalUpdate.h)
-        ewk_view_repaint_add(smartData->_priv, verticalUpdate.x, verticalUpdate.y, verticalUpdate.w, verticalUpdate.h);
-
-    Eina_Rectangle horizontalUpdate;
-    horizontalUpdate.x = destinationX;
-    horizontalUpdate.y = destinationY ? 0 : copyHeight - 1;
-    horizontalUpdate.w = copyWidth;
-    horizontalUpdate.h = abs(scrollOffset.height());
-    if (horizontalUpdate.w && horizontalUpdate.h)
-        ewk_view_repaint_add(smartData->_priv, horizontalUpdate.x, horizontalUpdate.y, horizontalUpdate.w, horizontalUpdate.h);
-}
-
-static Eina_Bool _ewk_view_single_smart_scrolls_process(Ewk_View_Smart_Data* smartData)
-{
-    Evas_Coord imageWidth, imageHeight;
-    evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight);
-
-    const WTF::Vector<WebCore::IntSize>& scrollOffsets = ewk_view_scroll_offsets_get(smartData->_priv);
-    const WTF::Vector<WebCore::IntRect>& rectsToScroll = ewk_view_scroll_rects_get(smartData->_priv);
-
-    WebCore::IntRect rectToScroll(0, 0, imageWidth, imageHeight);
-    WebCore::IntSize scrollOffset;
-    for (size_t i = 0; i < scrollOffsets.size(); ++i) {
-        rectToScroll.intersect(rectsToScroll[i]);
-        scrollOffset += scrollOffsets[i];
-    }
-
-    if (scrollOffset.isZero())
-        return true;
-
-    void* pixels = evas_object_image_data_get(smartData->backing_store, 1);
-    _ewk_view_single_scroll_process_single(smartData, pixels, imageWidth, imageHeight, scrollOffset, rectToScroll);
-
-    evas_object_image_data_set(smartData->backing_store, pixels);
-
-    return true;
-}
-
-static Eina_Bool _ewk_view_single_smart_repaints_process(Ewk_View_Smart_Data* smartData)
-{
-    if (smartData->animated_zoom.zoom.current < 0.00001) {
-        Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
-
-        // reset effects of zoom_weak_set()
-        evas_object_image_fill_set(smartData->backing_store, 0, 0, smartData->view.w, smartData->view.h);
-        evas_object_move(clip, smartData->view.x, smartData->view.y);
-
-        Evas_Coord width = smartData->view.w;
-        Evas_Coord height = smartData->view.h;
-
-        Evas_Coord centerWidth, centerHeight;
-        ewk_frame_contents_size_get(smartData->main_frame, &centerWidth, &centerHeight);
-        if (width > centerWidth)
-            width = centerWidth;
-
-        if (height > centerHeight)
-            height = centerHeight;
-
-        evas_object_resize(clip, width, height);
-    }
-
-    Evas_Coord imageWidth, imageHeight;
-    evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight);
-
-    Eina_Tiler* tiler = eina_tiler_new(imageWidth, imageHeight);
-    if (!tiler) {
-        ERR("could not create tiler %dx%d", imageWidth, imageHeight);
-        return false;
-    }
-
-    ewk_view_layout_if_needed_recursive(smartData->_priv);
-
-    size_t count;
-    const Eina_Rectangle* paintRequest = ewk_view_repaints_pop(smartData->_priv, &count);
-    const Eina_Rectangle* paintRequestEnd = paintRequest + count;
-    for (; paintRequest < paintRequestEnd; paintRequest++)
-        eina_tiler_rect_add(tiler, paintRequest);
-
-    Eina_Iterator* iterator = eina_tiler_iterator_new(tiler);
-    if (!iterator) {
-        ERR("could not get iterator for tiler");
-        eina_tiler_free(tiler);
-        return false;
-    }
-
-#if USE(TILED_BACKING_STORE)
-    WebCore::Frame* mainFrame = EWKPrivate::coreFrame(smartData->main_frame);
-    if (mainFrame && mainFrame->tiledBackingStore())
-        mainFrame->tiledBackingStore()->coverWithTilesIfNeeded();
-#endif
-
-    Ewk_Paint_Context* context = ewk_paint_context_from_image_new(smartData->backing_store);
-    ewk_paint_context_save(context);
-
-    Eina_Rectangle* rect;
-    EINA_ITERATOR_FOREACH(iterator, rect) {
-        ewk_view_paint(smartData->_priv, context, rect);
-        evas_object_image_data_update_add(smartData->backing_store, rect->x, rect->y, rect->w, rect->h);
-    }
-
-#if ENABLE(INSPECTOR)
-    WebCore::Page* page = EWKPrivate::corePage(smartData->self);
-    if (page) {
-        WebCore::InspectorController* controller = page->inspectorController();
-        if (controller->highlightedNode())
-            controller->drawHighlight(*context->graphicContext);
-    }
-#endif
-
-    ewk_paint_context_restore(context);
-    ewk_paint_context_free(context);
-
-    eina_tiler_free(tiler);
-    eina_iterator_free(iterator);
-
-    return true;
-}
-
-static Eina_Bool _ewk_view_single_smart_zoom_weak_set(Ewk_View_Smart_Data* smartData, float zoom, Evas_Coord centerX, Evas_Coord centerY)
-{
-    // TODO: review
-    float scale = zoom / smartData->animated_zoom.zoom.start;
-    Evas_Coord w = smartData->view.w * scale;
-    Evas_Coord h = smartData->view.h * scale;
-    Evas_Coord dx, dy, cw, ch;
-    Evas_Object* clip = evas_object_clip_get(smartData->backing_store);
-
-    ewk_frame_contents_size_get(smartData->main_frame, &cw, &ch);
-    if (smartData->view.w > 0 && smartData->view.h > 0) {
-        dx = (w * (smartData->view.w - centerX)) / smartData->view.w;
-        dy = (h * (smartData->view.h - centerY)) / smartData->view.h;
-    } else {
-        dx = 0;
-        dy = 0;
-    }
-
-    evas_object_image_fill_set(smartData->backing_store, centerX + dx, centerY + dy, w, h);
-
-    if (smartData->view.w > 0 && smartData->view.h > 0) {
-        dx = ((smartData->view.w - w) * centerX) / smartData->view.w;
-        dy = ((smartData->view.h - h) * centerY) / smartData->view.h;
-    } else {
-        dx = 0;
-        dy = 0;
-    }
-    evas_object_move(clip, smartData->view.x + dx, smartData->view.y + dy);
-
-    if (cw < smartData->view.w)
-        w = cw * scale;
-    if (ch < smartData->view.h)
-        h = ch * scale;
-    evas_object_resize(clip, w, h);
-    return true;
-}
-
-static void _ewk_view_single_smart_zoom_weak_smooth_scale_set(Ewk_View_Smart_Data* smartData, Eina_Bool smooth_scale)
-{
-    evas_object_image_smooth_scale_set(smartData->backing_store, smooth_scale);
-}
-
-static void _ewk_view_single_smart_bg_color_set(Ewk_View_Smart_Data* smartData, unsigned char /*red*/, unsigned char /*green*/, unsigned char /*blue*/, unsigned char alpha)
-{
-    evas_object_image_alpha_set(smartData->backing_store, alpha < 255);
-}
-
-Eina_Bool ewk_view_single_smart_set(Ewk_View_Smart_Class* api)
-{
-    if (!ewk_view_base_smart_set(api))
-        return false;
-
-    if (EINA_UNLIKELY(!_parent_sc.sc.add))
-        ewk_view_base_smart_set(&_parent_sc);
-
-    api->sc.add = _ewk_view_single_smart_add;
-    api->sc.resize = _ewk_view_single_smart_resize;
-
-    api->backing_store_add = _ewk_view_single_smart_backing_store_add;
-    api->scrolls_process = _ewk_view_single_smart_scrolls_process;
-    api->repaints_process = _ewk_view_single_smart_repaints_process;
-    api->zoom_weak_set = _ewk_view_single_smart_zoom_weak_set;
-    api->zoom_weak_smooth_scale_set = _ewk_view_single_smart_zoom_weak_smooth_scale_set;
-    api->bg_color_set = _ewk_view_single_smart_bg_color_set;
-
-    return true;
-}
-
-static inline Evas_Smart* _ewk_view_single_smart_class_new(void)
-{
-    static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(ewkViewSingleName);
-    static Evas_Smart* smart = 0;
-
-    if (EINA_UNLIKELY(!smart)) {
-        ewk_view_single_smart_set(&api);
-        smart = evas_smart_class_new(&api.sc);
-    }
-
-    return smart;
-}
-
-Evas_Object* ewk_view_single_add(Evas* canvas)
-{
-    return evas_object_smart_add(canvas, _ewk_view_single_smart_class_new());
-}