From ed66d1c729afdad61eb7a37e6b635a38ca5c0d94 Mon Sep 17 00:00:00 2001 From: "danakj@chromium.org" Date: Sat, 14 Sep 2013 05:33:29 +0000 Subject: aura: When skipping frames, ensure next frame damages what was skipped. In the delegated path, if we skip a frame, we are just dropping the damage. If the resize lock times out, we can end up swapping a partial frame that is out of sync with the rest of the visible content. Since we always have all the quads available to us (unlike the old double-buffered texture path), when we stop skipping a frame, just damage the whole RenderWidgetHostView to ensure we draw the skipped frames' damage. Refactors ResizeLock out so that we can fake it out in tests. Tests: RenderWidgetHostViewAuraTest.SkippedDelegatedFrames R=jbauman, piman BUG=288993 Depends on: https://codereview.chromium.org/23506032/ Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=223140 Review URL: https://chromiumcodereview.appspot.com/23496042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223228 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/aura/compositor_resize_lock.cc | 65 ++++++++++++++++++++++++++ content/browser/aura/compositor_resize_lock.h | 46 ++++++++++++++++++ content/browser/aura/image_transport_factory.h | 2 +- content/browser/aura/resize_lock.cc | 35 ++++++++++++++ content/browser/aura/resize_lock.h | 37 +++++++++++++++ 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 content/browser/aura/compositor_resize_lock.cc create mode 100644 content/browser/aura/compositor_resize_lock.h create mode 100644 content/browser/aura/resize_lock.cc create mode 100644 content/browser/aura/resize_lock.h (limited to 'content/browser/aura') diff --git a/content/browser/aura/compositor_resize_lock.cc b/content/browser/aura/compositor_resize_lock.cc new file mode 100644 index 0000000..e80baba --- /dev/null +++ b/content/browser/aura/compositor_resize_lock.cc @@ -0,0 +1,65 @@ +// Copyright 2013 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. + +#include "content/browser/aura/compositor_resize_lock.h" + +#include "base/debug/trace_event.h" +#include "content/public/browser/browser_thread.h" +#include "ui/aura/root_window.h" +#include "ui/compositor/compositor.h" + +namespace content { + +CompositorResizeLock::CompositorResizeLock(aura::RootWindow* root_window, + const gfx::Size new_size, + bool defer_compositor_lock, + const base::TimeDelta& timeout) + : ResizeLock(new_size, defer_compositor_lock), + root_window_(root_window), + weak_ptr_factory_(this), + cancelled_(false) { + DCHECK(root_window_); + + TRACE_EVENT_ASYNC_BEGIN2("ui", "CompositorResizeLock", this, + "width", expected_size().width(), + "height", expected_size().height()); + root_window_->HoldPointerMoves(); + + BrowserThread::PostDelayedTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&CompositorResizeLock::CancelLock, + weak_ptr_factory_.GetWeakPtr()), + timeout); +} + +CompositorResizeLock::~CompositorResizeLock() { + CancelLock(); + TRACE_EVENT_ASYNC_END2("ui", "CompositorResizeLock", this, + "width", expected_size().width(), + "height", expected_size().height()); +} + +bool CompositorResizeLock::GrabDeferredLock() { + return ResizeLock::GrabDeferredLock(); +} + +void CompositorResizeLock::UnlockCompositor() { + ResizeLock::UnlockCompositor(); + compositor_lock_ = NULL; +} + +void CompositorResizeLock::LockCompositor() { + ResizeLock::LockCompositor(); + compositor_lock_ = root_window_->compositor()->GetCompositorLock(); +} + +void CompositorResizeLock::CancelLock() { + if (cancelled_) + return; + cancelled_ = true; + UnlockCompositor(); + root_window_->ReleasePointerMoves(); +} + +} // namespace content diff --git a/content/browser/aura/compositor_resize_lock.h b/content/browser/aura/compositor_resize_lock.h new file mode 100644 index 0000000..51787e4 --- /dev/null +++ b/content/browser/aura/compositor_resize_lock.h @@ -0,0 +1,46 @@ +// Copyright 2013 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. + +#ifndef CONTENT_BROWSER_AURA_RESIZE_LOCK_AURA_H_ +#define CONTENT_BROWSER_AURA_RESIZE_LOCK_AURA_H_ + +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "base/time/time.h" +#include "content/browser/aura/resize_lock.h" + +namespace aura { class RootWindow; } + +namespace ui { class CompositorLock; } + +namespace content { + +// Used to prevent further resizes while a resize is pending. +class CompositorResizeLock : public ResizeLock { + public: + CompositorResizeLock(aura::RootWindow* root_window, + const gfx::Size new_size, + bool defer_compositor_lock, + const base::TimeDelta& timeout); + virtual ~CompositorResizeLock(); + + virtual bool GrabDeferredLock() OVERRIDE; + virtual void UnlockCompositor() OVERRIDE; + + protected: + virtual void LockCompositor() OVERRIDE; + void CancelLock(); + + private: + aura::RootWindow* root_window_; + scoped_refptr compositor_lock_; + base::WeakPtrFactory weak_ptr_factory_; + bool cancelled_; + + DISALLOW_COPY_AND_ASSIGN(CompositorResizeLock); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_AURA_RESIZE_LOCK_AURA_H_ diff --git a/content/browser/aura/image_transport_factory.h b/content/browser/aura/image_transport_factory.h index e5964809..7cd2523 100644 --- a/content/browser/aura/image_transport_factory.h +++ b/content/browser/aura/image_transport_factory.h @@ -28,7 +28,7 @@ namespace content { class GLHelper; // This class provides a way to get notified when surface handles get lost. -class ImageTransportFactoryObserver { +class CONTENT_EXPORT ImageTransportFactoryObserver { public: virtual ~ImageTransportFactoryObserver() {} diff --git a/content/browser/aura/resize_lock.cc b/content/browser/aura/resize_lock.cc new file mode 100644 index 0000000..4c8cd95 --- /dev/null +++ b/content/browser/aura/resize_lock.cc @@ -0,0 +1,35 @@ +// Copyright 2013 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. + +#include "content/browser/aura/resize_lock.h" + +namespace content { + +ResizeLock::ResizeLock(const gfx::Size new_size, bool defer_compositor_lock) + : new_size_(new_size), + defer_compositor_lock_(defer_compositor_lock) { + if (!defer_compositor_lock_) + LockCompositor(); +} + +ResizeLock::~ResizeLock() { + UnlockCompositor(); +} + +bool ResizeLock::GrabDeferredLock() { + if (!defer_compositor_lock_) + return false; + LockCompositor(); + return true; +} + +void ResizeLock::UnlockCompositor() { + defer_compositor_lock_ = false; +} + +void ResizeLock::LockCompositor() { + defer_compositor_lock_ = false; +} + +} // namespace content diff --git a/content/browser/aura/resize_lock.h b/content/browser/aura/resize_lock.h new file mode 100644 index 0000000..cff9822 --- /dev/null +++ b/content/browser/aura/resize_lock.h @@ -0,0 +1,37 @@ +// Copyright 2013 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. + +#ifndef CONTENT_BROWSER_AURA_RESIZE_LOCK_H_ +#define CONTENT_BROWSER_AURA_RESIZE_LOCK_H_ + +#include "base/basictypes.h" +#include "content/common/content_export.h" +#include "ui/gfx/size.h" + +namespace content { + +class CONTENT_EXPORT ResizeLock { + public: + virtual ~ResizeLock(); + + virtual bool GrabDeferredLock(); + virtual void UnlockCompositor(); + + const gfx::Size& expected_size() const { return new_size_; } + + protected: + ResizeLock(const gfx::Size new_size, bool defer_compositor_lock); + + virtual void LockCompositor(); + + private: + gfx::Size new_size_; + bool defer_compositor_lock_; + + DISALLOW_COPY_AND_ASSIGN(ResizeLock); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_AURA_RESIZE_LOCK_H_ -- cgit v1.1