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

Unified Diff: cc/blimp/compositor_state_deserializer.h

Issue 2375363002: cc/blimp: Set up the framework for state serialization. (Closed)
Patch Set: test update Created 4 years, 2 months 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/blimp/compositor_proto_state.cc ('k') | cc/blimp/compositor_state_deserializer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/blimp/compositor_state_deserializer.h
diff --git a/cc/blimp/compositor_state_deserializer.h b/cc/blimp/compositor_state_deserializer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5357bcf5c5da81a3c0846b456f19b5c08a7dba97
--- /dev/null
+++ b/cc/blimp/compositor_state_deserializer.h
@@ -0,0 +1,77 @@
+// 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_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
+#define CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
+
+#include <unordered_map>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+namespace proto {
+class LayerNode;
+class LayerProperties;
+class LayerTree;
+class LayerTreeHost;
+} // namespace proto
+
+class CompositorStateDeserializerClient;
+class Layer;
+class LayerFactory;
+class LayerTreeHost;
+
+// Deserializes the compositor updates into the LayerTreeHost.
+class CC_EXPORT CompositorStateDeserializer {
+ public:
+ // ScrollCallback used to notify the client when the scroll offset for a layer
+ // is updated.
+ using ScrollCallback = base::Callback<void(int engine_layer_id)>;
+
+ CompositorStateDeserializer(LayerTreeHost* layer_tree_host,
+ ScrollCallback scroll_callback,
+ CompositorStateDeserializerClient* client);
+ ~CompositorStateDeserializer();
+
+ // Returns the local layer on the client for the given |engine_layer_id|.
+ Layer* GetLayerForEngineId(int engine_layer_id) const;
+
+ // Deserializes the |layer_tree_host_proto| into the LayerTreeHost.
+ void DeserializeCompositorUpdate(
+ const proto::LayerTreeHost& layer_tree_host_proto);
+
+ // Allows tests to inject the LayerFactory.
+ void SetLayerFactoryForTesting(std::unique_ptr<LayerFactory> layer_factory);
+
+ private:
+ using EngineIdToLayerMap = std::unordered_map<int, scoped_refptr<Layer>>;
+
+ void SychronizeLayerTreeState(const proto::LayerTree& layer_tree_proto);
+ void SynchronizeLayerState(
+ const proto::LayerProperties& layer_properties_proto);
+ void SynchronizeLayerHierarchyRecursive(Layer* layer,
+ const proto::LayerNode& layer_node,
+ EngineIdToLayerMap* new_layer_map);
+ scoped_refptr<Layer> GetLayerAndAddToNewMap(
+ const proto::LayerNode& layer_node,
+ EngineIdToLayerMap* new_layer_map);
+
+ int GetClientIdFromEngineId(int engine_layer_id);
+ scoped_refptr<Layer> GetLayer(int engine_layer_id);
+
+ std::unique_ptr<LayerFactory> layer_factory_;
+ LayerTreeHost* layer_tree_host_;
+ ScrollCallback scroll_callback_;
+ CompositorStateDeserializerClient* client_;
+
+ EngineIdToLayerMap engine_id_to_layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositorStateDeserializer);
+};
+
+} // namespace cc
+
+#endif // CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
« no previous file with comments | « cc/blimp/compositor_proto_state.cc ('k') | cc/blimp/compositor_state_deserializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698