summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 19:11:17 +0000
committerdongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 19:11:17 +0000
commite7ad294747df745e4f0376b7cbc8b0cb1aca9eb9 (patch)
treef8d10d94fabfcbb0951d3981491120096d09738a /cc
parentf125f922278ba8ca2558da2bda7914742931d3c2 (diff)
downloadchromium_src-e7ad294747df745e4f0376b7cbc8b0cb1aca9eb9.zip
chromium_src-e7ad294747df745e4f0376b7cbc8b0cb1aca9eb9.tar.gz
chromium_src-e7ad294747df745e4f0376b7cbc8b0cb1aca9eb9.tar.bz2
Make tree id sequence in LayerTreeHost thread-safe.
LayerTreeHost instances can exists in multiple threads. e.g. Aura with --single-process. So this CL makes the sequence thread-safe. In addition, this CL removes unused s_num_layer_tree_instances. Review URL: https://codereview.chromium.org/57713004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host.cc22
-rw-r--r--cc/trees/layer_tree_host.h3
2 files changed, 11 insertions, 14 deletions
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index b0eed2f..c14736a 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());
+ 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
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index 5a3ca04..aa057e0 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -121,9 +121,6 @@ class CC_EXPORT LayerTreeHost {
void SetLayerTreeHostClientReady();
- // Returns true if any LayerTreeHost is alive.
- static bool AnyLayerTreeHostInstanceExists();
-
void set_needs_filter_context() { needs_filter_context_ = true; }
bool needs_offscreen_context() const {
return needs_filter_context_;