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 FloatQuad
CCLayerQuad::floatQuad() const
42 return FloatQuad(m_left
.intersect(m_top
),
43 m_top
.intersect(m_right
),
44 m_right
.intersect(m_bottom
),
45 m_bottom
.intersect(m_left
));
48 void CCLayerQuad::toFloatArray(float flattened
[12]) const
50 flattened
[0] = m_left
.x();
51 flattened
[1] = m_left
.y();
52 flattened
[2] = m_left
.z();
53 flattened
[3] = m_top
.x();
54 flattened
[4] = m_top
.y();
55 flattened
[5] = m_top
.z();
56 flattened
[6] = m_right
.x();
57 flattened
[7] = m_right
.y();
58 flattened
[8] = m_right
.z();
59 flattened
[9] = m_bottom
.x();
60 flattened
[10] = m_bottom
.y();
61 flattened
[11] = m_bottom
.z();
66 #endif // USE(ACCELERATED_COMPOSITING)