Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: cc/trees/layer_tree_host.cc

Issue 57713004: Make tree id sequence in LayerTreeHost thread-safe. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index d93e3d5e032e80c8cf353b672338904f832a16f2..bc346e86921d7758ac96848a0ec6aeeaa1906e7a 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -8,9 +8,11 @@
#include <stack>
#include <string>
+#include "base/atomic_sequence_num.h"
#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"
@@ -41,7 +43,14 @@
#include "ui/gfx/size_conversions.h"
namespace {
-static int s_num_layer_tree_instances;
+base::LazyInstance<base::AtomicSequenceNumber>
+ s_next_tree_id = LAZY_INSTANCE_INITIALIZER;
+
+inline int GetNextTreeId() {
+ static int initializeTo1 = s_next_tree_id.Pointer()->GetNext();
+ (void)initializeTo1;
jamesr 2013/11/04 19:18:01 what does this line do? I don't think this complex
dshwang 2013/11/04 19:34:47 Thank you for review. Done.
+ return s_next_tree_id.Pointer()->GetNext();
+}
}
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,7 +184,6 @@ LayerTreeHost::~LayerTreeHost() {
proxy_->Stop();
}
- s_num_layer_tree_instances--;
RateLimiterMap::iterator it = rate_limiters_.begin();
if (it != rate_limiters_.end())
it->second->Stop();
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698