Chromium Code Reviews| Index: src/gpu/GrQuad.h |
| diff --git a/src/gpu/GrQuad.h b/src/gpu/GrQuad.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0134cd9781c42d026f87b0abc991a13a48e14492 |
| --- /dev/null |
| +++ b/src/gpu/GrQuad.h |
| @@ -0,0 +1,54 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrQuad_DEFINED |
| +#define GrQuad_DEFINED |
| + |
| +#include "SkPoint.h" |
| +#include "SkMatrix.h" |
| + |
| +/** |
| + * GrQuad is a collection of 4 points which can be used to represent an arbitrary quadrilateral |
| + */ |
| +class GrQuad { |
| +public: |
| + GrQuad(const GrQuad& that) { |
| + *this = that; |
| + } |
| + |
| + GrQuad(const SkRect& rect) { |
|
bsalomon
2015/08/19 15:04:51
explicit
|
| + this->set(rect); |
| + } |
| + |
| + void set(const SkRect& rect) { |
| + fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| + } |
| + |
| + void map(const SkMatrix& matrix) { |
| + matrix.mapPoints(fPoints, kNumPoints); |
| + } |
| + |
| + void map(const SkRect& rect, const SkMatrix& matrix) { |
|
bsalomon
2015/08/19 15:04:51
The other "map" maps the existing values. This one
|
| + this->set(rect); |
| + matrix.mapPoints(fPoints, kNumPoints); |
| + } |
| + |
| + const GrQuad& operator=(const GrQuad& that) { |
| + memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints); |
| + return *this; |
| + } |
| + |
| + SkPoint* points() { |
|
bsalomon
2015/08/19 15:04:51
const version?
|
| + return fPoints; |
| + } |
| + |
| +private: |
| + static const int kNumPoints = 4; |
| + SkPoint fPoints[kNumPoints]; |
| +}; |
| + |
| +#endif |