draw_properties.h revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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.
4
5#ifndef CC_LAYERS_DRAW_PROPERTIES_H_
6#define CC_LAYERS_DRAW_PROPERTIES_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "ui/gfx/rect.h"
10#include "ui/gfx/transform.h"
11
12namespace cc {
13
14// Container for properties that layers need to compute before they can be
15// drawn.
16template <typename LayerType, typename RenderSurfaceType>
17struct 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        descendants_can_clip_selves(false),
32        can_draw_directly_to_backbuffer(false),
33        layer_or_descendant_has_copy_request(false) {}
34
35  // Transforms objects from content space to target surface space, where
36  // this layer would be drawn.
37  gfx::Transform target_space_transform;
38
39  // Transforms objects from content space to screen space (viewport space).
40  gfx::Transform screen_space_transform;
41
42  // DrawProperties::opacity may be different than LayerType::opacity,
43  // particularly in the case when a RenderSurface re-parents the layer's
44  // opacity, or when opacity is compounded by the hierarchy.
45  float opacity;
46
47  // xxx_is_animating flags are used to indicate whether the DrawProperties
48  // are actually meaningful on the main thread. When the properties are
49  // animating, the main thread may not have the same values that are used
50  // to draw.
51  bool opacity_is_animating;
52  bool screen_space_opacity_is_animating;
53  bool target_space_transform_is_animating;
54  bool screen_space_transform_is_animating;
55
56  // True if the layer can use LCD text.
57  bool can_use_lcd_text;
58
59  // True if the layer needs to be clipped by clip_rect.
60  bool is_clipped;
61
62  // The layer whose coordinate space this layer draws into. This can be
63  // either the same layer (draw_properties_.render_target == this) or an
64  // ancestor of this layer.
65  LayerType* render_target;
66
67  // The surface that this layer and its subtree would contribute to.
68  scoped_ptr<RenderSurfaceType> render_surface;
69
70  // This rect is in the layer's content space.
71  gfx::Rect visible_content_rect;
72
73  // In target surface space, the rect that encloses the clipped, drawable
74  // content of the layer.
75  gfx::Rect drawable_content_rect;
76
77  // In target surface space, the original rect that clipped this layer. This
78  // value is used to avoid unnecessarily changing GL scissor state.
79  gfx::Rect clip_rect;
80
81  // The scale used to move between layer space and content space, and bounds
82  // of the space. One is always a function of the other, but which one
83  // depends on the layer type. For picture layers, this is an ideal scale,
84  // and not always the one used.
85  float contents_scale_x;
86  float contents_scale_y;
87  gfx::Size content_bounds;
88
89  // Does not include this layer itself, only its children and descendants.
90  int num_descendants_that_draw_content;
91
92  // Number of descendants with a clip parent that is our ancestor. NB - this
93  // does not include our clip children because they are clipped by us.
94  int num_unclipped_descendants;
95
96  // If true, every descendant in the sub-tree can clip itself without the
97  // need to use hardware sissoring or a new render target.
98  bool descendants_can_clip_selves;
99
100  bool can_draw_directly_to_backbuffer;
101
102  // If true, the layer or some layer in its sub-tree has a CopyOutputRequest
103  // present on it.
104  bool layer_or_descendant_has_copy_request;
105};
106
107}  // namespace cc
108
109#endif  // CC_LAYERS_DRAW_PROPERTIES_H_
110