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

Side by Side Diff: cc/blimp/compositor_state_deserializer.h

Issue 2375363002: cc/blimp: Set up the framework for state serialization. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
6 #define CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
7
8 #include <unordered_map>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "cc/base/cc_export.h"
13
14 namespace cc {
15 namespace proto {
16 class LayerNode;
17 class LayerProperties;
18 class LayerTree;
19 class LayerTreeHost;
20 } // namespace proto
21
22 class CompositorStateDeserializerClient;
23 class Layer;
24 class LayerTreeHost;
25
26 // Deserializes the compositor updates into the LayerTreeHost.
27 class CC_EXPORT CompositorStateDeserializer {
28 public:
29 // ScrollCallback used to notify the client when the scroll offset for a layer
30 // is updated.
31 using ScrollCallback = base::Callback<void(int engine_layer_id)>;
32
33 CompositorStateDeserializer(LayerTreeHost* layer_tree_host,
34 ScrollCallback scroll_callback,
35 CompositorStateDeserializerClient* client);
36 ~CompositorStateDeserializer();
37
38 // Returns the local layer on the client for the given |engine_layer_id|.
39 Layer* GetLayerForEngineId(int engine_layer_id) const;
40
41 // Deserializes the |layer_tree_host_proto| into the LayerTreeHost.
42 void DeserializeCompositorUpdate(
43 const proto::LayerTreeHost& layer_tree_host_proto);
44
45 private:
46 using EngineIdToLayerMap = std::unordered_map<int, scoped_refptr<Layer>>;
47
48 void SychronizeLayerTreeState(const proto::LayerTree& layer_tree_proto);
49 void SynchronizeLayerState(
50 const proto::LayerProperties& layer_properties_proto);
51 void SynchronizeLayerHeirarchyRecursive(Layer* layer,
52 const proto::LayerNode& layer_node,
53 EngineIdToLayerMap* new_layer_map);
54 scoped_refptr<Layer> GetLayerAndAddToNewMap(
55 const proto::LayerNode& layer_node,
56 EngineIdToLayerMap* new_layer_map);
57
58 int GetClientIdFromEngineId(int engine_layer_id);
59 scoped_refptr<Layer> GetLayer(int engine_layer_id);
60
61 LayerTreeHost* layer_tree_host_;
62 ScrollCallback scroll_callback_;
63 CompositorStateDeserializerClient* client_;
64
65 EngineIdToLayerMap engine_id_to_layer_;
66
67 DISALLOW_COPY_AND_ASSIGN(CompositorStateDeserializer);
68 };
69
70 } // namespace cc
71
72 #endif // CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698