Chromium Code Reviews| 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> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 ~ClipNode(); | 28 ~ClipNode(); |
| 29 | 29 |
| 30 // The node index of this node in the clip tree node vector. | 30 // The node index of this node in the clip tree node vector. |
| 31 int id; | 31 int id; |
| 32 // The node index of the parent node in the clip tree node vector. | 32 // The node index of the parent node in the clip tree node vector. |
| 33 int parent_id; | 33 int parent_id; |
| 34 // The layer id of the layer that owns this node. | 34 // The layer id of the layer that owns this node. |
| 35 int owning_layer_id; | 35 int owning_layer_id; |
| 36 | 36 |
| 37 enum class ClipType { | 37 enum class ClipType { |
| 38 // The node doesn't contribute a new clip. It exists only for caching clips | |
| 39 // or for resetting clipping state. | |
| 40 NONE, | |
| 41 | |
| 42 // The node contributes a new clip (that is, |clip| needs to be applied). | 38 // The node contributes a new clip (that is, |clip| needs to be applied). |
| 43 APPLIES_LOCAL_CLIP, | 39 APPLIES_LOCAL_CLIP, |
| 44 | 40 |
| 45 // This node represents a space expansion. When computing visible rects, | 41 // This node represents a space expansion. When computing visible rects, |
| 46 // the accumulated clip inherited by this node gets expanded. Similarly, | 42 // the accumulated clip inherited by this node gets expanded. Similarly, |
| 47 // when mapping a rect in descendant space to the rect in ancestor space | 43 // when mapping a rect in descendant space to the rect in ancestor space |
| 48 // that depends on the descendant rect's contents, this node expands the | 44 // that depends on the descendant rect's contents, this node expands the |
| 49 // descendant rect. This is used for effects like pixel-moving filters, | 45 // descendant rect. This is used for effects like pixel-moving filters, |
| 50 // where clipped-out content can affect visible output. | 46 // where clipped-out content can affect visible output. |
| 51 EXPANDS_CLIP | 47 EXPANDS_CLIP |
| 52 }; | 48 }; |
| 53 | 49 |
| 54 ClipType clip_type; | 50 ClipType clip_type; |
| 55 | 51 |
| 56 // The clip rect that this node contributes, expressed in the space of its | 52 // The clip rect that this node contributes, expressed in the space of its |
| 57 // transform node. | 53 // transform node. |
| 58 gfx::RectF clip; | 54 gfx::RectF clip; |
| 59 | 55 |
| 56 // Each element of this cache stores the accumulated clip from this clip | |
| 57 // node to a particular target. | |
| 58 mutable std::vector<ClipRectData> cached_clip_rects; | |
| 59 | |
| 60 // This rect accumulates all clips from this node to the root in screen space. | |
| 61 // It is used in the computation of layer's visible rect. | |
| 62 gfx::RectF accumulated_rect_in_screen_space; | |
|
weiliangc
2017/03/14 22:04:29
Is this also a cached value? Could this be express
jaydasika
2017/03/16 20:33:30
Yes, it is a cached value and it can be expressed
| |
| 63 | |
| 60 // For nodes that expand, this represents the amount of expansion. | 64 // For nodes that expand, this represents the amount of expansion. |
| 61 std::unique_ptr<ClipExpander> clip_expander; | 65 std::unique_ptr<ClipExpander> clip_expander; |
| 62 | 66 |
| 63 // Clip nodes are used for two reasons. First, they are used for determining | |
| 64 // which parts of each layer are visible. Second, they are used for | |
| 65 // determining whether a clip needs to be applied when drawing a layer, and if | |
| 66 // so, the rect that needs to be used. These can be different since not all | |
| 67 // clips need to be applied directly to each layer. For example, a layer is | |
| 68 // implicitly clipped by the bounds of its target render surface and by clips | |
| 69 // applied to this surface. |combined_clip_in_target_space| is used for | |
| 70 // computing visible rects, and |clip_in_target_space| is used for computing | |
| 71 // clips applied at draw time. Both rects are expressed in the space of the | |
| 72 // target transform node, and may include clips contributed by ancestors. | |
| 73 gfx::RectF combined_clip_in_target_space; | |
| 74 gfx::RectF clip_in_target_space; | |
| 75 | |
| 76 // The id of the transform node that defines the clip node's local space. | 67 // The id of the transform node that defines the clip node's local space. |
| 77 int transform_id; | 68 int transform_id; |
| 78 | 69 |
| 79 // The id of the transform node that defines the clip node's target space. | |
| 80 int target_transform_id; | |
| 81 | |
| 82 // The id of the effect node that defines the clip node's target space. | |
| 83 // TODO(crbug.com/642581 crbug.com/642584): As we progress toward SPv2 and | |
| 84 // layer list mode, there may be layers having the same clip but draw onto | |
| 85 // different target. Target information shall be removed from here. | |
| 86 int target_effect_id; | |
| 87 | |
| 88 // When true, |clip_in_target_space| does not include clips from ancestor | |
| 89 // nodes. | |
| 90 bool layer_clipping_uses_only_local_clip : 1; | |
| 91 | |
| 92 // True if layers with this clip tree node need to be drawn with a clip | |
| 93 // applied. | |
| 94 bool layers_are_clipped : 1; | |
| 95 bool layers_are_clipped_when_surfaces_disabled : 1; | |
| 96 | |
| 97 // Nodes that correspond to unclipped surfaces disregard ancestor clips. | |
| 98 bool resets_clip : 1; | |
| 99 | |
| 100 bool operator==(const ClipNode& other) const; | 70 bool operator==(const ClipNode& other) const; |
| 101 | 71 |
| 102 void AsValueInto(base::trace_event::TracedValue* value) const; | 72 void AsValueInto(base::trace_event::TracedValue* value) const; |
| 103 }; | 73 }; |
| 104 | 74 |
| 105 } // namespace cc | 75 } // namespace cc |
| 106 | 76 |
| 107 #endif // CC_TREES_CLIP_NODE_H_ | 77 #endif // CC_TREES_CLIP_NODE_H_ |
| OLD | NEW |