OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrQuad_DEFINED | 8 #ifndef GrQuad_DEFINED |
9 #define GrQuad_DEFINED | 9 #define GrQuad_DEFINED |
10 | 10 |
11 #include "SkPoint.h" | 11 #include "SkPoint.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 | 13 |
14 /** | 14 /** |
15 * GrQuad is a collection of 4 points which can be used to represent an arbitrar
y quadrilateral | 15 * GrQuad is a collection of 4 points which can be used to represent an arbitrar
y quadrilateral |
16 */ | 16 */ |
17 class GrQuad { | 17 class GrQuad { |
18 public: | 18 public: |
| 19 GrQuad() {} |
| 20 |
19 GrQuad(const GrQuad& that) { | 21 GrQuad(const GrQuad& that) { |
20 *this = that; | 22 *this = that; |
21 } | 23 } |
22 | 24 |
23 explicit GrQuad(const SkRect& rect) { | 25 explicit GrQuad(const SkRect& rect) { |
24 this->set(rect); | 26 this->set(rect); |
25 } | 27 } |
26 | 28 |
27 void set(const SkRect& rect) { | 29 void set(const SkRect& rect) { |
28 fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); | 30 fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
(...skipping 14 matching lines...) Expand all Loading... |
43 } | 45 } |
44 | 46 |
45 SkPoint* points() { | 47 SkPoint* points() { |
46 return fPoints; | 48 return fPoints; |
47 } | 49 } |
48 | 50 |
49 const SkPoint* points() const { | 51 const SkPoint* points() const { |
50 return fPoints; | 52 return fPoints; |
51 } | 53 } |
52 | 54 |
| 55 const SkPoint& point(int i) const { |
| 56 SkASSERT(i < kNumPoints); |
| 57 return fPoints[i]; |
| 58 } |
| 59 |
53 private: | 60 private: |
54 static const int kNumPoints = 4; | 61 static const int kNumPoints = 4; |
55 SkPoint fPoints[kNumPoints]; | 62 SkPoint fPoints[kNumPoints]; |
56 }; | 63 }; |
57 | 64 |
58 #endif | 65 #endif |
OLD | NEW |