Use SCHEME_HTTP for HTTPS proxies on Android.
[chromium-blink-merge.git] / cc / layer_quad.cc
blob038c602020ed7fb1b51e746ffbc7d102648ad832
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.
5 #include "cc/layer_quad.h"
7 #include "base/logging.h"
8 #include "ui/gfx/quad_f.h"
10 namespace cc {
12 LayerQuad::Edge::Edge(const gfx::PointF& p, const gfx::PointF& q)
14 DCHECK(p != q);
16 gfx::Vector2dF tangent(p.y() - q.y(), q.x() - p.x());
17 float cross2 = p.x() * q.y() - q.x() * p.y();
19 set(tangent.x(), tangent.y(), cross2);
20 scale(1.0f / tangent.Length());
23 LayerQuad::LayerQuad(const gfx::QuadF& quad)
25 // Create edges.
26 m_left = Edge(quad.p4(), quad.p1());
27 m_right = Edge(quad.p2(), quad.p3());
28 m_top = Edge(quad.p1(), quad.p2());
29 m_bottom = Edge(quad.p3(), quad.p4());
31 float sign = quad.IsCounterClockwise() ? -1 : 1;
32 m_left.scale(sign);
33 m_right.scale(sign);
34 m_top.scale(sign);
35 m_bottom.scale(sign);
38 LayerQuad::LayerQuad(const Edge& left, const Edge& top, const Edge& right, const Edge& bottom)
39 : m_left(left)
40 , m_top(top)
41 , m_right(right)
42 , m_bottom(bottom)
46 gfx::QuadF LayerQuad::ToQuadF() const
48 return gfx::QuadF(m_left.intersect(m_top),
49 m_top.intersect(m_right),
50 m_right.intersect(m_bottom),
51 m_bottom.intersect(m_left));
54 void LayerQuad::toFloatArray(float flattened[12]) const
56 flattened[0] = m_left.x();
57 flattened[1] = m_left.y();
58 flattened[2] = m_left.z();
59 flattened[3] = m_top.x();
60 flattened[4] = m_top.y();
61 flattened[5] = m_top.z();
62 flattened[6] = m_right.x();
63 flattened[7] = m_right.y();
64 flattened[8] = m_right.z();
65 flattened[9] = m_bottom.x();
66 flattened[10] = m_bottom.y();
67 flattened[11] = m_bottom.z();
70 } // namespace cc