Index: cc/trees/layer_tree_host.cc |
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc |
index b0eed2f63205e01af80d600a73218404ec108179..c14736a939ed6f9fb213dbbca516fb4e8b776c0b 100644 |
--- a/cc/trees/layer_tree_host.cc |
+++ b/cc/trees/layer_tree_host.cc |
@@ -11,10 +11,12 @@ |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/debug/trace_event.h" |
+#include "base/lazy_instance.h" |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram.h" |
#include "base/stl_util.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/synchronization/lock.h" |
#include "cc/animation/animation_registrar.h" |
#include "cc/animation/layer_animation_controller.h" |
#include "cc/base/math_util.h" |
@@ -41,7 +43,14 @@ |
#include "ui/gfx/size_conversions.h" |
namespace { |
-static int s_num_layer_tree_instances; |
+static base::LazyInstance<base::Lock>::Leaky |
+ s_next_tree_id_lock = LAZY_INSTANCE_INITIALIZER; |
+ |
+inline int GetNextTreeId() { |
+ static int s_next_tree_id = 1; |
+ base::AutoLock lock(s_next_tree_id_lock.Get()); |
caseq
2013/11/07 09:20:03
Any reason to not use StaticAtomicSequenceNumber h
dshwang
2013/11/07 09:46:03
Hi, Patch Set 1 used AtomicSequenceNumber, but Ato
|
+ return s_next_tree_id++; |
+} |
} |
namespace cc { |
@@ -89,10 +98,6 @@ UIResourceRequest& UIResourceRequest::operator=( |
UIResourceRequest::~UIResourceRequest() {} |
-bool LayerTreeHost::AnyLayerTreeHostInstanceExists() { |
- return s_num_layer_tree_instances > 0; |
-} |
- |
scoped_ptr<LayerTreeHost> LayerTreeHost::Create( |
LayerTreeHostClient* client, |
SharedBitmapManager* manager, |
@@ -105,8 +110,6 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::Create( |
return layer_tree_host.Pass(); |
} |
-static int s_next_tree_id = 1; |
- |
LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
SharedBitmapManager* manager, |
const LayerTreeSettings& settings) |
@@ -135,12 +138,11 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
partial_texture_update_requests_(0), |
in_paint_layer_contents_(false), |
total_frames_used_for_lcd_text_metrics_(0), |
- tree_id_(s_next_tree_id++), |
+ tree_id_(GetNextTreeId()), |
next_commit_forces_redraw_(false), |
shared_bitmap_manager_(manager) { |
if (settings_.accelerated_animation_enabled) |
animation_registrar_ = AnimationRegistrar::Create(); |
- s_num_layer_tree_instances++; |
rendering_stats_instrumentation_->set_record_rendering_stats( |
debug_state_.RecordRenderingStats()); |
} |
@@ -182,8 +184,6 @@ LayerTreeHost::~LayerTreeHost() { |
proxy_->Stop(); |
} |
- s_num_layer_tree_instances--; |
- |
if (root_layer_.get()) { |
// The layer tree must be destroyed before the layer tree host. We've |
// made a contract with our animation controllers that the registrar |