summaryrefslogtreecommitdiffstats
path: root/cc/layers/layer_list_impl.h
diff options
context:
space:
mode:
authorvollick <vollick@chromium.org>2016-02-29 21:00:43 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-01 05:01:47 +0000
commit299bf1f63b8253c77530b904874f3435f9bde6d3 (patch)
tree093621b8fc836d3aa87357b06b1976ec83569360 /cc/layers/layer_list_impl.h
parent84e53c857ee87964ca99b52cc892a407b56e2dca (diff)
downloadchromium_src-299bf1f63b8253c77530b904874f3435f9bde6d3.zip
chromium_src-299bf1f63b8253c77530b904874f3435f9bde6d3.tar.gz
chromium_src-299bf1f63b8253c77530b904874f3435f9bde6d3.tar.bz2
Introduce LayerListImpl
In this cl, the LayerTreeImpl constructs a LayerListImpl. The idea being that most plumbing won't need to change at first to get the list to where it needs to be. The first consumer of the LayerTreeImpl that I'm attempting to teach to speak LayerListImpl-ese is the LayerImpl. That has not been completely finished in this cl so that it doesn't become too big and difficult to review. NB: since the actual storage of the LayerImpls doesn't change in this cl (they're still in the LayerTreeImpl), there's no need to guard this work behind a flag. BUG=557194 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1746603002 Cr-Commit-Position: refs/heads/master@{#378398}
Diffstat (limited to 'cc/layers/layer_list_impl.h')
-rw-r--r--cc/layers/layer_list_impl.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/cc/layers/layer_list_impl.h b/cc/layers/layer_list_impl.h
new file mode 100644
index 0000000..befe59e
--- /dev/null
+++ b/cc/layers/layer_list_impl.h
@@ -0,0 +1,81 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_LAYERS_LAYER_LIST_IMPL_H_
+#define CC_LAYERS_LAYER_LIST_IMPL_H_
+
+#include <stdint.h>
+#include <unordered_map>
+
+#include "cc/base/cc_export.h"
+#include "cc/layers/layer_lists.h"
+
+namespace cc {
+class AnimationRegistrar;
+class LayerTreeHostImpl;
+typedef LayerTreeHostImpl LayerListHostImpl;
+
+// This class will eventually replace LayerTreeImpl.
+//
+// There is certainly some unfortunate ambiguity with LayerImplList and
+// OwnedLayerImplList, but this should be temporary. OwnedLayerImplList is used
+// solely for the children of a LayerImpl and this will cease to be a thing as
+// we move away from the layer hierarchy. The LayerImplList, however, does get
+// used a fair bit to describe a list of LayerImpl*'s. I.e., an unowned layer
+// list. In the medium term, I'd like to rename this LayerImplPtrList and, in
+// the fullness of time, a LayerPtrList once Layer disappears.
+class CC_EXPORT LayerListImpl {
+ public:
+ explicit LayerListImpl(LayerListHostImpl* host_impl);
+ ~LayerListImpl();
+
+ AnimationRegistrar* GetAnimationRegistrar() const;
+
+ LayerImpl* LayerById(int id) const;
+
+ // These should be called by LayerImpl's ctor/dtor.
+ void RegisterLayer(LayerImpl* layer);
+ void UnregisterLayer(LayerImpl* layer);
+
+ size_t NumLayers();
+
+ LayerImpl* FindActiveLayerById(int id);
+ LayerImpl* FindPendingLayerById(int id);
+
+ // TODO(vollick): once we've built compositor worker on top of animations,
+ // then this association of id to element layers will not be necessary. The
+ // association will instead be maintained via the animation.
+ void AddToElementMap(LayerImpl* layer);
+ void RemoveFromElementMap(LayerImpl* layer);
+
+ // TODO(thakis): Consider marking this CC_EXPORT once we understand
+ // http://crbug.com/575700 better.
+ struct ElementLayers {
+ // Transform and opacity mutations apply to this layer.
+ LayerImpl* main = nullptr;
+ // Scroll mutations apply to this layer.
+ LayerImpl* scroll = nullptr;
+ };
+
+ // TODO(vollick): this should be removed as well.
+ ElementLayers GetMutableLayers(uint64_t element_id);
+
+ private:
+ bool IsActiveList() const;
+ bool IsPendingList() const;
+
+ // TODO(vollick): Remove after compositor worker is built on animations.
+ using ElementLayersMap = std::unordered_map<uint64_t, ElementLayers>;
+ ElementLayersMap element_layers_map_;
+
+ using LayerIdMap = std::unordered_map<int, LayerImpl*>;
+ LayerIdMap layer_id_map_;
+
+ LayerListHostImpl* layer_list_host_;
+ scoped_ptr<OwnedLayerImplList> layer_;
+};
+
+} // namespace cc
+
+#endif // CC_LAYERS_LAYER_LIST_IMPL_H_