| 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 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4137 | 4137 |
| 4138 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons
ole: DontDisplayInConsole; | 4138 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons
ole: DontDisplayInConsole; |
| 4139 synthesizeGLError(GC3D_CONTEXT_LOST_WEBGL, "loseContext", "context lost", di
splay); | 4139 synthesizeGLError(GC3D_CONTEXT_LOST_WEBGL, "loseContext", "context lost", di
splay); |
| 4140 | 4140 |
| 4141 // Don't allow restoration unless the context lost event has both been | 4141 // Don't allow restoration unless the context lost event has both been |
| 4142 // dispatched and its default behavior prevented. | 4142 // dispatched and its default behavior prevented. |
| 4143 m_restoreAllowed = false; | 4143 m_restoreAllowed = false; |
| 4144 | 4144 |
| 4145 // Always defer the dispatch of the context lost event, to implement | 4145 // Always defer the dispatch of the context lost event, to implement |
| 4146 // the spec behavior of queueing a task. | 4146 // the spec behavior of queueing a task. |
| 4147 m_dispatchContextLostEventTimer.startOneShot(0); | 4147 m_dispatchContextLostEventTimer.startOneShot(0, FROM_HERE); |
| 4148 } | 4148 } |
| 4149 | 4149 |
| 4150 void WebGLRenderingContextBase::forceRestoreContext() | 4150 void WebGLRenderingContextBase::forceRestoreContext() |
| 4151 { | 4151 { |
| 4152 if (!isContextLost()) { | 4152 if (!isContextLost()) { |
| 4153 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context not l
ost"); | 4153 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context not l
ost"); |
| 4154 return; | 4154 return; |
| 4155 } | 4155 } |
| 4156 | 4156 |
| 4157 if (!m_restoreAllowed) { | 4157 if (!m_restoreAllowed) { |
| 4158 if (m_contextLostMode == SyntheticLostContext) | 4158 if (m_contextLostMode == SyntheticLostContext) |
| 4159 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); | 4159 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); |
| 4160 return; | 4160 return; |
| 4161 } | 4161 } |
| 4162 | 4162 |
| 4163 if (!m_restoreTimer.isActive()) | 4163 if (!m_restoreTimer.isActive()) |
| 4164 m_restoreTimer.startOneShot(0); | 4164 m_restoreTimer.startOneShot(0, FROM_HERE); |
| 4165 } | 4165 } |
| 4166 | 4166 |
| 4167 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const | 4167 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const |
| 4168 { | 4168 { |
| 4169 return m_drawingBuffer->platformLayer(); | 4169 return m_drawingBuffer->platformLayer(); |
| 4170 } | 4170 } |
| 4171 | 4171 |
| 4172 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() | 4172 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() |
| 4173 { | 4173 { |
| 4174 if (!m_extensionsUtil) | 4174 if (!m_extensionsUtil) |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5302 attribValue.value[ii] = v[ii]; | 5302 attribValue.value[ii] = v[ii]; |
| 5303 } | 5303 } |
| 5304 | 5304 |
| 5305 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) | 5305 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) |
| 5306 { | 5306 { |
| 5307 RefPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames::
webglcontextlost, false, true, ""); | 5307 RefPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames::
webglcontextlost, false, true, ""); |
| 5308 canvas()->dispatchEvent(event); | 5308 canvas()->dispatchEvent(event); |
| 5309 m_restoreAllowed = event->defaultPrevented(); | 5309 m_restoreAllowed = event->defaultPrevented(); |
| 5310 deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAll
owed); | 5310 deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAll
owed); |
| 5311 if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecove
rSyntheticLostContext) && m_restoreAllowed) | 5311 if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecove
rSyntheticLostContext) && m_restoreAllowed) |
| 5312 m_restoreTimer.startOneShot(0); | 5312 m_restoreTimer.startOneShot(0, FROM_HERE); |
| 5313 } | 5313 } |
| 5314 | 5314 |
| 5315 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) | 5315 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) |
| 5316 { | 5316 { |
| 5317 ASSERT(isContextLost()); | 5317 ASSERT(isContextLost()); |
| 5318 | 5318 |
| 5319 // The rendering context is not restored unless the default behavior of the | 5319 // The rendering context is not restored unless the default behavior of the |
| 5320 // webglcontextlost event was prevented earlier. | 5320 // webglcontextlost event was prevented earlier. |
| 5321 // | 5321 // |
| 5322 // Because of the way m_restoreTimer is set up for real vs. synthetic lost | 5322 // Because of the way m_restoreTimer is set up for real vs. synthetic lost |
| 5323 // context events, we don't have to worry about this test short-circuiting | 5323 // context events, we don't have to worry about this test short-circuiting |
| 5324 // the retry loop for real context lost events. | 5324 // the retry loop for real context lost events. |
| 5325 if (!m_restoreAllowed) | 5325 if (!m_restoreAllowed) |
| 5326 return; | 5326 return; |
| 5327 | 5327 |
| 5328 LocalFrame* frame = canvas()->document().frame(); | 5328 LocalFrame* frame = canvas()->document().frame(); |
| 5329 if (!frame) | 5329 if (!frame) |
| 5330 return; | 5330 return; |
| 5331 | 5331 |
| 5332 Settings* settings = frame->settings(); | 5332 Settings* settings = frame->settings(); |
| 5333 | 5333 |
| 5334 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 5334 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
| 5335 return; | 5335 return; |
| 5336 | 5336 |
| 5337 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); | 5337 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); |
| 5338 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); | 5338 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); |
| 5339 if (!context) { | 5339 if (!context) { |
| 5340 if (m_contextLostMode == RealLostContext) { | 5340 if (m_contextLostMode == RealLostContext) { |
| 5341 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); | 5341 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); |
| 5342 } else { | 5342 } else { |
| 5343 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 5343 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
| 5344 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 5344 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
| 5345 } | 5345 } |
| 5346 return; | 5346 return; |
| 5347 } | 5347 } |
| 5348 | 5348 |
| 5349 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 5349 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
| 5350 | 5350 |
| 5351 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 5351 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5555 if (m_textureUnits[i].m_texture2DBinding | 5555 if (m_textureUnits[i].m_texture2DBinding |
| 5556 || m_textureUnits[i].m_textureCubeMapBinding) { | 5556 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5557 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5557 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5558 return; | 5558 return; |
| 5559 } | 5559 } |
| 5560 } | 5560 } |
| 5561 m_onePlusMaxNonDefaultTextureUnit = 0; | 5561 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5562 } | 5562 } |
| 5563 | 5563 |
| 5564 } // namespace WebCore | 5564 } // namespace WebCore |
| OLD | NEW |