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

Side by Side Diff: cc/layers/layer.h

Issue 1398443008: Add support for (de)serializing cc::Layer hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@review-1394353002
Patch Set: Reorderded TODO Created 5 years, 1 month 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/cc_tests.gyp ('k') | cc/layers/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_LAYERS_LAYER_H_ 5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_ 6 #define CC_LAYERS_LAYER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 class LayerTreeHost; 60 class LayerTreeHost;
61 class LayerTreeHostCommon; 61 class LayerTreeHostCommon;
62 class LayerTreeImpl; 62 class LayerTreeImpl;
63 class LayerTreeSettings; 63 class LayerTreeSettings;
64 class RenderingStatsInstrumentation; 64 class RenderingStatsInstrumentation;
65 class ResourceUpdateQueue; 65 class ResourceUpdateQueue;
66 class ScrollbarLayerInterface; 66 class ScrollbarLayerInterface;
67 class SimpleEnclosedRegion; 67 class SimpleEnclosedRegion;
68 struct AnimationEvent; 68 struct AnimationEvent;
69 69
70 namespace proto {
71 class LayerNode;
72 } // namespace proto
73
70 // Base class for composited layers. Special layer types are derived from 74 // Base class for composited layers. Special layer types are derived from
71 // this class. 75 // this class.
72 class CC_EXPORT Layer : public base::RefCounted<Layer>, 76 class CC_EXPORT Layer : public base::RefCounted<Layer>,
73 public LayerAnimationValueObserver, 77 public LayerAnimationValueObserver,
74 public LayerAnimationValueProvider { 78 public LayerAnimationValueProvider {
75 public: 79 public:
76 typedef LayerList LayerListType; 80 typedef LayerList LayerListType;
81 typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap;
77 82
78 enum LayerIdLabels { 83 enum LayerIdLabels {
79 INVALID_ID = -1, 84 INVALID_ID = -1,
80 }; 85 };
81 86
82 static scoped_refptr<Layer> Create(const LayerSettings& settings); 87 static scoped_refptr<Layer> Create(const LayerSettings& settings);
83 88
84 int id() const { return layer_id_; } 89 int id() const { return layer_id_; }
85 90
86 Layer* RootLayer(); 91 Layer* RootLayer();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 virtual void SetIsMask(bool is_mask) {} 356 virtual void SetIsMask(bool is_mask) {}
352 virtual bool IsSuitableForGpuRasterization() const; 357 virtual bool IsSuitableForGpuRasterization() const;
353 358
354 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> 359 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat>
355 TakeDebugInfo(); 360 TakeDebugInfo();
356 361
357 void SetLayerClient(LayerClient* client) { client_ = client; } 362 void SetLayerClient(LayerClient* client) { client_ = client; }
358 363
359 virtual void PushPropertiesTo(LayerImpl* layer); 364 virtual void PushPropertiesTo(LayerImpl* layer);
360 365
366 // Sets the type proto::LayerType that should be used for serialization
367 // of the current layer by calling LayerNode::set_type(proto::LayerType).
368 // TODO(nyquist): Start using a forward declared enum class when
369 // https://github.com/google/protobuf/issues/67 has been fixed and rolled in.
370 // This function would preferably instead return a proto::LayerType, but
371 // since that is an enum (the protobuf library does not generate enum
372 // classes), it can't be forward declared. We don't want to include
373 // //cc/proto/layer.pb.h in this header file, as it requires that all
374 // dependent targets would have to be given the config for how to include it.
375 virtual void SetTypeForProtoSerialization(proto::LayerNode* proto) const;
376
377 // Recursively iterate over this layer and all children and write the
378 // hierarchical structure to the given LayerNode proto. In addition to the
379 // structure itself, the Layer id and type is also written to facilitate
380 // construction of the correct layer on the client.
381 void ToLayerNodeProto(proto::LayerNode* proto) const;
382
383 // Recursively iterate over the given LayerNode proto and read the structure
384 // into this node and its children. The |layer_map| should be used to look
385 // for previously existing Layers, since they should be re-used between each
386 // hierarchy update.
387 void FromLayerNodeProto(const proto::LayerNode& proto,
388 const LayerIdMap& layer_map);
389
361 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } 390 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
362 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 391 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
363 392
364 bool AddAnimation(scoped_ptr<Animation> animation); 393 bool AddAnimation(scoped_ptr<Animation> animation);
365 void PauseAnimation(int animation_id, double time_offset); 394 void PauseAnimation(int animation_id, double time_offset);
366 void RemoveAnimation(int animation_id); 395 void RemoveAnimation(int animation_id);
367 void RemoveAnimation(int animation_id, Animation::TargetProperty property); 396 void RemoveAnimation(int animation_id, Animation::TargetProperty property);
368 LayerAnimationController* layer_animation_controller() const { 397 LayerAnimationController* layer_animation_controller() const {
369 return layer_animation_controller_.get(); 398 return layer_animation_controller_.get();
370 } 399 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 742
714 std::vector<FrameTimingRequest> frame_timing_requests_; 743 std::vector<FrameTimingRequest> frame_timing_requests_;
715 bool frame_timing_requests_dirty_; 744 bool frame_timing_requests_dirty_;
716 745
717 DISALLOW_COPY_AND_ASSIGN(Layer); 746 DISALLOW_COPY_AND_ASSIGN(Layer);
718 }; 747 };
719 748
720 } // namespace cc 749 } // namespace cc
721 750
722 #endif // CC_LAYERS_LAYER_H_ 751 #endif // CC_LAYERS_LAYER_H_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698