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_OUTPUT_LAYER_QUAD_H_
7 #define CC_OUTPUT_LAYER_QUAD_H_
9 #include "base/basictypes.h"
10 #include "cc/base/cc_export.h"
11 #include "ui/gfx/geometry/point_f.h"
17 static const float kAntiAliasingInflateDistance
= 0.5f
;
21 class CC_EXPORT LayerQuad
{
23 class CC_EXPORT Edge
{
25 Edge() : x_(0), y_(0), z_(0), degenerate_(false) {}
26 Edge(const gfx::PointF
& p
, const gfx::PointF
& q
);
28 float x() const { return x_
; }
29 float y() const { return y_
; }
30 float z() const { return z_
; }
32 void set_x(float x
) { x_
= x
; }
33 void set_y(float y
) { y_
= y
; }
34 void set_z(float z
) { z_
= z
; }
35 void set(float x
, float y
, float z
) {
41 void move_x(float dx
) { x_
+= dx
; }
42 void move_y(float dy
) { y_
+= dy
; }
43 void move_z(float dz
) { z_
+= dz
; }
44 void move(float dx
, float dy
, float dz
) {
50 void scale_x(float sx
) { x_
*= sx
; }
51 void scale_y(float sy
) { y_
*= sy
; }
52 void scale_z(float sz
) { z_
*= sz
; }
53 void scale(float sx
, float sy
, float sz
) {
58 void scale(float s
) { scale(s
, s
, s
); }
60 bool degenerate() const { return degenerate_
; }
62 gfx::PointF
Intersect(const Edge
& e
) const;
71 LayerQuad(const Edge
& left
,
75 explicit LayerQuad(const gfx::QuadF
& quad
);
77 Edge
left() const { return left_
; }
78 Edge
top() const { return top_
; }
79 Edge
right() const { return right_
; }
80 Edge
bottom() const { return bottom_
; }
82 void InflateX(float dx
) {
86 void InflateY(float dy
) {
90 void Inflate(float d
) {
94 void InflateAntiAliasingDistance() {
95 Inflate(kAntiAliasingInflateDistance
);
98 gfx::QuadF
ToQuadF() const;
100 void ToFloatArray(float flattened
[12]) const;
108 DISALLOW_COPY_AND_ASSIGN(LayerQuad
);
113 #endif // CC_OUTPUT_LAYER_QUAD_H_