Evas_Object* is a ref'ed structure, so tread it as such
authorkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 09:27:28 +0000 (09:27 +0000)
committerkenneth@webkit.org <kenneth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 09:27:28 +0000 (09:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96659

Source/WebCore:

Reviewed by Adam Barth.

Replace OwnPtr<Evas_Object> with RefPtr.

* PlatformEfl.cmake:
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::ThemePartCacheEntry::create):
(WebCore::RenderThemeEfl::loadTheme):
(WebCore::RenderThemeEfl::applyPartDescriptionsFrom):
* platform/efl/RenderThemeEfl.h:
(RenderThemeEfl):
(ThemePartCacheEntry):

Source/WebKit/efl:

Reviewed by Adam Barth.

Replace OwnPtr<Evas_Object> with RefPtr.

* tests/UnitTestUtils/EWKTestView.cpp:
(EWKUnitTests::EWKTestView::init):
* tests/UnitTestUtils/EWKTestView.h:
(EWKTestView):

Source/WTF:

Reviewed by Gyuyoung Kim.

Remove OwnPtr support for Evas_Object* and add support for it
with RefPtr instead (the latter moved from WebCore).

* wtf/PlatformEfl.cmake:
* wtf/efl/OwnPtrEfl.cpp:
* wtf/efl/RefPtrEfl.cpp: Renamed from Source/WebCore/platform/efl/RefPtrEfl.cpp.
(WTF):
(WTF::refIfNotNull):
(WTF::derefIfNotNull):
* wtf/efl/RefPtrEfl.h: Renamed from Source/WebCore/platform/efl/RefPtrEfl.h.
(WTF):

Tools:

Reviewed by Adam Barth.

Replace OwnPtr<Evas_Object> with RefPtr.

* DumpRenderTree/efl/ImageDiff.cpp:
(calculateDifference):
(printImageDifferences):
(readImageFromStdin):
(main):

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

14 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformEfl.cmake
Source/WTF/wtf/efl/OwnPtrEfl.cpp
Source/WTF/wtf/efl/RefPtrEfl.cpp [moved from Source/WebCore/platform/efl/RefPtrEfl.cpp with 68% similarity]
Source/WTF/wtf/efl/RefPtrEfl.h [moved from Source/WebCore/platform/efl/RefPtrEfl.h with 100% similarity]
Source/WebCore/ChangeLog
Source/WebCore/PlatformEfl.cmake
Source/WebCore/platform/efl/RenderThemeEfl.cpp
Source/WebCore/platform/efl/RenderThemeEfl.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.cpp
Source/WebKit/efl/tests/UnitTestUtils/EWKTestView.h
Tools/ChangeLog
Tools/DumpRenderTree/efl/ImageDiff.cpp

index 784e99e..ebd8c0f 100644 (file)
@@ -1,3 +1,22 @@
+2012-09-13  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        Evas_Object* is a ref'ed structure, so tread it as such
+        https://bugs.webkit.org/show_bug.cgi?id=96659
+
+        Reviewed by Gyuyoung Kim.
+
+        Remove OwnPtr support for Evas_Object* and add support for it
+        with RefPtr instead (the latter moved from WebCore).
+
+        * wtf/PlatformEfl.cmake:
+        * wtf/efl/OwnPtrEfl.cpp:
+        * wtf/efl/RefPtrEfl.cpp: Renamed from Source/WebCore/platform/efl/RefPtrEfl.cpp.
+        (WTF):
+        (WTF::refIfNotNull):
+        (WTF::derefIfNotNull):
+        * wtf/efl/RefPtrEfl.h: Renamed from Source/WebCore/platform/efl/RefPtrEfl.h.
+        (WTF):
+
 2012-09-14  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, rolling out r128507.
index 05ad847..2d663fa 100644 (file)
@@ -1,6 +1,7 @@
 LIST(APPEND WTF_SOURCES
     efl/MainThreadEfl.cpp
     efl/OwnPtrEfl.cpp
+    efl/RefPtrEfl.cpp
     gobject/GOwnPtr.cpp
     gobject/GRefPtr.cpp
 
@@ -33,5 +34,6 @@ LIST(APPEND WTF_INCLUDE_DIRECTORIES
     ${GLIB_INCLUDE_DIRS}
     ${ICU_INCLUDE_DIRS}
     ${JAVASCRIPTCORE_DIR}/wtf/gobject
-    ${JAVASCRIPTCORE_DIR}/wtf/unicode/
+    ${JAVASCRIPTCORE_DIR}/wtf/unicode
+    ${JAVASCRIPTCORE_DIR}/wtf/efl
 )
index 6501a96..c6ca5e2 100644 (file)
@@ -40,11 +40,6 @@ void deleteOwnedPtr(Ecore_Evas* ptr)
         ecore_evas_free(ptr);
 }
 
-void deleteOwnedPtr(Evas_Object* ptr)
-{
-    evas_object_del(ptr);
-}
-
 void deleteOwnedPtr(Ecore_Pipe* ptr)
 {
     if (ptr)
similarity index 68%
rename from Source/WebCore/platform/efl/RefPtrEfl.cpp
rename to Source/WTF/wtf/efl/RefPtrEfl.cpp
index a6b1908..f5335cc 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2011 Samsung Electronics
+ *  Copyright (C) 2012 Intel Corporation. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -31,9 +32,16 @@ template<> void refIfNotNull(Evas_Object* ptr)
 
 template<> void derefIfNotNull(Evas_Object* ptr)
 {
+    // Refcounting in Evas_Object is different that normal. The object is created
+    // with an external ref count of 0, but with one internal count of 1 which can
+    // only be removed by calling _del. Calling _del with an external ref count > 0,
+    // postposes deletion until it reaches 0.
+
     if (LIKELY(!!ptr)) {
-        evas_object_unref(ptr);
-        evas_object_del(ptr);
+        if (evas_object_ref_get(ptr) > 0)
+            evas_object_unref(ptr);
+        else
+            evas_object_del(ptr);
     }
 }
 
index 5b95804..d6a837f 100644 (file)
@@ -1,3 +1,21 @@
+2012-09-13  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        Evas_Object* is a ref'ed structure, so tread it as such
+        https://bugs.webkit.org/show_bug.cgi?id=96659
+
+        Reviewed by Adam Barth.
+
+        Replace OwnPtr<Evas_Object> with RefPtr.
+
+        * PlatformEfl.cmake:
+        * platform/efl/RenderThemeEfl.cpp:
+        (WebCore::RenderThemeEfl::ThemePartCacheEntry::create):
+        (WebCore::RenderThemeEfl::loadTheme):
+        (WebCore::RenderThemeEfl::applyPartDescriptionsFrom):
+        * platform/efl/RenderThemeEfl.h:
+        (RenderThemeEfl):
+        (ThemePartCacheEntry):
+
 2012-09-14  Zoltan Horvath  <zoltan@webkit.org>
 
         Extend the coverage of the Custom Allocation Framework in WebCore
index 793c821..70d68d7 100644 (file)
@@ -39,7 +39,6 @@ LIST(APPEND WebCore_SOURCES
   platform/efl/PlatformMouseEventEfl.cpp
   platform/efl/PlatformScreenEfl.cpp
   platform/efl/PlatformWheelEventEfl.cpp
-  platform/efl/RefPtrEfl.cpp
   platform/efl/RenderThemeEfl.cpp
   platform/efl/RunLoopEfl.cpp
   platform/efl/ScrollViewEfl.cpp
index 6eccc04..3887dd3 100644 (file)
@@ -214,7 +214,7 @@ RenderThemeEfl::ThemePartCacheEntry* RenderThemeEfl::ThemePartCacheEntry::create
     // By default EFL creates buffers without alpha.
     ecore_evas_alpha_set(entry->canvas(), EINA_TRUE);
 
-    entry->m_edje = adoptPtr(edje_object_add(ecore_evas_get(entry->canvas())));
+    entry->m_edje = adoptRef(edje_object_add(ecore_evas_get(entry->canvas())));
     ASSERT(entry->edje());
 
     if (!setSourceGroupForEdjeObject(entry->edje(), themePath, toEdjeGroup(type)))
@@ -509,7 +509,7 @@ bool RenderThemeEfl::loadTheme()
                 "Could not create canvas required by theme, things will not work properly.");
     }
 
-    OwnPtr<Evas_Object> o = adoptPtr(edje_object_add(ecore_evas_get(canvas())));
+    RefPtr<Evas_Object> o = adoptRef(edje_object_add(ecore_evas_get(canvas())));
     _ASSERT_ON_RELEASE_RETURN_VAL(o, false, "Could not create new base Edje object.");
 
     if (!setSourceGroupForEdjeObject(o.get(), m_themePath, "webkit/base"))
@@ -520,7 +520,7 @@ bool RenderThemeEfl::loadTheme()
         flushThemePartCache();
 
     // Set new loaded theme, and apply it.
-    m_edje.swap(o);
+    m_edje = o;
 
     edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/active", applyColorCallback, this);
     edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/inactive", applyColorCallback, this);
@@ -601,7 +601,7 @@ void RenderThemeEfl::applyPartDescription(Evas_Object* object, ThemePartDesc* de
 
 void RenderThemeEfl::applyPartDescriptionsFrom(const String& themePath)
 {
-    OwnPtr<Evas_Object> temp = adoptPtr(edje_object_add(ecore_evas_get(canvas())));
+    RefPtr<Evas_Object> temp = adoptRef(edje_object_add(ecore_evas_get(canvas())));
     _ASSERT_ON_RELEASE_RETURN(temp, "Could not create Edje object.");
 
     for (size_t i = 0; i < FormTypeLast; i++) {
index d1b81e0..4ab5890 100644 (file)
@@ -36,6 +36,7 @@
 #include "RenderTheme.h"
 
 #include <cairo.h>
+#include <wtf/efl/RefPtrEfl.h>
 
 typedef struct _Ecore_Evas Ecore_Evas;
 typedef struct _Evas_Object Evas_Object;
@@ -250,7 +251,7 @@ private:
     String m_themePath;
     // Order so that the canvas gets destroyed at last.
     OwnPtr<Ecore_Evas> m_canvas;
-    OwnPtr<Evas_Object> m_edje;
+    RefPtr<Evas_Object> m_edje;
 
     struct ThemePartDesc {
         FormType type;
@@ -275,7 +276,7 @@ private:
     private:
         // Order so that the canvas gets destroyed at last.
         OwnPtr<Ecore_Evas> m_canvas;
-        OwnPtr<Evas_Object> m_edje;
+        RefPtr<Evas_Object> m_edje;
         RefPtr<cairo_surface_t> m_surface;
     };
 
index eba4650..5dee317 100644 (file)
@@ -1,3 +1,17 @@
+2012-09-13  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        Evas_Object* is a ref'ed structure, so tread it as such
+        https://bugs.webkit.org/show_bug.cgi?id=96659
+
+        Reviewed by Adam Barth.
+
+        Replace OwnPtr<Evas_Object> with RefPtr.
+
+        * tests/UnitTestUtils/EWKTestView.cpp:
+        (EWKUnitTests::EWKTestView::init):
+        * tests/UnitTestUtils/EWKTestView.h:
+        (EWKTestView):
+
 2012-09-14  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, rolling out r128507.
index fd29b81..dbb0092 100644 (file)
@@ -23,6 +23,7 @@
 #include <EWebKit.h>
 
 #include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
 
 namespace EWKUnitTests {
 
@@ -98,11 +99,11 @@ bool EWKTestView::init()
 
     switch (m_defaultViewType) {
     case SingleView:
-        m_webView = adoptPtr(ewk_view_single_add(m_evas));
+        m_webView = adoptRef(ewk_view_single_add(m_evas));
         break;
 
     case TiledView:
-        m_webView = adoptPtr(ewk_view_tiled_add(m_evas));
+        m_webView = adoptRef(ewk_view_tiled_add(m_evas));
         break;
     }
 
index 6d15d0d..1bdd9ed 100644 (file)
@@ -23,6 +23,7 @@
 #include <Evas.h>
 #include <string>
 #include <wtf/OwnPtr.h>
+#include <wtf/efl/RefPtrEfl.h>
 
 namespace EWKUnitTests {
 
@@ -63,7 +64,7 @@ private:
     EWKTestView operator=(const EWKTestView&);
 
     Evas* m_evas;
-    OwnPtr<Evas_Object> m_webView;
+    RefPtr<Evas_Object> m_webView;
 
     int m_width, m_height;
     EwkViewType m_defaultViewType;
index 0490969..153704f 100644 (file)
@@ -1,3 +1,18 @@
+2012-09-13  Kenneth Rohde Christiansen  <kenneth@webkit.org>
+
+        Evas_Object* is a ref'ed structure, so tread it as such
+        https://bugs.webkit.org/show_bug.cgi?id=96659
+
+        Reviewed by Adam Barth.
+
+        Replace OwnPtr<Evas_Object> with RefPtr.
+
+        * DumpRenderTree/efl/ImageDiff.cpp:
+        (calculateDifference):
+        (printImageDifferences):
+        (readImageFromStdin):
+        (main):
+
 2012-09-14  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, rolling out r128507.
index 88a0e4a..129b6ca 100644 (file)
@@ -45,6 +45,8 @@
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/efl/RefPtrEfl.h>
 
 enum PixelComponent {
     Red,
@@ -106,7 +108,7 @@ static float calculatePixelDifference(unsigned char* basePixel, unsigned char* a
     return sqrtf(red * red + green * green + blue * blue + alpha * alpha) / 2.0f;
 }
 
-static float calculateDifference(Evas_Object* baselineImage, Evas_Object* actualImage, OwnPtr<Evas_Object>& differenceImage)
+static float calculateDifference(Evas_Object* baselineImage, Evas_Object* actualImage, RefPtr<Evas_Object>& differenceImage)
 {
     int width, height, baselineWidth, baselineHeight;
     evas_object_image_size_get(actualImage, &width, &height);
@@ -163,7 +165,7 @@ static float calculateDifference(Evas_Object* baselineImage, Evas_Object* actual
         difference = roundf(difference * 100.0f) / 100.0f;
         difference = std::max(difference, 0.01f); // round to 2 decimal places
 
-        differenceImage = adoptPtr(differenceImageFromDifferenceBuffer(evas_object_evas_get(baselineImage), diffBuffer.get(), width, height));
+        differenceImage = adoptRef(differenceImageFromDifferenceBuffer(evas_object_evas_get(baselineImage), diffBuffer.get(), width, height));
     }
 
     return difference;
@@ -226,7 +228,7 @@ static void printImage(Evas_Object* image)
 
 static void printImageDifferences(Evas_Object* baselineImage, Evas_Object* actualImage)
 {
-    OwnPtr<Evas_Object> differenceImage;
+    RefPtr<Evas_Object> differenceImage;
     const float difference = calculateDifference(baselineImage, actualImage, differenceImage);
 
     if (difference > 0.0f) {
@@ -254,7 +256,7 @@ static void resizeEcoreEvasIfNeeded(Evas_Object* image)
     ecore_evas_resize(gEcoreEvas.get(), currentWidth, currentHeight);
 }
 
-static PassOwnPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize)
+static PassRefPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize)
 {
     OwnArrayPtr<unsigned char> imageBuffer = adoptArrayPtr(new unsigned char[imageSize]);
     if (!imageBuffer)
@@ -262,7 +264,7 @@ static PassOwnPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize)
 
     const size_t bytesRead = fread(imageBuffer.get(), 1, imageSize, stdin);
     if (!bytesRead)
-        return PassOwnPtr<Evas_Object>();
+        return PassRefPtr<Evas_Object>();
 
     Evas_Object* image = evas_object_image_filled_add(evas);
     evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
@@ -270,7 +272,7 @@ static PassOwnPtr<Evas_Object> readImageFromStdin(Evas* evas, long imageSize)
 
     resizeEcoreEvasIfNeeded(image);
 
-    return adoptPtr(image);
+    return adoptRef(image);
 }
 
 static bool parseCommandLineOptions(int argc, char** argv)
@@ -331,8 +333,8 @@ int main(int argc, char* argv[])
 
     Evas* evas = initEfl();
 
-    OwnPtr<Evas_Object> actualImage;
-    OwnPtr<Evas_Object> baselineImage;
+    RefPtr<Evas_Object> actualImage;
+    RefPtr<Evas_Object> baselineImage;
 
     char buffer[2048];
     while (fgets(buffer, sizeof(buffer), stdin)) {