2011-04-14 Joone Hur <joone.hur@collabora.co.uk>
authorjoone.hur@collabora.co.uk <joone.hur@collabora.co.uk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2011 05:18:02 +0000 (05:18 +0000)
committerjoone.hur@collabora.co.uk <joone.hur@collabora.co.uk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2011 05:18:02 +0000 (05:18 +0000)
        Reviewed by Martin Robinson.

        Creating a CairoPath instance is not thread safe
        https://bugs.webkit.org/show_bug.cgi?id=58514

        This patch allows a cairo surface to be created just one time in order to
        guarantee thread safety.
        In addition, CairoPath.{h,cpp} is renamed to PlatformPathCairo.{h,cpp} to
        prevent confusing them with PathCairo.cpp

        * CMakeListsEfl.txt: Added PlatformPathCairo.cpp
        * GNUmakefile.list.am: Added PlatformPathCairo.{h,cpp} instead of CairoPath.h.
        * platform/graphics/cairo/CairoPath.h: Removed.
        * platform/graphics/cairo/CairoUtilities.cpp: Include PlatformPathCairo.h instead of CairoPath.h.
        * platform/graphics/cairo/GraphicsContextCairo.cpp: Ditto.
        * platform/graphics/cairo/PathCairo.cpp: Ditto.
        * platform/graphics/cairo/PlatformPathCairo.cpp: Added.
        (WebCore::getPathSurface): Getting a static cairo surface.
        (WebCore::CairoPath::CairoPath): Moved the implementation of the constructor
        into the CPP file.
        * platform/graphics/cairo/PlatformPathCairo.h: Renamed CairoPath.h to this.
        (WebCore::CairoPath::~CairoPath):
        (WebCore::CairoPath::context):

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

Source/WebCore/CMakeListsEfl.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/platform/graphics/cairo/CairoPath.h [deleted file]
Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cairo/PathCairo.cpp
Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h [new file with mode: 0644]

index b31babc..1006ac4 100644 (file)
@@ -91,6 +91,7 @@ IF (WTF_PLATFORM_CAIRO)
     platform/graphics/cairo/PathCairo.cpp
     platform/graphics/cairo/PatternCairo.cpp
     platform/graphics/cairo/PlatformContextCairo.cpp
+    platform/graphics/cairo/PlatformPathCairo.cpp
     platform/graphics/cairo/RefPtrCairo.cpp
     platform/graphics/cairo/TransformationMatrixCairo.cpp
 
index 118fbc2..ffa1298 100644 (file)
@@ -1,3 +1,29 @@
+2011-04-14  Joone Hur  <joone.hur@collabora.co.uk>
+
+        Reviewed by Martin Robinson.
+
+        Creating a CairoPath instance is not thread safe
+        https://bugs.webkit.org/show_bug.cgi?id=58514
+
+        This patch allows a cairo surface to be created just one time in order to 
+        guarantee thread safety.
+        In addition, CairoPath.{h,cpp} is renamed to PlatformPathCairo.{h,cpp} to 
+        prevent confusing them with PathCairo.cpp
+
+        * CMakeListsEfl.txt: Added PlatformPathCairo.cpp
+        * GNUmakefile.list.am: Added PlatformPathCairo.{h,cpp} instead of CairoPath.h.
+        * platform/graphics/cairo/CairoPath.h: Removed.
+        * platform/graphics/cairo/CairoUtilities.cpp: Include PlatformPathCairo.h instead of CairoPath.h.
+        * platform/graphics/cairo/GraphicsContextCairo.cpp: Ditto.
+        * platform/graphics/cairo/PathCairo.cpp: Ditto.
+        * platform/graphics/cairo/PlatformPathCairo.cpp: Added.
+        (WebCore::getPathSurface): Getting a static cairo surface.
+        (WebCore::CairoPath::CairoPath): Moved the implementation of the constructor 
+        into the CPP file.
+        * platform/graphics/cairo/PlatformPathCairo.h: Renamed CairoPath.h to this.
+        (WebCore::CairoPath::~CairoPath):
+        (WebCore::CairoPath::context):
+
 2011-04-14  Nat Duca  <nduca@chromium.org>
 
         Reviewed by Darin Fisher.
index e9acc00..bc2a705 100644 (file)
@@ -3683,7 +3683,6 @@ webcoregtk_sources += \
        Source/WebCore/page/gtk/DragControllerGtk.cpp \
        Source/WebCore/page/gtk/EventHandlerGtk.cpp \
        Source/WebCore/page/gtk/FrameGtk.cpp \
-       Source/WebCore/platform/graphics/cairo/CairoPath.h \
        Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp \
        Source/WebCore/platform/graphics/cairo/CairoUtilities.h \
        Source/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp \
@@ -3702,6 +3701,8 @@ webcoregtk_sources += \
        Source/WebCore/platform/graphics/cairo/PatternCairo.cpp \
        Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp \
        Source/WebCore/platform/graphics/cairo/PlatformContextCairo.h \
+       Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h \
+       Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp \
        Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp \
        Source/WebCore/platform/graphics/cairo/RefPtrCairo.h \
        Source/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp \
diff --git a/Source/WebCore/platform/graphics/cairo/CairoPath.h b/Source/WebCore/platform/graphics/cairo/CairoPath.h
deleted file mode 100644 (file)
index da7affb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-    Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
-    Copyright (C) 2010 Igalia S.L.
-
-    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
-    aint 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.
-*/
-
-#ifndef CairoPath_h
-#define CairoPath_h
-
-#include <cairo.h>
-
-namespace WebCore {
-
-// This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
-class CairoPath {
-public:
-    CairoPath()
-    {
-        static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
-        m_cr = cairo_create(pathSurface);
-    }
-
-    ~CairoPath()
-    {
-        cairo_destroy(m_cr);
-    }
-
-    cairo_t* context() { return m_cr; }
-
-private:
-    cairo_t* m_cr;
-};
-
-} // namespace WebCore
-
-#endif // CairoPath_h
index ee159a1..758bce9 100644 (file)
 #include "CairoUtilities.h"
 
 #include "AffineTransform.h"
-#include "CairoPath.h"
 #include "Color.h"
 #include "FloatPoint.h"
 #include "FloatRect.h"
 #include "IntRect.h"
 #include "OwnPtrCairo.h"
 #include "Path.h"
+#include "PlatformPathCairo.h"
 #include "RefPtrCairo.h"
 #include <wtf/Vector.h>
 
index e395ccb..d6dd374 100644 (file)
@@ -35,7 +35,6 @@
 #if PLATFORM(CAIRO)
 
 #include "AffineTransform.h"
-#include "CairoPath.h"
 #include "CairoUtilities.h"
 #include "ContextShadow.h"
 #include "FloatConversion.h"
@@ -48,6 +47,7 @@
 #include "Path.h"
 #include "Pattern.h"
 #include "PlatformContextCairo.h"
+#include "PlatformPathCairo.h"
 #include "RefPtrCairo.h"
 #include "SimpleFontData.h"
 #include <cairo.h>
index 533df10..d62c33f 100644 (file)
 #include "Path.h"
 
 #include "AffineTransform.h"
-#include "CairoPath.h"
 #include "FloatRect.h"
 #include "GraphicsContext.h"
 #include "OwnPtrCairo.h"
+#include "PlatformPathCairo.h"
 #include "PlatformString.h"
 #include "StrokeStyleApplier.h"
 #include <cairo.h>
diff --git a/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp b/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp
new file mode 100644 (file)
index 0000000..3a7d512
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * 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 "PlatformPathCairo.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+static cairo_surface_t* getPathSurface() 
+{
+    return cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
+}
+
+static cairo_surface_t* gPathSurface = getPathSurface(); 
+
+CairoPath::CairoPath()
+    : m_cr(adoptRef(cairo_create(gPathSurface)))
+{
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h b/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h
new file mode 100644 (file)
index 0000000..938b942
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
+ *  Copyright (C) 2010 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef PlatformPathCairo_h
+#define PlatformPathCairo_h
+
+#include "RefPtrCairo.h"
+
+namespace WebCore {
+
+// This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
+class CairoPath {
+public:
+    CairoPath();
+
+    ~CairoPath() {}
+
+    cairo_t* context() { return m_cr.get(); }
+
+private:
+    RefPtr<cairo_t> m_cr;
+};
+
+} // namespace WebCore
+
+#endif // PlatformPathCairo_h