Title: [225774] trunk/Source/WebCore
- Revision
- 225774
- Author
- [email protected]
- Date
- 2017-12-11 23:05:30 -0800 (Mon, 11 Dec 2017)
Log Message
[Cairo] Don't use a static cairo_surface_t object for CairoPath contexts
https://bugs.webkit.org/show_bug.cgi?id=180663
Reviewed by Michael Catanzaro.
Instead of using a single cairo_surface_t object and sharing it between
different cairo_t objects handled by CairoPath, create a new mock 1x1px
alpha-only surface for each cairo_t object that's allocated in the
CairoPath constructor.
This avoids potential issues in how Cairo's state handling internally
uses these surfaces, which is completely opaque to us and out of our
control. This also avoids crashes when using this one cairo_surface_t
object through different CairoPath objects across different threads.
No new tests -- no change in behavior.
* platform/graphics/cairo/PlatformPathCairo.cpp:
(WebCore::CairoPath::CairoPath):
(WebCore::pathSurface): Deleted.
* platform/graphics/cairo/PlatformPathCairo.h:
(WebCore::CairoPath::context):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (225773 => 225774)
--- trunk/Source/WebCore/ChangeLog 2017-12-12 07:04:44 UTC (rev 225773)
+++ trunk/Source/WebCore/ChangeLog 2017-12-12 07:05:30 UTC (rev 225774)
@@ -1,5 +1,30 @@
2017-12-11 Zan Dobersek <[email protected]>
+ [Cairo] Don't use a static cairo_surface_t object for CairoPath contexts
+ https://bugs.webkit.org/show_bug.cgi?id=180663
+
+ Reviewed by Michael Catanzaro.
+
+ Instead of using a single cairo_surface_t object and sharing it between
+ different cairo_t objects handled by CairoPath, create a new mock 1x1px
+ alpha-only surface for each cairo_t object that's allocated in the
+ CairoPath constructor.
+
+ This avoids potential issues in how Cairo's state handling internally
+ uses these surfaces, which is completely opaque to us and out of our
+ control. This also avoids crashes when using this one cairo_surface_t
+ object through different CairoPath objects across different threads.
+
+ No new tests -- no change in behavior.
+
+ * platform/graphics/cairo/PlatformPathCairo.cpp:
+ (WebCore::CairoPath::CairoPath):
+ (WebCore::pathSurface): Deleted.
+ * platform/graphics/cairo/PlatformPathCairo.h:
+ (WebCore::CairoPath::context):
+
+2017-12-11 Zan Dobersek <[email protected]>
+
[CoordGraphics] Move UpdateAtlas, AreaAllocator into the platform layer
https://bugs.webkit.org/show_bug.cgi?id=180641
Modified: trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp (225773 => 225774)
--- trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp 2017-12-12 07:04:44 UTC (rev 225773)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.cpp 2017-12-12 07:05:30 UTC (rev 225774)
@@ -26,15 +26,11 @@
namespace WebCore {
-static cairo_surface_t* pathSurface()
-{
- static cairo_surface_t* s_pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
- return s_pathSurface;
-}
-
CairoPath::CairoPath()
- : m_cr(adoptRef(cairo_create(pathSurface())))
{
+ // cairo_t takes its own reference of the surface, meaning we don't have to keep one.
+ auto surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1));
+ m_context = adoptRef(cairo_create(surface.get()));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h (225773 => 225774)
--- trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h 2017-12-12 07:04:44 UTC (rev 225773)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformPathCairo.h 2017-12-12 07:05:30 UTC (rev 225774)
@@ -18,8 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef PlatformPathCairo_h
-#define PlatformPathCairo_h
+#pragma once
#if USE(CAIRO)
@@ -31,17 +30,14 @@
class CairoPath {
public:
CairoPath();
-
~CairoPath() = default;
- cairo_t* context() { return m_cr.get(); }
+ cairo_t* context() { return m_context.get(); }
private:
- RefPtr<cairo_t> m_cr;
+ RefPtr<cairo_t> m_context;
};
} // namespace WebCore
#endif // USE(CAIRO)
-
-#endif // PlatformPathCairo_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes