Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: cc/trees/clip_node.h

Issue 2655233006: cc : Clean up cc clip tree (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | cc/trees/clip_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cc_export.h" 10 #include "cc/cc_export.h"
11 #include "cc/trees/clip_expander.h" 11 #include "cc/trees/clip_expander.h"
12 #include "ui/gfx/geometry/rect_f.h" 12 #include "ui/gfx/geometry/rect_f.h"
13 13
14 namespace base { 14 namespace base {
15 namespace trace_event { 15 namespace trace_event {
16 class TracedValue; 16 class TracedValue;
17 } // namespace trace_event 17 } // namespace trace_event
18 } // namespace base 18 } // namespace base
19 19
20 namespace cc { 20 namespace cc {
21 21
22 struct CC_EXPORT ClipNode { 22 struct CC_EXPORT ClipNode {
23 ClipNode(); 23 ClipNode();
24 ClipNode(const ClipNode& other); 24 ClipNode(const ClipNode& other);
25 25
26 ClipNode& operator=(const ClipNode& other); 26 ClipNode& operator=(const ClipNode& other);
27 27
28 ~ClipNode(); 28 ~ClipNode();
29 29
30 static const int defaultCachedClipsSize = 1;
31
30 // The node index of this node in the clip tree node vector. 32 // The node index of this node in the clip tree node vector.
31 int id; 33 int id;
32 // The node index of the parent node in the clip tree node vector. 34 // The node index of the parent node in the clip tree node vector.
33 int parent_id; 35 int parent_id;
34 // The layer id of the layer that owns this node. 36 // The layer id of the layer that owns this node.
35 int owning_layer_id; 37 int owning_layer_id;
36 38
37 enum class ClipType { 39 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). 40 // The node contributes a new clip (that is, |clip| needs to be applied).
43 APPLIES_LOCAL_CLIP, 41 APPLIES_LOCAL_CLIP,
44 42
45 // This node represents a space expansion. When computing visible rects, 43 // This node represents a space expansion. When computing visible rects,
46 // the accumulated clip inherited by this node gets expanded. Similarly, 44 // the accumulated clip inherited by this node gets expanded. Similarly,
47 // when mapping a rect in descendant space to the rect in ancestor space 45 // 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 46 // that depends on the descendant rect's contents, this node expands the
49 // descendant rect. This is used for effects like pixel-moving filters, 47 // descendant rect. This is used for effects like pixel-moving filters,
50 // where clipped-out content can affect visible output. 48 // where clipped-out content can affect visible output.
51 EXPANDS_CLIP 49 EXPANDS_CLIP
52 }; 50 };
53 51
54 ClipType clip_type; 52 ClipType clip_type;
55 53
56 // The clip rect that this node contributes, expressed in the space of its 54 // The clip rect that this node contributes, expressed in the space of its
57 // transform node. 55 // transform node.
58 gfx::RectF clip; 56 gfx::RectF clip;
59 57
58 // Each element of this cache stores the accumulated clip from this clip
59 // node to a particular target.
60 mutable std::vector<ClipRectData> cached_clip_rects;
61
62 // This rect accumulates all clips from this node to the root in screen space.
63 // It is used in the computation of layer's visible rect.
64 gfx::RectF cached_accumulated_rect_in_screen_space;
65
60 // For nodes that expand, this represents the amount of expansion. 66 // For nodes that expand, this represents the amount of expansion.
61 std::unique_ptr<ClipExpander> clip_expander; 67 std::unique_ptr<ClipExpander> clip_expander;
62 68
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. 69 // The id of the transform node that defines the clip node's local space.
77 int transform_id; 70 int transform_id;
78 71
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; 72 bool operator==(const ClipNode& other) const;
101 73
102 void AsValueInto(base::trace_event::TracedValue* value) const; 74 void AsValueInto(base::trace_event::TracedValue* value) const;
103 }; 75 };
104 76
105 } // namespace cc 77 } // namespace cc
106 78
107 #endif // CC_TREES_CLIP_NODE_H_ 79 #endif // CC_TREES_CLIP_NODE_H_
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | cc/trees/clip_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698