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 "cc/trees/clip_expander.h" | |
9 #include "ui/gfx/geometry/rect_f.h" | 10 #include "ui/gfx/geometry/rect_f.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 namespace trace_event { | 13 namespace trace_event { |
13 class TracedValue; | 14 class TracedValue; |
14 } // namespace trace_event | 15 } // namespace trace_event |
15 } // namespace base | 16 } // namespace base |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 namespace proto { | 20 namespace proto { |
20 class TreeNode; | 21 class TreeNode; |
21 } // namespace proto | 22 } // namespace proto |
22 | 23 |
23 struct CC_EXPORT ClipNode { | 24 struct CC_EXPORT ClipNode { |
24 ClipNode(); | 25 ClipNode(); |
25 ClipNode(const ClipNode& other); | 26 ClipNode(const ClipNode& other); |
26 | 27 |
27 int id; | 28 int id; |
28 int parent_id; | 29 int parent_id; |
29 int owner_id; | 30 int owner_id; |
30 | 31 |
31 enum class ClipType { | 32 enum class ClipType { |
32 // The node doesn't contribute a new clip. It exists only for caching clips | 33 // The node doesn't contribute a new clip. It exists only for caching clips |
33 // or for resetting clipping state. | 34 // or for resetting clipping state. |
34 NONE, | 35 NONE, |
35 | 36 |
36 // The node contributes a new clip (that is, |clip| needs to be applied). | 37 // The node contributes a new clip (that is, |clip| needs to be applied). |
37 APPLIES_LOCAL_CLIP | 38 APPLIES_LOCAL_CLIP, |
39 | |
40 // This node represents a space expansion. When computing visible rects, | |
41 // the accumulated clip inherited by this node gets expanded. Similarly, | |
42 // when mapping a rect in descendant space to the rect in ancestor space | |
43 // that depends on the descendant rect's contents, this node expands the | |
44 // descendant rect. This is used for effects like pixel-moving filters, | |
45 // where clipped-out content can affect visible output. | |
46 EXPANDS_CLIP | |
38 }; | 47 }; |
39 | 48 |
40 ClipType clip_type; | 49 ClipType clip_type; |
41 | 50 |
42 // The clip rect that this node contributes, expressed in the space of its | 51 // The clip rect that this node contributes, expressed in the space of its |
43 // transform node. | 52 // transform node. |
44 gfx::RectF clip; | 53 gfx::RectF clip; |
45 | 54 |
55 // For nodes that expand, this represents the amount of expansion. | |
56 ClipExpander clip_expander; | |
weiliangc
2016/10/26 16:57:03
Why not a nullable unique_ptr? We could avoid defa
ajuma
2016/10/31 17:43:07
Done. Also added the protobuf transfer logic and a
| |
57 | |
46 // Clip nodes are used for two reasons. First, they are used for determining | 58 // Clip nodes are used for two reasons. First, they are used for determining |
47 // which parts of each layer are visible. Second, they are used for | 59 // which parts of each layer are visible. Second, they are used for |
48 // determining whether a clip needs to be applied when drawing a layer, and if | 60 // determining whether a clip needs to be applied when drawing a layer, and if |
49 // so, the rect that needs to be used. These can be different since not all | 61 // so, the rect that needs to be used. These can be different since not all |
50 // clips need to be applied directly to each layer. For example, a layer is | 62 // clips need to be applied directly to each layer. For example, a layer is |
51 // implicitly clipped by the bounds of its target render surface and by clips | 63 // implicitly clipped by the bounds of its target render surface and by clips |
52 // applied to this surface. |combined_clip_in_target_space| is used for | 64 // applied to this surface. |combined_clip_in_target_space| is used for |
53 // computing visible rects, and |clip_in_target_space| is used for computing | 65 // computing visible rects, and |clip_in_target_space| is used for computing |
54 // clips applied at draw time. Both rects are expressed in the space of the | 66 // clips applied at draw time. Both rects are expressed in the space of the |
55 // target transform node, and may include clips contributed by ancestors. | 67 // target transform node, and may include clips contributed by ancestors. |
(...skipping 27 matching lines...) Expand all Loading... | |
83 bool operator==(const ClipNode& other) const; | 95 bool operator==(const ClipNode& other) const; |
84 | 96 |
85 void ToProtobuf(proto::TreeNode* proto) const; | 97 void ToProtobuf(proto::TreeNode* proto) const; |
86 void FromProtobuf(const proto::TreeNode& proto); | 98 void FromProtobuf(const proto::TreeNode& proto); |
87 void AsValueInto(base::trace_event::TracedValue* value) const; | 99 void AsValueInto(base::trace_event::TracedValue* value) const; |
88 }; | 100 }; |
89 | 101 |
90 } // namespace cc | 102 } // namespace cc |
91 | 103 |
92 #endif // CC_TREES_CLIP_NODE_H_ | 104 #endif // CC_TREES_CLIP_NODE_H_ |
OLD | NEW |