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"
16 static const float kAntiAliasingInflateDistance
= 0.5f
;
20 class CC_EXPORT LayerQuad
{
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
)
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
)
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
)
65 void scale(float s
) { scale(s
, s
, s
); }
67 gfx::PointF
intersect(const Edge
& e
) const
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()));
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;
106 #endif // CC_LAYER_QUAD_H_