| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 | |
| 6 #ifndef CC_RESOURCES_LAYER_QUAD_H_ | |
| 7 #define CC_RESOURCES_LAYER_QUAD_H_ | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "ui/gfx/geometry/point_f.h" | |
| 11 | |
| 12 namespace gfx { | |
| 13 class QuadF; | |
| 14 } | |
| 15 | |
| 16 static const float kAntiAliasingInflateDistance = 0.5f; | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 class LayerQuad { | |
| 21 public: | |
| 22 class Edge { | |
| 23 public: | |
| 24 Edge() : x_(0), y_(0), z_(0), degenerate_(false) {} | |
| 25 Edge(const gfx::PointF& p, const gfx::PointF& q); | |
| 26 | |
| 27 float x() const { return x_; } | |
| 28 float y() const { return y_; } | |
| 29 float z() const { return z_; } | |
| 30 | |
| 31 void set_x(float x) { x_ = x; } | |
| 32 void set_y(float y) { y_ = y; } | |
| 33 void set_z(float z) { z_ = z; } | |
| 34 void set(float x, float y, float z) { | |
| 35 x_ = x; | |
| 36 y_ = y; | |
| 37 z_ = z; | |
| 38 } | |
| 39 | |
| 40 void move_x(float dx) { x_ += dx; } | |
| 41 void move_y(float dy) { y_ += dy; } | |
| 42 void move_z(float dz) { z_ += dz; } | |
| 43 void move(float dx, float dy, float dz) { | |
| 44 x_ += dx; | |
| 45 y_ += dy; | |
| 46 z_ += dz; | |
| 47 } | |
| 48 | |
| 49 void scale_x(float sx) { x_ *= sx; } | |
| 50 void scale_y(float sy) { y_ *= sy; } | |
| 51 void scale_z(float sz) { z_ *= sz; } | |
| 52 void scale(float sx, float sy, float sz) { | |
| 53 x_ *= sx; | |
| 54 y_ *= sy; | |
| 55 z_ *= sz; | |
| 56 } | |
| 57 void scale(float s) { scale(s, s, s); } | |
| 58 | |
| 59 bool degenerate() const { return degenerate_; } | |
| 60 | |
| 61 gfx::PointF Intersect(const Edge& e) const; | |
| 62 | |
| 63 private: | |
| 64 float x_; | |
| 65 float y_; | |
| 66 float z_; | |
| 67 bool degenerate_; | |
| 68 }; | |
| 69 | |
| 70 LayerQuad(const Edge& left, | |
| 71 const Edge& top, | |
| 72 const Edge& right, | |
| 73 const Edge& bottom); | |
| 74 explicit LayerQuad(const gfx::QuadF& quad); | |
| 75 | |
| 76 Edge left() const { return left_; } | |
| 77 Edge top() const { return top_; } | |
| 78 Edge right() const { return right_; } | |
| 79 Edge bottom() const { return bottom_; } | |
| 80 | |
| 81 void InflateX(float dx) { | |
| 82 left_.move_z(dx); | |
| 83 right_.move_z(dx); | |
| 84 } | |
| 85 void InflateY(float dy) { | |
| 86 top_.move_z(dy); | |
| 87 bottom_.move_z(dy); | |
| 88 } | |
| 89 void Inflate(float d) { | |
| 90 InflateX(d); | |
| 91 InflateY(d); | |
| 92 } | |
| 93 void InflateAntiAliasingDistance() { | |
| 94 Inflate(kAntiAliasingInflateDistance); | |
| 95 } | |
| 96 | |
| 97 gfx::QuadF ToQuadF() const; | |
| 98 | |
| 99 void ToFloatArray(float flattened[12]) const; | |
| 100 | |
| 101 private: | |
| 102 Edge left_; | |
| 103 Edge top_; | |
| 104 Edge right_; | |
| 105 Edge bottom_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(LayerQuad); | |
| 108 }; | |
| 109 | |
| 110 } // namespace cc | |
| 111 | |
| 112 #endif // CC_RESOURCES_LAYER_QUAD_H_ | |
| OLD | NEW |