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 "cc/trees/occlusion.h"
10 #include "third_party/skia/include/core/SkXfermode.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/transform.h"
16 // Container for properties that layers need to compute before they can be
18 template <typename LayerType
>
19 struct CC_EXPORT DrawProperties
{
22 blend_mode(SkXfermode::kSrcOver_Mode
),
23 opacity_is_animating(false),
24 screen_space_opacity_is_animating(false),
25 target_space_transform_is_animating(false),
26 screen_space_transform_is_animating(false),
27 can_use_lcd_text(false),
29 render_target(nullptr),
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 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 maximum_animation_contents_scale(0.f
),
40 starting_animation_contents_scale(0.f
) {}
42 // Transforms objects from content space to target surface space, where
43 // this layer would be drawn.
44 gfx::Transform target_space_transform
;
46 // Transforms objects from content space to screen space (viewport space).
47 gfx::Transform screen_space_transform
;
49 // Known occlusion above the layer mapped to the content space of the layer.
50 Occlusion occlusion_in_content_space
;
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.
57 // DrawProperties::blend_mode may be different than LayerType::blend_mode,
58 // when a RenderSurface re-parents the layer's blend_mode.
59 SkXfermode::Mode blend_mode
;
61 // xxx_is_animating flags are used to indicate whether the DrawProperties
62 // are actually meaningful on the main thread. When the properties are
63 // animating, the main thread may not have the same values that are used
65 bool opacity_is_animating
;
66 bool screen_space_opacity_is_animating
;
67 bool target_space_transform_is_animating
;
68 bool screen_space_transform_is_animating
;
70 // True if the layer can use LCD text.
71 bool can_use_lcd_text
;
73 // True if the layer needs to be clipped by clip_rect.
76 // The layer whose coordinate space this layer draws into. This can be
77 // either the same layer (draw_properties_.render_target == this) or an
78 // ancestor of this layer.
79 LayerType
* render_target
;
81 // This rect is a bounding box around what part of the layer is visible, in
82 // the layer's coordinate space.
83 gfx::Rect visible_layer_rect
;
85 // In target surface space, the rect that encloses the clipped, drawable
86 // content of the layer.
87 gfx::Rect drawable_content_rect
;
89 // In target surface space, the original rect that clipped this layer. This
90 // value is used to avoid unnecessarily changing GL scissor state.
93 // Number of descendants with a clip parent that is our ancestor. NB - this
94 // does not include our clip children because they are clipped by us.
95 size_t num_unclipped_descendants
;
97 // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
99 bool layer_or_descendant_has_copy_request
;
101 // If true, the layer or one of its descendants has a wheel or touch handler.
102 bool layer_or_descendant_has_input_handler
;
104 // This is true if the layer has any direct child that has a scroll parent.
105 // This layer will not be the scroll parent in this case. This information
106 // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our
107 // children have scroll parents, we will not need to recur out of order.
108 bool has_child_with_a_scroll_parent
;
110 // If this layer is visited out of order, its contribution to the descendant
111 // and render surface layer lists will be put aside in a temporary list.
112 // These values will allow for an efficient reordering of these additions.
113 size_t index_of_first_descendants_addition
;
114 size_t num_descendants_added
;
115 size_t index_of_first_render_surface_layer_list_addition
;
116 size_t num_render_surfaces_added
;
118 // Each time we generate a new render surface layer list, an ID is used to
119 // identify it. |last_drawn_render_surface_layer_list_id| is set to the ID
120 // that marked the render surface layer list generation which last updated
121 // these draw properties and determined that this layer will draw itself.
122 // If these draw properties are not a part of the render surface layer list,
123 // or the layer doesn't contribute anything, then this ID will be either out
125 int last_drawn_render_surface_layer_list_id
;
127 // The maximum scale during the layers current animation at which content
128 // should be rastered at to be crisp.
129 float maximum_animation_contents_scale
;
131 // The scale during the layer animation start at which content should be
132 // rastered at to be crisp.
133 float starting_animation_contents_scale
;
138 #endif // CC_LAYERS_DRAW_PROPERTIES_H_