| 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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 return true; | 826 return true; |
| 827 default: | 827 default: |
| 828 return false; | 828 return false; |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 | 831 |
| 832 } // namespace | 832 } // namespace |
| 833 | 833 |
| 834 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re
questedAttributes) | 834 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re
questedAttributes) |
| 835 : CanvasRenderingContext(passedCanvas) | 835 : CanvasRenderingContext(passedCanvas) |
| 836 , m_isHidden(false) |
| 836 , m_contextLostMode(NotLostContext) | 837 , m_contextLostMode(NotLostContext) |
| 837 , m_autoRecoveryMethod(Manual) | 838 , m_autoRecoveryMethod(Manual) |
| 838 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) | 839 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) |
| 839 , m_restoreAllowed(false) | 840 , m_restoreAllowed(false) |
| 840 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 841 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
| 841 , m_preservedDefaultVAOObjectWrapper(false) | 842 , m_preservedDefaultVAOObjectWrapper(false) |
| 842 , m_generatedImageCache(4) | 843 , m_generatedImageCache(4) |
| 843 , m_requestedAttributes(requestedAttributes) | 844 , m_requestedAttributes(requestedAttributes) |
| 844 , m_synthesizedErrorsToConsole(true) | 845 , m_synthesizedErrorsToConsole(true) |
| 845 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 846 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1208 } |
| 1208 | 1209 |
| 1209 void WebGLRenderingContextBase::markLayerComposited() | 1210 void WebGLRenderingContextBase::markLayerComposited() |
| 1210 { | 1211 { |
| 1211 if (!isContextLost()) | 1212 if (!isContextLost()) |
| 1212 drawingBuffer()->setBufferClearNeeded(true); | 1213 drawingBuffer()->setBufferClearNeeded(true); |
| 1213 } | 1214 } |
| 1214 | 1215 |
| 1215 void WebGLRenderingContextBase::setIsHidden(bool hidden) | 1216 void WebGLRenderingContextBase::setIsHidden(bool hidden) |
| 1216 { | 1217 { |
| 1218 m_isHidden = hidden; |
| 1217 if (drawingBuffer()) | 1219 if (drawingBuffer()) |
| 1218 drawingBuffer()->setIsHidden(hidden); | 1220 drawingBuffer()->setIsHidden(hidden); |
| 1221 |
| 1222 if (!hidden && isContextLost() && m_restoreAllowed && m_autoRecoveryMethod =
= Auto) { |
| 1223 ASSERT(!m_restoreTimer.isActive()); |
| 1224 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1225 } |
| 1219 } | 1226 } |
| 1220 | 1227 |
| 1221 bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
r sourceBuffer) | 1228 bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
r sourceBuffer) |
| 1222 { | 1229 { |
| 1223 if (isContextLost()) | 1230 if (isContextLost()) |
| 1224 return false; | 1231 return false; |
| 1225 | 1232 |
| 1226 bool mustClearNow = clearIfComposited() != Skipped; | 1233 bool mustClearNow = clearIfComposited() != Skipped; |
| 1227 if (!m_markedCanvasDirty && !mustClearNow) | 1234 if (!m_markedCanvasDirty && !mustClearNow) |
| 1228 return false; | 1235 return false; |
| (...skipping 4665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5894 } | 5901 } |
| 5895 | 5902 |
| 5896 return true; | 5903 return true; |
| 5897 } | 5904 } |
| 5898 | 5905 |
| 5899 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) | 5906 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) |
| 5900 { | 5907 { |
| 5901 RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(Even
tTypeNames::webglcontextlost, false, true, ""); | 5908 RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(Even
tTypeNames::webglcontextlost, false, true, ""); |
| 5902 canvas()->dispatchEvent(event); | 5909 canvas()->dispatchEvent(event); |
| 5903 m_restoreAllowed = event->defaultPrevented(); | 5910 m_restoreAllowed = event->defaultPrevented(); |
| 5904 if (m_restoreAllowed) { | 5911 if (m_restoreAllowed && !m_isHidden) { |
| 5905 if (m_autoRecoveryMethod == Auto) | 5912 if (m_autoRecoveryMethod == Auto) |
| 5906 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); | 5913 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); |
| 5907 } | 5914 } |
| 5908 } | 5915 } |
| 5909 | 5916 |
| 5910 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) | 5917 void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
ase>*) |
| 5911 { | 5918 { |
| 5912 ASSERT(isContextLost()); | 5919 ASSERT(isContextLost()); |
| 5913 | 5920 |
| 5914 // The rendering context is not restored unless the default behavior of the | 5921 // The rendering context is not restored unless the default behavior of the |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6278 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6285 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6279 } | 6286 } |
| 6280 | 6287 |
| 6281 void WebGLRenderingContextBase::restoreUnpackParameters() | 6288 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6282 { | 6289 { |
| 6283 if (m_unpackAlignment != 1) | 6290 if (m_unpackAlignment != 1) |
| 6284 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6291 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6285 } | 6292 } |
| 6286 | 6293 |
| 6287 } // namespace blink | 6294 } // namespace blink |
| OLD | NEW |