Add Sad Tab resources to the iOS build.
[chromium-blink-merge.git] / cc / layer_quad.h
blob29bbec8f755e039c2a812cc13fd4e880c19bfcb9
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.
6 #ifndef CC_LAYER_QUAD_H_
7 #define CC_LAYER_QUAD_H_
9 #include "cc/cc_export.h"
10 #include "ui/gfx/point_f.h"
12 namespace gfx {
13 class QuadF;
16 static const float kAntiAliasingInflateDistance = 0.5f;
18 namespace cc {
20 class CC_EXPORT LayerQuad {
21 public:
22 class Edge {
23 public:
24 Edge()
25 : m_x(0)
26 , m_y(0)
27 , m_z(0)
30 Edge(const gfx::PointF&, const gfx::PointF&);
32 float x() const { return m_x; }
33 float y() const { return m_y; }
34 float z() const { return m_z; }
36 void setX(float x) { m_x = x; }
37 void setY(float y) { m_y = y; }
38 void setZ(float z) { m_z = z; }
39 void set(float x, float y, float z)
41 m_x = x;
42 m_y = y;
43 m_z = z;
46 void moveX(float dx) { m_x += dx; }
47 void moveY(float dy) { m_y += dy; }
48 void moveZ(float dz) { m_z += dz; }
49 void move(float dx, float dy, float dz)
51 m_x += dx;
52 m_y += dy;
53 m_z += dz;
56 void scaleX(float sx) { m_x *= sx; }
57 void scaleY(float sy) { m_y *= sy; }
58 void scaleZ(float sz) { m_z *= sz; }
59 void scale(float sx, float sy, float sz)
61 m_x *= sx;
62 m_y *= sy;
63 m_z *= sz;
65 void scale(float s) { scale(s, s, s); }
67 gfx::PointF intersect(const Edge& e) const
69 return gfx::PointF(
70 (y() * e.z() - e.y() * z()) / (x() * e.y() - e.x() * y()),
71 (x() * e.z() - e.x() * z()) / (e.x() * y() - x() * e.y()));
74 private:
75 float m_x;
76 float m_y;
77 float m_z;
80 LayerQuad(const Edge& left, const Edge& top, const Edge& right, const Edge& bottom);
81 LayerQuad(const gfx::QuadF&);
83 Edge left() const { return m_left; }
84 Edge top() const { return m_top; }
85 Edge right() const { return m_right; }
86 Edge bottom() const { return m_bottom; }
88 void inflateX(float dx) { m_left.moveZ(dx); m_right.moveZ(dx); }
89 void inflateY(float dy) { m_top.moveZ(dy); m_bottom.moveZ(dy); }
90 void inflate(float d) { inflateX(d); inflateY(d); }
91 void inflateAntiAliasingDistance() { inflate(kAntiAliasingInflateDistance); }
93 gfx::QuadF ToQuadF() const;
95 void toFloatArray(float[12]) const;
97 private:
98 Edge m_left;
99 Edge m_top;
100 Edge m_right;
101 Edge m_bottom;
106 #endif // CC_LAYER_QUAD_H_