aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrQuad.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-05-17 10:42:14 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-17 15:29:13 +0000
commita33b67c36bcdf70221c459a5fcfec48055f66505 (patch)
treee8608ec03cb34b14e31673aec600af84a0e81ec3 /src/gpu/GrQuad.h
parent6403b0e29055b8573eab20b5cb586c07785a2435 (diff)
Rewrite GrQuad to use separate arrays of x and y values to be Sk4f friendly.
Change-Id: Ie2ad197c5f17849fe6e034b60bc7ec18a00edb24 Reviewed-on: https://skia-review.googlesource.com/128842 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrQuad.h')
-rw-r--r--src/gpu/GrQuad.h57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/gpu/GrQuad.h b/src/gpu/GrQuad.h
index ca51f6496f..62f025d162 100644
--- a/src/gpu/GrQuad.h
+++ b/src/gpu/GrQuad.h
@@ -8,9 +8,9 @@
#ifndef GrQuad_DEFINED
#define GrQuad_DEFINED
-#include "SkPoint.h"
#include "SkMatrix.h"
-#include "SkMatrixPriv.h"
+#include "SkNx.h"
+#include "SkPoint.h"
/**
* GrQuad is a collection of 4 points which can be used to represent an arbitrary quadrilateral. The
@@ -18,50 +18,39 @@
*/
class GrQuad {
public:
- GrQuad() {}
+ GrQuad() = default;
- GrQuad(const GrQuad& that) {
- *this = that;
- }
+ GrQuad(const GrQuad& that) = default;
- explicit GrQuad(const SkRect& rect) {
- this->set(rect);
- }
+ explicit GrQuad(const SkRect& rect)
+ : fX{rect.fLeft, rect.fLeft, rect.fRight, rect.fRight}
+ , fY{rect.fTop, rect.fBottom, rect.fTop, rect.fBottom} {}
- void set(const SkRect& rect) {
- SkPointPriv::SetRectTriStrip(fPoints, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom,
- sizeof(SkPoint));
- }
+ /** Sets the quad to the rect as transformed by the matrix. */
+ GrQuad(const SkRect&, const SkMatrix&);
- void map(const SkMatrix& matrix) {
- matrix.mapPoints(fPoints, kNumPoints);
- }
+ explicit GrQuad(const SkPoint pts[4])
+ : fX{pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX}
+ , fY{pts[0].fY, pts[1].fY, pts[2].fY, pts[3].fY} {}
- void setFromMappedRect(const SkRect& rect, const SkMatrix& matrix) {
- SkMatrixPriv::SetMappedRectTriStrip(matrix, rect, fPoints);
- }
+ GrQuad& operator=(const GrQuad& that) = default;
- const GrQuad& operator=(const GrQuad& that) {
- memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints);
- return *this;
- }
+ SkPoint point(int i) const { return {fX[i], fY[i]}; }
- SkPoint* points() {
- return fPoints;
+ SkRect bounds() const {
+ auto x = this->x4f(), y = this->y4f();
+ return {x.min(), y.min(), x.max(), y.max()};
}
- const SkPoint* points() const {
- return fPoints;
- }
+ float x(int i) const { return fX[i]; }
+ float y(int i) const { return fY[i]; }
- const SkPoint& point(int i) const {
- SkASSERT(i < kNumPoints);
- return fPoints[i];
- }
+ Sk4f x4f() const { return Sk4f::Load(fX); }
+ Sk4f y4f() const { return Sk4f::Load(fY); }
private:
- static const int kNumPoints = 4;
- SkPoint fPoints[kNumPoints];
+ float fX[4];
+ float fY[4];
};
#endif