summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-11 23:43:08 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-11 23:43:08 +0000
commit37a6f30b693c48d5d855f2f26633078d7947a892 (patch)
tree12679e8602a314b1e2511723761a53470ddd0692 /content
parent2d8a4eb0fd04bf7733d1db2e4ada3a4aacad46bb (diff)
downloadchromium_src-37a6f30b693c48d5d855f2f26633078d7947a892.zip
chromium_src-37a6f30b693c48d5d855f2f26633078d7947a892.tar.gz
chromium_src-37a6f30b693c48d5d855f2f26633078d7947a892.tar.bz2
Fix num_swapbuffers_complete_pending_ accounting.
Move the accounting into the context itself, which knows accurately when a swapbuffers is sent. This fixes issues with the GPU process dying while an active tab is in the background. BUG=chromium-os:16960 TEST=Go to youtube with Pepper Flash, switch to a different tab, kill GPU process, go to youtube tab, check that it still displays. Do it again twice. Review URL: http://codereview.chromium.org/7313033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc7
-rw-r--r--content/renderer/render_view.cc4
-rw-r--r--content/renderer/render_view.h3
-rw-r--r--content/renderer/render_widget.cc11
-rw-r--r--content/renderer/render_widget.h10
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc8
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.h1
7 files changed, 32 insertions, 12 deletions
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
index b4e0bf1..73153bc 100644
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
@@ -209,6 +209,10 @@ WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() {
void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
// Copies the contents of the off-screen render target into the texture
// used by the compositor.
+ RenderView* renderview =
+ web_view_ ? RenderView::FromWebView(web_view_) : NULL;
+ if (renderview)
+ renderview->OnViewContextSwapBuffersPosted();
context_->SwapBuffers();
}
@@ -1023,8 +1027,7 @@ void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() {
}
void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* cb)
-{
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
context_lost_callback_ = cb;
}
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index e6724b5..7082f29 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -3709,6 +3709,10 @@ void RenderView::DidFlushPaint() {
}
}
+void RenderView::OnViewContextSwapBuffersPosted() {
+ RenderWidget::OnSwapBuffersPosted();
+}
+
void RenderView::OnViewContextSwapBuffersComplete() {
RenderWidget::OnSwapBuffersComplete();
}
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 444d8555..0ef0805 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -201,7 +201,8 @@ class RenderView : public RenderWidget,
WebKit::WebView* webview() const;
// Called by a GraphicsContext associated with this view when swapbuffers
- // completes or is aborted.
+ // is posted, completes or is aborted.
+ void OnViewContextSwapBuffersPosted();
void OnViewContextSwapBuffersComplete();
void OnViewContextSwapBuffersAborted();
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 5cc8d73..4e2cae1 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -387,8 +387,13 @@ void RenderWidget::OnSwapBuffersAborted()
scheduleComposite();
}
-void RenderWidget::OnSwapBuffersComplete()
-{
+void RenderWidget::OnSwapBuffersPosted() {
+ TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
+ if (using_asynchronous_swapbuffers_)
+ num_swapbuffers_complete_pending_++;
+}
+
+void RenderWidget::OnSwapBuffersComplete() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
// When compositing deactivates, we reset the swapbuffers pending count. The
// swapbuffers acks may still arrive, however.
@@ -800,8 +805,6 @@ void RenderWidget::DoDeferredUpdate() {
} else { // Accelerated compositing path
// Begin painting.
webwidget_->composite(false);
- if (using_asynchronous_swapbuffers_)
- num_swapbuffers_complete_pending_++;
}
// sending an ack to browser process that the paint is complete...
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index e6c896f8..3bad78a 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -218,15 +218,17 @@ class RenderWidget : public IPC::Channel::Listener,
virtual void DidFlushPaint() {}
// Override and return true when the widget is rendered with a graphics
- // context that supports asynchronous swapbuffers. When returning true,
- // the subclass must call RenderWidget::OnSwapBuffersComplete() when
- // swaps complete, and OnSwapBuffersAborted if the context is lost.
+ // context that supports asynchronous swapbuffers. When returning true, the
+ // subclass must call OnSwapBuffersPosted() when swap is posted,
+ // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if
+ // the context is lost.
virtual bool SupportsAsynchronousSwapBuffers();
// Notifies scheduler that the RenderWidget's subclass has finished or aborted
// a swap buffers.
- void OnSwapBuffersAborted();
+ void OnSwapBuffersPosted();
void OnSwapBuffersComplete();
+ void OnSwapBuffersAborted();
// Detects if a suitable opaque plugin covers the given paint bounds with no
// compositing necessary.
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index 04f9c1c..ed4a5e8 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -90,7 +90,7 @@ class PepperWidget : public WebWidget {
unsigned int texture = plugin_->GetBackingTextureId();
gl->BindTexture(GL_TEXTURE_2D, texture);
gl->DrawArrays(GL_TRIANGLES, 0, 3);
- context->SwapBuffers();
+ widget_->SwapBuffers();
}
virtual void themeChanged() {
@@ -465,6 +465,12 @@ bool RenderWidgetFullscreenPepper::CheckCompositing() {
return compositing;
}
+void RenderWidgetFullscreenPepper::SwapBuffers() {
+ DCHECK(context_);
+ OnSwapBuffersPosted();
+ context_->SwapBuffers();
+}
+
void RenderWidgetFullscreenPepper::OnLostContext() {
if (!context_)
return;
diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h
index e83ca18..d22b418 100644
--- a/content/renderer/render_widget_fullscreen_pepper.h
+++ b/content/renderer/render_widget_fullscreen_pepper.h
@@ -39,6 +39,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen,
virtual webkit::ppapi::PluginDelegate::PlatformContext3D* CreateContext3D();
RendererGLContext* context() const { return context_; }
+ void SwapBuffers();
protected:
RenderWidgetFullscreenPepper(RenderThreadBase* render_thread,