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

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: Fix GYP build in //cc 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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "cc/animation/layer_animation_controller.h" 15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/layer_animation_value_observer.h" 16 #include "cc/animation/layer_animation_value_observer.h"
17 #include "cc/animation/layer_animation_value_provider.h" 17 #include "cc/animation/layer_animation_value_provider.h"
18 #include "cc/base/cc_export.h" 18 #include "cc/base/cc_export.h"
19 #include "cc/base/region.h" 19 #include "cc/base/region.h"
20 #include "cc/base/scoped_ptr_vector.h" 20 #include "cc/base/scoped_ptr_vector.h"
21 #include "cc/debug/frame_timing_request.h" 21 #include "cc/debug/frame_timing_request.h"
22 #include "cc/debug/micro_benchmark.h" 22 #include "cc/debug/micro_benchmark.h"
23 #include "cc/layers/layer_lists.h" 23 #include "cc/layers/layer_lists.h"
24 #include "cc/layers/layer_position_constraint.h" 24 #include "cc/layers/layer_position_constraint.h"
25 #include "cc/layers/paint_properties.h" 25 #include "cc/layers/paint_properties.h"
26 #include "cc/layers/scroll_blocks_on.h" 26 #include "cc/layers/scroll_blocks_on.h"
27 #include "cc/output/filter_operations.h" 27 #include "cc/output/filter_operations.h"
28 #include "cc/proto/layer.pb.h"
28 #include "cc/trees/property_tree.h" 29 #include "cc/trees/property_tree.h"
29 #include "skia/ext/refptr.h" 30 #include "skia/ext/refptr.h"
30 #include "third_party/skia/include/core/SkColor.h" 31 #include "third_party/skia/include/core/SkColor.h"
31 #include "third_party/skia/include/core/SkImageFilter.h" 32 #include "third_party/skia/include/core/SkImageFilter.h"
32 #include "third_party/skia/include/core/SkPicture.h" 33 #include "third_party/skia/include/core/SkPicture.h"
33 #include "third_party/skia/include/core/SkXfermode.h" 34 #include "third_party/skia/include/core/SkXfermode.h"
34 #include "ui/gfx/geometry/point3_f.h" 35 #include "ui/gfx/geometry/point3_f.h"
35 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
36 #include "ui/gfx/geometry/rect_f.h" 37 #include "ui/gfx/geometry/rect_f.h"
37 #include "ui/gfx/geometry/scroll_offset.h" 38 #include "ui/gfx/geometry/scroll_offset.h"
(...skipping 29 matching lines...) Expand all
67 class SimpleEnclosedRegion; 68 class SimpleEnclosedRegion;
68 struct AnimationEvent; 69 struct AnimationEvent;
69 70
70 // Base class for composited layers. Special layer types are derived from 71 // Base class for composited layers. Special layer types are derived from
71 // this class. 72 // this class.
72 class CC_EXPORT Layer : public base::RefCounted<Layer>, 73 class CC_EXPORT Layer : public base::RefCounted<Layer>,
73 public LayerAnimationValueObserver, 74 public LayerAnimationValueObserver,
74 public LayerAnimationValueProvider { 75 public LayerAnimationValueProvider {
75 public: 76 public:
76 typedef LayerList LayerListType; 77 typedef LayerList LayerListType;
78 typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap;
77 79
78 enum LayerIdLabels { 80 enum LayerIdLabels {
79 INVALID_ID = -1, 81 INVALID_ID = -1,
80 }; 82 };
81 83
82 static scoped_refptr<Layer> Create(const LayerSettings& settings); 84 static scoped_refptr<Layer> Create(const LayerSettings& settings);
83 85
84 int id() const { return layer_id_; } 86 int id() const { return layer_id_; }
85 87
86 Layer* RootLayer(); 88 Layer* RootLayer();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 virtual void SetIsMask(bool is_mask) {} 353 virtual void SetIsMask(bool is_mask) {}
352 virtual bool IsSuitableForGpuRasterization() const; 354 virtual bool IsSuitableForGpuRasterization() const;
353 355
354 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> 356 virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat>
355 TakeDebugInfo(); 357 TakeDebugInfo();
356 358
357 void SetLayerClient(LayerClient* client) { client_ = client; } 359 void SetLayerClient(LayerClient* client) { client_ = client; }
358 360
359 virtual void PushPropertiesTo(LayerImpl* layer); 361 virtual void PushPropertiesTo(LayerImpl* layer);
360 362
363 // Return the proto::LayerType that should be used for serialization of the
364 // current layer.
365 virtual proto::LayerType GetTypeForProtoSerialization() const;
Wez 2015/10/27 03:07:06 IIUC this was previously implicit in the behaviour
nyquist 2015/10/28 16:03:44 Yeah, it could have been done like that. However,
366
367 // Recursively iterate over this layer and all children and write the
368 // hierarchical structure to the given LayerNode proto. In addition to the
369 // structure itself, the Layer id and type is also written to facilitate
370 // construction of the correct layer on the client.
371 void ToLayerNodeProto(proto::LayerNode* proto) const;
Wez 2015/10/27 03:07:06 Is it necessary for these to live on the actual La
nyquist 2015/10/28 16:03:44 AFAIK there is no way to set the Layer id outside
vmpstr 2015/10/28 18:20:49 Yeah, my suggestions only really apply if this is
Wez 2015/10/28 23:59:23 It's not clear that we want to be setting the Laye
372
373 // Recursively iterate over the given LayerNode proto and read the structure
374 // into this node and its children. The |layer_map| should be used to look
375 // for previously existing Layers, since they should be re-used between each
376 // hierarchy update.
377 void FromLayerNodeProto(const proto::LayerNode& proto,
378 const LayerIdMap& layer_map);
379
361 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } 380 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
362 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 381 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
363 382
364 bool AddAnimation(scoped_ptr<Animation> animation); 383 bool AddAnimation(scoped_ptr<Animation> animation);
365 void PauseAnimation(int animation_id, double time_offset); 384 void PauseAnimation(int animation_id, double time_offset);
366 void RemoveAnimation(int animation_id); 385 void RemoveAnimation(int animation_id);
367 void RemoveAnimation(int animation_id, Animation::TargetProperty property); 386 void RemoveAnimation(int animation_id, Animation::TargetProperty property);
368 LayerAnimationController* layer_animation_controller() const { 387 LayerAnimationController* layer_animation_controller() const {
369 return layer_animation_controller_.get(); 388 return layer_animation_controller_.get();
370 } 389 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 732
714 std::vector<FrameTimingRequest> frame_timing_requests_; 733 std::vector<FrameTimingRequest> frame_timing_requests_;
715 bool frame_timing_requests_dirty_; 734 bool frame_timing_requests_dirty_;
716 735
717 DISALLOW_COPY_AND_ASSIGN(Layer); 736 DISALLOW_COPY_AND_ASSIGN(Layer);
718 }; 737 };
719 738
720 } // namespace cc 739 } // namespace cc
721 740
722 #endif // CC_LAYERS_LAYER_H_ 741 #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