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 WebDisplayItemTransformTree_h
6 #define WebDisplayItemTransformTree_h
8 #include "public/platform/WebCommon.h"
9 #include "public/platform/WebFloatSize.h"
10 #include "public/platform/WebPrivateOwnPtr.h"
11 #include "third_party/skia/include/core/SkPoint3.h"
12 #include "third_party/skia/include/utils/SkMatrix44.h"
16 class DisplayItemTransformTree
;
18 // Represents the hierarchy of transforms which apply to ranges of a display
19 // item list and may be of interest to the compositor.
21 // It consists of a tree of "transform nodes", stored in a flattened
22 // representation in which their order is not guaranteed. Each node has a
23 // parent, relative to whom its transform should be interpreted (i.e. the
24 // total transform at a node is the product of its transform and its parent's
26 class BLINK_PLATFORM_EXPORT WebDisplayItemTransformTree
{
28 enum : size_t { kInvalidIndex
= static_cast<size_t>(-1) };
30 struct TransformNode
{
31 TransformNode(size_t parent
, const SkMatrix44
& matrix44
, const SkPoint3
& origin
)
32 : parentNodeIndex(parent
)
34 , transformOrigin(origin
)
38 bool isRoot() const { return parentNodeIndex
== kInvalidIndex
; }
40 // Index of parent in m_nodes (kInvalidIndex for root).
41 size_t parentNodeIndex
;
43 // Transformation matrix of this node, relative to its parent.
46 // Origin of the transform given by |matrix|.
47 SkPoint3 transformOrigin
;
50 WebDisplayItemTransformTree();
52 WebDisplayItemTransformTree(const WTF::PassOwnPtr
<DisplayItemTransformTree
>&);
55 ~WebDisplayItemTransformTree();
57 // Returns the number of nodes in the transform tree.
58 size_t nodeCount() const;
60 // Returns a node in the transform tree by its index (from 0 to nodeCount() - 1).
61 const TransformNode
& nodeAt(size_t index
) const;
64 WebPrivateOwnPtr
<const DisplayItemTransformTree
> m_private
;
69 #endif // WebDisplayItemTransformTree_h