| 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 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure(WTF::b
ind(&WebGLRenderingContextBase::forceLostContext, createWeakThisPointer(), WebGL
RenderingContextBase::RealLostContext, WebGLRenderingContextBase::Auto))); |
| 1000 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 978 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| 1001 | 979 |
| 1002 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. | 980 // 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(); | 981 contextGL()->Flush(); |
| 1004 | 982 |
| 1005 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 983 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 1006 m_extensionEnabled[i] = false; | 984 m_extensionEnabled[i] = false; |
| 1007 | 985 |
| 1008 m_isWebGL2FormatsTypesAdded = false; | 986 m_isWebGL2FormatsTypesAdded = false; |
| 1009 m_isWebGL2InternalFormatsCopyTexImageAdded = false; | 987 m_isWebGL2InternalFormatsCopyTexImageAdded = false; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 willDestroyContext(this); | 1083 willDestroyContext(this); |
| 1106 } | 1084 } |
| 1107 | 1085 |
| 1108 void WebGLRenderingContextBase::destroyContext() | 1086 void WebGLRenderingContextBase::destroyContext() |
| 1109 { | 1087 { |
| 1110 if (!drawingBuffer()) | 1088 if (!drawingBuffer()) |
| 1111 return; | 1089 return; |
| 1112 | 1090 |
| 1113 m_extensionsUtil.clear(); | 1091 m_extensionsUtil.clear(); |
| 1114 | 1092 |
| 1115 webContext()->setContextLostCallback(nullptr); | 1093 drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); |
| 1116 webContext()->setErrorMessageCallback(nullptr); | 1094 webContext()->setErrorMessageCallback(nullptr); |
| 1117 | 1095 |
| 1118 ASSERT(drawingBuffer()); | 1096 ASSERT(drawingBuffer()); |
| 1119 m_drawingBuffer->beginDestruction(); | 1097 m_drawingBuffer->beginDestruction(); |
| 1120 m_drawingBuffer.clear(); | 1098 m_drawingBuffer.clear(); |
| 1121 } | 1099 } |
| 1122 | 1100 |
| 1123 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) | 1101 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) |
| 1124 { | 1102 { |
| 1125 if (m_framebufferBinding || isContextLost()) | 1103 if (m_framebufferBinding || isContextLost()) |
| (...skipping 5150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6276 visitor->trace(m_textureCubeMapBinding); | 6254 visitor->trace(m_textureCubeMapBinding); |
| 6277 visitor->trace(m_texture3DBinding); | 6255 visitor->trace(m_texture3DBinding); |
| 6278 visitor->trace(m_texture2DArrayBinding); | 6256 visitor->trace(m_texture2DArrayBinding); |
| 6279 } | 6257 } |
| 6280 | 6258 |
| 6281 DEFINE_TRACE(WebGLRenderingContextBase) | 6259 DEFINE_TRACE(WebGLRenderingContextBase) |
| 6282 { | 6260 { |
| 6283 #if ENABLE(OILPAN) | 6261 #if ENABLE(OILPAN) |
| 6284 visitor->trace(m_contextObjects); | 6262 visitor->trace(m_contextObjects); |
| 6285 #endif | 6263 #endif |
| 6286 visitor->trace(m_contextLostCallbackAdapter); | |
| 6287 visitor->trace(m_errorMessageCallbackAdapter); | 6264 visitor->trace(m_errorMessageCallbackAdapter); |
| 6288 visitor->trace(m_boundArrayBuffer); | 6265 visitor->trace(m_boundArrayBuffer); |
| 6289 visitor->trace(m_defaultVertexArrayObject); | 6266 visitor->trace(m_defaultVertexArrayObject); |
| 6290 visitor->trace(m_boundVertexArrayObject); | 6267 visitor->trace(m_boundVertexArrayObject); |
| 6291 visitor->trace(m_currentProgram); | 6268 visitor->trace(m_currentProgram); |
| 6292 visitor->trace(m_framebufferBinding); | 6269 visitor->trace(m_framebufferBinding); |
| 6293 visitor->trace(m_renderbufferBinding); | 6270 visitor->trace(m_renderbufferBinding); |
| 6294 visitor->trace(m_valuebufferBinding); | 6271 visitor->trace(m_valuebufferBinding); |
| 6295 visitor->trace(m_textureUnits); | 6272 visitor->trace(m_textureUnits); |
| 6296 visitor->trace(m_extensions); | 6273 visitor->trace(m_extensions); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6334 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6311 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6335 } | 6312 } |
| 6336 | 6313 |
| 6337 void WebGLRenderingContextBase::restoreUnpackParameters() | 6314 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6338 { | 6315 { |
| 6339 if (m_unpackAlignment != 1) | 6316 if (m_unpackAlignment != 1) |
| 6340 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6317 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6341 } | 6318 } |
| 6342 | 6319 |
| 6343 } // namespace blink | 6320 } // namespace blink |
| OLD | NEW |