| 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 #include "SkMatrixPriv.h" |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * GrQuad is a collection of 4 points which can be used to represent an arbitrar
y quadrilateral | 16 * GrQuad is a collection of 4 points which can be used to represent an arbitrar
y quadrilateral |
| 16 */ | 17 */ |
| 17 class GrQuad { | 18 class GrQuad { |
| 18 public: | 19 public: |
| 19 GrQuad() {} | 20 GrQuad() {} |
| 20 | 21 |
| 21 GrQuad(const GrQuad& that) { | 22 GrQuad(const GrQuad& that) { |
| 22 *this = that; | 23 *this = that; |
| 23 } | 24 } |
| 24 | 25 |
| 25 explicit GrQuad(const SkRect& rect) { | 26 explicit GrQuad(const SkRect& rect) { |
| 26 this->set(rect); | 27 this->set(rect); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void set(const SkRect& rect) { | 30 void set(const SkRect& rect) { |
| 30 fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); | 31 fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void map(const SkMatrix& matrix) { | 34 void map(const SkMatrix& matrix) { |
| 34 matrix.mapPoints(fPoints, kNumPoints); | 35 matrix.mapPoints(fPoints, kNumPoints); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void setFromMappedRect(const SkRect& rect, const SkMatrix& matrix) { | 38 void setFromMappedRect(const SkRect& rect, const SkMatrix& matrix) { |
| 38 this->set(rect); | 39 SkMatrixPriv::SetMappedRectFan(matrix, rect, fPoints); |
| 39 matrix.mapPoints(fPoints, kNumPoints); | |
| 40 } | 40 } |
| 41 | 41 |
| 42 const GrQuad& operator=(const GrQuad& that) { | 42 const GrQuad& operator=(const GrQuad& that) { |
| 43 memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints); | 43 memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints); |
| 44 return *this; | 44 return *this; |
| 45 } | 45 } |
| 46 | 46 |
| 47 SkPoint* points() { | 47 SkPoint* points() { |
| 48 return fPoints; | 48 return fPoints; |
| 49 } | 49 } |
| 50 | 50 |
| 51 const SkPoint* points() const { | 51 const SkPoint* points() const { |
| 52 return fPoints; | 52 return fPoints; |
| 53 } | 53 } |
| 54 | 54 |
| 55 const SkPoint& point(int i) const { | 55 const SkPoint& point(int i) const { |
| 56 SkASSERT(i < kNumPoints); | 56 SkASSERT(i < kNumPoints); |
| 57 return fPoints[i]; | 57 return fPoints[i]; |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 static const int kNumPoints = 4; | 61 static const int kNumPoints = 4; |
| 62 SkPoint fPoints[kNumPoints]; | 62 SkPoint fPoints[kNumPoints]; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 #endif | 65 #endif |
| OLD | NEW |