aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-07-10 11:45:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-10 11:45:35 -0700
commit6092b6e0e57be20d2e1ad079c0af133d2f67bfd3 (patch)
treee3afc2ac6554be3827b03bf7703b7a6aa6355cbe
parent14dce6ed5934d7a6e1fac79f8e76e12f5670aae2 (diff)
Revert of change mapRectScaleTranslate to pass args/ret by value (patchset #1 id:1 of https://codereview.chromium.org/2137853002/ )
Reason for revert: Triggered a compiler bug on Android? FAILED: /usr/bin/ccache /b/work/skia/platform_tools/android/bin/../toolchains/arm-r11c-14/bin/arm-linux-androideabi-g++ -MMD -MF obj/src/core/core.SkMatrix.o.d -DSK_INTERNAL -DSK_GAMMA_APPLY_TO_A8 -DQT_NO_KEYWORDS -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 -DSK_SUPPORT_GPU=1 -DSK_FORCE_DISTANCE_FIELD_TEXT=0 -DSK_HAS_GIF_LIBRARY -DSK_HAS_JPEG_LIBRARY -DSK_HAS_PNG_LIBRARY -DSK_HAS_WEBP_LIBRARY -DSK_TEST_QCMS -DSK_IS_BOT -DSK_CODEC_DECODES_RAW -DSK_ARM_HAS_NEON -DSK_BUILD_FOR_ANDROID -DSK_GAMMA_EXPONENT=1.4 -DSK_GAMMA_CONTRAST=0.0 -DSKIA_DLL -DSKIA_IMPLEMENTATION=1 -DSK_SUPPORT_LEGACY_CLIPTOLAYERFLAG -DNDEBUG -I../../../include/c -I../../../include/config -I../../../include/core -I../../../include/pathops -I../../../include/ports -I../../../include/private -I../../../include/utils -I../../../include/images -I../../../src/core -I../../../src/sfnt -I../../../src/image -I../../../src/opts -I../../../src/utils -I../../../include/gpu -I../../../src/gpu -I../../../platform_tools/android/third_party/cpufeatures -fPIC -g -fno-exceptions -fstrict-aliasing -Wall -Wextra -Winit-self -Wpointer-arith -Wsign-compare -Wvla -Wno-unused-parameter -Werror -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=softfp -fuse-ld=gold -O2 -std=c++11 -fno-rtti -fno-threadsafe-statics -Wnon-virtual-dtor -c ../../../src/core/SkMatrix.cpp -o obj/src/core/core.SkMatrix.o ../../../src/core/SkMatrix.cpp: In member function 'SkRect SkMatrix::mapRectScaleTranslate(SkRect) const': ../../../src/core/SkMatrix.cpp:1120:1: error: unrecognizable insn: } ^ (insn 32 31 33 2 (set (reg:V4SF 115 [ D.83077 ]) (unspec:V4SF [ (mem/c:V4SF (reg/f:SI 104 virtual-incoming-args) [0 MEM[(const __builtin_neon_sf[4] *)&src]+0 S16 A32]) ] UNSPEC_VLD1)) /b/work/skia/platform_tools/android/toolchains/arm-r11c-14/lib/gcc/arm-linux-androideabi/4.9/include/arm_neon.h:8693 -1 (nil)) ../../../src/core/SkMatrix.cpp:1120:1: internal compiler error: in extract_insn, at recog.c:2202 Please submit a full bug report, with preprocessed source if appropriate. See <http://source.android.com/source/report-bugs.html>; for instructions. Original issue's description: > change mapRectScaleTranslate to pass args/ret by value > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2137853002 > > TBR=mtklein > > Committed: https://skia.googlesource.com/skia/+/14dce6ed5934d7a6e1fac79f8e76e12f5670aae2 TBR=msarett@google.com,mtklein@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2139523002
-rw-r--r--bench/MatrixBench.cpp2
-rw-r--r--include/core/SkMatrix.h2
-rw-r--r--src/core/SkCanvas.cpp13
-rw-r--r--src/core/SkMatrix.cpp11
-rw-r--r--src/utils/SkDeferredCanvas.cpp2
-rw-r--r--tests/MatrixTest.cpp2
6 files changed, 17 insertions, 15 deletions
diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp
index 185ea7924c..53e7296731 100644
--- a/bench/MatrixBench.cpp
+++ b/bench/MatrixBench.cpp
@@ -320,7 +320,7 @@ public:
SkRect dst;
if (fScaleTrans) {
for (int i = 0; i < MEGA_LOOP; ++i) {
- dst = fM.mapRectScaleTranslate(fR);
+ fM.mapRectScaleTranslate(&dst, fR);
}
} else {
for (int i = 0; i < MEGA_LOOP; ++i) {
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index 8f70d4c91b..5b22a77481 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -565,7 +565,7 @@ public:
* Maps a rect to another rect, asserting (in debug mode) that the matrix only contains
* scale and translate elements. If it contains other elements, the results are undefined.
*/
- SkRect mapRectScaleTranslate(SkRect src) const;
+ void mapRectScaleTranslate(SkRect* dst, const SkRect& src) const;
/** Return the mean radius of a circle after it has been mapped by
this matrix. NOTE: in perspective this value assumes the circle
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 23442779ce..0ce97fff20 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -75,11 +75,13 @@ bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
}
if (rect) {
- const SkMatrix& ctm = this->getTotalMatrix();
- if (!ctm.isScaleTranslate()) {
+ if (!this->getTotalMatrix().isScaleTranslate()) {
return false; // conservative
}
- if (!ctm.mapRectScaleTranslate(*rect).contains(bounds)) {
+
+ SkRect devRect;
+ this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect);
+ if (!devRect.contains(bounds)) {
return false;
}
}
@@ -1542,7 +1544,8 @@ 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(rect);
+ SkRect devR;
+ fMCRec->fMatrix.mapRectScaleTranslate(&devR, 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).
@@ -1582,7 +1585,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate();
SkRect devR;
if (isScaleTrans) {
- devR = fMCRec->fMatrix.mapRectScaleTranslate(rect);
+ fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
}
#ifndef SK_SUPPORT_PRECHECK_CLIPRECT
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 71ef24c5e8..492f3f6ac4 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1097,7 +1097,8 @@ void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
}
}
-SkRect SkMatrix::mapRectScaleTranslate(SkRect src) const {
+void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
+ SkASSERT(dst);
SkASSERT(this->isScaleTranslate());
SkScalar sx = fMat[kMScaleX];
@@ -1106,7 +1107,7 @@ SkRect SkMatrix::mapRectScaleTranslate(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]);
@@ -1114,16 +1115,14 @@ SkRect SkMatrix::mapRectScaleTranslate(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).
- SkRect dst;
- Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft);
- return dst;
+ Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft);
}
bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const {
SkASSERT(dst);
if (this->isScaleTranslate()) {
- *dst = this->mapRectScaleTranslate(src);
+ this->mapRectScaleTranslate(dst, src);
return true;
} else {
SkPoint quad[4];
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index c8a37c36b7..14220209cc 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);
- *bounds = m.mapRectScaleTranslate(*bounds);
+ m.mapRectScaleTranslate(bounds, *bounds);
} else {
goto STOP;
}
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index 4386c5f491..c4eb9c7011 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -978,7 +978,7 @@ DEF_TEST(Matrix_maprects, r) {
mat.mapPoints((SkPoint*)&dst[0].fLeft, (SkPoint*)&src.fLeft, 2);
dst[0].sort();
mat.mapRect(&dst[1], src);
- dst[2] = mat.mapRectScaleTranslate(src);
+ mat.mapRectScaleTranslate(&dst[2], src);
REPORTER_ASSERT(r, dst[0] == dst[1]);
REPORTER_ASSERT(r, dst[0] == dst[2]);