summaryrefslogtreecommitdiffstats
path: root/cc/base
diff options
context:
space:
mode:
authorjamesr <jamesr@chromium.org>2015-03-16 14:27:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-16 21:28:32 +0000
commitf313a215a789688cff2d56cef89c60e2de416220 (patch)
treeee8ce0d63ab91a75acf8e4d25941ea1ac94e6c4d /cc/base
parent745e53b571adbe742caf3b92cc8c692eb1f51b6e (diff)
downloadchromium_src-f313a215a789688cff2d56cef89c60e2de416220.zip
chromium_src-f313a215a789688cff2d56cef89c60e2de416220.tar.gz
chromium_src-f313a215a789688cff2d56cef89c60e2de416220.tar.bz2
Split cc/base into separate GN source_set and clean deps
//cc/base is intended to be a set of low level utilities used by the rest of cc (and consumers of cc) and as such shouldn't contain dependencies on other parts of //cc. This splits the //cc/base files into a separate GN source_set so 'gn check' can examine dependencies and moves a few types that have dependencies on other types out: swap_promise is conceptually about swapping frames, so it goes into cc/output *swap_promise_monitor is dealing with swaps on trees, so it goes in cc/trees R=danakj@chromium.org Review URL: https://codereview.chromium.org/1002073002 Cr-Commit-Position: refs/heads/master@{#320796}
Diffstat (limited to 'cc/base')
-rw-r--r--cc/base/BUILD.gn51
-rw-r--r--cc/base/DEPS12
-rw-r--r--cc/base/latency_info_swap_promise.cc52
-rw-r--r--cc/base/latency_info_swap_promise.h30
-rw-r--r--cc/base/latency_info_swap_promise_monitor.cc99
-rw-r--r--cc/base/latency_info_swap_promise_monitor.h37
-rw-r--r--cc/base/swap_promise.h53
-rw-r--r--cc/base/swap_promise_monitor.cc31
-rw-r--r--cc/base/swap_promise_monitor.h45
9 files changed, 63 insertions, 347 deletions
diff --git a/cc/base/BUILD.gn b/cc/base/BUILD.gn
new file mode 100644
index 0000000..203f84a
--- /dev/null
+++ b/cc/base/BUILD.gn
@@ -0,0 +1,51 @@
+# Copyright 2015 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.
+
+source_set("base") {
+ visibility = [ "//cc" ]
+
+ sources = [
+ "completion_event.h",
+ "delayed_unique_notifier.cc",
+ "delayed_unique_notifier.h",
+ "invalidation_region.cc",
+ "invalidation_region.h",
+ "math_util.cc",
+ "math_util.h",
+ "ref_counted_managed.h",
+ "region.cc",
+ "region.h",
+ "rolling_time_delta_history.cc",
+ "rolling_time_delta_history.h",
+ "scoped_ptr_algorithm.h",
+ "scoped_ptr_deque.h",
+ "scoped_ptr_vector.h",
+ "simple_enclosed_region.cc",
+ "simple_enclosed_region.h",
+ "switches.cc",
+ "switches.h",
+ "synced_property.h",
+ "tiling_data.cc",
+ "tiling_data.h",
+ "time_util.h",
+ "unique_notifier.cc",
+ "unique_notifier.h",
+ "util.h",
+ ]
+
+ deps = [
+ "//base",
+ "//base/third_party/dynamic_annotations",
+ "//skia",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ ]
+
+ defines = [ "CC_IMPLEMENTATION=1" ]
+
+ if (!is_debug && (is_win || is_android)) {
+ configs -= [ "//build/config/compiler:optimize" ]
+ configs += [ "//build/config/compiler:optimize_max" ]
+ }
+}
diff --git a/cc/base/DEPS b/cc/base/DEPS
new file mode 100644
index 0000000..33b4e8f
--- /dev/null
+++ b/cc/base/DEPS
@@ -0,0 +1,12 @@
+# Things within cc/base should not depend on things in cc/ outside of cc/base.
+include_rules = [
+ "-cc",
+ "+cc/base",
+]
+
+# Tests can use things in cc/test
+specific_include_rules = {
+ ".*unittest\.cc": [
+ "+cc/test",
+ ]
+}
diff --git a/cc/base/latency_info_swap_promise.cc b/cc/base/latency_info_swap_promise.cc
deleted file mode 100644
index 8c6ee0e..0000000
--- a/cc/base/latency_info_swap_promise.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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.h"
-
-#include "base/logging.h"
-
-namespace {
- ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType(
- cc::SwapPromise::DidNotSwapReason reason) {
- switch (reason) {
- case cc::SwapPromise::DID_NOT_SWAP_UNKNOWN:
- case cc::SwapPromise::SWAP_FAILS:
- return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
- case cc::SwapPromise::COMMIT_FAILS:
- return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT;
- case cc::SwapPromise::COMMIT_NO_UPDATE:
- return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT;
- }
- NOTREACHED() << "Unhandled DidNotSwapReason.";
- return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
- }
-} // namespace
-
-namespace cc {
-
-LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency)
- : latency_(latency) {
-}
-
-LatencyInfoSwapPromise::~LatencyInfoSwapPromise() {
-}
-
-void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) {
- DCHECK(!latency_.terminated);
- metadata->latency_info.push_back(latency_);
-}
-
-void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) {
- latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason),
- 0, 0);
- // TODO(miletus): Turn this back on once per-event LatencyInfo tracking
- // is enabled in GPU side.
- // DCHECK(latency_.terminated);
-}
-
-int64 LatencyInfoSwapPromise::TraceId() const {
- return latency_.trace_id;
-}
-
-} // namespace cc
diff --git a/cc/base/latency_info_swap_promise.h b/cc/base/latency_info_swap_promise.h
deleted file mode 100644
index a7941f1..0000000
--- a/cc/base/latency_info_swap_promise.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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_LATENCY_INFO_SWAP_PROMISE_H_
-#define CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
-
-#include "base/compiler_specific.h"
-#include "cc/base/swap_promise.h"
-#include "ui/events/latency_info.h"
-
-namespace cc {
-
-class CC_EXPORT LatencyInfoSwapPromise : public SwapPromise {
- public:
- explicit LatencyInfoSwapPromise(const ui::LatencyInfo& latency_info);
- ~LatencyInfoSwapPromise() override;
-
- void DidSwap(CompositorFrameMetadata* metadata) override;
- void DidNotSwap(DidNotSwapReason reason) override;
-
- int64 TraceId() const override;
-
- private:
- ui::LatencyInfo latency_;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
diff --git a/cc/base/latency_info_swap_promise_monitor.cc b/cc/base/latency_info_swap_promise_monitor.cc
deleted file mode 100644
index de065d1..0000000
--- a/cc/base/latency_info_swap_promise_monitor.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// 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 "base/threading/platform_thread.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 {
-
-bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info,
- bool on_main) {
- ui::LatencyComponentType type = on_main ?
- ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT :
- ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT;
- if (latency_info->FindLatency(type, 0, nullptr))
- return false;
- latency_info->AddLatencyNumber(type, 0, 0);
- return true;
-}
-
-bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) {
- if (latency_info->FindLatency(
- ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT,
- 0,
- nullptr))
- return false;
- latency_info->AddLatencyNumber(
- ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT,
- 0,
- latency_info->trace_id);
- return true;
-}
-
-} // namespace
-
-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 (AddRenderingScheduledComponent(latency_, true /* on_main */)) {
- scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
- layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
- }
-}
-
-void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
- if (AddRenderingScheduledComponent(latency_, false /* on_main */)) {
- scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
- layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
- }
-}
-
-void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
- if (AddForwardingScrollUpdateToMainComponent(latency_)) {
- int64 new_sequence_number = 0;
- for (ui::LatencyInfo::LatencyMap::const_iterator it =
- latency_->latency_components.begin();
- it != latency_->latency_components.end();
- ++it) {
- if (it->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) {
- new_sequence_number =
- (static_cast<int64>(base::PlatformThread::CurrentId()) << 32) |
- (it->second.sequence_number & 0xffffffff);
- DCHECK(new_sequence_number != it->second.sequence_number);
- break;
- }
- }
- if (!new_sequence_number)
- return;
- ui::LatencyInfo new_latency;
- new_latency.AddLatencyNumber(
- ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT,
- 0,
- new_sequence_number);
- new_latency.TraceEventType("ScrollUpdate");
- new_latency.CopyLatencyFrom(
- *latency_,
- ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT);
- scoped_ptr<SwapPromise> swap_promise(
- new LatencyInfoSwapPromise(new_latency));
- layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
- 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
deleted file mode 100644
index d9e71fb..0000000
--- a/cc/base/latency_info_swap_promise_monitor.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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);
- ~LatencyInfoSwapPromiseMonitor() override;
-
- void OnSetNeedsCommitOnMain() override;
- void OnSetNeedsRedrawOnImpl() override;
- void OnForwardScrollUpdateToMainThreadOnImpl() override;
-
- private:
- ui::LatencyInfo* latency_;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_
diff --git a/cc/base/swap_promise.h b/cc/base/swap_promise.h
deleted file mode 100644
index a406fda..0000000
--- a/cc/base/swap_promise.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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_H_
-#define CC_BASE_SWAP_PROMISE_H_
-
-#include "cc/output/compositor_frame_metadata.h"
-
-namespace cc {
-
-// When a change to the compositor's state/invalidation/whatever happens, a
-// Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track
-// whether the compositor's reply to the new state/invaliadtion/whatever is
-// completed in the compositor, i.e. the compositor knows it has been sent
-// to its output or not.
-//
-// If the new compositor state is sent to the output, SwapPromise::DidSwap()
-// will be called, and if the compositor fails to send its new state to the
-// output, SwapPromise::DidNotSwap() will be called.
-//
-// Client wishes to use SwapPromise should have a subclass that defines
-// the behavior of DidSwap() and DidNotSwap(). Notice that the promise can
-// be broken at either main or impl thread, e.g. commit fails on main thread,
-// new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers()
-// bails out early on impl thread, so don't assume that DidSwap() and
-// DidNotSwap() are called at a particular thread. It is better to let the
-// subclass carry thread-safe member data and operate on that member data in
-// DidSwap() and DidNotSwap().
-class CC_EXPORT SwapPromise {
- public:
- enum DidNotSwapReason {
- DID_NOT_SWAP_UNKNOWN,
- SWAP_FAILS,
- COMMIT_FAILS,
- COMMIT_NO_UPDATE,
- };
-
- SwapPromise() {}
- virtual ~SwapPromise() {}
-
- virtual void DidSwap(CompositorFrameMetadata* metadata) = 0;
- virtual void DidNotSwap(DidNotSwapReason reason) = 0;
-
- // A non-zero trace id identifies a trace flow object that is embedded in the
- // swap promise. This can be used for registering additional flow steps to
- // visualize the object's path through the system.
- virtual int64 TraceId() const = 0;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_SWAP_PROMISE_H_
diff --git a/cc/base/swap_promise_monitor.cc b/cc/base/swap_promise_monitor.cc
deleted file mode 100644
index 0c04f35..0000000
--- a/cc/base/swap_promise_monitor.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
deleted file mode 100644
index cf06bee..0000000
--- a/cc/base/swap_promise_monitor.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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 nullptr.
- // If the monitor lives on the impl thread, pass in layer_tree_host_impl
- // and set layer_tree_host to nullptr.
- SwapPromiseMonitor(LayerTreeHost* layer_tree_host,
- LayerTreeHostImpl* layer_tree_host_impl);
- virtual ~SwapPromiseMonitor();
-
- virtual void OnSetNeedsCommitOnMain() = 0;
- virtual void OnSetNeedsRedrawOnImpl() = 0;
- virtual void OnForwardScrollUpdateToMainThreadOnImpl() = 0;
-
- protected:
- LayerTreeHost* layer_tree_host_;
- LayerTreeHostImpl* layer_tree_host_impl_;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_SWAP_PROMISE_MONITOR_H_