Separate projection mode from rest of touch HUD
[chromium-blink-merge.git] / cc / layers / render_surface_impl.h
blob6f3e752fb21b9a673facb77a6482c095b9c942f2
1 // Copyright 2011 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_LAYERS_RENDER_SURFACE_IMPL_H_
6 #define CC_LAYERS_RENDER_SURFACE_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/layers/layer_lists.h"
15 #include "cc/quads/render_pass.h"
16 #include "cc/quads/shared_quad_state.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/rect_f.h"
19 #include "ui/gfx/transform.h"
21 namespace cc {
23 class DamageTracker;
24 class DelegatedRendererLayerImpl;
25 class QuadSink;
26 class RenderPassSink;
27 class LayerImpl;
29 struct AppendQuadsData;
31 class CC_EXPORT RenderSurfaceImpl {
32 public:
33 explicit RenderSurfaceImpl(LayerImpl* owning_layer);
34 virtual ~RenderSurfaceImpl();
36 std::string Name() const;
38 gfx::PointF ContentRectCenter() const {
39 return gfx::RectF(content_rect_).CenterPoint();
42 // Returns the rect that encloses the RenderSurfaceImpl including any
43 // reflection.
44 gfx::RectF DrawableContentRect() const;
46 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; }
47 float draw_opacity() const { return draw_opacity_; }
49 void SetNearestAncestorThatMovesPixels(RenderSurfaceImpl* surface) {
50 nearest_ancestor_that_moves_pixels_ = surface;
52 const RenderSurfaceImpl* nearest_ancestor_that_moves_pixels() const {
53 return nearest_ancestor_that_moves_pixels_;
56 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) {
57 draw_opacity_is_animating_ = draw_opacity_is_animating;
59 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
61 void SetDrawTransform(const gfx::Transform& draw_transform) {
62 draw_transform_ = draw_transform;
64 const gfx::Transform& draw_transform() const { return draw_transform_; }
66 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) {
67 screen_space_transform_ = screen_space_transform;
69 const gfx::Transform& screen_space_transform() const {
70 return screen_space_transform_;
73 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) {
74 replica_draw_transform_ = replica_draw_transform;
76 const gfx::Transform& replica_draw_transform() const {
77 return replica_draw_transform_;
80 void SetReplicaScreenSpaceTransform(
81 const gfx::Transform& replica_screen_space_transform) {
82 replica_screen_space_transform_ = replica_screen_space_transform;
84 const gfx::Transform& replica_screen_space_transform() const {
85 return replica_screen_space_transform_;
88 void SetTargetSurfaceTransformsAreAnimating(bool animating) {
89 target_surface_transforms_are_animating_ = animating;
91 bool target_surface_transforms_are_animating() const {
92 return target_surface_transforms_are_animating_;
94 void SetScreenSpaceTransformsAreAnimating(bool animating) {
95 screen_space_transforms_are_animating_ = animating;
97 bool screen_space_transforms_are_animating() const {
98 return screen_space_transforms_are_animating_;
101 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; }
102 bool is_clipped() const { return is_clipped_; }
104 void SetClipRect(gfx::Rect clip_rect);
105 gfx::Rect clip_rect() const { return clip_rect_; }
107 bool ContentsChanged() const;
109 void SetContentRect(gfx::Rect content_rect);
110 gfx::Rect content_rect() const { return content_rect_; }
112 LayerImplList& layer_list() { return layer_list_; }
113 void AddContributingDelegatedRenderPassLayer(LayerImpl* layer);
114 void ClearLayerLists();
116 int OwningLayerId() const;
118 void ResetPropertyChangedFlag() { surface_property_changed_ = false; }
119 bool SurfacePropertyChanged() const;
120 bool SurfacePropertyChangedOnlyFromDescendant() const;
122 DamageTracker* damage_tracker() const { return damage_tracker_.get(); }
124 RenderPass::Id RenderPassId();
126 void AppendRenderPasses(RenderPassSink* pass_sink);
127 void AppendQuads(QuadSink* quad_sink,
128 AppendQuadsData* append_quads_data,
129 bool for_replica,
130 RenderPass::Id render_pass_id);
132 private:
133 LayerImpl* owning_layer_;
135 // Uses this surface's space.
136 gfx::Rect content_rect_;
137 bool surface_property_changed_;
139 float draw_opacity_;
140 bool draw_opacity_is_animating_;
141 gfx::Transform draw_transform_;
142 gfx::Transform screen_space_transform_;
143 gfx::Transform replica_draw_transform_;
144 gfx::Transform replica_screen_space_transform_;
145 bool target_surface_transforms_are_animating_;
146 bool screen_space_transforms_are_animating_;
148 bool is_clipped_;
150 // Uses the space of the surface's target surface.
151 gfx::Rect clip_rect_;
153 LayerImplList layer_list_;
154 std::vector<DelegatedRendererLayerImpl*>
155 contributing_delegated_render_pass_layer_list_;
157 // The nearest ancestor target surface that will contain the contents of this
158 // surface, and that is going to move pixels within the surface (such as with
159 // a blur). This can point to itself.
160 RenderSurfaceImpl* nearest_ancestor_that_moves_pixels_;
162 scoped_ptr<DamageTracker> damage_tracker_;
164 // For LayerIteratorActions
165 int target_render_surface_layer_index_history_;
166 int current_layer_index_history_;
168 friend struct LayerIteratorActions;
170 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl);
173 } // namespace cc
174 #endif // CC_LAYERS_RENDER_SURFACE_IMPL_H_