1 // Copyright 2011 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.
8 #if USE(ACCELERATED_COMPOSITING)
10 #include "CCLayerQuad.h"
14 CCLayerQuad::Edge::Edge(const FloatPoint
& p
, const FloatPoint
& q
)
18 FloatPoint
tangent(p
.y() - q
.y(), q
.x() - p
.x());
19 float cross2
= p
.x() * q
.y() - q
.x() * p
.y();
21 set(tangent
.x(), tangent
.y(), cross2
);
22 scale(1.0f
/ tangent
.length());
25 CCLayerQuad::CCLayerQuad(const FloatQuad
& quad
)
28 m_left
= Edge(quad
.p4(), quad
.p1());
29 m_right
= Edge(quad
.p2(), quad
.p3());
30 m_top
= Edge(quad
.p1(), quad
.p2());
31 m_bottom
= Edge(quad
.p3(), quad
.p4());
33 float sign
= quad
.isCounterclockwise() ? -1 : 1;
40 CCLayerQuad::CCLayerQuad(const Edge
& left
, const Edge
& top
, const Edge
& right
, const Edge
& bottom
)
48 FloatQuad
CCLayerQuad::floatQuad() const
50 return FloatQuad(m_left
.intersect(m_top
),
51 m_top
.intersect(m_right
),
52 m_right
.intersect(m_bottom
),
53 m_bottom
.intersect(m_left
));
56 void CCLayerQuad::toFloatArray(float flattened
[12]) const
58 flattened
[0] = m_left
.x();
59 flattened
[1] = m_left
.y();
60 flattened
[2] = m_left
.z();
61 flattened
[3] = m_top
.x();
62 flattened
[4] = m_top
.y();
63 flattened
[5] = m_top
.z();
64 flattened
[6] = m_right
.x();
65 flattened
[7] = m_right
.y();
66 flattened
[8] = m_right
.z();
67 flattened
[9] = m_bottom
.x();
68 flattened
[10] = m_bottom
.y();
69 flattened
[11] = m_bottom
.z();
74 #endif // USE(ACCELERATED_COMPOSITING)