diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 3f8d6a21bf6b..bfd4a0361a8b 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -697,12 +697,17 @@ 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; } diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 3b8612639d91..70ba9362428e 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -113,6 +113,11 @@ public: */ 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.