OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TREES_CLIP_NODE_H_ | 5 #ifndef CC_TREES_CLIP_NODE_H_ |
6 #define CC_TREES_CLIP_NODE_H_ | 6 #define CC_TREES_CLIP_NODE_H_ |
7 | 7 |
8 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
9 #include "ui/gfx/geometry/rect_f.h" | 9 #include "ui/gfx/geometry/rect_f.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 } // namespace proto | 21 } // namespace proto |
22 | 22 |
23 struct CC_EXPORT ClipNode { | 23 struct CC_EXPORT ClipNode { |
24 ClipNode(); | 24 ClipNode(); |
25 ClipNode(const ClipNode& other); | 25 ClipNode(const ClipNode& other); |
26 | 26 |
27 int id; | 27 int id; |
28 int parent_id; | 28 int parent_id; |
29 int owner_id; | 29 int owner_id; |
30 | 30 |
| 31 enum class ClipType { |
| 32 // The node doesn't contribute a new clip. It exists only for caching clips |
| 33 // or for resetting clipping state. |
| 34 NONE, |
| 35 |
| 36 // The node contributes a new clip (that is, |clip| needs to be applied). |
| 37 APPLIES_LOCAL_CLIP |
| 38 }; |
| 39 |
| 40 ClipType clip_type; |
| 41 |
31 // The clip rect that this node contributes, expressed in the space of its | 42 // The clip rect that this node contributes, expressed in the space of its |
32 // transform node. | 43 // transform node. |
33 gfx::RectF clip; | 44 gfx::RectF clip; |
34 | 45 |
35 // Clip nodes are uses for two reasons. First, they are used for determining | 46 // Clip nodes are used for two reasons. First, they are used for determining |
36 // which parts of each layer are visible. Second, they are used for | 47 // which parts of each layer are visible. Second, they are used for |
37 // determining whether a clip needs to be applied when drawing a layer, and if | 48 // determining whether a clip needs to be applied when drawing a layer, and if |
38 // so, the rect that needs to be used. These can be different since not all | 49 // so, the rect that needs to be used. These can be different since not all |
39 // clips need to be applied directly to each layer. For example, a layer is | 50 // clips need to be applied directly to each layer. For example, a layer is |
40 // implicitly clipped by the bounds of its target render surface and by clips | 51 // implicitly clipped by the bounds of its target render surface and by clips |
41 // applied to this surface. |combined_clip_in_target_space| is used for | 52 // applied to this surface. |combined_clip_in_target_space| is used for |
42 // computing visible rects, and |clip_in_target_space| is used for computing | 53 // computing visible rects, and |clip_in_target_space| is used for computing |
43 // clips applied at draw time. Both rects are expressed in the space of the | 54 // clips applied at draw time. Both rects are expressed in the space of the |
44 // target transform node, and may include clips contributed by ancestors. | 55 // target transform node, and may include clips contributed by ancestors. |
45 gfx::RectF combined_clip_in_target_space; | 56 gfx::RectF combined_clip_in_target_space; |
46 gfx::RectF clip_in_target_space; | 57 gfx::RectF clip_in_target_space; |
47 | 58 |
48 // The id of the transform node that defines the clip node's local space. | 59 // The id of the transform node that defines the clip node's local space. |
49 int transform_id; | 60 int transform_id; |
50 | 61 |
51 // The id of the transform node that defines the clip node's target space. | 62 // The id of the transform node that defines the clip node's target space. |
52 int target_transform_id; | 63 int target_transform_id; |
53 | 64 |
54 // The id of the effect node that defines the clip node's target space. | 65 // The id of the effect node that defines the clip node's target space. |
55 int target_effect_id; | 66 int target_effect_id; |
56 | 67 |
57 // Whether this node contributes a new clip (that is, whether |clip| needs to | |
58 // be applied), rather than only inheriting ancestor clips. | |
59 bool applies_local_clip : 1; | |
60 | |
61 // When true, |clip_in_target_space| does not include clips from ancestor | 68 // When true, |clip_in_target_space| does not include clips from ancestor |
62 // nodes. | 69 // nodes. |
63 bool layer_clipping_uses_only_local_clip : 1; | 70 bool layer_clipping_uses_only_local_clip : 1; |
64 | 71 |
65 // True if target surface needs to be drawn with a clip applied. | 72 // True if target surface needs to be drawn with a clip applied. |
66 bool target_is_clipped : 1; | 73 bool target_is_clipped : 1; |
67 | 74 |
68 // True if layers with this clip tree node need to be drawn with a clip | 75 // True if layers with this clip tree node need to be drawn with a clip |
69 // applied. | 76 // applied. |
70 bool layers_are_clipped : 1; | 77 bool layers_are_clipped : 1; |
71 bool layers_are_clipped_when_surfaces_disabled : 1; | 78 bool layers_are_clipped_when_surfaces_disabled : 1; |
72 | 79 |
73 // Nodes that correspond to unclipped surfaces disregard ancestor clips. | 80 // Nodes that correspond to unclipped surfaces disregard ancestor clips. |
74 bool resets_clip : 1; | 81 bool resets_clip : 1; |
75 | 82 |
76 bool operator==(const ClipNode& other) const; | 83 bool operator==(const ClipNode& other) const; |
77 | 84 |
78 void ToProtobuf(proto::TreeNode* proto) const; | 85 void ToProtobuf(proto::TreeNode* proto) const; |
79 void FromProtobuf(const proto::TreeNode& proto); | 86 void FromProtobuf(const proto::TreeNode& proto); |
80 void AsValueInto(base::trace_event::TracedValue* value) const; | 87 void AsValueInto(base::trace_event::TracedValue* value) const; |
81 }; | 88 }; |
82 | 89 |
83 } // namespace cc | 90 } // namespace cc |
84 | 91 |
85 #endif // CC_TREES_CLIP_NODE_H_ | 92 #endif // CC_TREES_CLIP_NODE_H_ |
OLD | NEW |