aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-08-19 08:48:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-19 08:48:41 -0700
commitae5b2c623b22b24ea7c0d6200298e5bc366faa63 (patch)
treee9d170cfd76884346b125214bc016ab44da8536e
parentbca86202a48b2afa527b6e40d8b360ce3bc7c2e7 (diff)
Create GrQuad
-rw-r--r--gyp/gpu.gypi1
-rw-r--r--src/gpu/GrQuad.h58
-rw-r--r--src/gpu/batches/GrBWFillRectBatch.cpp1
3 files changed, 60 insertions, 0 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 838d99c379..55d2273aaa 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -163,6 +163,7 @@
'<(skia_src_path)/gpu/GrProcOptInfo.cpp',
'<(skia_src_path)/gpu/GrProcOptInfo.h',
'<(skia_src_path)/gpu/GrGpuResourceRef.cpp',
+ '<(skia_src_path)/gpu/GrQuad.h',
'<(skia_src_path)/gpu/GrRecordReplaceDraw.cpp',
'<(skia_src_path)/gpu/GrRecordReplaceDraw.h',
'<(skia_src_path)/gpu/GrRectanizer.h',
diff --git a/src/gpu/GrQuad.h b/src/gpu/GrQuad.h
new file mode 100644
index 0000000000..fc169ead6d
--- /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
diff --git a/src/gpu/batches/GrBWFillRectBatch.cpp b/src/gpu/batches/GrBWFillRectBatch.cpp
index ffd4cefc86..5c14aae25f 100644
--- a/src/gpu/batches/GrBWFillRectBatch.cpp
+++ b/src/gpu/batches/GrBWFillRectBatch.cpp
@@ -11,6 +11,7 @@
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrPrimitiveProcessor.h"
+#include "GrQuad.h"
#include "GrResourceProvider.h"
#include "GrTInstanceBatch.h"
#include "GrVertexBatch.h"