Modified: trunk/Source/WebCore/ChangeLog (128468 => 128469)
--- trunk/Source/WebCore/ChangeLog 2012-09-13 15:22:37 UTC (rev 128468)
+++ trunk/Source/WebCore/ChangeLog 2012-09-13 15:27:39 UTC (rev 128469)
@@ -1,3 +1,21 @@
+2012-09-13 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ [EFL] Use RefPtr for storing cairo_surface_t
+ https://bugs.webkit.org/show_bug.cgi?id=96647
+
+ Reviewed by Simon Hausmann.
+
+ Refactoring, covered by existing tests.
+
+ * platform/efl/RenderThemeEfl.cpp:
+ (WebCore::createSurfaceForBackingStore):
+ (WebCore::RenderThemeEfl::ThemePartCacheEntry::create):
+ (WebCore::RenderThemeEfl::ThemePartCacheEntry::reuse):
+ (WebCore::RenderThemeEfl::paintThemePart):
+ * platform/efl/RenderThemeEfl.h:
+ (WebCore::RenderThemeEfl::ThemePartCacheEntry::surface):
+ (ThemePartCacheEntry):
+
2012-09-13 Allan Sandfeld Jensen <allan.jen...@nokia.com>
Move updateHoverActiveState to Document.
Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp (128468 => 128469)
--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp 2012-09-13 15:22:37 UTC (rev 128468)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp 2012-09-13 15:27:39 UTC (rev 128469)
@@ -162,29 +162,19 @@
style->setPaddingRight(desc->padding.right());
}
-RenderThemeEfl::ThemePartCacheEntry::ThemePartCacheEntry()
- : surface(0)
+static PassRefPtr<cairo_surface_t> createSurfaceForBackingStore(Ecore_Evas* ee)
{
-}
-
-RenderThemeEfl::ThemePartCacheEntry::~ThemePartCacheEntry()
-{
- if (surface)
- cairo_surface_destroy(surface);
-}
-
-static cairo_surface_t* createCairoSurfaceFor(Ecore_Evas* ee)
-{
ASSERT(ee);
- int width, height;
+ int width;
+ int height;
ecore_evas_geometry_get(ee, 0, 0, &width, &height);
ASSERT(width > 0 && height > 0);
unsigned char* buffer = static_cast<unsigned char*>(const_cast<void*>(ecore_evas_buffer_pixels_get(ee)));
- cairo_surface_t* surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4);
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4));
- cairo_status_t status = cairo_surface_status(surface);
+ cairo_status_t status = cairo_surface_status(surface.get());
if (status != CAIRO_STATUS_SUCCESS) {
EINA_LOG_ERR("Could not create cairo surface: %s", cairo_status_to_string(status));
return 0;
@@ -230,8 +220,8 @@
if (!setSourceGroupForEdjeObject(entry->edje(), themePath, toEdjeGroup(type)))
return 0;
- entry->surface = createCairoSurfaceFor(entry->canvas());
- if (!entry->surface)
+ entry->m_surface = createSurfaceForBackingStore(entry->canvas());
+ if (!entry->surface())
return 0;
evas_object_resize(entry->edje(), size.width(), size.height());
@@ -248,14 +238,14 @@
ASSERT(!themePath.isEmpty());
if (!newSize.isEmpty()) {
- cairo_surface_finish(surface);
+ cairo_surface_finish(surface());
size = newSize;
ecore_evas_resize(canvas(), newSize.width(), newSize.height());
evas_object_resize(edje(), newSize.width(), newSize.height());
- surface = createCairoSurfaceFor(canvas());
- if (!surface) {
+ m_surface = createSurfaceForBackingStore(canvas());
+ if (!surface()) {
type = FormTypeLast; // Invalidate;
return;
}
@@ -417,7 +407,7 @@
evas_render_updates_free(updates);
cairo_save(cairo);
- cairo_set_source_surface(cairo, entry->surface, rect.x(), rect.y());
+ cairo_set_source_surface(cairo, entry->surface(), rect.x(), rect.y());
cairo_paint_with_alpha(cairo, 1.0);
cairo_restore(cairo);
Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.h (128468 => 128469)
--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.h 2012-09-13 15:22:37 UTC (rev 128468)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.h 2012-09-13 15:27:39 UTC (rev 128469)
@@ -262,22 +262,21 @@
void applyPartDescription(Evas_Object*, struct ThemePartDesc*);
struct ThemePartCacheEntry {
- ThemePartCacheEntry();
- ~ThemePartCacheEntry();
static ThemePartCacheEntry* create(const String& themePath, FormType, const IntSize&);
void reuse(const String& themePath, FormType, const IntSize& = IntSize());
ALWAYS_INLINE Ecore_Evas* canvas() { return m_canvas.get(); }
ALWAYS_INLINE Evas_Object* edje() { return m_edje.get(); }
+ ALWAYS_INLINE cairo_surface_t* surface() { return m_surface.get(); }
FormType type;
IntSize size;
- cairo_surface_t* surface;
private:
// Order so that the canvas gets destroyed at last.
OwnPtr<Ecore_Evas> m_canvas;
OwnPtr<Evas_Object> m_edje;
+ RefPtr<cairo_surface_t> m_surface;
};
struct ThemePartDesc m_partDescs[FormTypeLast];