Title: [89878] trunk/Source/WebCore
- Revision
- 89878
- Author
- [email protected]
- Date
- 2011-06-27 16:57:48 -0700 (Mon, 27 Jun 2011)
Log Message
2011-06-27 Joseph Pecoraro <[email protected]>
Reviewed by Darin Adler.
Allow non-main thread text drawing in ICU ports
https://bugs.webkit.org/show_bug.cgi?id=63482
Some ports allow multiple threads to draw strings.
LineBreakIteratorPool is not thread safe and the existing
ASSERT caught cases where multiple threads were trying
to access the shared pool. This makes the pool a lazily
created per-thread pool to allow for thread safe pool use.
* platform/ThreadGlobalData.h:
* platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::ThreadGlobalData): start with null.
(WebCore::ThreadGlobalData::lineBreakIteratorPool): lazily create.
(WebCore::ThreadGlobalData::destroy): delete.
Manage the lifetime of the per-thread pool instance.
* platform/text/LineBreakIteratorPoolICU.h:
(WebCore::LineBreakIteratorPool::sharedPool):
Use the per-thread pool instance and remove the ASSERT that
this needs to be on the main thread.
(WebCore::LineBreakIteratorPool::create):
Create a PassOwnPtr so we can use OwnPtr on pools.
(WebCore::LineBreakIteratorPool::LineBreakIteratorPool):
Private now that there is a public create function.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (89877 => 89878)
--- trunk/Source/WebCore/ChangeLog 2011-06-27 23:50:12 UTC (rev 89877)
+++ trunk/Source/WebCore/ChangeLog 2011-06-27 23:57:48 UTC (rev 89878)
@@ -108,6 +108,37 @@
Reviewed by Darin Adler.
+ Allow non-main thread text drawing in ICU ports
+ https://bugs.webkit.org/show_bug.cgi?id=63482
+
+ Some ports allow multiple threads to draw strings.
+ LineBreakIteratorPool is not thread safe and the existing
+ ASSERT caught cases where multiple threads were trying
+ to access the shared pool. This makes the pool a lazily
+ created per-thread pool to allow for thread safe pool use.
+
+ * platform/ThreadGlobalData.h:
+ * platform/ThreadGlobalData.cpp:
+ (WebCore::ThreadGlobalData::ThreadGlobalData): start with null.
+ (WebCore::ThreadGlobalData::lineBreakIteratorPool): lazily create.
+ (WebCore::ThreadGlobalData::destroy): delete.
+ Manage the lifetime of the per-thread pool instance.
+
+ * platform/text/LineBreakIteratorPoolICU.h:
+ (WebCore::LineBreakIteratorPool::sharedPool):
+ Use the per-thread pool instance and remove the ASSERT that
+ this needs to be on the main thread.
+
+ (WebCore::LineBreakIteratorPool::create):
+ Create a PassOwnPtr so we can use OwnPtr on pools.
+
+ (WebCore::LineBreakIteratorPool::LineBreakIteratorPool):
+ Private now that there is a public create function.
+
+2011-06-27 Joseph Pecoraro <[email protected]>
+
+ Reviewed by Darin Adler.
+
Extract LineBreakIteratorPool class into its own file
https://bugs.webkit.org/show_bug.cgi?id=63471
Modified: trunk/Source/WebCore/platform/ThreadGlobalData.cpp (89877 => 89878)
--- trunk/Source/WebCore/platform/ThreadGlobalData.cpp 2011-06-27 23:50:12 UTC (rev 89877)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.cpp 2011-06-27 23:57:48 UTC (rev 89878)
@@ -34,6 +34,7 @@
#include <wtf/text/StringImpl.h>
#if USE(ICU_UNICODE)
+#include "LineBreakIteratorPoolICU.h"
#include "TextCodecICU.h"
#endif
@@ -81,6 +82,15 @@
destroy();
}
+#if USE(ICU_UNICODE)
+LineBreakIteratorPool& ThreadGlobalData::lineBreakIteratorPool()
+{
+ if (!m_lineBreakIteratorPool)
+ m_lineBreakIteratorPool = LineBreakIteratorPool::create();
+ return *m_lineBreakIteratorPool;
+}
+#endif
+
void ThreadGlobalData::destroy()
{
#if PLATFORM(MAC)
@@ -91,6 +101,7 @@
#if USE(ICU_UNICODE)
delete m_cachedConverterICU;
m_cachedConverterICU = 0;
+ m_lineBreakIteratorPool = nullptr;
#endif
delete m_eventNames;
Modified: trunk/Source/WebCore/platform/ThreadGlobalData.h (89877 => 89878)
--- trunk/Source/WebCore/platform/ThreadGlobalData.h 2011-06-27 23:50:12 UTC (rev 89877)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.h 2011-06-27 23:57:48 UTC (rev 89878)
@@ -30,6 +30,7 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
#include <wtf/text/StringHash.h>
#if ENABLE(WORKERS)
@@ -41,9 +42,11 @@
namespace WebCore {
class EventNames;
+ class LineBreakIteratorPool;
+ class ThreadTimers;
+
struct ICUConverterWrapper;
struct TECConverterWrapper;
- class ThreadTimers;
class ThreadGlobalData {
WTF_MAKE_NONCOPYABLE(ThreadGlobalData);
@@ -57,6 +60,7 @@
#if USE(ICU_UNICODE)
ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
+ LineBreakIteratorPool& lineBreakIteratorPool();
#endif
#if PLATFORM(MAC)
@@ -73,6 +77,7 @@
#if USE(ICU_UNICODE)
ICUConverterWrapper* m_cachedConverterICU;
+ OwnPtr<LineBreakIteratorPool> m_lineBreakIteratorPool;
#endif
#if PLATFORM(MAC)
Modified: trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h (89877 => 89878)
--- trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h 2011-06-27 23:50:12 UTC (rev 89877)
+++ trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h 2011-06-27 23:57:48 UTC (rev 89878)
@@ -27,9 +27,11 @@
#define LineBreakIteratorPoolICU_h
#include "TextBreakIteratorInternalICU.h"
+#include "ThreadGlobalData.h"
#include <unicode/ubrk.h>
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/text/CString.h>
namespace WebCore {
@@ -39,12 +41,10 @@
public:
static LineBreakIteratorPool& sharedPool()
{
- ASSERT(isMainThread());
- DEFINE_STATIC_LOCAL(LineBreakIteratorPool, pool, ());
- return pool;
+ return threadGlobalData().lineBreakIteratorPool();
}
- LineBreakIteratorPool() { }
+ static PassOwnPtr<LineBreakIteratorPool> create() { return adoptPtr(new LineBreakIteratorPool); }
UBreakIterator* take(const AtomicString& locale)
{
@@ -84,6 +84,8 @@
}
private:
+ LineBreakIteratorPool() { }
+
static const size_t capacity = 4;
typedef pair<AtomicString, UBreakIterator*> Entry;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes