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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 LayerFactory;
25 class LayerTreeHost;
26
27 // Deserializes the compositor updates into the LayerTreeHost.
28 class CC_EXPORT CompositorStateDeserializer {
29 public:
30 // ScrollCallback used to notify the client when the scroll offset for a layer
31 // is updated.
32 using ScrollCallback = base::Callback<void(int engine_layer_id)>;
33
34 CompositorStateDeserializer(LayerTreeHost* layer_tree_host,
35 ScrollCallback scroll_callback,
36 CompositorStateDeserializerClient* client);
37 ~CompositorStateDeserializer();
38
39 // Returns the local layer on the client for the given |engine_layer_id|.
40 Layer* GetLayerForEngineId(int engine_layer_id) const;
41
42 // Deserializes the |layer_tree_host_proto| into the LayerTreeHost.
43 void DeserializeCompositorUpdate(
44 const proto::LayerTreeHost& layer_tree_host_proto);
45
46 // Allows tests to inject the LayerFactory.
47 void SetLayerFactoryForTesting(std::unique_ptr<LayerFactory> layer_factory);
48
49 private:
50 using EngineIdToLayerMap = std::unordered_map<int, scoped_refptr<Layer>>;
51
52 void SychronizeLayerTreeState(const proto::LayerTree& layer_tree_proto);
53 void SynchronizeLayerState(
54 const proto::LayerProperties& layer_properties_proto);
55 void SynchronizeLayerHierarchyRecursive(Layer* layer,
56 const proto::LayerNode& layer_node,
57 EngineIdToLayerMap* new_layer_map);
58 scoped_refptr<Layer> GetLayerAndAddToNewMap(
59 const proto::LayerNode& layer_node,
60 EngineIdToLayerMap* new_layer_map);
61
62 int GetClientIdFromEngineId(int engine_layer_id);
63 scoped_refptr<Layer> GetLayer(int engine_layer_id);
64
65 std::unique_ptr<LayerFactory> layer_factory_;
66 LayerTreeHost* layer_tree_host_;
67 ScrollCallback scroll_callback_;
68 CompositorStateDeserializerClient* client_;
69
70 EngineIdToLayerMap engine_id_to_layer_;
71
72 DISALLOW_COPY_AND_ASSIGN(CompositorStateDeserializer);
73 };
74
75 } // namespace cc
76
77 #endif // CC_BLIMP_COMPOSITOR_STATE_DESERIALIZER_H_
OLDNEW
« 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