| Index: Source/core/html/canvas/WebGLRenderingContext.cpp
|
| diff --git a/Source/core/html/canvas/WebGLRenderingContext.cpp b/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| index 34cf1793dff9881e7320d7f5595e53d10af9f036..1213c71128357dd6288430331a4b1188f409c04b 100644
|
| --- a/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| +++ b/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| @@ -450,6 +450,15 @@ namespace {
|
| break;
|
| }
|
| }
|
| +
|
| + GraphicsContext3D::Attributes adjustAttributes(GraphicsContext3D::Attributes attributes, Settings* settings) {
|
| + if (attributes.antialias) {
|
| + if (settings && !settings->openGLMultisamplingEnabled())
|
| + attributes.antialias = false;
|
| + }
|
| +
|
| + return attributes;
|
| + }
|
| } // namespace anonymous
|
|
|
| class WebGLRenderingContextLostCallback : public GraphicsContext3D::ContextLostCallback {
|
| @@ -492,17 +501,13 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen
|
| }
|
|
|
| HostWindow* hostWindow = document->view()->root()->hostWindow();
|
| - GraphicsContext3D::Attributes attributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
|
| -
|
| - if (attributes.antialias) {
|
| - if (settings && !settings->openGLMultisamplingEnabled())
|
| - attributes.antialias = false;
|
| - }
|
| + GraphicsContext3D::Attributes requestedAttributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
|
| + requestedAttributes.noExtensions = true;
|
| + requestedAttributes.shareResources = true;
|
| + requestedAttributes.preferDiscreteGPU = true;
|
| + requestedAttributes.topDocumentURL = document->topDocument()->url();
|
|
|
| - attributes.noExtensions = true;
|
| - attributes.shareResources = true;
|
| - attributes.preferDiscreteGPU = true;
|
| - attributes.topDocumentURL = document->topDocument()->url();
|
| + GraphicsContext3D::Attributes attributes = adjustAttributes(requestedAttributes, settings);
|
|
|
| RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attributes, hostWindow));
|
|
|
| @@ -515,7 +520,7 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen
|
| if (extensions->supports("GL_EXT_debug_marker"))
|
| extensions->pushGroupMarkerEXT("WebGLRenderingContext");
|
|
|
| - OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRenderingContext(canvas, context, attributes));
|
| + OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRenderingContext(canvas, context, attributes, requestedAttributes));
|
| renderingContext->suspendIfNeeded();
|
|
|
| if (renderingContext->m_drawingBuffer->isZeroSized()) {
|
| @@ -527,7 +532,8 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen
|
| }
|
|
|
| WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
|
| - GraphicsContext3D::Attributes attributes)
|
| + GraphicsContext3D::Attributes attributes,
|
| + GraphicsContext3D::Attributes requestedAttributes)
|
| : CanvasRenderingContext(passedCanvas)
|
| , ActiveDOMObject(passedCanvas->document())
|
| , m_context(context)
|
| @@ -539,6 +545,7 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
|
| , m_contextLost(false)
|
| , m_contextLostMode(SyntheticLostContext)
|
| , m_attributes(attributes)
|
| + , m_requestedAttributes(requestedAttributes)
|
| , m_synthesizedErrorsToConsole(true)
|
| , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
|
| {
|
| @@ -646,9 +653,15 @@ void WebGLRenderingContext::setupFlags()
|
| ASSERT(m_context);
|
|
|
| Page* p = canvas()->document()->page();
|
| - if (p)
|
| + if (p) {
|
| m_synthesizedErrorsToConsole = p->settings()->webGLErrorsToConsoleEnabled();
|
|
|
| + if (m_multisamplingChangedObserver == 0) {
|
| + m_multisamplingChangedObserver = adoptRef(new WebGLMultisamplingChangedObserver(this, p));
|
| + p->addMultisamplingChangedObserver(m_multisamplingChangedObserver.get());
|
| + }
|
| + }
|
| +
|
| m_isGLES2NPOTStrict = !m_context->getExtensions()->isEnabled("GL_OES_texture_npot");
|
| m_isDepthStencilSupported = m_context->getExtensions()->isEnabled("GL_OES_packed_depth_stencil");
|
| m_isRobustnessEXTSupported = m_context->getExtensions()->isEnabled("GL_EXT_robustness");
|
| @@ -5244,7 +5257,7 @@ void WebGLRenderingContext::dispatchContextLostEvent(Timer<WebGLRenderingContext
|
| canvas()->dispatchEvent(event);
|
| m_restoreAllowed = event->defaultPrevented();
|
| deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAllowed);
|
| - if (m_contextLostMode == RealLostContext && m_restoreAllowed)
|
| + if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecoverSyntheticLostContext) && m_restoreAllowed)
|
| m_restoreTimer.startOneShot(0);
|
| }
|
|
|
| @@ -5268,7 +5281,9 @@ void WebGLRenderingContext::maybeRestoreContext(Timer<WebGLRenderingContext>*)
|
| if (!frame)
|
| return;
|
|
|
| - if (!frame->loader()->client()->allowWebGL(frame->settings() && frame->settings()->webGLEnabled()))
|
| + Settings* settings = frame->settings();
|
| +
|
| + if (!frame->loader()->client()->allowWebGL(settings && settings->webGLEnabled()))
|
| return;
|
|
|
| FrameView* view = frame->view();
|
| @@ -5281,6 +5296,9 @@ void WebGLRenderingContext::maybeRestoreContext(Timer<WebGLRenderingContext>*)
|
| if (!hostWindow)
|
| return;
|
|
|
| + // Reset the context attributes back to the requested attributes and re-apply restrictions
|
| + m_attributes = adjustAttributes(m_requestedAttributes, settings);
|
| +
|
| RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes, hostWindow));
|
| if (!context) {
|
| if (m_contextLostMode == RealLostContext)
|
| @@ -5471,4 +5489,24 @@ void WebGLRenderingContext::restoreCurrentTexture2D()
|
| bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(), ec);
|
| }
|
|
|
| +WebGLRenderingContext::WebGLMultisamplingChangedObserver::WebGLMultisamplingChangedObserver(WebGLRenderingContext* context, Page* page)
|
| + : m_context(context)
|
| + , m_page(page)
|
| +{
|
| + m_multisamplingAllowed = m_context->getContextAttributes()->antialias();
|
| +}
|
| +
|
| +void WebGLRenderingContext::WebGLMultisamplingChangedObserver::multisamplingChanged(bool enabled)
|
| +{
|
| + if(m_multisamplingAllowed != enabled) {
|
| + m_multisamplingAllowed = enabled;
|
| + m_context->forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext);
|
| + }
|
| +}
|
| +
|
| +WebGLRenderingContext::WebGLMultisamplingChangedObserver::~WebGLMultisamplingChangedObserver()
|
| +{
|
| + m_page->removeMultisamplingChangedObserver(this);
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|