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..715028acdcf92a70ee69c2abf19f35ed70893b8b |
| --- /dev/null |
| +++ b/src/gpu/GrQuad.h |
| @@ -0,0 +1,45 @@ |
| +/* |
| + * 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: |
|
bsalomon
2015/08/19 14:20:04
Constructor from rect?
|
| + GrQuad(const GrQuad& that) { |
|
bsalomon
2015/08/19 14:20:04
op =?
|
| + memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints); |
| + } |
| + |
| + void set(const SkRect& rect) { |
| + fPoints->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| + } |
| + |
| + void map(const SkMatrix& viewMatrix) { |
|
bsalomon
2015/08/19 14:20:04
This isn't necessarily a "view" matrix, just a mat
|
| + viewMatrix.mapPoints(fPoints, kNumPoints); |
| + } |
| + |
| + void map(const SkRect& rect, const SkMatrix& viewMatrix) { |
| + this->set(rect); |
| + viewMatrix.mapPoints(fPoints, kNumPoints); |
| + } |
| + |
| + operator SkPoint*() { |
|
bsalomon
2015/08/19 14:20:04
Hm... not sure I love the auto-conversion to SkPoi
|
| + return fPoints; |
| + } |
| + |
| +private: |
| + static const int kNumPoints = 4; |
| + SkPoint fPoints[kNumPoints]; |
| +}; |
| + |
| +#endif |