| 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 <memory> | |
| 9 | |
| 10 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
| 11 #include "cc/trees/clip_expander.h" | |
| 12 #include "ui/gfx/geometry/rect_f.h" | 9 #include "ui/gfx/geometry/rect_f.h" |
| 13 | 10 |
| 14 namespace base { | 11 namespace base { |
| 15 namespace trace_event { | 12 namespace trace_event { |
| 16 class TracedValue; | 13 class TracedValue; |
| 17 } // namespace trace_event | 14 } // namespace trace_event |
| 18 } // namespace base | 15 } // namespace base |
| 19 | 16 |
| 20 namespace cc { | 17 namespace cc { |
| 21 | 18 |
| 22 namespace proto { | 19 namespace proto { |
| 23 class TreeNode; | 20 class TreeNode; |
| 24 } // namespace proto | 21 } // namespace proto |
| 25 | 22 |
| 26 struct CC_EXPORT ClipNode { | 23 struct CC_EXPORT ClipNode { |
| 27 ClipNode(); | 24 ClipNode(); |
| 28 ClipNode(const ClipNode& other); | 25 ClipNode(const ClipNode& other); |
| 29 | 26 |
| 30 ClipNode& operator=(const ClipNode& other); | |
| 31 | |
| 32 ~ClipNode(); | |
| 33 | |
| 34 int id; | 27 int id; |
| 35 int parent_id; | 28 int parent_id; |
| 36 int owner_id; | 29 int owner_id; |
| 37 | 30 |
| 38 enum class ClipType { | 31 enum class ClipType { |
| 39 // The node doesn't contribute a new clip. It exists only for caching clips | 32 // The node doesn't contribute a new clip. It exists only for caching clips |
| 40 // or for resetting clipping state. | 33 // or for resetting clipping state. |
| 41 NONE, | 34 NONE, |
| 42 | 35 |
| 43 // The node contributes a new clip (that is, |clip| needs to be applied). | 36 // The node contributes a new clip (that is, |clip| needs to be applied). |
| 44 APPLIES_LOCAL_CLIP, | 37 APPLIES_LOCAL_CLIP |
| 45 | |
| 46 // This node represents a space expansion. When computing visible rects, | |
| 47 // the accumulated clip inherited by this node gets expanded. Similarly, | |
| 48 // when mapping a rect in descendant space to the rect in ancestor space | |
| 49 // that depends on the descendant rect's contents, this node expands the | |
| 50 // descendant rect. This is used for effects like pixel-moving filters, | |
| 51 // where clipped-out content can affect visible output. | |
| 52 EXPANDS_CLIP | |
| 53 }; | 38 }; |
| 54 | 39 |
| 55 ClipType clip_type; | 40 ClipType clip_type; |
| 56 | 41 |
| 57 // 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 |
| 58 // transform node. | 43 // transform node. |
| 59 gfx::RectF clip; | 44 gfx::RectF clip; |
| 60 | 45 |
| 61 // For nodes that expand, this represents the amount of expansion. | |
| 62 std::unique_ptr<ClipExpander> clip_expander; | |
| 63 | |
| 64 // Clip nodes are used for two reasons. First, they are used for determining | 46 // Clip nodes are used for two reasons. First, they are used for determining |
| 65 // 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 |
| 66 // 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 |
| 67 // 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 |
| 68 // 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 |
| 69 // 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 |
| 70 // 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 |
| 71 // 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 |
| 72 // 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 |
| 73 // target transform node, and may include clips contributed by ancestors. | 55 // target transform node, and may include clips contributed by ancestors. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 101 bool operator==(const ClipNode& other) const; | 83 bool operator==(const ClipNode& other) const; |
| 102 | 84 |
| 103 void ToProtobuf(proto::TreeNode* proto) const; | 85 void ToProtobuf(proto::TreeNode* proto) const; |
| 104 void FromProtobuf(const proto::TreeNode& proto); | 86 void FromProtobuf(const proto::TreeNode& proto); |
| 105 void AsValueInto(base::trace_event::TracedValue* value) const; | 87 void AsValueInto(base::trace_event::TracedValue* value) const; |
| 106 }; | 88 }; |
| 107 | 89 |
| 108 } // namespace cc | 90 } // namespace cc |
| 109 | 91 |
| 110 #endif // CC_TREES_CLIP_NODE_H_ | 92 #endif // CC_TREES_CLIP_NODE_H_ |
| OLD | NEW |