| 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 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, webGLVersion); |
| 566 Platform::GraphicsInfo glInfo; | 566 Platform::GraphicsInfo glInfo; |
| 567 glInfo.testFailContext = shouldFailContextCreationForTesting; | 567 glInfo.testFailContext = shouldFailContextCreationForTesting; |
| 568 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(wgc3dAttributes, 0, &glInfo)); | 568 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( |
| 569 wgc3dAttributes, document.topDocument().url(), 0, &glInfo)); |
| 569 if (!contextProvider || shouldFailContextCreationForTesting) { | 570 if (!contextProvider || shouldFailContextCreationForTesting) { |
| 570 shouldFailContextCreationForTesting = false; | 571 shouldFailContextCreationForTesting = false; |
| 571 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); | 572 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); |
| 572 return nullptr; | 573 return nullptr; |
| 573 } | 574 } |
| 574 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 575 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 575 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { | 576 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { |
| 576 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); | 577 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); |
| 577 return nullptr; | 578 return nullptr; |
| 578 } | 579 } |
| (...skipping 5421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6000 | 6001 |
| 6001 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 6002 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
| 6002 return; | 6003 return; |
| 6003 | 6004 |
| 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. | 6005 // 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. |
| 6005 if (drawingBuffer()) { | 6006 if (drawingBuffer()) { |
| 6006 m_drawingBuffer->beginDestruction(); | 6007 m_drawingBuffer->beginDestruction(); |
| 6007 m_drawingBuffer.clear(); | 6008 m_drawingBuffer.clear(); |
| 6008 } | 6009 } |
| 6009 | 6010 |
| 6010 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().getString(),
version()); | 6011 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, version()); |
| 6011 Platform::GraphicsInfo glInfo; | 6012 Platform::GraphicsInfo glInfo; |
| 6012 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(attributes, 0, &glInfo)); | 6013 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( |
| 6014 attributes, canvas()->document().topDocument().url(), 0, &glInfo)); |
| 6013 RefPtr<DrawingBuffer> buffer; | 6015 RefPtr<DrawingBuffer> buffer; |
| 6014 if (contextProvider) { | 6016 if (contextProvider) { |
| 6015 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 6017 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| 6016 buffer = createDrawingBuffer(contextProvider.release()); | 6018 buffer = createDrawingBuffer(contextProvider.release()); |
| 6017 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 6019 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
| 6018 } | 6020 } |
| 6019 if (!buffer) { | 6021 if (!buffer) { |
| 6020 if (m_contextLostMode == RealLostContext) { | 6022 if (m_contextLostMode == RealLostContext) { |
| 6021 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); | 6023 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); |
| 6022 } else { | 6024 } else { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6351 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6353 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6352 } | 6354 } |
| 6353 | 6355 |
| 6354 void WebGLRenderingContextBase::restoreUnpackParameters() | 6356 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6355 { | 6357 { |
| 6356 if (m_unpackAlignment != 1) | 6358 if (m_unpackAlignment != 1) |
| 6357 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6359 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6358 } | 6360 } |
| 6359 | 6361 |
| 6360 } // namespace blink | 6362 } // namespace blink |
| OLD | NEW |