Bug 866232 - Reserve a layer tree id for the root layer tree. r=BenWa
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 30 Jul 2013 14:03:38 -0400
changeset 152815 e0e4277435b46897d95e6c9769a6c6507540407e
parent 152814 5f3b576714e543f33041f2a85bd48fd0ce1c88ae
child 152816 ef02c1c1d6d50cc0b1f600078bccbb29bc77a52f
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs866232
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 866232 - Reserve a layer tree id for the root layer tree. r=BenWa
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -692,22 +692,27 @@ CompositorParent::RecvNotifyChildCreated
 }
 
 void
 CompositorParent::NotifyChildCreated(uint64_t aChild)
 {
   sIndirectLayerTrees[aChild].mParent = this;
 }
 
+// Ensure all layer tree IDs are greater than zero, so if we
+// ever see a zero-valued layer tree id we know it's actually
+// uninitialized and/or garbage.
+uint64_t CompositorParent::ROOT_LAYER_TREE_ID = 1;
+
 /*static*/ uint64_t
 CompositorParent::AllocateLayerTreeId()
 {
   MOZ_ASSERT(CompositorLoop());
   MOZ_ASSERT(NS_IsMainThread());
-  static uint64_t ids;
+  static uint64_t ids = ROOT_LAYER_TREE_ID;
   return ++ids;
 }
 
 static void
 EraseLayerState(uint64_t aId)
 {
   sIndirectLayerTrees.erase(aId);
 }
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -109,16 +109,21 @@ public:
   static void StartUp();
 
   /**
    * Destroys the compositor thread and the global compositor map.
    */
   static void ShutDown();
 
   /**
+   * The reserved layer tree ID for the root of the layer tree.
+   */
+  static uint64_t ROOT_LAYER_TREE_ID;
+
+  /**
    * Allocate an ID that can be used to refer to a layer tree and
    * associated resources that live only on the compositor thread.
    *
    * Must run on the content main thread.
    */
   static uint64_t AllocateLayerTreeId();
   /**
    * Release compositor-thread resources referred to by |aID|.