Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / cc / layers / draw_properties.h
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.
4
5 #ifndef CC_LAYERS_DRAW_PROPERTIES_H_
6 #define CC_LAYERS_DRAW_PROPERTIES_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/transform.h"
11
12 namespace cc {
13
14 // Container for properties that layers need to compute before they can be
15 // drawn.
16 template <typename LayerType>
17 struct CC_EXPORT DrawProperties {
18   DrawProperties()
19       : opacity(0.f),
20         opacity_is_animating(false),
21         screen_space_opacity_is_animating(false),
22         target_space_transform_is_animating(false),
23         screen_space_transform_is_animating(false),
24         can_use_lcd_text(false),
25         is_clipped(false),
26         render_target(NULL),
27         contents_scale_x(1.f),
28         contents_scale_y(1.f),
29         num_descendants_that_draw_content(0),
30         num_unclipped_descendants(0),
31         layer_or_descendant_has_copy_request(false),
32         has_child_with_a_scroll_parent(false),
33         sorted_for_recursion(false),
34         index_of_first_descendants_addition(0),
35         num_descendants_added(0),
36         index_of_first_render_surface_layer_list_addition(0),
37         num_render_surfaces_added(0),
38         last_drawn_render_surface_layer_list_id(0) {}
39
40   // Transforms objects from content space to target surface space, where
41   // this layer would be drawn.
42   gfx::Transform target_space_transform;
43
44   // Transforms objects from content space to screen space (viewport space).
45   gfx::Transform screen_space_transform;
46
47   // DrawProperties::opacity may be different than LayerType::opacity,
48   // particularly in the case when a RenderSurface re-parents the layer's
49   // opacity, or when opacity is compounded by the hierarchy.
50   float opacity;
51
52   // xxx_is_animating flags are used to indicate whether the DrawProperties
53   // are actually meaningful on the main thread. When the properties are
54   // animating, the main thread may not have the same values that are used
55   // to draw.
56   bool opacity_is_animating;
57   bool screen_space_opacity_is_animating;
58   bool target_space_transform_is_animating;
59   bool screen_space_transform_is_animating;
60
61   // True if the layer can use LCD text.
62   bool can_use_lcd_text;
63
64   // True if the layer needs to be clipped by clip_rect.
65   bool is_clipped;
66
67   // The layer whose coordinate space this layer draws into. This can be
68   // either the same layer (draw_properties_.render_target == this) or an
69   // ancestor of this layer.
70   LayerType* render_target;
71
72   // The surface that this layer and its subtree would contribute to.
73   scoped_ptr<typename LayerType::RenderSurfaceType> render_surface;
74
75   // This rect is in the layer's content space.
76   gfx::Rect visible_content_rect;
77
78   // In target surface space, the rect that encloses the clipped, drawable
79   // content of the layer.
80   gfx::Rect drawable_content_rect;
81
82   // In target surface space, the original rect that clipped this layer. This
83   // value is used to avoid unnecessarily changing GL scissor state.
84   gfx::Rect clip_rect;
85
86   // The scale used to move between layer space and content space, and bounds
87   // of the space. One is always a function of the other, but which one
88   // depends on the layer type. For picture layers, this is an ideal scale,
89   // and not always the one used.
90   float contents_scale_x;
91   float contents_scale_y;
92   gfx::Size content_bounds;
93
94   // Does not include this layer itself, only its children and descendants.
95   int num_descendants_that_draw_content;
96
97   // Number of descendants with a clip parent that is our ancestor. NB - this
98   // does not include our clip children because they are clipped by us.
99   int num_unclipped_descendants;
100
101   // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
102   // present on it.
103   bool layer_or_descendant_has_copy_request;
104
105   // This is true if the layer has any direct child that has a scroll parent.
106   // This layer will not be the scroll parent in this case. This information
107   // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our
108   // children have scroll parents, we will not need to recur out of order.
109   bool has_child_with_a_scroll_parent;
110
111   // This is true if the order (wrt to its siblings in the tree) in which the
112   // layer will be visited while computing draw properties has been determined.
113   bool sorted_for_recursion;
114
115   // If this layer is visited out of order, its contribution to the descendant
116   // and render surface layer lists will be put aside in a temporary list.
117   // These values will allow for an efficient reordering of these additions.
118   size_t index_of_first_descendants_addition;
119   size_t num_descendants_added;
120   size_t index_of_first_render_surface_layer_list_addition;
121   size_t num_render_surfaces_added;
122
123   // Each time we generate a new render surface layer list, an ID is used to
124   // identify it. |last_drawn_render_surface_layer_list_id| is set to the ID
125   // that marked the render surface layer list generation which last updated
126   // these draw properties and determined that this layer will draw itself.
127   // If these draw properties are not a part of the render surface layer list,
128   // or the layer doesn't contribute anything, then this ID will be either out
129   // of date or 0.
130   int last_drawn_render_surface_layer_list_id;
131 };
132
133 }  // namespace cc
134
135 #endif  // CC_LAYERS_DRAW_PROPERTIES_H_