aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-03-13 06:08:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-13 06:08:28 -0700
commit11fa2247b747eb75e2f158dc7571d458ed6c0115 (patch)
treed48a0f701365a92f47e712781207f10718ab72f1 /include
parentd1f7f990a126ec5d3ca3efefe9d27a36f68272ab (diff)
some utils for rect and matrix
Diffstat (limited to 'include')
-rw-r--r--include/core/SkMatrix.h17
-rw-r--r--include/core/SkRect.h20
-rw-r--r--include/gpu/GrCoordTransform.h2
3 files changed, 35 insertions, 4 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index da7838b781..a272051067 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -457,6 +457,12 @@ public:
this->getMapXYProc()(*this, x, y, result);
}
+ SkPoint mapXY(SkScalar x, SkScalar y) const {
+ SkPoint result;
+ this->getMapXYProc()(*this, x, y, &result);
+ return result;
+ }
+
/** Apply this matrix to the array of vectors specified by src, and write
the transformed vectors into the array of vectors specified by dst.
This is similar to mapPoints, but ignores any translation in the matrix.
@@ -480,6 +486,17 @@ public:
this->mapVectors(vecs, vecs, count);
}
+ void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
+ SkVector vec = { dx, dy };
+ this->mapVectors(result, &vec, 1);
+ }
+
+ SkVector mapVector(SkScalar dx, SkScalar dy) const {
+ SkVector vec = { dx, dy };
+ this->mapVectors(&vec, &vec, 1);
+ return vec;
+ }
+
/** Apply this matrix to the src rectangle, and write the transformed
rectangle into dst. This is accomplished by transforming the 4 corners
of src, and then setting dst to the bounds of those points.
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 8d68c97feb..5c806a963b 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -162,17 +162,24 @@ struct SK_API SkIRect {
/**
* Return a new IRect, built as an offset of this rect.
*/
- SkIRect makeOffset(int dx, int dy) const {
+ SkIRect makeOffset(int32_t dx, int32_t dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
}
/**
* Return a new IRect, built as an inset of this rect.
*/
- SkIRect makeInset(int dx, int dy) const {
+ SkIRect makeInset(int32_t dx, int32_t dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
}
+ /**
+ * Return a new Rect, built as an outset of this rect.
+ */
+ SkIRect makeOutset(int32_t dx, int32_t dy) const {
+ return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
@@ -608,7 +615,7 @@ struct SK_API SkRect {
SkRect makeOffset(SkScalar dx, SkScalar dy) const {
return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
}
-
+
/**
* Return a new Rect, built as an inset of this rect.
*/
@@ -616,6 +623,13 @@ struct SK_API SkRect {
return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
}
+ /**
+ * Return a new Rect, built as an outset of this rect.
+ */
+ SkRect makeOutset(SkScalar dx, SkScalar dy) const {
+ return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
+ }
+
/** Offset set the rectangle by adding dx to its left and right,
and adding dy to its top and bottom.
*/
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h
index 09f4ac9dfa..4d96cd9c97 100644
--- a/include/gpu/GrCoordTransform.h
+++ b/include/gpu/GrCoordTransform.h
@@ -125,7 +125,7 @@ public:
static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
SkASSERT(texture);
SkMatrix mat;
- mat.setIDiv(texture->width(), texture->height());
+ (void)mat.setIDiv(texture->width(), texture->height());
return mat;
}