aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-07-10 11:35:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-10 11:35:03 -0700
commit14dce6ed5934d7a6e1fac79f8e76e12f5670aae2 (patch)
tree12d660e3d38ed118faf4aa2635db4c52eed87627 /src
parent4c42eebc55518019e6c2437e59adba28297221df (diff)
change mapRectScaleTranslate to pass args/ret by value
Diffstat (limited to 'src')
-rw-r--r--src/core/SkCanvas.cpp13
-rw-r--r--src/core/SkMatrix.cpp11
-rw-r--r--src/utils/SkDeferredCanvas.cpp2
3 files changed, 12 insertions, 14 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0ce97fff20..23442779ce 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -75,13 +75,11 @@ bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
}
if (rect) {
- if (!this->getTotalMatrix().isScaleTranslate()) {
+ const SkMatrix& ctm = this->getTotalMatrix();
+ if (!ctm.isScaleTranslate()) {
return false; // conservative
}
-
- SkRect devRect;
- this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect);
- if (!devRect.contains(bounds)) {
+ if (!ctm.mapRectScaleTranslate(*rect).contains(bounds)) {
return false;
}
}
@@ -1544,8 +1542,7 @@ void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
// Check if we can quick-accept the clip call (and do nothing)
//
if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTranslate()) {
- SkRect devR;
- fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
+ SkRect devR = fMCRec->fMatrix.mapRectScaleTranslate(rect);
// NOTE: this check is CTM specific, since we might round differently with a different
// CTM. Thus this is only 100% reliable if there is not global CTM scale to be
// applied later (i.e. if this is going into a picture).
@@ -1585,7 +1582,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate();
SkRect devR;
if (isScaleTrans) {
- fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
+ devR = fMCRec->fMatrix.mapRectScaleTranslate(rect);
}
#ifndef SK_SUPPORT_PRECHECK_CLIPRECT
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 492f3f6ac4..71ef24c5e8 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1097,8 +1097,7 @@ void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
}
}
-void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
- SkASSERT(dst);
+SkRect SkMatrix::mapRectScaleTranslate(SkRect src) const {
SkASSERT(this->isScaleTranslate());
SkScalar sx = fMat[kMScaleX];
@@ -1107,7 +1106,7 @@ void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
SkScalar ty = fMat[kMTransY];
Sk4f scale(sx, sy, sx, sy);
Sk4f trans(tx, ty, tx, ty);
-
+
Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans;
// need to sort so we're not inverted
Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]);
@@ -1115,14 +1114,16 @@ void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
Sk4f max = Sk4f::Max(ltrb, rblt);
// We can extract either pair [0,1] or [2,3] from min and max and be correct, but on
// ARM this sequence generates the fastest (a single instruction).
- Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft);
+ SkRect dst;
+ Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft);
+ return dst;
}
bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const {
SkASSERT(dst);
if (this->isScaleTranslate()) {
- this->mapRectScaleTranslate(dst, src);
+ *dst = this->mapRectScaleTranslate(src);
return true;
} else {
SkPoint quad[4];
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 14220209cc..c8a37c36b7 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -200,7 +200,7 @@ void SkDeferredCanvas::flush_check(SkRect* bounds, const SkPaint* paint, unsigne
if (canScale) {
SkMatrix m;
rec.getConcat(&m);
- m.mapRectScaleTranslate(bounds, *bounds);
+ *bounds = m.mapRectScaleTranslate(*bounds);
} else {
goto STOP;
}