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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 #include "platform/NotImplemented.h" | 89 #include "platform/NotImplemented.h" |
90 #include "platform/RuntimeEnabledFeatures.h" | 90 #include "platform/RuntimeEnabledFeatures.h" |
91 #include "platform/geometry/IntSize.h" | 91 #include "platform/geometry/IntSize.h" |
92 #include "platform/graphics/GraphicsContext.h" | 92 #include "platform/graphics/GraphicsContext.h" |
93 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 93 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
94 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 94 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
95 #include "platform/graphics/gpu/DrawingBuffer.h" | 95 #include "platform/graphics/gpu/DrawingBuffer.h" |
96 #include "public/platform/Platform.h" | 96 #include "public/platform/Platform.h" |
97 #include "public/platform/WebGraphicsContext3D.h" | 97 #include "public/platform/WebGraphicsContext3D.h" |
98 #include "public/platform/WebGraphicsContext3DProvider.h" | 98 #include "public/platform/WebGraphicsContext3DProvider.h" |
99 #include "public/platform/callback/WebClosure.h" | |
99 #include "wtf/ArrayBufferContents.h" | 100 #include "wtf/ArrayBufferContents.h" |
101 #include "wtf/Functional.h" | |
100 #include "wtf/PassOwnPtr.h" | 102 #include "wtf/PassOwnPtr.h" |
101 #include "wtf/text/StringBuilder.h" | 103 #include "wtf/text/StringBuilder.h" |
102 #include "wtf/text/StringUTF8Adaptor.h" | 104 #include "wtf/text/StringUTF8Adaptor.h" |
103 | 105 |
104 namespace blink { | 106 namespace blink { |
105 | 107 |
106 namespace { | 108 namespace { |
107 | 109 |
108 const double secondsBetweenRestoreAttempts = 1.0; | 110 const double secondsBetweenRestoreAttempts = 1.0; |
109 const int maxGLErrorsAllowedToConsole = 256; | 111 const int maxGLErrorsAllowedToConsole = 256; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 | 486 |
485 ~ScopedFramebufferRestorer() | 487 ~ScopedFramebufferRestorer() |
486 { | 488 { |
487 m_context->restoreCurrentFramebuffer(); | 489 m_context->restoreCurrentFramebuffer(); |
488 } | 490 } |
489 | 491 |
490 private: | 492 private: |
491 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | 493 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
492 }; | 494 }; |
493 | 495 |
494 class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized <WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsCon textLostCallback { | 496 class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized <WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsCon textLostCallback { |
Ken Russell (switch to Gerrit)
2016/03/24 18:29:04
Can this class be removed now?
danakj
2016/03/24 18:36:50
Oh, ya! Thanks
| |
495 public: | 497 public: |
496 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context) | 498 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context) |
497 { | 499 { |
498 return new WebGLRenderingContextLostCallback(context); | 500 return new WebGLRenderingContextLostCallback(context); |
499 } | 501 } |
500 | 502 |
501 ~WebGLRenderingContextLostCallback() override { } | 503 ~WebGLRenderingContextLostCallback() override { } |
502 | 504 |
503 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); } | 505 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); } |
504 | 506 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 // for the default VAO. (This object is never exposed to JavaScript, but we need to link other | 988 // for the default VAO. (This object is never exposed to JavaScript, but we need to link other |
987 // JavaScript wrappers to it.) | 989 // JavaScript wrappers to it.) |
988 m_preservedDefaultVAOObjectWrapper = false; | 990 m_preservedDefaultVAOObjectWrapper = false; |
989 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 991 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
990 | 992 |
991 m_vertexAttribType.resize(m_maxVertexAttribs); | 993 m_vertexAttribType.resize(m_maxVertexAttribs); |
992 | 994 |
993 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 995 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
994 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 996 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
995 | 997 |
996 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); | |
997 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); | 998 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); |
998 | 999 |
999 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 1000 // Uses raw |this| as the callback is reset before |this| is destroyed. |
1001 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure(WTF::b ind(&WebGLRenderingContextBase::forceLostContext, this, WebGLRenderingContextBas e::RealLostContext, WebGLRenderingContextBase::Auto))); | |
1000 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 1002 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
1001 | 1003 |
1002 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. | 1004 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. |
1003 contextGL()->Flush(); | 1005 contextGL()->Flush(); |
1004 | 1006 |
1005 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 1007 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
1006 m_extensionEnabled[i] = false; | 1008 m_extensionEnabled[i] = false; |
1007 | 1009 |
1008 m_isWebGL2FormatsTypesAdded = false; | 1010 m_isWebGL2FormatsTypesAdded = false; |
1009 m_isWebGL2InternalFormatsCopyTexImageAdded = false; | 1011 m_isWebGL2InternalFormatsCopyTexImageAdded = false; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 willDestroyContext(this); | 1107 willDestroyContext(this); |
1106 } | 1108 } |
1107 | 1109 |
1108 void WebGLRenderingContextBase::destroyContext() | 1110 void WebGLRenderingContextBase::destroyContext() |
1109 { | 1111 { |
1110 if (!drawingBuffer()) | 1112 if (!drawingBuffer()) |
1111 return; | 1113 return; |
1112 | 1114 |
1113 m_extensionsUtil.clear(); | 1115 m_extensionsUtil.clear(); |
1114 | 1116 |
1115 webContext()->setContextLostCallback(nullptr); | 1117 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); |
1116 webContext()->setErrorMessageCallback(nullptr); | 1118 webContext()->setErrorMessageCallback(nullptr); |
1117 | 1119 |
1118 ASSERT(drawingBuffer()); | 1120 ASSERT(drawingBuffer()); |
1119 m_drawingBuffer->beginDestruction(); | 1121 m_drawingBuffer->beginDestruction(); |
1120 m_drawingBuffer.clear(); | 1122 m_drawingBuffer.clear(); |
1121 } | 1123 } |
1122 | 1124 |
1123 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) | 1125 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) |
1124 { | 1126 { |
1125 if (m_framebufferBinding || isContextLost()) | 1127 if (m_framebufferBinding || isContextLost()) |
(...skipping 5150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6276 visitor->trace(m_textureCubeMapBinding); | 6278 visitor->trace(m_textureCubeMapBinding); |
6277 visitor->trace(m_texture3DBinding); | 6279 visitor->trace(m_texture3DBinding); |
6278 visitor->trace(m_texture2DArrayBinding); | 6280 visitor->trace(m_texture2DArrayBinding); |
6279 } | 6281 } |
6280 | 6282 |
6281 DEFINE_TRACE(WebGLRenderingContextBase) | 6283 DEFINE_TRACE(WebGLRenderingContextBase) |
6282 { | 6284 { |
6283 #if ENABLE(OILPAN) | 6285 #if ENABLE(OILPAN) |
6284 visitor->trace(m_contextObjects); | 6286 visitor->trace(m_contextObjects); |
6285 #endif | 6287 #endif |
6286 visitor->trace(m_contextLostCallbackAdapter); | |
6287 visitor->trace(m_errorMessageCallbackAdapter); | 6288 visitor->trace(m_errorMessageCallbackAdapter); |
6288 visitor->trace(m_boundArrayBuffer); | 6289 visitor->trace(m_boundArrayBuffer); |
6289 visitor->trace(m_defaultVertexArrayObject); | 6290 visitor->trace(m_defaultVertexArrayObject); |
6290 visitor->trace(m_boundVertexArrayObject); | 6291 visitor->trace(m_boundVertexArrayObject); |
6291 visitor->trace(m_currentProgram); | 6292 visitor->trace(m_currentProgram); |
6292 visitor->trace(m_framebufferBinding); | 6293 visitor->trace(m_framebufferBinding); |
6293 visitor->trace(m_renderbufferBinding); | 6294 visitor->trace(m_renderbufferBinding); |
6294 visitor->trace(m_valuebufferBinding); | 6295 visitor->trace(m_valuebufferBinding); |
6295 visitor->trace(m_textureUnits); | 6296 visitor->trace(m_textureUnits); |
6296 visitor->trace(m_extensions); | 6297 visitor->trace(m_extensions); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6334 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6335 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6335 } | 6336 } |
6336 | 6337 |
6337 void WebGLRenderingContextBase::restoreUnpackParameters() | 6338 void WebGLRenderingContextBase::restoreUnpackParameters() |
6338 { | 6339 { |
6339 if (m_unpackAlignment != 1) | 6340 if (m_unpackAlignment != 1) |
6340 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6341 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6341 } | 6342 } |
6342 | 6343 |
6343 } // namespace blink | 6344 } // namespace blink |
OLD | NEW |