Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: src/gpu/GrQuad.h

Issue 1294713009: Create GrQuad (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/batches/GrBWFillRectBatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrQuad.h
diff --git a/src/gpu/GrQuad.h b/src/gpu/GrQuad.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc169ead6d2b56daebf2518b520e9354c4165402
--- /dev/null
+++ b/src/gpu/GrQuad.h
@@ -0,0 +1,58 @@
+/*
+ * 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;
+ }
+
+ explicit GrQuad(const SkRect& rect) {
+ 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 setFromMappedRect(const SkRect& rect, const SkMatrix& matrix) {
+ this->set(rect);
+ matrix.mapPoints(fPoints, kNumPoints);
+ }
+
+ const GrQuad& operator=(const GrQuad& that) {
+ memcpy(fPoints, that.fPoints, sizeof(SkPoint) * kNumPoints);
+ return *this;
+ }
+
+ SkPoint* points() {
+ return fPoints;
+ }
+
+ const SkPoint* points() const {
+ return fPoints;
+ }
+
+private:
+ static const int kNumPoints = 4;
+ SkPoint fPoints[kNumPoints];
+};
+
+#endif
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/batches/GrBWFillRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698