[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 18:06:18 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ea763926fe4e65dd275f7bffdb0fd7e345c47a77
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 7 04:24:25 2010 +0000
2010-12-06 Alexey Marinichev <amarinichev at chromium.org>
Reviewed by Kenneth Russell.
Throw webglcontextlost and webglcontextrestored events when a WebGL context is lost and restored.
https://bugs.webkit.org/show_bug.cgi?id=50364
No new tests since there is currently no way to force a context lost event.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
(WebCore::WebGLRenderingContext::create):
(WebCore::WebGLRenderingContext::WebGLRenderingContext):
(WebCore::WebGLRenderingContext::isContextLost):
(WebCore::WebGLRenderingContext::loseContext):
(WebCore::WebGLRenderingContext::restoreContext):
* html/canvas/WebGLRenderingContext.h:
(WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::WebGLRenderingContextRestoreTimer):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73424 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f6dd548..76d4bc7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-06 Alexey Marinichev <amarinichev at chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ Throw webglcontextlost and webglcontextrestored events when a WebGL context is lost and restored.
+ https://bugs.webkit.org/show_bug.cgi?id=50364
+
+ No new tests since there is currently no way to force a context lost event.
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
+ (WebCore::WebGLRenderingContext::create):
+ (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+ (WebCore::WebGLRenderingContext::isContextLost):
+ (WebCore::WebGLRenderingContext::loseContext):
+ (WebCore::WebGLRenderingContext::restoreContext):
+ * html/canvas/WebGLRenderingContext.h:
+ (WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::WebGLRenderingContextRestoreTimer):
+
2010-12-06 David Hyatt <hyatt at apple.com>
Reviewed by Simon Fraser.
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 8cd46a3..90e8833 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -62,6 +62,8 @@
namespace WebCore {
+const double secondsBetweenRestoreAttempts = 1.0;
+
static inline Platform3DObject objectOrZero(WebGLObject* object)
{
return object ? object->object() : 0;
@@ -86,25 +88,49 @@ private:
bool m_changed;
};
+void WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired()
+{
+ // Timer is started when m_contextLost is false. It will first call
+ // loseContext, which will set m_contextLost to true. Then it will keep
+ // calling restoreContext and reschedule itself until m_contextLost is back
+ // to false.
+ if (!m_context->m_contextLost) {
+ m_context->loseContext();
+ startOneShot(secondsBetweenRestoreAttempts);
+ } else {
+ // The rendering context is not restored if there is no handler for
+ // the context restored event.
+ if (!m_context->canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent))
+ return;
+
+ m_context->restoreContext();
+ if (m_context->m_contextLost)
+ startOneShot(secondsBetweenRestoreAttempts);
+ }
+}
+
PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs)
{
HostWindow* hostWindow = canvas->document()->view()->root()->hostWindow();
- GraphicsContext3D::Attributes emptyAttributes;
- RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs ? attrs->attributes() : emptyAttributes, hostWindow));
+ GraphicsContext3D::Attributes attributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
+ RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attributes, hostWindow));
if (!context) {
canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context."));
return 0;
}
- return new WebGLRenderingContext(canvas, context);
+ return new WebGLRenderingContext(canvas, context, attributes);
}
-WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context)
+WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context,
+ GraphicsContext3D::Attributes attributes)
: CanvasRenderingContext(passedCanvas)
, m_context(context)
+ , m_restoreTimer(this)
, m_videoCache(4)
, m_contextLost(false)
+ , m_attributes(attributes)
{
ASSERT(m_context);
setupFlags();
@@ -2092,8 +2118,16 @@ bool WebGLRenderingContext::isBuffer(WebGLBuffer* buffer)
return m_context->isBuffer(buffer->object());
}
-bool WebGLRenderingContext::isContextLost() const
+bool WebGLRenderingContext::isContextLost()
{
+ if (m_restoreTimer.isActive())
+ return true;
+
+ bool newContextLost = m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
+
+ if (newContextLost != m_contextLost)
+ m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts);
+
return m_contextLost;
}
@@ -3247,9 +3281,6 @@ void WebGLRenderingContext::viewport(long x, long y, unsigned long width, unsign
void WebGLRenderingContext::loseContext()
{
- if (isContextLost())
- return;
-
m_contextLost = true;
detachAndRemoveAllObjects();
@@ -3269,17 +3300,13 @@ void WebGLRenderingContext::loseContext()
void WebGLRenderingContext::restoreContext()
{
- if (!isContextLost())
+ RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes, canvas()->document()->view()->root()->hostWindow()));
+ if (!context)
return;
- // The rendering context is not restored if there is no handler for
- // the context restored event.
- if (!canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent))
- return;
-
- m_contextLost = false;
+ m_context = context;
initializeNewContext();
-
+ m_contextLost = false;
canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, ""));
}
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index 950d704..a94d4bd 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -32,6 +32,7 @@
#include "GraphicsContext3D.h"
#include "Int32Array.h"
#include "PlatformString.h"
+#include "Timer.h"
#include "Uint8Array.h"
#include "WebGLGetInfo.h"
@@ -175,7 +176,7 @@ public:
void hint(unsigned long target, unsigned long mode);
bool isBuffer(WebGLBuffer*);
- bool isContextLost() const;
+ bool isContextLost();
bool isEnabled(unsigned long cap);
bool isFramebuffer(WebGLFramebuffer*);
bool isProgram(WebGLProgram*);
@@ -294,7 +295,7 @@ public:
private:
friend class WebGLObject;
- WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>);
+ WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes);
void initializeNewContext();
void setupFlags();
@@ -343,6 +344,17 @@ public:
PassRefPtr<Image> videoFrameToImage(HTMLVideoElement* video);
RefPtr<GraphicsContext3D> m_context;
+
+ class WebGLRenderingContextRestoreTimer : public TimerBase {
+ public:
+ WebGLRenderingContextRestoreTimer(WebGLRenderingContext* context) : m_context(context) { }
+ private:
+ virtual void fired();
+ WebGLRenderingContext* m_context;
+ };
+
+ WebGLRenderingContextRestoreTimer m_restoreTimer;
+
bool m_needsUpdate;
bool m_markedCanvasDirty;
HashSet<RefPtr<WebGLObject> > m_canvasObjects;
@@ -431,6 +443,7 @@ public:
bool m_unpackPremultiplyAlpha;
unsigned long m_unpackColorspaceConversion;
bool m_contextLost;
+ GraphicsContext3D::Attributes m_attributes;
long m_stencilBits;
unsigned long m_stencilMask;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list