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 { | |
495 public: | |
496 static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context) | |
497 { | |
498 return new WebGLRenderingContextLostCallback(context); | |
499 } | |
500 | |
501 ~WebGLRenderingContextLostCallback() override { } | |
502 | |
503 virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingCon textBase::RealLostContext, WebGLRenderingContextBase::Auto); } | |
504 | |
505 DEFINE_INLINE_TRACE() | |
506 { | |
507 visitor->trace(m_context); | |
508 } | |
509 | |
510 private: | |
511 explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* contex t) | |
512 : m_context(context) { } | |
513 | |
514 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | |
515 }; | |
516 | |
517 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D ::WebGraphicsErrorMessageCallback { | 496 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D ::WebGraphicsErrorMessageCallback { |
518 public: | 497 public: |
519 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte xtBase* context) | 498 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte xtBase* context) |
520 { | 499 { |
521 return new WebGLRenderingContextErrorMessageCallback(context); | 500 return new WebGLRenderingContextErrorMessageCallback(context); |
522 } | 501 } |
523 | 502 |
524 ~WebGLRenderingContextErrorMessageCallback() override { } | 503 ~WebGLRenderingContextErrorMessageCallback() override { } |
525 | 504 |
526 virtual void onErrorMessage(const WebString& message, WGC3Dint) | 505 virtual void onErrorMessage(const WebString& message, WGC3Dint) |
(...skipping 459 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 | 965 // for the default VAO. (This object is never exposed to JavaScript, but we need to link other |
987 // JavaScript wrappers to it.) | 966 // JavaScript wrappers to it.) |
988 m_preservedDefaultVAOObjectWrapper = false; | 967 m_preservedDefaultVAOObjectWrapper = false; |
989 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 968 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
990 | 969 |
991 m_vertexAttribType.resize(m_maxVertexAttribs); | 970 m_vertexAttribType.resize(m_maxVertexAttribs); |
992 | 971 |
993 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 972 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
994 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 973 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
995 | 974 |
996 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); | |
997 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); | 975 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); |
998 | 976 |
999 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 977 // Uses raw |this| as the callback is reset before |this| is destroyed. |
978 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure(WTF::b ind(&WebGLRenderingContextBase::forceLostContext, this, WebGLRenderingContextBas e::RealLostContext, WebGLRenderingContextBase::Auto))); | |
danakj
2016/03/24 23:12:56
Maybe this bind is keeping things alive from being
| |
1000 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 979 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
1001 | 980 |
1002 // This ensures that the context has a valid "lastFlushID" and won't be mist akenly identified as the "least recently used" context. | 981 // 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(); | 982 contextGL()->Flush(); |
1004 | 983 |
1005 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 984 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
1006 m_extensionEnabled[i] = false; | 985 m_extensionEnabled[i] = false; |
1007 | 986 |
1008 m_isWebGL2FormatsTypesAdded = false; | 987 m_isWebGL2FormatsTypesAdded = false; |
1009 m_isWebGL2InternalFormatsCopyTexImageAdded = false; | 988 m_isWebGL2InternalFormatsCopyTexImageAdded = false; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 willDestroyContext(this); | 1084 willDestroyContext(this); |
1106 } | 1085 } |
1107 | 1086 |
1108 void WebGLRenderingContextBase::destroyContext() | 1087 void WebGLRenderingContextBase::destroyContext() |
1109 { | 1088 { |
1110 if (!drawingBuffer()) | 1089 if (!drawingBuffer()) |
1111 return; | 1090 return; |
1112 | 1091 |
1113 m_extensionsUtil.clear(); | 1092 m_extensionsUtil.clear(); |
1114 | 1093 |
1115 webContext()->setContextLostCallback(nullptr); | 1094 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); |
1116 webContext()->setErrorMessageCallback(nullptr); | 1095 webContext()->setErrorMessageCallback(nullptr); |
1117 | 1096 |
1118 ASSERT(drawingBuffer()); | 1097 ASSERT(drawingBuffer()); |
1119 m_drawingBuffer->beginDestruction(); | 1098 m_drawingBuffer->beginDestruction(); |
1120 m_drawingBuffer.clear(); | 1099 m_drawingBuffer.clear(); |
1121 } | 1100 } |
1122 | 1101 |
1123 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) | 1102 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) |
1124 { | 1103 { |
1125 if (m_framebufferBinding || isContextLost()) | 1104 if (m_framebufferBinding || isContextLost()) |
(...skipping 5150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6276 visitor->trace(m_textureCubeMapBinding); | 6255 visitor->trace(m_textureCubeMapBinding); |
6277 visitor->trace(m_texture3DBinding); | 6256 visitor->trace(m_texture3DBinding); |
6278 visitor->trace(m_texture2DArrayBinding); | 6257 visitor->trace(m_texture2DArrayBinding); |
6279 } | 6258 } |
6280 | 6259 |
6281 DEFINE_TRACE(WebGLRenderingContextBase) | 6260 DEFINE_TRACE(WebGLRenderingContextBase) |
6282 { | 6261 { |
6283 #if ENABLE(OILPAN) | 6262 #if ENABLE(OILPAN) |
6284 visitor->trace(m_contextObjects); | 6263 visitor->trace(m_contextObjects); |
6285 #endif | 6264 #endif |
6286 visitor->trace(m_contextLostCallbackAdapter); | |
6287 visitor->trace(m_errorMessageCallbackAdapter); | 6265 visitor->trace(m_errorMessageCallbackAdapter); |
6288 visitor->trace(m_boundArrayBuffer); | 6266 visitor->trace(m_boundArrayBuffer); |
6289 visitor->trace(m_defaultVertexArrayObject); | 6267 visitor->trace(m_defaultVertexArrayObject); |
6290 visitor->trace(m_boundVertexArrayObject); | 6268 visitor->trace(m_boundVertexArrayObject); |
6291 visitor->trace(m_currentProgram); | 6269 visitor->trace(m_currentProgram); |
6292 visitor->trace(m_framebufferBinding); | 6270 visitor->trace(m_framebufferBinding); |
6293 visitor->trace(m_renderbufferBinding); | 6271 visitor->trace(m_renderbufferBinding); |
6294 visitor->trace(m_valuebufferBinding); | 6272 visitor->trace(m_valuebufferBinding); |
6295 visitor->trace(m_textureUnits); | 6273 visitor->trace(m_textureUnits); |
6296 visitor->trace(m_extensions); | 6274 visitor->trace(m_extensions); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6334 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6312 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6335 } | 6313 } |
6336 | 6314 |
6337 void WebGLRenderingContextBase::restoreUnpackParameters() | 6315 void WebGLRenderingContextBase::restoreUnpackParameters() |
6338 { | 6316 { |
6339 if (m_unpackAlignment != 1) | 6317 if (m_unpackAlignment != 1) |
6340 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6318 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6341 } | 6319 } |
6342 | 6320 |
6343 } // namespace blink | 6321 } // namespace blink |
OLD | NEW |