| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #ifndef CC_RESOURCES_LAYER_QUAD_H_ | 6 #ifndef CC_RESOURCES_LAYER_QUAD_H_ |
| 7 #define CC_RESOURCES_LAYER_QUAD_H_ | 7 #define CC_RESOURCES_LAYER_QUAD_H_ |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class QuadF; | 14 class QuadF; |
| 15 } | 15 } |
| 16 | 16 |
| 17 static const float kAntiAliasingInflateDistance = 0.5f; | 17 static const float kAntiAliasingInflateDistance = 0.5f; |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 class CC_EXPORT LayerQuad { | 21 class CC_EXPORT LayerQuad { |
| 22 public: | 22 public: |
| 23 class Edge { | 23 class Edge { |
| 24 public: | 24 public: |
| 25 Edge() : x_(0), y_(0), z_(0), degenerate_(false) {} | 25 Edge() : x_(0), y_(0), z_(0) {} |
| 26 Edge(const gfx::PointF& p, const gfx::PointF& q); | 26 Edge(const gfx::PointF& p, const gfx::PointF& q); |
| 27 | 27 |
| 28 float x() const { return x_; } | 28 float x() const { return x_; } |
| 29 float y() const { return y_; } | 29 float y() const { return y_; } |
| 30 float z() const { return z_; } | 30 float z() const { return z_; } |
| 31 | 31 |
| 32 void set_x(float x) { x_ = x; } | 32 void set_x(float x) { x_ = x; } |
| 33 void set_y(float y) { y_ = y; } | 33 void set_y(float y) { y_ = y; } |
| 34 void set_z(float z) { z_ = z; } | 34 void set_z(float z) { z_ = z; } |
| 35 void set(float x, float y, float z) { | 35 void set(float x, float y, float z) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 void scale_x(float sx) { x_ *= sx; } | 50 void scale_x(float sx) { x_ *= sx; } |
| 51 void scale_y(float sy) { y_ *= sy; } | 51 void scale_y(float sy) { y_ *= sy; } |
| 52 void scale_z(float sz) { z_ *= sz; } | 52 void scale_z(float sz) { z_ *= sz; } |
| 53 void scale(float sx, float sy, float sz) { | 53 void scale(float sx, float sy, float sz) { |
| 54 x_ *= sx; | 54 x_ *= sx; |
| 55 y_ *= sy; | 55 y_ *= sy; |
| 56 z_ *= sz; | 56 z_ *= sz; |
| 57 } | 57 } |
| 58 void scale(float s) { scale(s, s, s); } | 58 void scale(float s) { scale(s, s, s); } |
| 59 | 59 |
| 60 bool degenerate() const { return degenerate_; } | |
| 61 | |
| 62 gfx::PointF Intersect(const Edge& e) const { | 60 gfx::PointF Intersect(const Edge& e) const { |
| 63 return gfx::PointF( | 61 return gfx::PointF( |
| 64 (y() * e.z() - e.y() * z()) / (x() * e.y() - e.x() * y()), | 62 (y() * e.z() - e.y() * z()) / (x() * e.y() - e.x() * y()), |
| 65 (x() * e.z() - e.x() * z()) / (e.x() * y() - x() * e.y())); | 63 (x() * e.z() - e.x() * z()) / (e.x() * y() - x() * e.y())); |
| 66 } | 64 } |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 float x_; | 67 float x_; |
| 70 float y_; | 68 float y_; |
| 71 float z_; | 69 float z_; |
| 72 bool degenerate_; | |
| 73 }; | 70 }; |
| 74 | 71 |
| 75 LayerQuad(const Edge& left, | 72 LayerQuad(const Edge& left, |
| 76 const Edge& top, | 73 const Edge& top, |
| 77 const Edge& right, | 74 const Edge& right, |
| 78 const Edge& bottom); | 75 const Edge& bottom); |
| 79 explicit LayerQuad(const gfx::QuadF& quad); | 76 explicit LayerQuad(const gfx::QuadF& quad); |
| 80 | 77 |
| 81 Edge left() const { return left_; } | 78 Edge left() const { return left_; } |
| 82 Edge top() const { return top_; } | 79 Edge top() const { return top_; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 108 Edge top_; | 105 Edge top_; |
| 109 Edge right_; | 106 Edge right_; |
| 110 Edge bottom_; | 107 Edge bottom_; |
| 111 | 108 |
| 112 DISALLOW_COPY_AND_ASSIGN(LayerQuad); | 109 DISALLOW_COPY_AND_ASSIGN(LayerQuad); |
| 113 }; | 110 }; |
| 114 | 111 |
| 115 } // namespace cc | 112 } // namespace cc |
| 116 | 113 |
| 117 #endif // CC_RESOURCES_LAYER_QUAD_H_ | 114 #endif // CC_RESOURCES_LAYER_QUAD_H_ |
| OLD | NEW |