diff options
author | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 06:47:31 +0000 |
---|---|---|
committer | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 06:47:31 +0000 |
commit | 6be422be283bff883a198254047ff23dc2f4baa0 (patch) | |
tree | 0d945e2cd10fdc1f15ab9c3bd6a212e379ea270c /cc/base | |
parent | 81ebff3b727b9e86317a235d4b97f9c718471fc0 (diff) | |
download | chromium_src-6be422be283bff883a198254047ff23dc2f4baa0.zip chromium_src-6be422be283bff883a198254047ff23dc2f4baa0.tar.gz chromium_src-6be422be283bff883a198254047ff23dc2f4baa0.tar.bz2 |
For main thread event handling, if event causes
SetNeedsCommit, SetNeedsUpdateLayer or SetNeedsAnimate during
event processing, then it is considered to cause rendering and
its LatencyInfo is pushed into LayerTreeHost through
LatencyInfoSwapPromise.
For impl thread event handling, if event causes
SetNeedsRedraw or SetNeedsRedrawRect during event processing,
then it is considered to cause rendering and its LatencyInfo is
pushed into LayerTreeHostImpl through LatencyInfoSwapPromise.
BUG=246034, 271583
TEST=Manually tested on Pixel. The LatencyInfo for events that
causes impl/main thread scrolling are correctly passed to LTH/LTHI.
Review URL: https://codereview.chromium.org/55273003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239375 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base')
-rw-r--r-- | cc/base/latency_info_swap_promise_monitor.cc | 43 | ||||
-rw-r--r-- | cc/base/latency_info_swap_promise_monitor.h | 36 | ||||
-rw-r--r-- | cc/base/swap_promise_monitor.cc | 31 | ||||
-rw-r--r-- | cc/base/swap_promise_monitor.h | 44 |
4 files changed, 154 insertions, 0 deletions
diff --git a/cc/base/latency_info_swap_promise_monitor.cc b/cc/base/latency_info_swap_promise_monitor.cc new file mode 100644 index 0000000..0f2ff74 --- /dev/null +++ b/cc/base/latency_info_swap_promise_monitor.cc @@ -0,0 +1,43 @@ +// 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 "cc/base/latency_info_swap_promise_monitor.h" + +#include "cc/base/latency_info_swap_promise.h" +#include "cc/trees/layer_tree_host.h" +#include "cc/trees/layer_tree_host_impl.h" +#include "cc/trees/layer_tree_impl.h" + +namespace cc { + +LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( + ui::LatencyInfo* latency, + LayerTreeHost* layer_tree_host, + LayerTreeHostImpl* layer_tree_host_impl) + : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), + latency_(latency) {} + +LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} + +void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { + if (!latency_->FindLatency( + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) { + latency_->AddLatencyNumber( + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0); + scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); + layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); + } +} + +void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { + if (!latency_->FindLatency( + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) { + latency_->AddLatencyNumber( + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0); + scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); + layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); + } +} + +} // namespace cc diff --git a/cc/base/latency_info_swap_promise_monitor.h b/cc/base/latency_info_swap_promise_monitor.h new file mode 100644 index 0000000..a463fdb --- /dev/null +++ b/cc/base/latency_info_swap_promise_monitor.h @@ -0,0 +1,36 @@ +// 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 "base/compiler_specific.h" +#include "cc/base/swap_promise_monitor.h" + +#ifndef CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_ +#define CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_ + +namespace ui { +struct LatencyInfo; +} // namespace ui + +namespace cc { + +// A LatencyInfoSwapPromiseMonitor queues a LatencyInfoSwapPromise into +// LayerTreeHost or LayerTreeHostImpl if there is compositor state change +// while it is being mointored. +class CC_EXPORT LatencyInfoSwapPromiseMonitor : public SwapPromiseMonitor { + public: + LatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency, + LayerTreeHost* layer_tree_host, + LayerTreeHostImpl* layer_tree_host_impl); + virtual ~LatencyInfoSwapPromiseMonitor(); + + virtual void OnSetNeedsCommitOnMain() OVERRIDE; + virtual void OnSetNeedsRedrawOnImpl() OVERRIDE; + + private: + ui::LatencyInfo* latency_; +}; + +} // namespace cc + +#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_ diff --git a/cc/base/swap_promise_monitor.cc b/cc/base/swap_promise_monitor.cc new file mode 100644 index 0000000..0c04f35 --- /dev/null +++ b/cc/base/swap_promise_monitor.cc @@ -0,0 +1,31 @@ +// 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 "base/logging.h" +#include "cc/base/swap_promise_monitor.h" +#include "cc/trees/layer_tree_host.h" +#include "cc/trees/layer_tree_host_impl.h" + +namespace cc { + +SwapPromiseMonitor::SwapPromiseMonitor(LayerTreeHost* layer_tree_host, + LayerTreeHostImpl* layer_tree_host_impl) + : layer_tree_host_(layer_tree_host), + layer_tree_host_impl_(layer_tree_host_impl) { + DCHECK((layer_tree_host && !layer_tree_host_impl) || + (!layer_tree_host && layer_tree_host_impl)); + if (layer_tree_host_) + layer_tree_host_->InsertSwapPromiseMonitor(this); + if (layer_tree_host_impl_) + layer_tree_host_impl_->InsertSwapPromiseMonitor(this); +} + +SwapPromiseMonitor::~SwapPromiseMonitor() { + if (layer_tree_host_) + layer_tree_host_->RemoveSwapPromiseMonitor(this); + if (layer_tree_host_impl_) + layer_tree_host_impl_->RemoveSwapPromiseMonitor(this); +} + +} // namespace cc diff --git a/cc/base/swap_promise_monitor.h b/cc/base/swap_promise_monitor.h new file mode 100644 index 0000000..21a159a --- /dev/null +++ b/cc/base/swap_promise_monitor.h @@ -0,0 +1,44 @@ +// 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 CC_BASE_SWAP_PROMISE_MONITOR_H_ +#define CC_BASE_SWAP_PROMISE_MONITOR_H_ + +#include "cc/base/cc_export.h" + +namespace cc { + +class LayerTreeHost; +class LayerTreeHostImpl; + +// A SwapPromiseMonitor is used to monitor compositor state change that +// should be associated with a SwapPromise, e.g. SetNeedsCommit() is +// called on main thread or SetNeedsRedraw() is called on impl thread. +// Creating a SwapPromiseMonitor will insert itself into a LayerTreeHost +// or LayerTreeHostImpl. You must provide a pointer to the appropriate +// structure to the monitor (and only one of the two). Notification of +// compositor state change will be sent through OnSetNeedsCommitOnMain() +// or OnSetNeedsRedrawOnImpl(). When SwapPromiseMonitor is destroyed, it +// will unregister itself from LayerTreeHost or LayerTreeHostImpl. +class CC_EXPORT SwapPromiseMonitor { + public: + // If the monitor lives on the main thread, pass in layer_tree_host + // and set layer_tree_host_impl to NULL. + // If the monitor lives on the impl thread, pass in layer_tree_host_impl + // and set layer_tree_host to NULL. + SwapPromiseMonitor(LayerTreeHost* layer_tree_host, + LayerTreeHostImpl* layer_tree_host_impl); + virtual ~SwapPromiseMonitor(); + + virtual void OnSetNeedsCommitOnMain() = 0; + virtual void OnSetNeedsRedrawOnImpl() = 0; + + protected: + LayerTreeHost* layer_tree_host_; + LayerTreeHostImpl* layer_tree_host_impl_; +}; + +} // namespace cc + +#endif // CC_BASE_SWAP_PROMISE_MONITOR_H_ |