1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WebDisplayItemClipTree_h
6 #define WebDisplayItemClipTree_h
8 #include "public/platform/WebCommon.h"
9 #include "public/platform/WebFloatRect.h"
10 #include "public/platform/WebPrivateOwnPtr.h"
14 class DisplayItemClipTree
;
16 // Represents a hierarchy of rectangular clips which apply to ranges of a
17 // display list and may be of interest to the compositor.
19 // It consists of a tree of "transform nodes", stored in a flattened
20 // representation in which their order is not guaranteed. Each node has a
21 // parent (whose clip, and those of its ancestors, also apply to content),
22 // a transform node index (into an associated |WebDisplayItemTransformTree|
23 // which defines the coordinate space in which this clip is interpreted),
24 // and a rectangle representing the clip.
26 // Rounded-rect clips are represented here by their bounding rect; the rounded
27 // clip should be represented outside the clip tree (e.g. as a mask).
28 class BLINK_PLATFORM_EXPORT WebDisplayItemClipTree
{
30 enum : size_t { kInvalidIndex
= static_cast<size_t>(-1) };
33 ClipNode(size_t parent
, size_t transformNodeIndex
, const WebFloatRect
& clipRect
)
34 : parentNodeIndex(parent
)
35 , transformNodeIndex(transformNodeIndex
)
40 bool isRoot() const { return parentNodeIndex
== kInvalidIndex
; }
42 // Index of parent in m_nodes (kInvalidIndex for root).
43 size_t parentNodeIndex
;
45 // Index of transform node in which this clip should be interpreted.
46 // Cannot be WebDisplayItemTransformTree::kInvalidIndex.
47 size_t transformNodeIndex
;
49 // Rectangular clip in the space of the transform node.
50 WebFloatRect clipRect
;
53 WebDisplayItemClipTree();
55 WebDisplayItemClipTree(const WTF::PassOwnPtr
<DisplayItemClipTree
>&);
58 ~WebDisplayItemClipTree();
60 // Returns the number of nodes in the clip tree.
61 size_t nodeCount() const;
63 // Returns a node in the clip tree by its index (from 0 to nodeCount() - 1).
64 const ClipNode
& nodeAt(size_t index
) const;
67 WebPrivateOwnPtr
<const DisplayItemClipTree
> m_private
;
72 #endif // WebDisplayItemClipTree_h