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_LAYERS_DRAW_PROPERTIES_H_
6 #define CC_LAYERS_DRAW_PROPERTIES_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/transform.h"
14 // Container for properties that layers need to compute before they can be
16 template <typename LayerType>
17 struct CC_EXPORT DrawProperties {
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),
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 can_draw_directly_to_backbuffer(false),
32 layer_or_descendant_has_copy_request(false),
33 has_child_with_a_scroll_parent(false),
34 sorted_for_recursion(false),
35 index_of_first_descendants_addition(0),
36 num_descendants_added(0),
37 index_of_first_render_surface_layer_list_addition(0),
38 num_render_surfaces_added(0) {}
40 // Transforms objects from content space to target surface space, where
41 // this layer would be drawn.
42 gfx::Transform target_space_transform;
44 // Transforms objects from content space to screen space (viewport space).
45 gfx::Transform screen_space_transform;
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.
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
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;
61 // True if the layer can use LCD text.
62 bool can_use_lcd_text;
64 // True if the layer needs to be clipped by clip_rect.
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;
72 // The surface that this layer and its subtree would contribute to.
73 scoped_ptr<typename LayerType::RenderSurfaceType> render_surface;
75 // This rect is in the layer's content space.
76 gfx::Rect visible_content_rect;
78 // In target surface space, the rect that encloses the clipped, drawable
79 // content of the layer.
80 gfx::Rect drawable_content_rect;
82 // In target surface space, the original rect that clipped this layer. This
83 // value is used to avoid unnecessarily changing GL scissor state.
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;
94 // Does not include this layer itself, only its children and descendants.
95 int num_descendants_that_draw_content;
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;
101 bool can_draw_directly_to_backbuffer;
103 // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
105 bool layer_or_descendant_has_copy_request;
107 // This is true if the layer has any direct child that has a scroll parent.
108 // This layer will not be the scroll parent in this case. This information
109 // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our
110 // children have scroll parents, we will not need to recur out of order.
111 bool has_child_with_a_scroll_parent;
113 // This is true if the order (wrt to its siblings in the tree) in which the
114 // layer will be visited while computing draw properties has been determined.
115 bool sorted_for_recursion;
117 // If this layer is visited out of order, its contribution to the descendant
118 // and render surface layer lists will be put aside in a temporary list.
119 // These values will allow for an efficient reordering of these additions.
120 size_t index_of_first_descendants_addition;
121 size_t num_descendants_added;
122 size_t index_of_first_render_surface_layer_list_addition;
123 size_t num_render_surfaces_added;
128 #endif // CC_LAYERS_DRAW_PROPERTIES_H_