summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 20:48:04 +0000
committerjamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 20:48:04 +0000
commitef82acffb8b94957e8a65e7f72adab39398f04f8 (patch)
treee35c84e013ad13355c3c37ccdc44e2ab50c2566c /content
parentcdccbc64763227c16bb9fd4c3a12c16de49cd366 (diff)
downloadchromium_src-ef82acffb8b94957e8a65e7f72adab39398f04f8.zip
chromium_src-ef82acffb8b94957e8a65e7f72adab39398f04f8.tar.gz
chromium_src-ef82acffb8b94957e8a65e7f72adab39398f04f8.tar.bz2
Merge 120490 - Provide WillInitiatePaint() as well as DidInitiatePaint() and tweak semantics.
WillInitiatePaint() informs derived classes when the RenderWidget is about to perform a paint operation. DidInitiatePaint() informs derived classes that the RenderWidget has finished the paint operation and sent it to the browser to display. DidFlushPaint() informs derived classes when the paint operation has actually been displayed (either in response to UpdateRectAck, or OnSwapBuffersComplete()). Pepper Graphics2D uses WillInitiatePaint and DidFlushPaint to trigger its Flush callback only for flushes occurring after the paint has actually been initiated. Pepper Graphics3D uses DidInitiatePaint to know when the 3D pipeline is done with buffers from the previous paint operation, so that new content rendered to them won't be prematurely flushed to the screen. Known issues with this CL: * There is still scope for the Graphics2D to get confused when threaded compositing is in use, since DidFlushPaint for an older paint may be received after WillInitiatePaint for a more recent one, but that is a fix for another CL. * Graphics3D will now be notified earlier in than it would have been in the software case, since it previously hooked DidFlushPaint. BUG=111639 TEST=Run Native Client Examples "Pi generator", "Tumbler" and "Fullscreen Tumbler" with and without --force-composite-mode and verify they update correctly. Review URL: http://codereview.chromium.org/9328016 TBR=wez@chromium.org Review URL: https://chromiumcodereview.appspot.com/9360027 git-svn-id: svn://svn.chromium.org/chrome/branches/1025/src@121038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc20
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.h4
-rw-r--r--content/renderer/render_view_impl.cc7
-rw-r--r--content/renderer/render_view_impl.h3
-rw-r--r--content/renderer/render_widget.cc21
-rw-r--r--content/renderer/render_widget.h12
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc4
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.h4
8 files changed, 53 insertions, 22 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index b736ef5..eda1108 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -996,18 +996,30 @@ bool PepperPluginDelegateImpl::StopWaitingForPpapiBrokerConnection(
return false;
}
-void PepperPluginDelegateImpl::ViewInitiatedPaint() {
+void PepperPluginDelegateImpl::ViewWillInitiatePaint() {
// Notify all of our instances that we started painting. This is used for
// internal bookkeeping only, so we know that the set can not change under
// us.
for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
active_instances_.begin();
i != active_instances_.end(); ++i)
- (*i)->ViewInitiatedPaint();
+ (*i)->ViewWillInitiatePaint();
+}
+
+void PepperPluginDelegateImpl::ViewInitiatedPaint() {
+ // Notify all instances that we painted. The same caveats apply as for
+ // ViewFlushedPaint regarding instances closing themselves, so we take
+ // similar precautions.
+ std::set<webkit::ppapi::PluginInstance*> plugins = active_instances_;
+ for (std::set<webkit::ppapi::PluginInstance*>::iterator i = plugins.begin();
+ i != plugins.end(); ++i) {
+ if (active_instances_.find(*i) != active_instances_.end())
+ (*i)->ViewInitiatedPaint();
+ }
}
void PepperPluginDelegateImpl::ViewFlushedPaint() {
- // Notify all instances that we painted. This will call into the plugin, and
+ // Notify all instances that we flushed. This will call into the plugin, and
// we it may ask to close itself as a result. This will, in turn, modify our
// set, possibly invalidating the iterator. So we iterate on a copy that
// won't change out from under us.
@@ -1028,7 +1040,7 @@ void PepperPluginDelegateImpl::ViewFlushedPaint() {
// What about the case where a new one is created in a callback at a new
// address and we don't issue the callback? We're still OK since this
// callback is used for flush callbacks and we could not have possibly
- // started a new paint (ViewInitiatedPaint) for the new plugin while
+ // started a new paint (ViewWillInitiatePaint) for the new plugin while
// processing a previous paint for an existing one.
if (active_instances_.find(*i) != active_instances_.end())
(*i)->ViewFlushedPaint();
diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h
index 22de0d5..1cba5eb 100644
--- a/content/renderer/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper_plugin_delegate_impl.h
@@ -151,7 +151,9 @@ class PepperPluginDelegateImpl
bool* pepper_plugin_was_registered);
// Called by RenderView to tell us about painting events, these two functions
- // just correspond to the DidInitiatePaint and DidFlushPaint in R.V..
+ // just correspond to the WillInitiatePaint, DidInitiatePaint and
+ // DidFlushPaint hooks in RenderView.
+ void ViewWillInitiatePaint();
void ViewInitiatedPaint();
void ViewFlushedPaint();
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index c8eb610..f4dc033 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4299,8 +4299,13 @@ void RenderViewImpl::OnResize(const gfx::Size& new_size,
RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen);
}
+void RenderViewImpl::WillInitiatePaint() {
+ // Notify the pepper plugins that we're about to paint.
+ pepper_delegate_.ViewWillInitiatePaint();
+}
+
void RenderViewImpl::DidInitiatePaint() {
- // Notify the pepper plugins that we started painting.
+ // Notify the pepper plugins that we've painted, and are waiting to flush.
pepper_delegate_.ViewInitiatedPaint();
}
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index b892a80..7602f26 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -623,7 +623,6 @@ class RenderViewImpl : public RenderWidget,
// Please do not add your stuff randomly to the end here. If there is an
// appropriate section, add it there. If not, there are some random functions
// nearer to the top you can add it to.
- virtual void DidFlushPaint() OVERRIDE;
// Cannot use std::set unfortunately since linked_ptr<> does not support
// operator<.
@@ -636,7 +635,9 @@ class RenderViewImpl : public RenderWidget,
virtual void OnResize(const gfx::Size& new_size,
const gfx::Rect& resizer_rect,
bool is_fullscreen) OVERRIDE;
+ virtual void WillInitiatePaint() OVERRIDE;
virtual void DidInitiatePaint() OVERRIDE;
+ virtual void DidFlushPaint() OVERRIDE;
virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
const gfx::Rect& paint_bounds,
TransportDIB** dib,
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 2895623..50b1b07 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -374,9 +374,8 @@ void RenderWidget::OnUpdateRectAck() {
return;
}
- // Notify subclasses.
- if (!is_accelerated_compositing_active_)
- DidFlushPaint();
+ // Notify subclasses that software rendering was flushed to the screen.
+ DidFlushPaint();
// Continue painting if necessary...
DoDeferredUpdateAndSendInputAck();
@@ -421,6 +420,10 @@ void RenderWidget::OnSwapBuffersPosted() {
void RenderWidget::OnSwapBuffersComplete() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
+
+ // Notify subclasses that composited rendering got flushed to the screen.
+ DidFlushPaint();
+
// When compositing deactivates, we reset the swapbuffers pending count. The
// swapbuffers acks may still arrive, however.
if (num_swapbuffers_complete_pending_ == 0) {
@@ -802,6 +805,9 @@ void RenderWidget::DoDeferredUpdate() {
gfx::Rect scroll_damage = update.GetScrollDamage();
gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
+ // Notify derived classes that we're about to initiate a paint.
+ WillInitiatePaint();
+
// A plugin may be able to do an optimized paint. First check this, in which
// case we can skip all of the bitmap generation and regular paint code.
// This optimization allows PPAPI plugins that declare themselves on top of
@@ -905,8 +911,9 @@ void RenderWidget::DoDeferredUpdate() {
UpdateTextInputState();
UpdateSelectionBounds();
- // Let derived classes know we've painted.
- DidInitiatePaint();
+ // If we're software rendering then we're done initiating the paint.
+ if (!is_accelerated_compositing_active_)
+ DidInitiatePaint();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1032,8 +1039,8 @@ void RenderWidget::didCommitAndDrawCompositorFrame() {
// Accelerated FPS tick for performance tests. See throughput_tests.cc.
// NOTE: Tests may break if this event is renamed or moved.
UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickGPU");
- // Notify subclasses.
- DidFlushPaint();
+ // Notify subclasses that we initiated the paint operation.
+ DidInitiatePaint();
}
void RenderWidget::didCompleteSwapBuffers() {
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 5c11923..3b072e8 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -233,10 +233,14 @@ class CONTENT_EXPORT RenderWidget
void OnSetTextDirection(WebKit::WebTextDirection direction);
void OnGetFPS();
- // Override point to notify derived classes that a paint has happened.
- // DidInitiatePaint happens when we've generated a new bitmap and sent it to
- // the browser. DidFlushPaint happens once we've received the ACK that the
- // screen has actually been updated.
+ // Override points to notify derived classes that a paint has happened.
+ // WillInitiatePaint happens when we're about to generate a new bitmap and
+ // send it to the browser. DidInitiatePaint happens when that has completed,
+ // and subsequent rendering won't affect the painted content. DidFlushPaint
+ // happens once we've received the ACK that the screen has been updated.
+ // For a given paint operation, these overrides will always be called in the
+ // order WillInitiatePaint, DidInitiatePaint, DidFlushPaint.
+ virtual void WillInitiatePaint() {}
virtual void DidInitiatePaint() {}
virtual void DidFlushPaint() {}
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index 919cccc..35c9437e 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -284,9 +284,9 @@ RenderWidgetFullscreenPepper::CreateContext3D() {
#endif
}
-void RenderWidgetFullscreenPepper::DidInitiatePaint() {
+void RenderWidgetFullscreenPepper::WillInitiatePaint() {
if (plugin_)
- plugin_->ViewInitiatedPaint();
+ plugin_->ViewWillInitiatePaint();
}
void RenderWidgetFullscreenPepper::DidFlushPaint() {
diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h
index 75e1fea..9179668 100644
--- a/content/renderer/render_widget_fullscreen_pepper.h
+++ b/content/renderer/render_widget_fullscreen_pepper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -53,7 +53,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen,
virtual ~RenderWidgetFullscreenPepper();
// RenderWidget API.
- virtual void DidInitiatePaint() OVERRIDE;
+ virtual void WillInitiatePaint() OVERRIDE;
virtual void DidFlushPaint() OVERRIDE;
virtual void Close() OVERRIDE;
virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(