OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrQuad_DEFINED |
| 9 #define GrQuad_DEFINED |
| 10 |
| 11 #include "SkPoint.h" |
| 12 #include "SkMatrix.h" |
| 13 |
| 14 /** |
| 15 * GrQuad is a collection of 4 points which can be used to represent an arbitrar
y quadrilateral |
| 16 */ |
| 17 class GrQuad { |
| 18 public: |
| 19 GrQuad(const GrQuad& that) { |
| 20 *this = that; |
| 21 } |
| 22 |
| 23 explicit GrQuad(const SkRect& rect) { |
| 24 this->set(rect); |
| 25 } |
| 26 |
| 27 void set(const SkRect& rect) { |
| 28 fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 29 } |
| 30 |
| 31 void map(const SkMatrix& matrix) { |
| 32 matrix.mapPoints(fPoints, kNumPoints); |
| 33 } |
| 34 |
| 35 void setFromMappedRect(const SkRect& rect, const SkMatrix& matrix) { |
| 36 this->set(rect); |
| 37 matrix.mapPoints(fPoints, kNumPoints); |
| 38 } |
| 39 |
| 40 const GrQuad& operator=(const GrQuad& that) { |
| 41 memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints); |
| 42 return *this; |
| 43 } |
| 44 |
| 45 SkPoint* points() { |
| 46 return fPoints; |
| 47 } |
| 48 |
| 49 const SkPoint* points() const { |
| 50 return fPoints; |
| 51 } |
| 52 |
| 53 private: |
| 54 static const int kNumPoints = 4; |
| 55 SkPoint fPoints[kNumPoints]; |
| 56 }; |
| 57 |
| 58 #endif |
OLD | NEW |