Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / layers / draw_properties.h
bloba0bfc2a6f2f741eedb036e5c73d8c5c10baeaa27
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"
12 namespace cc {
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 layer_or_descendant_has_input_handler(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),
39 last_drawn_render_surface_layer_list_id(0),
40 ideal_contents_scale(0.f),
41 maximum_animation_contents_scale(0.f),
42 page_scale_factor(0.f),
43 device_scale_factor(0.f) {}
45 // Transforms objects from content space to target surface space, where
46 // this layer would be drawn.
47 gfx::Transform target_space_transform;
49 // Transforms objects from content space to screen space (viewport space).
50 gfx::Transform screen_space_transform;
52 // DrawProperties::opacity may be different than LayerType::opacity,
53 // particularly in the case when a RenderSurface re-parents the layer's
54 // opacity, or when opacity is compounded by the hierarchy.
55 float opacity;
57 // xxx_is_animating flags are used to indicate whether the DrawProperties
58 // are actually meaningful on the main thread. When the properties are
59 // animating, the main thread may not have the same values that are used
60 // to draw.
61 bool opacity_is_animating;
62 bool screen_space_opacity_is_animating;
63 bool target_space_transform_is_animating;
64 bool screen_space_transform_is_animating;
66 // True if the layer can use LCD text.
67 bool can_use_lcd_text;
69 // True if the layer needs to be clipped by clip_rect.
70 bool is_clipped;
72 // The layer whose coordinate space this layer draws into. This can be
73 // either the same layer (draw_properties_.render_target == this) or an
74 // ancestor of this layer.
75 LayerType* render_target;
77 // The surface that this layer and its subtree would contribute to.
78 scoped_ptr<typename LayerType::RenderSurfaceType> render_surface;
80 // This rect is in the layer's content space.
81 gfx::Rect visible_content_rect;
83 // In target surface space, the rect that encloses the clipped, drawable
84 // content of the layer.
85 gfx::Rect drawable_content_rect;
87 // In target surface space, the original rect that clipped this layer. This
88 // value is used to avoid unnecessarily changing GL scissor state.
89 gfx::Rect clip_rect;
91 // The scale used to move between layer space and content space, and bounds
92 // of the space. One is always a function of the other, but which one
93 // depends on the layer type. For picture layers, this is an ideal scale,
94 // and not always the one used.
95 float contents_scale_x;
96 float contents_scale_y;
97 gfx::Size content_bounds;
99 // Does not include this layer itself, only its children and descendants.
100 int num_descendants_that_draw_content;
102 // Number of descendants with a clip parent that is our ancestor. NB - this
103 // does not include our clip children because they are clipped by us.
104 int num_unclipped_descendants;
106 // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
107 // present on it.
108 bool layer_or_descendant_has_copy_request;
110 // If true, the layer or one of its descendants has a wheel or touch handler.
111 bool layer_or_descendant_has_input_handler;
113 // This is true if the layer has any direct child that has a scroll parent.
114 // This layer will not be the scroll parent in this case. This information
115 // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our
116 // children have scroll parents, we will not need to recur out of order.
117 bool has_child_with_a_scroll_parent;
119 // This is true if the order (wrt to its siblings in the tree) in which the
120 // layer will be visited while computing draw properties has been determined.
121 bool sorted_for_recursion;
123 // If this layer is visited out of order, its contribution to the descendant
124 // and render surface layer lists will be put aside in a temporary list.
125 // These values will allow for an efficient reordering of these additions.
126 size_t index_of_first_descendants_addition;
127 size_t num_descendants_added;
128 size_t index_of_first_render_surface_layer_list_addition;
129 size_t num_render_surfaces_added;
131 // Each time we generate a new render surface layer list, an ID is used to
132 // identify it. |last_drawn_render_surface_layer_list_id| is set to the ID
133 // that marked the render surface layer list generation which last updated
134 // these draw properties and determined that this layer will draw itself.
135 // If these draw properties are not a part of the render surface layer list,
136 // or the layer doesn't contribute anything, then this ID will be either out
137 // of date or 0.
138 int last_drawn_render_surface_layer_list_id;
140 // The scale at which content for the layer should be rastered in order to be
141 // perfectly crisp.
142 float ideal_contents_scale;
144 // The maximum scale during the layers current animation at which content
145 // should be rastered at to be crisp.
146 float maximum_animation_contents_scale;
148 // The page scale factor that is applied to the layer. Since some layers may
149 // have page scale applied and others not, this may differ between layers.
150 float page_scale_factor;
152 // The device scale factor that is applied to the layer.
153 float device_scale_factor;
156 } // namespace cc
158 #endif // CC_LAYERS_DRAW_PROPERTIES_H_