Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp |
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp |
| index abd64cd3f9a7ef0a18d2ffba522b064111e1029a..5371247b830d4507211ce432ae51cd41af316bfa 100644 |
| --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp |
| +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp |
| @@ -65,28 +65,51 @@ |
| namespace blink { |
| -CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| +// An helper function for the two create() methods. The return value is an |
| +// indicate of whether the create() should return nullptr or not. |
| +static bool shouldCreateFactory(WebGraphicsContext3DProvider* contextProvider) |
|
bajones
2016/04/27 20:18:48
This name caused me some confusion, because it doe
xidachen
2016/04/27 20:34:04
Done.
|
| { |
| - WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| - OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContext3DProvider(canvas, attributes, 1)); |
| if (!contextProvider) |
| - return nullptr; |
| + return false; |
| gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(gl); |
| if (!extensionsUtil) |
| - return nullptr; |
| + return false; |
| if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) { |
| - String contextLabel(String::format("WebGLRenderingContext-%p", contextProvider.get())); |
| + String contextLabel(String::format("WebGLRenderingContext-%p", contextProvider)); |
| gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); |
| } |
| + return true; |
| +} |
| - WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas, contextProvider.release(), attributes); |
| +CanvasRenderingContext* WebGLRenderingContext::Factory::create(ScriptState* scriptState, OffscreenCanvas* offscreenCanvas, const CanvasContextCreationAttributes& attrs) |
| +{ |
| + WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| + OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContext3DProvider(scriptState, attributes, 1)); |
| + if (!shouldCreateFactory(contextProvider.get())) |
| + return nullptr; |
| + |
| + WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscreenCanvas, contextProvider.release(), attributes); |
| + if (!renderingContext->drawingBuffer()) |
| + return nullptr; |
| + renderingContext->initializeNewContext(); |
| + renderingContext->registerContextExtensions(); |
| + return renderingContext; |
| +} |
| + |
| +CanvasRenderingContext* WebGLRenderingContext::Factory::create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, Document&) |
| +{ |
| + WebGLContextAttributes attributes = toWebGLContextAttributes(attrs); |
| + OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContext3DProvider(canvas, attributes, 1)); |
| + if (!shouldCreateFactory(contextProvider.get())) |
| + return nullptr; |
| + |
| + WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas, contextProvider.release(), attributes); |
| if (!renderingContext->drawingBuffer()) { |
| canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Could not create a WebGL context.")); |
| return nullptr; |
| } |
| - |
| renderingContext->initializeNewContext(); |
| renderingContext->registerContextExtensions(); |
| @@ -103,6 +126,11 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa |
| { |
| } |
| +WebGLRenderingContext::WebGLRenderingContext(OffscreenCanvas* passedOffscreenCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes) |
| + : WebGLRenderingContextBase(passedOffscreenCanvas, contextProvider, requestedAttributes) |
| +{ |
| +} |
| + |
| WebGLRenderingContext::~WebGLRenderingContext() |
| { |
| } |
| @@ -112,6 +140,17 @@ void WebGLRenderingContext::setCanvasGetContextResult(RenderingContext& result) |
| result.setWebGLRenderingContext(this); |
| } |
| +void WebGLRenderingContext::setOffscreenCanvasGetContextResult(OffscreenRenderingContext& result) |
| +{ |
| + result.setWebGLRenderingContext(this); |
| +} |
| + |
| +ImageBitmap* WebGLRenderingContext::transferToImageBitmap(ExceptionState& exceptionState) |
| +{ |
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| +} |
| + |
| void WebGLRenderingContext::registerContextExtensions() |
| { |
| // Register extensions. |