Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / cc / layer_tree_impl.h
blob1adade2c2b25ee95101abe9d3e1404eb0d636dd3
1 // 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.
5 #ifndef CC_LAYER_TREE_IMPL_H_
6 #define CC_LAYER_TREE_IMPL_H_
8 #include "base/hash_tables.h"
9 #include "cc/layer_impl.h"
11 #if defined(COMPILER_GCC)
12 namespace BASE_HASH_NAMESPACE {
13 template<>
14 struct hash<cc::LayerImpl*> {
15 size_t operator()(cc::LayerImpl* ptr) const {
16 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
19 } // namespace BASE_HASH_NAMESPACE
20 #endif // COMPILER
22 namespace cc {
24 class DebugRectHistory;
25 class FrameRateCounter;
26 class HeadsUpDisplayLayerImpl;
27 class LayerTreeDebugState;
28 class LayerTreeHostImpl;
29 class LayerTreeImpl;
30 class LayerTreeSettings;
31 class OutputSurface;
32 class PaintTimeCounter;
33 class PinchZoomViewport;
34 class Proxy;
35 class ResourceProvider;
36 class TileManager;
38 class CC_EXPORT LayerTreeImpl {
39 public:
40 typedef std::vector<LayerImpl*> LayerList;
42 static scoped_ptr<LayerTreeImpl> create(LayerTreeHostImpl* layer_tree_host_impl)
44 return make_scoped_ptr(new LayerTreeImpl(layer_tree_host_impl));
46 virtual ~LayerTreeImpl();
48 // Methods called by the layer tree that pass-through or access LTHI.
49 // ---------------------------------------------------------------------------
50 const LayerTreeSettings& settings() const;
51 OutputSurface* output_surface() const;
52 ResourceProvider* resource_provider() const;
53 TileManager* tile_manager() const;
54 FrameRateCounter* frame_rate_counter() const;
55 PaintTimeCounter* paint_time_counter() const;
56 bool IsActiveTree() const;
57 bool IsPendingTree() const;
58 bool IsRecycleTree() const;
59 LayerImpl* FindActiveTreeLayerById(int id);
60 LayerImpl* FindPendingTreeLayerById(int id);
61 int MaxTextureSize() const;
62 bool PinchGestureActive() const;
63 base::TimeTicks CurrentFrameTime() const;
65 // Tree specific methods exposed to layer-impl tree.
66 // ---------------------------------------------------------------------------
67 void SetNeedsRedraw();
69 // TODO(nduca): These are implemented in cc files temporarily, but will become
70 // trivial accessors in a followup patch.
71 const LayerTreeDebugState& debug_state() const;
72 float device_scale_factor() const;
73 const gfx::Size& device_viewport_size() const;
74 const gfx::Size& layout_viewport_size() const;
75 std::string layer_tree_as_text() const;
76 DebugRectHistory* debug_rect_history() const;
77 const PinchZoomViewport& pinch_zoom_viewport() const;
79 // Other public methods
80 // ---------------------------------------------------------------------------
81 LayerImpl* RootLayer() const { return root_layer_.get(); }
82 void SetRootLayer(scoped_ptr<LayerImpl>);
83 scoped_ptr<LayerImpl> DetachLayerTree();
85 int source_frame_number() const { return source_frame_number_; }
86 void set_source_frame_number(int frame_number) {
87 source_frame_number_ = frame_number;
90 HeadsUpDisplayLayerImpl* hud_layer() { return hud_layer_; }
91 void set_hud_layer(HeadsUpDisplayLayerImpl* layer_impl) {
92 hud_layer_ = layer_impl;
95 LayerImpl* RootScrollLayer();
96 LayerImpl* CurrentlyScrollingLayer();
97 void set_currently_scrolling_layer(LayerImpl* layer) {
98 currently_scrolling_layer_ = layer;
101 void ClearCurrentlyScrollingLayer();
103 void FindRootScrollLayer();
104 void UpdateMaxScrollOffset();
106 SkColor background_color() const { return background_color_; }
107 void set_background_color(SkColor color) { background_color_ = color; }
109 bool has_transparent_background() const {
110 return has_transparent_background_;
112 void set_has_transparent_background(bool transparent) {
113 has_transparent_background_ = transparent;
116 enum UpdateDrawPropertiesReason {
117 UPDATE_PENDING_TREE,
118 UPDATE_ACTIVE_TREE,
119 UPDATE_ACTIVE_TREE_FOR_DRAW
122 // Updates draw properties and render surface layer list
123 void UpdateDrawProperties(UpdateDrawPropertiesReason reason);
124 void set_needs_update_draw_properties() {
125 needs_update_draw_properties_ = true;
127 bool needs_update_draw_properties() const {
128 return needs_update_draw_properties_;
131 void ClearRenderSurfaces();
133 bool AreVisibleResourcesReady() const;
135 const LayerList& RenderSurfaceLayerList() const;
137 gfx::Size ScrollableSize() const;
139 LayerImpl* LayerById(int id);
141 // These should be called by LayerImpl's ctor/dtor.
142 void RegisterLayer(LayerImpl* layer);
143 void UnregisterLayer(LayerImpl* layer);
145 AnimationRegistrar* animationRegistrar() const;
147 void PushPersistedState(LayerTreeImpl* pendingTree);
149 void DidBecomeActive();
151 bool ContentsTexturesPurged() const;
152 void SetContentsTexturesPurged();
153 void ResetContentsTexturesPurged();
155 // Useful for debug assertions, probably shouldn't be used for anything else.
156 Proxy* proxy() const;
158 protected:
159 LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl);
161 LayerTreeHostImpl* layer_tree_host_impl_;
162 int source_frame_number_;
163 scoped_ptr<LayerImpl> root_layer_;
164 HeadsUpDisplayLayerImpl* hud_layer_;
165 LayerImpl* root_scroll_layer_;
166 LayerImpl* currently_scrolling_layer_;
167 SkColor background_color_;
168 bool has_transparent_background_;
170 typedef base::hash_map<int, LayerImpl*> LayerIdMap;
171 LayerIdMap layer_id_map_;
173 // Persisted state for non-impl-side-painting.
174 int scrolling_layer_id_from_previous_tree_;
176 // List of visible layers for the most recently prepared frame. Used for
177 // rendering and input event hit testing.
178 LayerList render_surface_layer_list_;
180 bool contents_textures_purged_;
181 bool needs_update_draw_properties_;
183 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
188 #endif // CC_LAYER_TREE_IMPL_H_