Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
index 26f07ba35e335d19dcc1d2cb2c91b643b4066e83..e8e2c5e90a02d806603bcafe9fb1634de3cd467c 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -66,7 +66,6 @@ |
#include "modules/webgl/WebGLCompressedTexturePVRTC.h" |
#include "modules/webgl/WebGLCompressedTextureS3TC.h" |
#include "modules/webgl/WebGLContextAttributeHelpers.h" |
-#include "modules/webgl/WebGLContextAttributes.h" |
#include "modules/webgl/WebGLContextEvent.h" |
#include "modules/webgl/WebGLContextGroup.h" |
#include "modules/webgl/WebGLDebugRendererInfo.h" |
@@ -79,19 +78,18 @@ |
#include "modules/webgl/WebGLRenderbuffer.h" |
#include "modules/webgl/WebGLShader.h" |
#include "modules/webgl/WebGLShaderPrecisionFormat.h" |
-#include "modules/webgl/WebGLTexture.h" |
#include "modules/webgl/WebGLUniformLocation.h" |
#include "modules/webgl/WebGLVertexArrayObject.h" |
#include "modules/webgl/WebGLVertexArrayObjectOES.h" |
#include "platform/CheckedInt.h" |
#include "platform/RuntimeEnabledFeatures.h" |
+#include "platform/ThreadSafeFunctional.h" |
+#include "platform/WaitableEvent.h" |
#include "platform/geometry/IntSize.h" |
#include "platform/graphics/GraphicsContext.h" |
#include "platform/graphics/UnacceleratedImageBufferSurface.h" |
#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
-#include "platform/graphics/gpu/DrawingBuffer.h" |
#include "public/platform/Platform.h" |
-#include "public/platform/WebGraphicsContext3DProvider.h" |
#include "public/platform/functional/WebFunction.h" |
#include "wtf/Functional.h" |
#include "wtf/PassOwnPtr.h" |
@@ -502,7 +500,17 @@ static String extractWebGLContextCreationError(const Platform::GraphicsInfo& inf |
return statusMessage; |
} |
-static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion) |
+void WebGLRenderingContextBase::createWebGraphicsContext3DProviderMainThread(WebGLRenderingContextBase::createWebGraphicsContext3DProviderUtils* createUtils, WaitableEvent* waitableEvent) |
Justin Novosad
2016/05/04 18:34:03
"OnMainThread"
|
+{ |
+ ASSERT(isMainThread()); |
+ Platform::GraphicsInfo glInfo = createUtils->glInfo(); |
+ OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider( |
+ createUtils->contextAttributes(), createUtils->scriptState()->getExecutionContext()->url(), 0, &glInfo)); |
+ createUtils->setContextProvider(provider.release()); |
+ waitableEvent->signal(); |
+} |
+ |
+PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttributes attributes, unsigned webGLVersion) |
{ |
Platform::ContextAttributes contextAttributes = toPlatformContextAttributes(attributes, webGLVersion); |
Platform::GraphicsInfo glInfo; |
@@ -511,8 +519,18 @@ static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProvid |
contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider( |
contextAttributes, canvas->document().topDocument().url(), 0, &glInfo)); |
} else { |
- contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider( |
- contextAttributes, scriptState->getExecutionContext()->url(), 0, &glInfo)); |
+ if (isMainThread()) { |
+ contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider( |
+ contextAttributes, scriptState->getExecutionContext()->url(), 0, &glInfo)); |
+ } else { |
+ WaitableEvent waitableEvent; |
+ WebTaskRunner* taskRunner = Platform::current()->mainThread()->getWebTaskRunner(); |
+ OwnPtr<WebGLRenderingContextBase::createWebGraphicsContext3DProviderUtils> createUtils = adoptPtr(new WebGLRenderingContextBase::createWebGraphicsContext3DProviderUtils(contextAttributes, glInfo, scriptState)); |
+ taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&createWebGraphicsContext3DProviderMainThread, AllowCrossThreadAccess(createUtils.get()), AllowCrossThreadAccess(&waitableEvent))); |
+ waitableEvent.wait(); |
+ contextProvider = createUtils->releaseContextProvider(); |
+ contextProvider->DetachFromThread(); |
+ } |
} |
if (!contextProvider || shouldFailContextCreationForTesting) { |
shouldFailContextCreationForTesting = false; |
@@ -526,7 +544,6 @@ static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProvid |
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "OES_packed_depth_stencil support is required.")); |
return nullptr; |
} |
- |
return contextProvider.release(); |
} |