summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-05-21 16:53:46 +0100
committerKristian Monsen <kristianm@google.com>2010-05-25 10:24:15 +0100
commit6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch)
treef7111b9b22befab472616c1d50ec94eb50f1ec8c /WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
parenta149172322a9067c14e8b474a53e63649aa17cad (diff)
downloadexternal_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp')
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp53
1 files changed, 47 insertions, 6 deletions
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
index 714a4ac..994d079 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
@@ -231,6 +231,7 @@ WKCACFLayerRenderer::WKCACFLayerRenderer()
, m_scrollPosition(0, 0)
, m_scrollSize(1, 1)
, m_backingStoreDirty(false)
+ , m_mustResetLostDeviceBeforeRendering(false)
{
#ifndef NDEBUG
char* printTreeFlag = getenv("CA_PRINT_TREE");
@@ -422,7 +423,9 @@ void WKCACFLayerRenderer::resize()
if (!m_d3dDevice)
return;
- resetDevice();
+ // Resetting the device might fail here. But that's OK, because if it does it we will attempt to
+ // reset the device the next time we try to render.
+ resetDevice(ChangedWindowSize);
if (m_rootLayer) {
m_rootLayer->setFrame(bounds());
@@ -491,6 +494,12 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)
{
ASSERT(m_d3dDevice);
+ if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
+ // We can't reset the device right now. Try again soon.
+ renderSoon();
+ return;
+ }
+
// Flush the root layer to the render tree.
WKCACFContextFlusher::shared().flushAllContexts();
@@ -547,10 +556,12 @@ void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)
err = m_d3dDevice->Present(0, 0, 0, 0);
if (err == D3DERR_DEVICELOST) {
- // Lost device situation.
- CARenderOGLPurge(m_renderer);
- resetDevice();
CARenderUpdateAddRect(u, &bounds);
+ if (!resetDevice(LostDevice)) {
+ // We can't reset the device right now. Try again soon.
+ renderSoon();
+ return;
+ }
}
} while (err == D3DERR_DEVICELOST);
@@ -593,13 +604,43 @@ void WKCACFLayerRenderer::initD3DGeometry()
m_d3dDevice->SetTransform(D3DTS_PROJECTION, &projection);
}
-void WKCACFLayerRenderer::resetDevice()
+bool WKCACFLayerRenderer::resetDevice(ResetReason reason)
{
ASSERT(m_d3dDevice);
+ ASSERT(m_renderContext);
+
+ HRESULT hr = m_d3dDevice->TestCooperativeLevel();
+
+ if (hr == D3DERR_DEVICELOST || hr == D3DERR_DRIVERINTERNALERROR) {
+ // The device cannot be reset at this time. Try again soon.
+ m_mustResetLostDeviceBeforeRendering = true;
+ return false;
+ }
+
+ m_mustResetLostDeviceBeforeRendering = false;
+
+ if (reason == LostDevice && hr == D3D_OK) {
+ // The device wasn't lost after all.
+ return true;
+ }
+
+ // We can reset the device.
+
+ // We have to purge the CARenderOGLContext whenever we reset the IDirect3DDevice9 in order to
+ // destroy any D3DPOOL_DEFAULT resources that Core Animation has allocated (e.g., textures used
+ // for mask layers). See <http://msdn.microsoft.com/en-us/library/bb174425(v=VS.85).aspx>.
+ CARenderOGLPurge(m_renderer);
D3DPRESENT_PARAMETERS parameters = initialPresentationParameters();
- m_d3dDevice->Reset(&parameters);
+ hr = m_d3dDevice->Reset(&parameters);
+
+ // TestCooperativeLevel told us the device may be reset now, so we should
+ // not be told here that the device is lost.
+ ASSERT(hr != D3DERR_DEVICELOST);
+
initD3DGeometry();
+
+ return true;
}
}