blob: 8d65030e13965991d35e2e232baa560e548a2dc2 [file] [log] [blame]
[email protected]3b31c6ac2012-12-06 21:27:291// Copyright 2012 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_LAYER_TREE_IMPL_H_
6#define CC_LAYER_TREE_IMPL_H_
7
[email protected]361bc00d2012-12-14 07:03:248#include "base/hash_tables.h"
[email protected]3b31c6ac2012-12-06 21:27:299#include "cc/layer_impl.h"
10
[email protected]361bc00d2012-12-14 07:03:2411#if defined(COMPILER_GCC)
12namespace BASE_HASH_NAMESPACE {
13template<>
14struct hash<cc::LayerImpl*> {
15 size_t operator()(cc::LayerImpl* ptr) const {
16 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
17 }
18};
19} // namespace BASE_HASH_NAMESPACE
20#endif // COMPILER
21
[email protected]3b31c6ac2012-12-06 21:27:2922namespace cc {
23
[email protected]ff762fb2012-12-12 19:18:3724class DebugRectHistory;
25class FrameRateCounter;
26class HeadsUpDisplayLayerImpl;
27class LayerTreeDebugState;
[email protected]3b31c6ac2012-12-06 21:27:2928class LayerTreeHostImpl;
29class LayerTreeImpl;
[email protected]ff762fb2012-12-12 19:18:3730class LayerTreeSettings;
31class OutputSurface;
[email protected]caa567d2012-12-20 07:56:1632class PinchZoomViewport;
[email protected]ff762fb2012-12-12 19:18:3733class ResourceProvider;
34class TileManager;
[email protected]3b31c6ac2012-12-06 21:27:2935
[email protected]3b31c6ac2012-12-06 21:27:2936class CC_EXPORT LayerTreeImpl {
37 public:
[email protected]76ffd9e2012-12-20 19:12:4738 typedef std::vector<LayerImpl*> LayerList;
39
[email protected]8bef40572012-12-11 21:38:0840 static scoped_ptr<LayerTreeImpl> create(LayerTreeHostImpl* layer_tree_host_impl)
[email protected]3b31c6ac2012-12-06 21:27:2941 {
[email protected]8bef40572012-12-11 21:38:0842 return make_scoped_ptr(new LayerTreeImpl(layer_tree_host_impl));
[email protected]3b31c6ac2012-12-06 21:27:2943 }
44 virtual ~LayerTreeImpl();
45
[email protected]f117a4c2012-12-16 04:53:1046 // Methods called by the layer tree that pass-through or access LTHI.
[email protected]8bef40572012-12-11 21:38:0847 // ---------------------------------------------------------------------------
[email protected]ff762fb2012-12-12 19:18:3748 const LayerTreeSettings& settings() const;
49 OutputSurface* output_surface() const;
50 ResourceProvider* resource_provider() const;
51 TileManager* tile_manager() const;
52 FrameRateCounter* frame_rate_counter() const;
[email protected]f117a4c2012-12-16 04:53:1053 bool IsActiveTree() const;
54 bool IsPendingTree() const;
55 LayerImpl* FindActiveTreeLayerById(int id);
56 LayerImpl* FindPendingTreeLayerById(int id);
[email protected]f6776532012-12-21 20:24:3357 int MaxTextureSize() const;
[email protected]ff762fb2012-12-12 19:18:3758
59 // Tree specific methods exposed to layer-impl tree.
60 // ---------------------------------------------------------------------------
61 void SetNeedsRedraw();
62 void SetNeedsUpdateDrawProperties();
63
64 // TODO(nduca): These are implemented in cc files temporarily, but will become
65 // trivial accessors in a followup patch.
66 const LayerTreeDebugState& debug_state() const;
67 float device_scale_factor() const;
68 const gfx::Size& device_viewport_size() const;
69 const gfx::Size& layout_viewport_size() const;
70 std::string layer_tree_as_text() const;
71 DebugRectHistory* debug_rect_history() const;
[email protected]caa567d2012-12-20 07:56:1672 const PinchZoomViewport& pinch_zoom_viewport() const;
[email protected]8bef40572012-12-11 21:38:0873
74 // Other public methods
75 // ---------------------------------------------------------------------------
[email protected]3b31c6ac2012-12-06 21:27:2976 LayerImpl* RootLayer() const { return root_layer_.get(); }
77 void SetRootLayer(scoped_ptr<LayerImpl>);
78 scoped_ptr<LayerImpl> DetachLayerTree();
79
80 int source_frame_number() const { return source_frame_number_; }
81 void set_source_frame_number(int frame_number) { source_frame_number_ = frame_number; }
82
83 HeadsUpDisplayLayerImpl* hud_layer() { return hud_layer_; }
84 void set_hud_layer(HeadsUpDisplayLayerImpl* layer_impl) { hud_layer_ = layer_impl; }
85
86 LayerImpl* root_scroll_layer() { return root_scroll_layer_; }
[email protected]caa567d2012-12-20 07:56:1687 const LayerImpl* root_scroll_layer() const { return root_scroll_layer_; }
[email protected]3b31c6ac2012-12-06 21:27:2988 void set_root_scroll_layer(LayerImpl* layer_impl) { root_scroll_layer_ = layer_impl; }
89
90 LayerImpl* currently_scrolling_layer() { return currently_scrolling_layer_; }
91 void set_currently_scrolling_layer(LayerImpl* layer_impl) { currently_scrolling_layer_ = layer_impl; }
92
93 void ClearCurrentlyScrollingLayer();
94
[email protected]caa567d2012-12-20 07:56:1695 void UpdateMaxScrollOffset();
96
[email protected]76ffd9e2012-12-20 19:12:4797 // Updates draw properties and render surface layer list
98 void UpdateDrawProperties();
99
100 void ClearRenderSurfaces();
101
102 const LayerList& RenderSurfaceLayerList() const;
103
[email protected]caa567d2012-12-20 07:56:16104 gfx::Size ContentSize() const;
105
[email protected]361bc00d2012-12-14 07:03:24106 LayerImpl* LayerById(int id);
107
108 // These should be called by LayerImpl's ctor/dtor.
109 void RegisterLayer(LayerImpl* layer);
110 void UnregisterLayer(LayerImpl* layer);
111
[email protected]de4afb5e2012-12-20 00:11:34112 AnimationRegistrar* animationRegistrar() const;
113
[email protected]3b31c6ac2012-12-06 21:27:29114protected:
[email protected]8bef40572012-12-11 21:38:08115 LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl);
[email protected]3b31c6ac2012-12-06 21:27:29116
[email protected]8bef40572012-12-11 21:38:08117 LayerTreeHostImpl* layer_tree_host_impl_;
[email protected]3b31c6ac2012-12-06 21:27:29118 int source_frame_number_;
119 scoped_ptr<LayerImpl> root_layer_;
120 HeadsUpDisplayLayerImpl* hud_layer_;
121 LayerImpl* root_scroll_layer_;
122 LayerImpl* currently_scrolling_layer_;
123
[email protected]361bc00d2012-12-14 07:03:24124 typedef base::hash_map<int, LayerImpl*> LayerIdMap;
125 LayerIdMap layer_id_map_;
126
[email protected]3b31c6ac2012-12-06 21:27:29127 // Persisted state
128 int scrolling_layer_id_from_previous_tree_;
129
[email protected]76ffd9e2012-12-20 19:12:47130 // List of visible layers for the most recently prepared frame. Used for
131 // rendering and input event hit testing.
132 LayerList render_surface_layer_list_;
133
[email protected]3b31c6ac2012-12-06 21:27:29134 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
135};
136
137}
138
139#endif // CC_LAYER_TREE_IMPL_H_