summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/debug/debug_rect_history.cc28
-rw-r--r--cc/debug/invalidation_benchmark.cc6
-rw-r--r--cc/debug/invalidation_benchmark.h1
-rw-r--r--cc/debug/picture_record_benchmark.cc6
-rw-r--r--cc/debug/picture_record_benchmark.h2
-rw-r--r--cc/debug/rasterize_and_record_benchmark.cc6
-rw-r--r--cc/debug/rasterize_and_record_benchmark.h1
-rw-r--r--cc/debug/rasterize_and_record_benchmark_impl.cc12
-rw-r--r--cc/debug/rasterize_and_record_benchmark_impl.h2
-rw-r--r--cc/trees/layer_tree_host.cc13
-rw-r--r--cc/trees/layer_tree_host_common.h32
-rw-r--r--cc/trees/layer_tree_host_impl.cc8
-rw-r--r--cc/trees/layer_tree_impl.cc50
-rw-r--r--cc/trees/layer_tree_impl.h2
14 files changed, 54 insertions, 115 deletions
diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc
index cde7765..22a612c 100644
--- a/cc/debug/debug_rect_history.cc
+++ b/cc/debug/debug_rect_history.cc
@@ -163,10 +163,9 @@ void DebugRectHistory::SaveScreenSpaceRects(
}
void DebugRectHistory::SaveTouchEventHandlerRects(LayerImpl* layer) {
- LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
- layer,
- base::Bind(&DebugRectHistory::SaveTouchEventHandlerRectsCallback,
- base::Unretained(this)));
+ LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
+ SaveTouchEventHandlerRectsCallback(layer);
+ });
}
void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) {
@@ -183,10 +182,9 @@ void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) {
}
void DebugRectHistory::SaveWheelEventHandlerRects(LayerImpl* layer) {
- LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
- layer,
- base::Bind(&DebugRectHistory::SaveWheelEventHandlerRectsCallback,
- base::Unretained(this)));
+ LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
+ SaveWheelEventHandlerRectsCallback(layer);
+ });
}
void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) {
@@ -204,10 +202,9 @@ void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) {
}
void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) {
- LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
- layer,
- base::Bind(&DebugRectHistory::SaveScrollEventHandlerRectsCallback,
- base::Unretained(this)));
+ LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
+ SaveScrollEventHandlerRectsCallback(layer);
+ });
}
void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) {
@@ -225,10 +222,9 @@ void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) {
}
void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) {
- LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
- layer,
- base::Bind(&DebugRectHistory::SaveNonFastScrollableRectsCallback,
- base::Unretained(this)));
+ LayerTreeHostCommon::CallFunctionForSubtree(layer, [this](LayerImpl* layer) {
+ SaveNonFastScrollableRectsCallback(layer);
+ });
}
void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) {
diff --git a/cc/debug/invalidation_benchmark.cc b/cc/debug/invalidation_benchmark.cc
index 1a6a2b8..bb98bcc 100644
--- a/cc/debug/invalidation_benchmark.cc
+++ b/cc/debug/invalidation_benchmark.cc
@@ -64,11 +64,7 @@ InvalidationBenchmark::~InvalidationBenchmark() {
void InvalidationBenchmark::DidUpdateLayers(LayerTreeHost* host) {
LayerTreeHostCommon::CallFunctionForSubtree(
host->root_layer(),
- base::Bind(&InvalidationBenchmark::Run, base::Unretained(this)));
-}
-
-void InvalidationBenchmark::Run(Layer* layer) {
- layer->RunMicroBenchmark(this);
+ [this](Layer* layer) { layer->RunMicroBenchmark(this); });
}
void InvalidationBenchmark::RunOnLayer(PictureLayer* layer) {
diff --git a/cc/debug/invalidation_benchmark.h b/cc/debug/invalidation_benchmark.h
index f17fdbd..9423d5d 100644
--- a/cc/debug/invalidation_benchmark.h
+++ b/cc/debug/invalidation_benchmark.h
@@ -31,7 +31,6 @@ class CC_EXPORT InvalidationBenchmark : public MicroBenchmark {
private:
enum Mode { FIXED_SIZE, LAYER, VIEWPORT, RANDOM };
- void Run(Layer* layer);
float LCGRandom();
Mode mode_;
diff --git a/cc/debug/picture_record_benchmark.cc b/cc/debug/picture_record_benchmark.cc
index b1b8188..3ef4708 100644
--- a/cc/debug/picture_record_benchmark.cc
+++ b/cc/debug/picture_record_benchmark.cc
@@ -57,7 +57,7 @@ PictureRecordBenchmark::~PictureRecordBenchmark() {}
void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) {
LayerTreeHostCommon::CallFunctionForSubtree(
host->root_layer(),
- base::Bind(&PictureRecordBenchmark::Run, base::Unretained(this)));
+ [this](Layer* layer) { layer->RunMicroBenchmark(this); });
scoped_ptr<base::ListValue> results(new base::ListValue());
for (std::map<std::pair<int, int>, TotalTime>::iterator it = times_.begin();
@@ -83,10 +83,6 @@ void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) {
NotifyDone(results.Pass());
}
-void PictureRecordBenchmark::Run(Layer* layer) {
- layer->RunMicroBenchmark(this);
-}
-
void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) {
ContentLayerClient* painter = layer->client();
gfx::Size content_bounds = layer->content_bounds();
diff --git a/cc/debug/picture_record_benchmark.h b/cc/debug/picture_record_benchmark.h
index d6330fe1..3710d83 100644
--- a/cc/debug/picture_record_benchmark.h
+++ b/cc/debug/picture_record_benchmark.h
@@ -27,8 +27,6 @@ class CC_EXPORT PictureRecordBenchmark : public MicroBenchmark {
void RunOnLayer(PictureLayer* layer) override;
private:
- void Run(Layer* layer);
-
typedef std::pair<base::TimeDelta, unsigned> TotalTime;
std::map<std::pair<int, int>, TotalTime> times_;
std::vector<std::pair<int, int>> dimensions_;
diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc
index e56a1e1..e46dcfe 100644
--- a/cc/debug/rasterize_and_record_benchmark.cc
+++ b/cc/debug/rasterize_and_record_benchmark.cc
@@ -65,7 +65,7 @@ void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) {
host_ = host;
LayerTreeHostCommon::CallFunctionForSubtree(
host->root_layer(),
- base::Bind(&RasterizeAndRecordBenchmark::Run, base::Unretained(this)));
+ [this](Layer* layer) { layer->RunMicroBenchmark(this); });
DCHECK(!results_.get());
results_ = make_scoped_ptr(new base::DictionaryValue);
@@ -102,10 +102,6 @@ scoped_ptr<MicroBenchmarkImpl> RasterizeAndRecordBenchmark::CreateBenchmarkImpl(
weak_ptr_factory_.GetWeakPtr())));
}
-void RasterizeAndRecordBenchmark::Run(Layer* layer) {
- layer->RunMicroBenchmark(this);
-}
-
void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
DCHECK(host_);
diff --git a/cc/debug/rasterize_and_record_benchmark.h b/cc/debug/rasterize_and_record_benchmark.h
index 30dcde0..bed446d 100644
--- a/cc/debug/rasterize_and_record_benchmark.h
+++ b/cc/debug/rasterize_and_record_benchmark.h
@@ -37,7 +37,6 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark {
scoped_refptr<base::MessageLoopProxy> origin_loop) override;
private:
- void Run(Layer* layer);
void RunOnDisplayListLayer(PictureLayer* layer,
const gfx::Rect& visible_content_rect);
void RunOnPictureLayer(PictureLayer* layer,
diff --git a/cc/debug/rasterize_and_record_benchmark_impl.cc b/cc/debug/rasterize_and_record_benchmark_impl.cc
index 5a9577b..443db8c 100644
--- a/cc/debug/rasterize_and_record_benchmark_impl.cc
+++ b/cc/debug/rasterize_and_record_benchmark_impl.cc
@@ -132,9 +132,10 @@ RasterizeAndRecordBenchmarkImpl::~RasterizeAndRecordBenchmarkImpl() {}
void RasterizeAndRecordBenchmarkImpl::DidCompleteCommit(
LayerTreeHostImpl* host) {
LayerTreeHostCommon::CallFunctionForSubtree(
- host->RootLayer(),
- base::Bind(&RasterizeAndRecordBenchmarkImpl::Run,
- base::Unretained(this)));
+ host->RootLayer(), [this](LayerImpl* layer) {
+ rasterize_results_.total_layers++;
+ layer->RunMicroBenchmark(this);
+ });
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
result->SetDouble("rasterize_time_ms",
@@ -157,11 +158,6 @@ void RasterizeAndRecordBenchmarkImpl::DidCompleteCommit(
NotifyDone(result.Pass());
}
-void RasterizeAndRecordBenchmarkImpl::Run(LayerImpl* layer) {
- rasterize_results_.total_layers++;
- layer->RunMicroBenchmark(this);
-}
-
void RasterizeAndRecordBenchmarkImpl::RunOnLayer(PictureLayerImpl* layer) {
rasterize_results_.total_picture_layers++;
if (!layer->CanHaveTilings()) {
diff --git a/cc/debug/rasterize_and_record_benchmark_impl.h b/cc/debug/rasterize_and_record_benchmark_impl.h
index e9ca27d..ae134ab 100644
--- a/cc/debug/rasterize_and_record_benchmark_impl.h
+++ b/cc/debug/rasterize_and_record_benchmark_impl.h
@@ -31,8 +31,6 @@ class RasterizeAndRecordBenchmarkImpl : public MicroBenchmarkImpl {
void RunOnLayer(PictureLayerImpl* layer) override;
private:
- void Run(LayerImpl* layer);
-
struct RasterizeResults {
RasterizeResults();
~RasterizeResults();
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index abc63fc..92e9c25 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -211,10 +211,6 @@ void LayerTreeHost::SetLayerTreeHostClientReady() {
proxy_->SetLayerTreeHostClientReady();
}
-static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) {
- layer->OnOutputSurfaceCreated();
-}
-
void LayerTreeHost::DeleteContentsTexturesOnImplThread(
ResourceProvider* resource_provider) {
DCHECK(proxy_->IsImplThread());
@@ -427,7 +423,7 @@ void LayerTreeHost::DidInitializeOutputSurface() {
if (root_layer()) {
LayerTreeHostCommon::CallFunctionForSubtree(
- root_layer(), base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback));
+ root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); });
}
client_->DidInitializeOutputSurface();
@@ -873,17 +869,12 @@ void LayerTreeHost::TriggerPrepaint() {
SetNeedsCommit();
}
-static void LayerTreeHostReduceMemoryCallback(Layer* layer) {
- layer->ReduceMemoryUsage();
-}
-
void LayerTreeHost::ReduceMemoryUsage() {
if (!root_layer())
return;
LayerTreeHostCommon::CallFunctionForSubtree(
- root_layer(),
- base::Bind(&LayerTreeHostReduceMemoryCallback));
+ root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); });
}
void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) {
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 86666176..6c03511 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -125,10 +125,9 @@ class CC_EXPORT LayerTreeHostCommon {
static bool RenderSurfaceContributesToTarget(LayerType*,
int target_surface_layer_id);
- template <typename LayerType>
- static void CallFunctionForSubtree(
- LayerType* root_layer,
- const base::Callback<void(LayerType* layer)>& function);
+ template <typename LayerType, typename Function>
+ static void CallFunctionForSubtree(LayerType* layer,
+ const Function& function);
// Returns a layer with the given id if one exists in the subtree starting
// from the given root layer (including mask and replica layers).
@@ -205,22 +204,21 @@ LayerType* LayerTreeHostCommon::FindLayerInSubtree(LayerType* root_layer,
return NULL;
}
-template <typename LayerType>
-void LayerTreeHostCommon::CallFunctionForSubtree(
- LayerType* root_layer,
- const base::Callback<void(LayerType* layer)>& function) {
- function.Run(root_layer);
-
- if (LayerType* mask_layer = root_layer->mask_layer())
- function.Run(mask_layer);
- if (LayerType* replica_layer = root_layer->replica_layer()) {
- function.Run(replica_layer);
+template <typename LayerType, typename Function>
+void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* layer,
+ const Function& function) {
+ function(layer);
+
+ if (LayerType* mask_layer = layer->mask_layer())
+ function(mask_layer);
+ if (LayerType* replica_layer = layer->replica_layer()) {
+ function(replica_layer);
if (LayerType* mask_layer = replica_layer->mask_layer())
- function.Run(mask_layer);
+ function(mask_layer);
}
- for (size_t i = 0; i < root_layer->children().size(); ++i) {
- CallFunctionForSubtree(get_layer_as_raw_ptr(root_layer->children(), i),
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ CallFunctionForSubtree(get_layer_as_raw_ptr(layer->children(), i),
function);
}
}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index eddbc60..c03f7f79 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1453,10 +1453,6 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
return metadata;
}
-static void LayerTreeHostImplDidBeginTracingCallback(LayerImpl* layer) {
- layer->DidBeginTracing();
-}
-
void LayerTreeHostImpl::DrawLayers(FrameData* frame,
base::TimeTicks frame_begin_time) {
TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers");
@@ -1506,11 +1502,11 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
if (pending_tree_) {
LayerTreeHostCommon::CallFunctionForSubtree(
pending_tree_->root_layer(),
- base::Bind(&LayerTreeHostImplDidBeginTracingCallback));
+ [](LayerImpl* layer) { layer->DidBeginTracing(); });
}
LayerTreeHostCommon::CallFunctionForSubtree(
active_tree_->root_layer(),
- base::Bind(&LayerTreeHostImplDidBeginTracingCallback));
+ [](LayerImpl* layer) { layer->DidBeginTracing(); });
}
{
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 62e4cd3..5114fdc 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -121,13 +121,18 @@ void LayerTreeImpl::Shutdown() {
}
void LayerTreeImpl::ReleaseResources() {
- if (root_layer_)
- ProcessLayersRecursive(root_layer_.get(), &LayerImpl::ReleaseResources);
+ if (root_layer_) {
+ LayerTreeHostCommon::CallFunctionForSubtree(
+ root_layer_.get(), [](LayerImpl* layer) { layer->ReleaseResources(); });
+ }
}
void LayerTreeImpl::RecreateResources() {
- if (root_layer_)
- ProcessLayersRecursive(root_layer_.get(), &LayerImpl::RecreateResources);
+ if (root_layer_) {
+ LayerTreeHostCommon::CallFunctionForSubtree(
+ root_layer_.get(),
+ [](LayerImpl* layer) { layer->RecreateResources(); });
+ }
}
void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
@@ -475,10 +480,6 @@ gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const {
gfx::Rect(layer->content_bounds()));
}
-static void ApplySentScrollDeltasFromAbortedCommitTo(LayerImpl* layer) {
- layer->ApplySentScrollDeltasFromAbortedCommit();
-}
-
void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() {
DCHECK(IsActiveTree());
@@ -490,7 +491,9 @@ void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() {
return;
LayerTreeHostCommon::CallFunctionForSubtree(
- root_layer(), base::Bind(&ApplySentScrollDeltasFromAbortedCommitTo));
+ root_layer(), [](LayerImpl* layer) {
+ layer->ApplySentScrollDeltasFromAbortedCommit();
+ });
}
void LayerTreeImpl::SetViewportLayersFromIds(
@@ -748,17 +751,6 @@ void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) {
currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0));
}
-static void DidBecomeActiveRecursive(LayerImpl* layer) {
- layer->DidBecomeActive();
- if (layer->mask_layer())
- layer->mask_layer()->DidBecomeActive();
- if (layer->replica_layer() && layer->replica_layer()->mask_layer())
- layer->replica_layer()->mask_layer()->DidBecomeActive();
-
- for (size_t i = 0; i < layer->children().size(); ++i)
- DidBecomeActiveRecursive(layer->children()[i]);
-}
-
void LayerTreeImpl::DidBecomeActive() {
if (next_activation_forces_redraw_) {
layer_tree_host_impl_->SetFullRootLayerDamage();
@@ -774,8 +766,10 @@ void LayerTreeImpl::DidBecomeActive() {
// if we were in a good state.
layer_tree_host_impl_->ResetRequiresHighResToDraw();
- if (root_layer())
- DidBecomeActiveRecursive(root_layer());
+ if (root_layer()) {
+ LayerTreeHostCommon::CallFunctionForSubtree(
+ root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); });
+ }
devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(),
source_frame_number_);
@@ -1267,18 +1261,6 @@ const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest()
return layers_with_copy_output_request_;
}
-void LayerTreeImpl::ProcessLayersRecursive(LayerImpl* current,
- void (LayerImpl::*function)()) {
- DCHECK(current);
- (current->*function)();
- if (current->mask_layer())
- ProcessLayersRecursive(current->mask_layer(), function);
- if (current->replica_layer())
- ProcessLayersRecursive(current->replica_layer(), function);
- for (size_t i = 0; i < current->children().size(); ++i)
- ProcessLayersRecursive(current->children()[i], function);
-}
-
template <typename LayerType>
static inline bool LayerClipsSubtree(LayerType* layer) {
return layer->masks_to_bounds() || layer->mask_layer();
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index f7b6ee4..3105e6f 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -335,8 +335,6 @@ class CC_EXPORT LayerTreeImpl {
scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor,
scoped_refptr<SyncedTopControls> top_controls_shown_ratio,
scoped_refptr<SyncedElasticOverscroll> elastic_overscroll);
- void ProcessLayersRecursive(LayerImpl* current,
- void (LayerImpl::*function)());
float ClampPageScaleFactorToLimits(float page_scale_factor) const;
void PushPageScaleFactorAndLimits(const float* page_scale_factor,
float min_page_scale_factor,