<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180609] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180609">180609</a></dd>
<dt>Author</dt> <dd>roger_fong@apple.com</dd>
<dt>Date</dt> <dd>2015-02-24 20:19:30 -0800 (Tue, 24 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebGL: Destroy the GLContext if a GPU restart has been detected.
https://bugs.webkit.org/show_bug.cgi?id=141567.
<rdar://problem/18507496>
Reviewed by Dean Jackson.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::setWebGLContext):
Keep track of which WebGLRenderingContext is associated with the current GraphicsContext3D.
* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::GraphicsContext3D::checkGPUStatusIfNecessary): Helper method to check GPU status.
(WebCore::GraphicsContext3D::GraphicsContext3D):
Don’t immediately abort the GPU process when the restart status is kCGLCPGPURestartStatusBlacklisted.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::forceContextLost):
Force the WebGLRenderingContext to be lost.
(WebCore::GraphicsContext3D::drawArrays): Check GPU status after calling drawArrays.
(WebCore::GraphicsContext3D::drawElements): Check GPU status after calling drawElements.
* WebCore.xcodeproj/project.pbxproj: Add SPI header for iOS.
* platform/spi/ios/OpenGLESSPI.h: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicseflGraphicsContext3DEflcpp">trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacGraphicsContext3DMacmm">trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp">trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsContext3DWincpp">trunk/Source/WebCore/platform/graphics/win/GraphicsContext3DWin.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformspiiosOpenGLESSPIh">trunk/Source/WebCore/platform/spi/ios/OpenGLESSPI.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/ChangeLog        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-02-19 Roger Fong <roger_fong@apple.com>
+
+ WebGL: Destroy the GLContext if a GPU restart has been detected.
+ https://bugs.webkit.org/show_bug.cgi?id=141567.
+ <rdar://problem/18507496>
+
+ Reviewed by Dean Jackson.
+
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+ * platform/graphics/GraphicsContext3D.h:
+ (WebCore::GraphicsContext3D::setWebGLContext):
+ Keep track of which WebGLRenderingContext is associated with the current GraphicsContext3D.
+ * platform/graphics/mac/GraphicsContext3DMac.mm:
+ (WebCore::GraphicsContext3D::checkGPUStatusIfNecessary): Helper method to check GPU status.
+ (WebCore::GraphicsContext3D::GraphicsContext3D):
+ Don’t immediately abort the GPU process when the restart status is kCGLCPGPURestartStatusBlacklisted.
+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+ (WebCore::GraphicsContext3D::forceContextLost):
+ Force the WebGLRenderingContext to be lost.
+ (WebCore::GraphicsContext3D::drawArrays): Check GPU status after calling drawArrays.
+ (WebCore::GraphicsContext3D::drawElements): Check GPU status after calling drawElements.
+ * WebCore.xcodeproj/project.pbxproj: Add SPI header for iOS.
+ * platform/spi/ios/OpenGLESSPI.h: Added.
+
</ins><span class="cx"> 2015-02-24 Stephanie Lewis <slewis@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed ios build fix after http://trac.webkit.org/changeset/180602.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -9498,6 +9498,7 @@
</span><span class="cx">                 6F995A2E1A70833700A735F4 /* JSWebGLTransformFeedback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLTransformFeedback.h; sourceTree = "<group>"; };
</span><span class="cx">                 6F995A2F1A70833700A735F4 /* JSWebGLVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObject.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
</span><ins>+                6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OpenGLESSPI.h; path = ios/OpenGLESSPI.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7117445614BC34E200EE5FC8 /* SVGTextMetricsBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextMetricsBuilder.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7117445714BC34E200EE5FC8 /* SVGTextMetricsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextMetricsBuilder.h; sourceTree = "<group>"; };
</span><span class="cx">                 7118FED215685CC60030B79A /* JSSVGViewSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGViewSpec.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -18570,6 +18571,7 @@
</span><span class="cx">                                 CE1252481A16C3BC00864480 /* MobileGestaltSPI.h */,
</span><span class="cx">                                 CE1252401A16B1B600864480 /* MediaPlayerSPI.h */,
</span><span class="cx">                                 CE1252381A166FA000864480 /* QuickLookSPI.h */,
</span><ins>+                                6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = ios;
</span><span class="cx">                         sourceTree = "<group>";
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -463,6 +463,8 @@
</span><span class="cx"> ASSERT(m_context);
</span><span class="cx"> m_contextGroup = WebGLContextGroup::create();
</span><span class="cx"> m_contextGroup->addContext(this);
</span><ins>+
+ m_context->setWebGLContext(this);
</ins><span class="cx">
</span><span class="cx"> m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
</span><span class="cx"> m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDims);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> class ImageData;
</span><span class="cx"> class IntRect;
</span><span class="cx"> class IntSize;
</span><ins>+class WebGLRenderingContextBase;
</ins><span class="cx"> #if USE(CAIRO)
</span><span class="cx"> class PlatformContextCairo;
</span><span class="cx"> #endif
</span><span class="lines">@@ -780,6 +781,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool makeContextCurrent();
</span><ins>+ void setWebGLContext(WebGLRenderingContextBase* base) { m_webglContext = base; }
</ins><span class="cx">
</span><span class="cx"> // With multisampling on, blit from multisampleFBO to regular FBO.
</span><span class="cx"> void prepareTexture();
</span><span class="lines">@@ -1128,6 +1130,7 @@
</span><span class="cx"> void markContextChanged();
</span><span class="cx"> void markLayerComposited();
</span><span class="cx"> bool layerComposited() const;
</span><ins>+ void forceContextLost();
</ins><span class="cx">
</span><span class="cx"> void paintRenderingResultsToCanvas(ImageBuffer*, DrawingBuffer*);
</span><span class="cx"> PassRefPtr<ImageData> paintRenderingResultsToImageData(DrawingBuffer*);
</span><span class="lines">@@ -1256,6 +1259,7 @@
</span><span class="cx"> private:
</span><span class="cx"> GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
</span><span class="cx"> static int numActiveContexts;
</span><ins>+ static int GPUCheckCounter;
</ins><span class="cx">
</span><span class="cx"> // Helper for packImageData/extractImageData/extractTextureData which implement packing of pixel
</span><span class="cx"> // data into the specified OpenGL destination format and type.
</span><span class="lines">@@ -1270,6 +1274,9 @@
</span><span class="cx"> // implementation.
</span><span class="cx"> void validateDepthStencil(const char* packedDepthStencilExtension);
</span><span class="cx"> void validateAttributes();
</span><ins>+
+ // Call to make during draw calls to check on the GPU's status.
+ void checkGPUStatusIfNecessary();
</ins><span class="cx">
</span><span class="cx"> // Read rendering results into a pixel array with the same format as the
</span><span class="cx"> // backbuffer.
</span><span class="lines">@@ -1438,6 +1445,8 @@
</span><span class="cx">
</span><span class="cx"> friend class GraphicsContext3DPrivate;
</span><span class="cx"> std::unique_ptr<GraphicsContext3DPrivate> m_private;
</span><ins>+
+ WebGLRenderingContextBase* m_webglContext;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -282,6 +282,10 @@
</span><span class="cx"> return m_private->makeContextCurrent();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void GraphicsContext3D::checkGPUStatusIfNecessary()
+{
+}
+
</ins><span class="cx"> PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
</span><span class="cx"> {
</span><span class="cx"> return m_private->platformContext();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicseflGraphicsContext3DEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -183,6 +183,10 @@
</span><span class="cx"> return m_private->makeContextCurrent();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void GraphicsContext3D::checkGPUStatusIfNecessary()
+{
+}
+
</ins><span class="cx"> bool GraphicsContext3D::isGLES2Compliant() const
</span><span class="cx"> {
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacGraphicsContext3DMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #include "HTMLCanvasElement.h"
</span><span class="cx"> #include "ImageBuffer.h"
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+#import "OpenGLESSPI.h"
</ins><span class="cx"> #import <OpenGLES/ES2/glext.h>
</span><span class="cx"> #import <OpenGLES/EAGL.h>
</span><span class="cx"> #import <OpenGLES/EAGLDrawable.h>
</span><span class="lines">@@ -52,6 +53,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #include "WebGLLayer.h"
</span><span class="cx"> #include "WebGLObject.h"
</span><ins>+#include "WebGLRenderingContextBase.h"
</ins><span class="cx"> #include <runtime/ArrayBuffer.h>
</span><span class="cx"> #include <runtime/ArrayBufferView.h>
</span><span class="cx"> #include <runtime/Int32Array.h>
</span><span class="lines">@@ -63,7 +65,9 @@
</span><span class="cx">
</span><span class="cx"> const int maxActiveContexts = 64;
</span><span class="cx"> int GraphicsContext3D::numActiveContexts = 0;
</span><del>-
</del><ins>+const int GPUStatusCheckThreshold = 5;
+int GraphicsContext3D::GPUCheckCounter = 0;
+
</ins><span class="cx"> // FIXME: This class is currently empty on Mac, but will get populated as
</span><span class="cx"> // the restructuring in https://bugs.webkit.org/show_bug.cgi?id=66903 is done
</span><span class="cx"> class GraphicsContext3DPrivate {
</span><span class="lines">@@ -145,6 +149,7 @@
</span><span class="cx"> , m_multisampleDepthStencilBuffer(0)
</span><span class="cx"> , m_multisampleColorBuffer(0)
</span><span class="cx"> , m_private(std::make_unique<GraphicsContext3DPrivate>(this))
</span><ins>+ , m_webglContext(0)
</ins><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(hostWindow);
</span><span class="cx"> UNUSED_PARAM(renderStyle);
</span><span class="lines">@@ -196,6 +201,15 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> CGLError err = CGLCreateContext(pixelFormatObj, 0, &m_contextObj);
</span><ins>+#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || PLATFORM(IOS))
+ GLint abortOnBlacklist = 0;
+#if PLATFORM(MAC)
+ CGLSetParameter(m_contextObj, kCGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
+#elif PLATFORM(IOS)
+ CGLSetParameter(m_contextObj, kEAGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
+#endif
+#endif
+
</ins><span class="cx"> CGLDestroyPixelFormat(pixelFormatObj);
</span><span class="cx">
</span><span class="cx"> if (err != kCGLNoError || !m_contextObj) {
</span><span class="lines">@@ -353,6 +367,33 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void GraphicsContext3D::checkGPUStatusIfNecessary()
+{
+#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || PLATFORM(IOS))
+ GPUCheckCounter = (GPUCheckCounter + 1) % GPUStatusCheckThreshold;
+ if (GPUCheckCounter)
+ return;
+#if PLATFORM(MAC)
+ GLint restartStatus = 0;
+ CGLGetParameter(platformGraphicsContext3D(), kCGLCPGPURestartStatus, &restartStatus);
+ if (restartStatus == kCGLCPGPURestartStatusCaused || restartStatus == kCGLCPGPURestartStatusBlacklisted) {
+ CGLSetCurrentContext(0);
+ CGLDestroyContext(platformGraphicsContext3D());
+ forceContextLost();
+ }
+#elif PLATFORM(IOS)
+ GLint restartStatus = 0;
+ EAGLContext* currentContext = static_cast<EAGLContext*>(PlatformGraphicsContext3D());
+ [currentContext getParameter:kEAGLCPGPURestartStatus to:&restartStatus];
+ if (restartStatus == kEAGLCPGPURestartStatusCaused || restartStatus == kEAGLCPGPURestartStatusBlacklisted) {
+ [EAGLContext setCurrentContext:0];
+ [static_cast<EAGLContext*>(currentContext) release];
+ forceContextLost();
+ }
+#endif
+#endif
+}
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> void GraphicsContext3D::endPaint()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> #include "IntSize.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "TemporaryOpenGLSetting.h"
</span><ins>+#include "WebGLRenderingContextBase.h"
</ins><span class="cx"> #include <cstring>
</span><span class="cx"> #include <runtime/ArrayBuffer.h>
</span><span class="cx"> #include <runtime/ArrayBufferView.h>
</span><span class="lines">@@ -75,6 +76,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> static ShaderNameHash* currentNameHashMapForShader = nullptr;
</span><span class="lines">@@ -683,12 +685,14 @@
</span><span class="cx"> {
</span><span class="cx"> makeContextCurrent();
</span><span class="cx"> ::glDrawArrays(mode, first, count);
</span><ins>+ checkGPUStatusIfNecessary();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset)
</span><span class="cx"> {
</span><span class="cx"> makeContextCurrent();
</span><span class="cx"> ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
</span><ins>+ checkGPUStatusIfNecessary();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void GraphicsContext3D::enable(GC3Denum cap)
</span><span class="lines">@@ -1763,6 +1767,12 @@
</span><span class="cx"> return m_layerComposited;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void GraphicsContext3D::forceContextLost()
+{
+ if (m_webglContext)
+ m_webglContext->forceLostContext(WebGLRenderingContextBase::RealLostContext);
+}
+
</ins><span class="cx"> void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
</span><span class="cx"> {
</span><span class="cx"> makeContextCurrent();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsContext3DWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsContext3DWin.cpp (180608 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsContext3DWin.cpp        2015-02-25 04:10:54 UTC (rev 180608)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsContext3DWin.cpp        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -178,6 +178,10 @@
</span><span class="cx"> return m_private->makeContextCurrent();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void GraphicsContext3D::checkGPUStatusIfNecessary()
+{
+}
+
</ins><span class="cx"> PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
</span><span class="cx"> {
</span><span class="cx"> return m_private->platformContext();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspiiosOpenGLESSPIh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/spi/ios/OpenGLESSPI.h (0 => 180609)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/ios/OpenGLESSPI.h         (rev 0)
+++ trunk/Source/WebCore/platform/spi/ios/OpenGLESSPI.h        2015-02-25 04:19:30 UTC (rev 180609)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <OpenGLES/EAGLPrivate.h>
+
+#else
+
+typedef uint32_t EAGLContextParameter;
+
+enum {
+ kEAGLCPGPURestartStatusNone = 0, /* context has not caused recent GPU restart */
+ kEAGLCPGPURestartStatusCaused = 1, /* context caused recent GPU restart (clear on query) */
+ kEAGLCPGPURestartStatusBlacklisted = 2, /* context is being ignored for excessive GPU restarts */
+};
+
+/* (read-only) context caused GPU hang/crash, requiring a restart (see EAGLGPGPURestartStatus) */
+#define kEAGLCPGPURestartStatus ((EAGLContextParameter)317)
+/* (read-write) how to react to being blacklisted for causing excessive restarts (default to 1) */
+#define kEAGLCPAbortOnGPURestartStatusBlacklisted ((EAGLContextParameter)318)
+/* (read-only) does driver support auto-restart of GPU on hang/crash? */
+#define kEAGLCPSupportGPURestart ((EAGLContextParameter)319)
+/* (read-only) does driver/GPU support separate address space per context? */
+#define kEAGLCPSupportSeparateAddressSpace ((EAGLContextParameter)320)
+
+@interface EAGLContext (EAGLPrivate)
+- (NSUInteger)setParameter:(EAGLContextParameter)pname to:(int32_t *)params;
+- (NSUInteger)getParameter:(EAGLContextParameter)pname to:(int32_t *)params;
+@end
+#endif
</ins></span></pre>
</div>
</div>
</body>
</html>