Simplify common case for recttorect
Change-Id: I70e295a677b8cac3d578e3cd57472c833af03877
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354336
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 98a6846..510882b 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -251,7 +251,7 @@
if (dimensions != srcDimensions) {
SkRect src = SkRect::Make(srcDimensions);
SkRect dst = SkRect::Make(dimensions);
- SkMatrix map = SkMatrix::MakeRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
+ SkMatrix map = SkMatrix::RectToRect(src, dst);
SkRect asRect = SkRect::Make(prevRect);
if (!map.mapRect(&asRect)) {
return false;
diff --git a/src/codec/SkWuffsCodec.cpp b/src/codec/SkWuffsCodec.cpp
index 1f0a3a1..8b000d3 100644
--- a/src/codec/SkWuffsCodec.cpp
+++ b/src/codec/SkWuffsCodec.cpp
@@ -691,9 +691,8 @@
SkDraw draw;
draw.fDst.reset(dstInfo(), fIncrDecDst, fIncrDecRowBytes);
- SkMatrix matrix = SkMatrix::MakeRectToRect(SkRect::Make(this->dimensions()),
- SkRect::Make(this->dstInfo().dimensions()),
- SkMatrix::kFill_ScaleToFit);
+ SkMatrix matrix = SkMatrix::RectToRect(SkRect::Make(this->dimensions()),
+ SkRect::Make(this->dstInfo().dimensions()));
SkSimpleMatrixProvider matrixProvider(matrix);
draw.fMatrixProvider = &matrixProvider;
SkRasterClip rc(SkIRect::MakeSize(this->dstInfo().dimensions()));
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index b970c4e..b8c236c 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -435,7 +435,6 @@
return;
}
- SkMatrix matrix;
SkRect bitmapBounds, tmpSrc, tmpDst;
SkBitmap tmpBitmap;
@@ -447,7 +446,7 @@
} else {
tmpSrc = bitmapBounds;
}
- matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
+ SkMatrix matrix = SkMatrix::RectToRect(tmpSrc, dst);
const SkRect* dstPtr = &dst;
const SkBitmap* bitmapPtr = &bitmap;
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index b48a2a4..eef0f6d 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -234,9 +234,7 @@
}
bitmap.setImmutable(); // Don't copy when we create an image.
- SkMatrix scale = SkMatrix::MakeRectToRect(SkRect::Make(src.bounds()),
- SkRect::Make(dst.bounds()),
- SkMatrix::kFill_ScaleToFit);
+ SkMatrix scale = SkMatrix::RectToRect(SkRect::Make(src.bounds()), SkRect::Make(dst.bounds()));
sk_sp<SkShader> shader = SkImageShader::Make(bitmap.asImage(),
SkTileMode::kClamp,
diff --git a/src/gpu/GrSurfaceFillContext.h b/src/gpu/GrSurfaceFillContext.h
index 88f192e..d7e4b5c 100644
--- a/src/gpu/GrSurfaceFillContext.h
+++ b/src/gpu/GrSurfaceFillContext.h
@@ -157,8 +157,7 @@
void fillRectToRectWithFP(const SkRect& srcRect,
const SkIRect& dstRect,
std::unique_ptr<GrFragmentProcessor> fp) {
- SkMatrix lm;
- lm.setRectToRect(SkRect::Make(dstRect), srcRect, SkMatrix::kFill_ScaleToFit);
+ SkMatrix lm = SkMatrix::RectToRect(SkRect::Make(dstRect), srcRect);
this->fillRectWithFP(dstRect, lm, std::move(fp));
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 7b30284..45a9a25 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -282,7 +282,7 @@
}
if (outDstRect) {
- srcToDst->setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
+ *srcToDst = SkMatrix::RectToRect(src, dst);
} else {
srcToDst->setIdentity();
}
@@ -677,7 +677,7 @@
SkRect src = SkRect::Make(special->subset());
SkRect dst = SkRect::MakeWH(special->width(), special->height());
- SkMatrix srcToDst = SkMatrix::MakeRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
+ SkMatrix srcToDst = SkMatrix::RectToRect(src, dst);
GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, downgrade_to_filter(sampling));
GrAA aa = paint.isAntiAlias() ? GrAA::kYes : GrAA::kNo;
diff --git a/src/gpu/geometry/GrRect.h b/src/gpu/geometry/GrRect.h
index 37e0001..546d349 100644
--- a/src/gpu/geometry/GrRect.h
+++ b/src/gpu/geometry/GrRect.h
@@ -93,8 +93,7 @@
*/
static inline void GrMapRectPoints(const SkRect& inRect, const SkRect& outRect,
const SkPoint inPts[], SkPoint outPts[], int ptCount) {
- SkMatrix rectTransform = SkMatrix::MakeRectToRect(inRect, outRect, SkMatrix::kFill_ScaleToFit);
- rectTransform.mapPoints(outPts, inPts, ptCount);
+ SkMatrix::RectToRect(inRect, outRect).mapPoints(outPts, inPts, ptCount);
}
/**
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index a1b866b..0ec1c63 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1452,8 +1452,7 @@
// First, figure out the src->dst transform and subset the image if needed.
SkIRect bounds = imageSubset.image()->bounds();
SkRect srcRect = src ? *src : SkRect::Make(bounds);
- SkMatrix transform;
- transform.setRectToRect(srcRect, dst, SkMatrix::kFill_ScaleToFit);
+ SkMatrix transform = SkMatrix::RectToRect(srcRect, dst);
if (src && *src != SkRect::Make(bounds)) {
if (!srcRect.intersect(SkRect::Make(bounds))) {
return;
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index 88f4759..58a2ac1 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -244,9 +244,8 @@
sk_sp<SkShader> tileShader;
if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) {
- SkMatrix tileMatrix;
- tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()),
- SkMatrix::kFill_ScaleToFit);
+ SkMatrix tileMatrix = SkMatrix::RectToRect(fTile, SkRect::MakeIWH(tileSize.width(),
+ tileSize.height()));
sk_sp<SkImage> tileImage = SkImage::MakeFromPicture(fPicture, tileSize, &tileMatrix,
nullptr, bitDepth, std::move(imgCS));
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index cabd0cb..1ee852f 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -965,11 +965,8 @@
cs->clipRect(dst, this->localToDevice(), kIntersect_SkClipOp, paint.isAntiAlias());
}
- SkMatrix adjustedMatrix;
- adjustedMatrix.setRectToRect(src ? *src : SkRect::Make(bm.bounds()),
- dst,
- SkMatrix::kFill_ScaleToFit);
- adjustedMatrix.postConcat(this->localToDevice());
+ SkMatrix adjustedMatrix = this->localToDevice()
+ * SkMatrix::RectToRect(src ? *src : SkRect::Make(bm.bounds()), dst);
drawBitmapCommon(MxCp(&adjustedMatrix, cs), bm, paint);
}
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 422d733..6d5fc4e 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -2014,7 +2014,7 @@
SkRect bitmapBounds = SkRect::Make(bitmap.bounds());
SkRect srcBounds = src ? *src : bitmapBounds;
- SkMatrix matrix = SkMatrix::MakeRectToRect(srcBounds, dst, SkMatrix::kFill_ScaleToFit);
+ SkMatrix matrix = SkMatrix::RectToRect(srcBounds, dst);
SkRect actualDst;
if (!src || bitmapBounds.contains(*src)) {
actualDst = dst;