| 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 5110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5121 | 5121 |
| 5122 // Don't allow restoration unless the context lost event has both been | 5122 // Don't allow restoration unless the context lost event has both been |
| 5123 // dispatched and its default behavior prevented. | 5123 // dispatched and its default behavior prevented. |
| 5124 m_restoreAllowed = false; | 5124 m_restoreAllowed = false; |
| 5125 deactivateContext(this); | 5125 deactivateContext(this); |
| 5126 if (m_autoRecoveryMethod == WhenAvailable) | 5126 if (m_autoRecoveryMethod == WhenAvailable) |
| 5127 addToEvictedList(this); | 5127 addToEvictedList(this); |
| 5128 | 5128 |
| 5129 // Always defer the dispatch of the context lost event, to implement | 5129 // Always defer the dispatch of the context lost event, to implement |
| 5130 // the spec behavior of queueing a task. | 5130 // the spec behavior of queueing a task. |
| 5131 m_dispatchContextLostEventTimer.startOneShot(0, FROM_HERE); | 5131 m_dispatchContextLostEventTimer.startOneShot(0, BLINK_FROM_HERE); |
| 5132 } | 5132 } |
| 5133 | 5133 |
| 5134 void WebGLRenderingContextBase::forceRestoreContext() | 5134 void WebGLRenderingContextBase::forceRestoreContext() |
| 5135 { | 5135 { |
| 5136 if (!isContextLost()) { | 5136 if (!isContextLost()) { |
| 5137 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context not l
ost"); | 5137 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context not l
ost"); |
| 5138 return; | 5138 return; |
| 5139 } | 5139 } |
| 5140 | 5140 |
| 5141 if (!m_restoreAllowed) { | 5141 if (!m_restoreAllowed) { |
| 5142 if (m_contextLostMode == WebGLLoseContextLostContext) | 5142 if (m_contextLostMode == WebGLLoseContextLostContext) |
| 5143 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); | 5143 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); |
| 5144 return; | 5144 return; |
| 5145 } | 5145 } |
| 5146 | 5146 |
| 5147 if (!m_restoreTimer.isActive()) | 5147 if (!m_restoreTimer.isActive()) |
| 5148 m_restoreTimer.startOneShot(0, FROM_HERE); | 5148 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); |
| 5149 } | 5149 } |
| 5150 | 5150 |
| 5151 WebLayer* WebGLRenderingContextBase::platformLayer() const | 5151 WebLayer* WebGLRenderingContextBase::platformLayer() const |
| 5152 { | 5152 { |
| 5153 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); | 5153 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); |
| 5154 } | 5154 } |
| 5155 | 5155 |
| 5156 void WebGLRenderingContextBase::setFilterQuality(SkFilterQuality filterQuality) | 5156 void WebGLRenderingContextBase::setFilterQuality(SkFilterQuality filterQuality) |
| 5157 { | 5157 { |
| 5158 if (!isContextLost() && drawingBuffer()) { | 5158 if (!isContextLost() && drawingBuffer()) { |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6460 attribValue.value.floatValue[ii] = v[ii]; | 6460 attribValue.value.floatValue[ii] = v[ii]; |
| 6461 } | 6461 } |
| 6462 | 6462 |
| 6463 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) | 6463 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) |
| 6464 { | 6464 { |
| 6465 RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(Even
tTypeNames::webglcontextlost, false, true, ""); | 6465 RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(Even
tTypeNames::webglcontextlost, false, true, ""); |
| 6466 canvas()->dispatchEvent(event); | 6466 canvas()->dispatchEvent(event); |
| 6467 m_restoreAllowed = event->defaultPrevented(); | 6467 m_restoreAllowed = event->defaultPrevented(); |
| 6468 if (m_restoreAllowed) { | 6468 if (m_restoreAllowed) { |
| 6469 if (m_autoRecoveryMethod == Auto) | 6469 if (m_autoRecoveryMethod == Auto) |
| 6470 m_restoreTimer.startOneShot(0, FROM_HERE); | 6470 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); |
| 6471 } | 6471 } |
| 6472 } | 6472 } |
| 6473 | 6473 |
| 6474 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) | 6474 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) |
| 6475 { | 6475 { |
| 6476 ASSERT(isContextLost()); | 6476 ASSERT(isContextLost()); |
| 6477 | 6477 |
| 6478 // The rendering context is not restored unless the default behavior of the | 6478 // The rendering context is not restored unless the default behavior of the |
| 6479 // webglcontextlost event was prevented earlier. | 6479 // webglcontextlost event was prevented earlier. |
| 6480 // | 6480 // |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6502 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().string(), set
tings, version()); | 6502 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().string(), set
tings, version()); |
| 6503 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO
ffscreenGraphicsContext3D(attributes, 0)); | 6503 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO
ffscreenGraphicsContext3D(attributes, 0)); |
| 6504 RefPtr<DrawingBuffer> buffer; | 6504 RefPtr<DrawingBuffer> buffer; |
| 6505 if (context) { | 6505 if (context) { |
| 6506 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 6506 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| 6507 buffer = createDrawingBuffer(context.release()); | 6507 buffer = createDrawingBuffer(context.release()); |
| 6508 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 6508 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
| 6509 } | 6509 } |
| 6510 if (!buffer) { | 6510 if (!buffer) { |
| 6511 if (m_contextLostMode == RealLostContext) { | 6511 if (m_contextLostMode == RealLostContext) { |
| 6512 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); | 6512 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); |
| 6513 } else { | 6513 } else { |
| 6514 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 6514 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
| 6515 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 6515 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
| 6516 } | 6516 } |
| 6517 return; | 6517 return; |
| 6518 } | 6518 } |
| 6519 | 6519 |
| 6520 m_drawingBuffer = buffer.release(); | 6520 m_drawingBuffer = buffer.release(); |
| 6521 | 6521 |
| 6522 drawingBuffer()->bind(GL_FRAMEBUFFER); | 6522 drawingBuffer()->bind(GL_FRAMEBUFFER); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6832 | 6832 |
| 6833 return totalBytesPerPixel; | 6833 return totalBytesPerPixel; |
| 6834 } | 6834 } |
| 6835 | 6835 |
| 6836 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6836 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6837 { | 6837 { |
| 6838 return m_drawingBuffer.get(); | 6838 return m_drawingBuffer.get(); |
| 6839 } | 6839 } |
| 6840 | 6840 |
| 6841 } // namespace blink | 6841 } // namespace blink |
| OLD | NEW |