Skip to content

Commit

Permalink
Disable force compositing mode when disabling compositing, re-enter i…
Browse files Browse the repository at this point in the history
…n DoDeferredUpdate

BUG=152355


Review URL: https://chromiumcodereview.appspot.com/11264058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164708 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jamesr@chromium.org committed Oct 29, 2012
1 parent 7bf13b9 commit 479b017
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
4 changes: 4 additions & 0 deletions content/renderer/render_view_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5697,6 +5697,10 @@ bool RenderViewImpl::SupportsAsynchronousSwapBuffers() {
return true;
}

bool RenderViewImpl::ForceCompositingModeEnabled() {
return webkit_preferences_.force_compositing_mode;
}

void RenderViewImpl::OnSetFocus(bool enable) {
RenderWidget::OnSetFocus(enable);

Expand Down
1 change: 1 addition & 0 deletions content/renderer/render_view_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ class RenderViewImpl : public RenderWidget,
virtual void OnWasHidden() OVERRIDE;
virtual void OnWasShown(bool needs_repainting) OVERRIDE;
virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
virtual bool ForceCompositingModeEnabled() OVERRIDE;
virtual void OnImeSetComposition(
const string16& text,
const std::vector<WebKit::WebCompositionUnderline>& underlines,
Expand Down
30 changes: 26 additions & 4 deletions content/renderer/render_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "build/build_config.h"
#include "content/common/swapped_out_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/compositor_util.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/render_process.h"
#include "content/renderer/render_thread_impl.h"
Expand Down Expand Up @@ -206,10 +207,11 @@ void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) {
host_window_ = parent_hwnd;
host_window_set_ = true;

#if WEBWIDGET_HAS_SETCOMPOSITORSURFACEREADY
if (webwidget_)
webwidget_->setCompositorSurfaceReady();
#endif
if (webwidget_) {
webwidget_->setCompositorSurfaceReady();
if (IsThreadedCompositingEnabled())
webwidget_->enterForceCompositingMode(true);
}
DoDeferredUpdate();

Send(new ViewHostMsg_RenderViewReady(routing_id_));
Expand Down Expand Up @@ -466,6 +468,10 @@ bool RenderWidget::SupportsAsynchronousSwapBuffers() {
return false;
}

bool RenderWidget::ForceCompositingModeEnabled() {
return false;
}

void RenderWidget::OnSwapBuffersAborted() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
while (!updates_pending_swap_.empty()) {
Expand Down Expand Up @@ -903,6 +909,12 @@ void RenderWidget::DoDeferredUpdate() {
return;
}

if (!is_accelerated_compositing_active_ &&
!IsThreadedCompositingEnabled() &&
ForceCompositingModeEnabled()) {
webwidget_->enterForceCompositingMode(true);
}

if (!last_do_deferred_update_time_.is_null()) {
base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
if (is_accelerated_compositing_active_) {
Expand Down Expand Up @@ -1063,6 +1075,8 @@ void RenderWidget::DoDeferredUpdate() {
// WebWidgetClient

void RenderWidget::didInvalidateRect(const WebRect& rect) {
TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
"width", rect.width, "height", rect.height);
// The invalidated rect might be outside the bounds of the view.
gfx::Rect view_rect(size_);
gfx::Rect damaged_rect = view_rect;
Expand Down Expand Up @@ -1178,6 +1192,13 @@ void RenderWidget::didDeactivateCompositor() {

if (using_asynchronous_swapbuffers_)
using_asynchronous_swapbuffers_ = false;

// In single-threaded mode, we exit force compositing mode and re-enter in
// DoDeferredUpdate() if appropriate. In threaded compositing mode,
// DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
// entering force compositing mode at the appropriate times.
if (!IsThreadedCompositingEnabled())
webwidget_->enterForceCompositingMode(false);
}

void RenderWidget::willBeginCompositorFrame() {
Expand Down Expand Up @@ -1238,6 +1259,7 @@ void RenderWidget::didCompleteSwapBuffers() {
}

void RenderWidget::scheduleComposite() {
TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite");
if (WebWidgetHandlesCompositorScheduling()) {
webwidget_->composite(false);
} else {
Expand Down
2 changes: 2 additions & 0 deletions content/renderer/render_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class CONTENT_EXPORT RenderWidget
// the context is lost.
virtual bool SupportsAsynchronousSwapBuffers();

virtual bool ForceCompositingModeEnabled();

// Notifies scheduler that the RenderWidget's subclass has finished or aborted
// a swap buffers.
void OnSwapBuffersPosted();
Expand Down
3 changes: 0 additions & 3 deletions webkit/glue/webpreferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ void WebPreferences::Apply(WebView* web_view) const {
// Enable gpu-accelerated compositing if requested on the command line.
settings->setAcceleratedCompositingEnabled(accelerated_compositing_enabled);

// Always enter compositing if requested on the command line.
settings->setForceCompositingMode(force_compositing_mode);

// Enable compositing for fixed position elements if requested
// on the command line.
settings->setAcceleratedCompositingForFixedPositionEnabled(
Expand Down

0 comments on commit 479b017

Please sign in to comment.