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 screen_space_transform_is_animating(false),
24 can_use_lcd_text(false),
25 render_target(nullptr),
26 num_unclipped_descendants(0),
27 layer_or_descendant_has_copy_request(false),
28 layer_or_descendant_has_input_handler(false),
29 has_child_with_a_scroll_parent(false),
30 index_of_first_descendants_addition(0),
31 num_descendants_added(0),
32 index_of_first_render_surface_layer_list_addition(0),
33 num_render_surfaces_added(0),
34 last_drawn_render_surface_layer_list_id(0),
35 maximum_animation_contents_scale(0.f
),
36 starting_animation_contents_scale(0.f
) {}
38 // Transforms objects from content space to target surface space, where
39 // this layer would be drawn.
40 gfx::Transform target_space_transform
;
42 // Transforms objects from content space to screen space (viewport space).
43 gfx::Transform screen_space_transform
;
45 // Known occlusion above the layer mapped to the content space of the layer.
46 Occlusion occlusion_in_content_space
;
48 // DrawProperties::opacity may be different than LayerType::opacity,
49 // particularly in the case when a RenderSurface re-parents the layer's
50 // opacity, or when opacity is compounded by the hierarchy.
53 // DrawProperties::blend_mode may be different than LayerType::blend_mode,
54 // when a RenderSurface re-parents the layer's blend_mode.
55 SkXfermode::Mode blend_mode
;
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
61 bool screen_space_transform_is_animating
;
63 // True if the layer can use LCD text.
64 bool can_use_lcd_text
;
66 // The layer whose coordinate space this layer draws into. This can be
67 // either the same layer (draw_properties_.render_target == this) or an
68 // ancestor of this layer.
69 LayerType
* render_target
;
71 // This rect is a bounding box around what part of the layer is visible, in
72 // the layer's coordinate space.
73 gfx::Rect visible_layer_rect
;
75 // In target surface space, the rect that encloses the clipped, drawable
76 // content of the layer.
77 gfx::Rect drawable_content_rect
;
79 // In target surface space, the original rect that clipped this layer. This
80 // value is used to avoid unnecessarily changing GL scissor state.
83 // Number of descendants with a clip parent that is our ancestor. NB - this
84 // does not include our clip children because they are clipped by us.
85 size_t num_unclipped_descendants
;
87 // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
89 bool layer_or_descendant_has_copy_request
;
91 // If true, the layer or one of its descendants has a wheel or touch handler.
92 bool layer_or_descendant_has_input_handler
;
94 // This is true if the layer has any direct child that has a scroll parent.
95 // This layer will not be the scroll parent in this case. This information
96 // lets us avoid work in CalculateDrawPropertiesInternal -- if none of our
97 // children have scroll parents, we will not need to recur out of order.
98 bool has_child_with_a_scroll_parent
;
100 // If this layer is visited out of order, its contribution to the descendant
101 // and render surface layer lists will be put aside in a temporary list.
102 // These values will allow for an efficient reordering of these additions.
103 size_t index_of_first_descendants_addition
;
104 size_t num_descendants_added
;
105 size_t index_of_first_render_surface_layer_list_addition
;
106 size_t num_render_surfaces_added
;
108 // Each time we generate a new render surface layer list, an ID is used to
109 // identify it. |last_drawn_render_surface_layer_list_id| is set to the ID
110 // that marked the render surface layer list generation which last updated
111 // these draw properties and determined that this layer will draw itself.
112 // If these draw properties are not a part of the render surface layer list,
113 // or the layer doesn't contribute anything, then this ID will be either out
115 int last_drawn_render_surface_layer_list_id
;
117 // The maximum scale during the layers current animation at which content
118 // should be rastered at to be crisp.
119 float maximum_animation_contents_scale
;
121 // The scale during the layer animation start at which content should be
122 // rastered at to be crisp.
123 float starting_animation_contents_scale
;
128 #endif // CC_LAYERS_DRAW_PROPERTIES_H_