Changeset 151226 in webkit
- Timestamp:
- Jun 5, 2013 8:54:22 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r151224 r151226 1 2013-06-05 Jae Hyun Park <jae.park@company100.net> 2 3 [GTK] Support using GLContext from multiple threads 4 https://bugs.webkit.org/show_bug.cgi?id=117238 5 6 Reviewed by Martin Robinson. 7 8 Current implementation assumes that GLContext is only used in the main thread. 9 However, to support using GLContext from multiple threads, we need to change it 10 to thread local. Therefore, ASSERT(isMainThread()) is removed and GLContext is 11 changed to thread local. 12 13 * platform/graphics/cairo/GLContext.cpp: 14 (WebCore::ThreadGlobalGLContext::setContext): 15 (WebCore::ThreadGlobalGLContext::context): 16 (WebCore::currentContext): 17 (WebCore::GLContext::sharingContext): 18 (WebCore::GLContext::~GLContext): 19 (WebCore::GLContext::makeContextCurrent): 20 (WebCore::GLContext::getCurrent): 21 1 22 2013-06-05 Christophe Dumez <ch.dumez@sisa.samsung.com> 2 23 -
trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp
r150440 r151226 24 24 #include "GLContextEGL.h" 25 25 #include "GLContextGLX.h" 26 #include <wtf/ MainThread.h>26 #include <wtf/ThreadSpecific.h> 27 27 28 28 #if PLATFORM(X11) … … 39 39 #endif 40 40 41 using WTF::ThreadSpecific; 42 41 43 namespace WebCore { 44 45 class ThreadGlobalGLContext { 46 public: 47 static ThreadSpecific<ThreadGlobalGLContext>* staticGLContext; 48 49 void setContext(GLContext* context) { m_context = context; } 50 GLContext* context() { return m_context; } 51 52 private: 53 GLContext* m_context; 54 }; 55 56 ThreadSpecific<ThreadGlobalGLContext>* ThreadGlobalGLContext::staticGLContext; 57 58 inline ThreadGlobalGLContext* currentContext() 59 { 60 if (!ThreadGlobalGLContext::staticGLContext) 61 ThreadGlobalGLContext::staticGLContext = new ThreadSpecific<ThreadGlobalGLContext>; 62 return *ThreadGlobalGLContext::staticGLContext; 63 } 42 64 43 65 GLContext* GLContext::sharingContext() 44 66 { 45 ASSERT(isMainThread());46 67 DEFINE_STATIC_LOCAL(OwnPtr<GLContext>, sharing, (createOffscreenContext())); 47 68 return sharing.get(); … … 154 175 } 155 176 156 // FIXME: This should be a thread local eventually if we157 // want to support using GLContexts from multiple threads.158 static GLContext* gCurrentContext = 0;159 160 177 GLContext::~GLContext() 161 178 { 162 if (this == gCurrentContext)163 gCurrentContext = 0;179 if (this == currentContext()->context()) 180 currentContext()->setContext(0); 164 181 removeActiveContext(this); 165 182 } … … 167 184 bool GLContext::makeContextCurrent() 168 185 { 169 ASSERT(isMainThread()); 170 gCurrentContext = this; 186 currentContext()->setContext(this); 171 187 return true; 172 188 } … … 174 190 GLContext* GLContext::getCurrent() 175 191 { 176 ASSERT(isMainThread()); 177 return gCurrentContext; 192 return currentContext()->context(); 178 193 } 179 194
Note: See TracChangeset
for help on using the changeset viewer.