| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 Settings* settings = frame->settings(); | 556 Settings* settings = frame->settings(); |
| 557 | 557 |
| 558 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in | 558 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in |
| 559 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. | 559 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. |
| 560 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { | 560 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { |
| 561 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); | 561 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); |
| 562 return nullptr; | 562 return nullptr; |
| 563 } | 563 } |
| 564 | 564 |
| 565 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, document.topDocument().url().getString(), webGLVersion); | 565 Platform::ContextAttributes contextAttributes = toPlatformContextAttributes(
attributes, webGLVersion); |
| 566 Platform::GraphicsInfo glInfo; | 566 Platform::GraphicsInfo glInfo; |
| 567 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(wgc3dAttributes, 0, &glInfo)); | 567 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( |
| 568 contextAttributes, document.topDocument().url(), 0, &glInfo)); |
| 568 if (!contextProvider || shouldFailContextCreationForTesting) { | 569 if (!contextProvider || shouldFailContextCreationForTesting) { |
| 569 shouldFailContextCreationForTesting = false; | 570 shouldFailContextCreationForTesting = false; |
| 570 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); | 571 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); |
| 571 return nullptr; | 572 return nullptr; |
| 572 } | 573 } |
| 573 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 574 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 574 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { | 575 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { |
| 575 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); | 576 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); |
| 576 return nullptr; | 577 return nullptr; |
| 577 } | 578 } |
| (...skipping 5421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5999 | 6000 |
| 6000 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 6001 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
| 6001 return; | 6002 return; |
| 6002 | 6003 |
| 6003 // If the context was lost due to RealLostContext, we need to destroy the ol
d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou
gh. | 6004 // If the context was lost due to RealLostContext, we need to destroy the ol
d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou
gh. |
| 6004 if (drawingBuffer()) { | 6005 if (drawingBuffer()) { |
| 6005 m_drawingBuffer->beginDestruction(); | 6006 m_drawingBuffer->beginDestruction(); |
| 6006 m_drawingBuffer.clear(); | 6007 m_drawingBuffer.clear(); |
| 6007 } | 6008 } |
| 6008 | 6009 |
| 6009 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().getString(),
version()); | 6010 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque
stedAttributes, version()); |
| 6010 Platform::GraphicsInfo glInfo; | 6011 Platform::GraphicsInfo glInfo; |
| 6011 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(attributes, 0, &glInfo)); | 6012 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( |
| 6013 attributes, canvas()->document().topDocument().url(), 0, &glInfo)); |
| 6012 RefPtr<DrawingBuffer> buffer; | 6014 RefPtr<DrawingBuffer> buffer; |
| 6013 if (contextProvider) { | 6015 if (contextProvider) { |
| 6014 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 6016 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| 6015 buffer = createDrawingBuffer(contextProvider.release()); | 6017 buffer = createDrawingBuffer(contextProvider.release()); |
| 6016 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 6018 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
| 6017 } | 6019 } |
| 6018 if (!buffer) { | 6020 if (!buffer) { |
| 6019 if (m_contextLostMode == RealLostContext) { | 6021 if (m_contextLostMode == RealLostContext) { |
| 6020 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); | 6022 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); |
| 6021 } else { | 6023 } else { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6350 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6352 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6351 } | 6353 } |
| 6352 | 6354 |
| 6353 void WebGLRenderingContextBase::restoreUnpackParameters() | 6355 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6354 { | 6356 { |
| 6355 if (m_unpackAlignment != 1) | 6357 if (m_unpackAlignment != 1) |
| 6356 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6358 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6357 } | 6359 } |
| 6358 | 6360 |
| 6359 } // namespace blink | 6361 } // namespace blink |
| OLD | NEW |