Skip to content

Commit

Permalink
Split cc/base into separate GN source_set and clean deps
Browse files Browse the repository at this point in the history
//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}
  • Loading branch information
jamesr authored and Commit bot committed Mar 16, 2015
1 parent 745e53b commit f313a21
Show file tree
Hide file tree
Showing 29 changed files with 145 additions and 109 deletions.
41 changes: 8 additions & 33 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@ component("cc") {
"animation/transform_operation.h",
"animation/transform_operations.cc",
"animation/transform_operations.h",
"base/completion_event.h",
"base/delayed_unique_notifier.cc",
"base/delayed_unique_notifier.h",
"base/invalidation_region.cc",
"base/invalidation_region.h",
"base/latency_info_swap_promise.cc",
"base/latency_info_swap_promise.h",
"base/latency_info_swap_promise_monitor.cc",
"base/latency_info_swap_promise_monitor.h",
"base/math_util.cc",
"base/math_util.h",
"base/ref_counted_managed.h",
"base/region.cc",
"base/region.h",
"base/rolling_time_delta_history.cc",
"base/rolling_time_delta_history.h",
"base/scoped_ptr_algorithm.h",
"base/scoped_ptr_deque.h",
"base/scoped_ptr_vector.h",
"base/simple_enclosed_region.cc",
"base/simple_enclosed_region.h",
"base/swap_promise.h",
"base/swap_promise_monitor.cc",
"base/swap_promise_monitor.h",
"base/switches.cc",
"base/switches.h",
"base/synced_property.h",
"base/tiling_data.cc",
"base/tiling_data.h",
"base/time_util.h",
"base/unique_notifier.cc",
"base/unique_notifier.h",
"base/util.h",
"debug/benchmark_instrumentation.cc",
"debug/benchmark_instrumentation.h",
"debug/debug_colors.cc",
Expand Down Expand Up @@ -267,6 +234,8 @@ component("cc") {
"output/gl_renderer.h",
"output/gl_renderer_draw_cache.cc",
"output/gl_renderer_draw_cache.h",
"output/latency_info_swap_promise.cc",
"output/latency_info_swap_promise.h",
"output/managed_memory_policy.cc",
"output/managed_memory_policy.h",
"output/output_surface.cc",
Expand Down Expand Up @@ -299,6 +268,7 @@ component("cc") {
"output/software_renderer.h",
"output/static_geometry_binding.cc",
"output/static_geometry_binding.h",
"output/swap_promise.h",
"output/viewport_selection_bound.cc",
"output/viewport_selection_bound.h",
"output/vsync_parameter_observer.h",
Expand Down Expand Up @@ -510,6 +480,8 @@ component("cc") {
"trees/damage_tracker.h",
"trees/draw_property_utils.cc",
"trees/draw_property_utils.h",
"trees/latency_info_swap_promise_monitor.cc",
"trees/latency_info_swap_promise_monitor.h",
"trees/layer_tree_host.cc",
"trees/layer_tree_host.h",
"trees/layer_tree_host_client.h",
Expand Down Expand Up @@ -537,6 +509,8 @@ component("cc") {
"trees/scoped_abort_remaining_swap_promises.h",
"trees/single_thread_proxy.cc",
"trees/single_thread_proxy.h",
"trees/swap_promise_monitor.cc",
"trees/swap_promise_monitor.h",
"trees/thread_proxy.cc",
"trees/thread_proxy.h",
"trees/tree_synchronizer.cc",
Expand All @@ -547,6 +521,7 @@ component("cc") {
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

public_deps = [
"//cc/base",
"//skia",
]
deps = [
Expand Down
51 changes: 51 additions & 0 deletions cc/base/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
}
12 changes: 12 additions & 0 deletions cc/base/DEPS
Original file line number Diff line number Diff line change
@@ -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",
]
}
14 changes: 7 additions & 7 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
'base/delayed_unique_notifier.h',
'base/invalidation_region.cc',
'base/invalidation_region.h',
'base/latency_info_swap_promise.cc',
'base/latency_info_swap_promise.h',
'base/latency_info_swap_promise_monitor.cc',
'base/latency_info_swap_promise_monitor.h',
'base/math_util.cc',
'base/math_util.h',
'base/ref_counted_managed.h',
Expand All @@ -85,9 +81,6 @@
'base/scoped_ptr_vector.h',
'base/simple_enclosed_region.cc',
'base/simple_enclosed_region.h',
'base/swap_promise.h',
'base/swap_promise_monitor.cc',
'base/swap_promise_monitor.h',
'base/switches.cc',
'base/switches.h',
'base/synced_property.h',
Expand Down Expand Up @@ -293,6 +286,8 @@
'output/gl_renderer.h',
'output/gl_renderer_draw_cache.cc',
'output/gl_renderer_draw_cache.h',
'output/latency_info_swap_promise.cc',
'output/latency_info_swap_promise.h',
'output/managed_memory_policy.cc',
'output/managed_memory_policy.h',
'output/output_surface.cc',
Expand Down Expand Up @@ -325,6 +320,7 @@
'output/software_renderer.h',
'output/static_geometry_binding.cc',
'output/static_geometry_binding.h',
'output/swap_promise.h',
'output/viewport_selection_bound.cc',
'output/viewport_selection_bound.h',
'output/vsync_parameter_observer.h',
Expand Down Expand Up @@ -537,6 +533,8 @@
'trees/damage_tracker.h',
'trees/draw_property_utils.cc',
'trees/draw_property_utils.h',
'trees/latency_info_swap_promise_monitor.cc',
'trees/latency_info_swap_promise_monitor.h',
'trees/layer_tree_host.cc',
'trees/layer_tree_host.h',
'trees/layer_tree_host_client.h',
Expand Down Expand Up @@ -564,6 +562,8 @@
'trees/scoped_abort_remaining_swap_promises.h',
'trees/single_thread_proxy.cc',
'trees/single_thread_proxy.h',
'trees/swap_promise_monitor.cc',
'trees/swap_promise_monitor.h',
'trees/thread_proxy.cc',
'trees/thread_proxy.h',
'trees/tree_synchronizer.cc',
Expand Down
2 changes: 1 addition & 1 deletion cc/input/input_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "cc/base/cc_export.h"
#include "cc/base/swap_promise_monitor.h"
#include "cc/input/scrollbar.h"
#include "cc/trees/swap_promise_monitor.h"

namespace gfx {
class Point;
Expand Down
2 changes: 1 addition & 1 deletion cc/layers/surface_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "cc/layers/surface_layer.h"

#include "cc/base/swap_promise.h"
#include "cc/layers/surface_layer_impl.h"
#include "cc/output/swap_promise.h"
#include "cc/trees/layer_tree_host.h"

namespace cc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
// 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 "cc/output/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;
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 {
Expand All @@ -38,8 +38,8 @@ void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) {
}

void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) {
latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason),
0, 0);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// 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_
#ifndef CC_OUTPUT_LATENCY_INFO_SWAP_PROMISE_H_
#define CC_OUTPUT_LATENCY_INFO_SWAP_PROMISE_H_

#include "base/compiler_specific.h"
#include "cc/base/swap_promise.h"
#include "cc/output/swap_promise.h"
#include "ui/events/latency_info.h"

namespace cc {
Expand All @@ -27,4 +27,4 @@ class CC_EXPORT LatencyInfoSwapPromise : public SwapPromise {

} // namespace cc

#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
#endif // CC_OUTPUT_LATENCY_INFO_SWAP_PROMISE_H_
6 changes: 3 additions & 3 deletions cc/base/swap_promise.h → cc/output/swap_promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// 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_
#ifndef CC_OUTPUT_SWAP_PROMISE_H_
#define CC_OUTPUT_SWAP_PROMISE_H_

#include "cc/output/compositor_frame_metadata.h"

Expand Down Expand Up @@ -50,4 +50,4 @@ class CC_EXPORT SwapPromise {

} // namespace cc

#endif // CC_BASE_SWAP_PROMISE_H_
#endif // CC_OUTPUT_SWAP_PROMISE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// 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/trees/latency_info_swap_promise_monitor.h"

#include "base/threading/platform_thread.h"
#include "cc/base/latency_info_swap_promise.h"
#include "cc/output/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"
Expand All @@ -14,9 +14,9 @@ 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;
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);
Expand All @@ -25,13 +25,11 @@ bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info,

bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) {
if (latency_info->FindLatency(
ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT,
0,
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,
ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0,
latency_info->trace_id);
return true;
}
Expand All @@ -45,9 +43,11 @@ LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
LayerTreeHost* layer_tree_host,
LayerTreeHostImpl* layer_tree_host_impl)
: SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
latency_(latency) {}
latency_(latency) {
}

LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {
}

void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
if (AddRenderingScheduledComponent(latency_, true /* on_main */)) {
Expand All @@ -68,8 +68,7 @@ void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
int64 new_sequence_number = 0;
for (ui::LatencyInfo::LatencyMap::const_iterator it =
latency_->latency_components.begin();
it != latency_->latency_components.end();
++it) {
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) |
Expand All @@ -82,8 +81,7 @@ void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
return;
ui::LatencyInfo new_latency;
new_latency.AddLatencyNumber(
ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT,
0,
ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT, 0,
new_sequence_number);
new_latency.TraceEventType("ScrollUpdate");
new_latency.CopyLatencyFrom(
Expand Down
Loading

0 comments on commit f313a21

Please sign in to comment.