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