aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2014-07-11 12:14:51 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-11 12:14:51 -0700
commit936b73424f7393994be832376287da988a52b993 (patch)
tree593058a39c92a62ab13de099542884aa307f6848 /src
parentbc9205be0a1094e312da098348601398c210dc5a (diff)
ios fixes
skia_ios.mm Get the app's Documents directory and pass use it to set the resource path. This is a quick hack which will be replaced by a new application that is a tiny shim around a command line tool. SkImageEncoder.h SkForceLinking.cpp SkImageDecoder_CG.cpp Add support for FORCE_LINKING so iOS sees the PNG encoder and others. SkFloatBits.cpp SkPoint.cpp Handle denormalized numbers that are floored by the iOS ARM processor. SkImageDecoder_iOS.mm Remove empty encoder factory. SkTouchGesture.cpp Return early on empty state on touch rather than aborting (crashing) JpegTest.cpp Hal via stackoverflow.com says partial jpegs can be gray as well. skia_test.cpp Remove crash handler call for now to avoid link failure. OverwriteLine.h Remove fancy line overwrite for iOS. Resources.cpp Add interface to set resource directory based on runtime query. BUG=skia:2736 skia:2737 skia:2738 R=reed@google.com, halcanary@google.com, mtklein@google.com, tfarina@chromium.org Author: caryclark@google.com Review URL: https://codereview.chromium.org/373383003
Diffstat (limited to 'src')
-rw-r--r--src/core/SkFloatBits.cpp19
-rw-r--r--src/core/SkMathPriv.h6
-rw-r--r--src/core/SkPoint.cpp11
-rw-r--r--src/images/SkForceLinking.cpp3
-rw-r--r--src/ports/SkImageDecoder_CG.cpp11
-rwxr-xr-xsrc/utils/ios/SkImageDecoder_iOS.mm3
-rw-r--r--src/views/SkTouchGesture.cpp4
7 files changed, 53 insertions, 4 deletions
diff --git a/src/core/SkFloatBits.cpp b/src/core/SkFloatBits.cpp
index 39b51abf1d..6b35a75c88 100644
--- a/src/core/SkFloatBits.cpp
+++ b/src/core/SkFloatBits.cpp
@@ -85,7 +85,16 @@ int32_t SkFloatBits_toIntFloor(int32_t packed) {
value = SkApplySign(value, SkExtractSign(packed));
exp = -exp;
if (exp > 25) { // underflow
+#ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED
+ // The iOS ARM processor discards small denormalized numbers to go faster.
+ // The comparision below empirically causes the result to agree with the
+ // tests in MathTest test_float_floor
+ if (exp > 149) {
+ return 0;
+ }
+#else
exp = 25;
+#endif
}
// int add = 0;
return value >> exp;
@@ -145,7 +154,17 @@ int32_t SkFloatBits_toIntCeil(int32_t packed) {
value = SkApplySign(value, SkExtractSign(packed));
exp = -exp;
if (exp > 25) { // underflow
+#ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED
+ // The iOS ARM processor discards small denormalized numbers to go faster.
+ // The comparision below empirically causes the result to agree with the
+ // tests in MathTest test_float_ceil
+ if (exp > 149) {
+ return 0;
+ }
+ return 0 < value;
+#else
exp = 25;
+#endif
}
int add = (1 << exp) - 1;
return (value + add) >> exp;
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h
index f93ab61078..e997045ea8 100644
--- a/src/core/SkMathPriv.h
+++ b/src/core/SkMathPriv.h
@@ -10,6 +10,12 @@
#include "SkMath.h"
+#ifdef SK_BUILD_FOR_IOS
+// The iOS ARM processor discards small denormalized numbers to go faster.
+// Algorithms that rely on denormalized numbers need alternative implementations.
+#define SK_DISCARD_DENORMALIZED_FOR_SPEED
+#endif
+
/** Returns -1 if n < 0, else returns 0
*/
#define SkExtractSign(n) ((int32_t)(n) >> 31)
diff --git a/src/core/SkPoint.cpp b/src/core/SkPoint.cpp
index 719ee54b22..8a6d0564af 100644
--- a/src/core/SkPoint.cpp
+++ b/src/core/SkPoint.cpp
@@ -7,6 +7,7 @@
*/
+#include "SkMathPriv.h"
#include "SkPoint.h"
void SkIPoint::rotateCW(SkIPoint* dst) const {
@@ -168,7 +169,17 @@ bool SkPoint::setLength(float x, float y, float length) {
// divide by inf. and return (0,0) vector.
double xx = x;
double yy = y;
+ #ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED
+ // The iOS ARM processor discards small denormalized numbers to go faster.
+ // Casting this to a float would cause the scale to go to zero. Keeping it
+ // as a double for the multiply keeps the scale non-zero.
+ double dscale = length / sqrt(xx * xx + yy * yy);
+ fX = x * dscale;
+ fY = y * dscale;
+ return true;
+ #else
scale = (float)(length / sqrt(xx * xx + yy * yy));
+ #endif
}
fX = x * scale;
fY = y * scale;
diff --git a/src/images/SkForceLinking.cpp b/src/images/SkForceLinking.cpp
index 2c9a38979a..442f0f77c0 100644
--- a/src/images/SkForceLinking.cpp
+++ b/src/images/SkForceLinking.cpp
@@ -29,6 +29,9 @@ int SkForceLinking(bool doNotPassTrue) {
#if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_IOS)
CreatePNGImageDecoder();
#endif
+#if defined(SK_BUILD_FOR_IOS)
+ CreatePNGImageEncoder_IOS();
+#endif
return -1;
}
return 0;
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index 7bebf394da..5b32502d8e 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -300,6 +300,17 @@ static SkImageEncoder* sk_imageencoder_cg_factory(SkImageEncoder::Type t) {
static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_cg_factory);
+#ifdef SK_BUILD_FOR_IOS
+class SkPNGImageEncoder_IOS : public SkImageEncoder_CG {
+public:
+ SkPNGImageEncoder_IOS()
+ : SkImageEncoder_CG(kPNG_Type) {
+ }
+};
+
+DEFINE_ENCODER_CREATOR(PNGImageEncoder_IOS);
+#endif
+
struct FormatConversion {
CFStringRef fUTType;
SkImageDecoder::Format fFormat;
diff --git a/src/utils/ios/SkImageDecoder_iOS.mm b/src/utils/ios/SkImageDecoder_iOS.mm
index 021fa25309..f3db65e035 100755
--- a/src/utils/ios/SkImageDecoder_iOS.mm
+++ b/src/utils/ios/SkImageDecoder_iOS.mm
@@ -62,7 +62,4 @@ SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
return NULL;
}
-SkImageEncoder* SkImageEncoder::Create(Type t) {
- return NULL;
-}
diff --git a/src/views/SkTouchGesture.cpp b/src/views/SkTouchGesture.cpp
index 9b02417771..e6a8eaeec6 100644
--- a/src/views/SkTouchGesture.cpp
+++ b/src/views/SkTouchGesture.cpp
@@ -203,7 +203,9 @@ float SkTouchGesture::limitTotalZoom(float scale) const {
void SkTouchGesture::touchMoved(void* owner, float x, float y) {
// GrPrintf("--- %d touchMoved %p %g %g\n", fTouches.count(), owner, x, y);
- SkASSERT(kEmpty_State != fState);
+ if (kEmpty_State == fState) {
+ return;
+ }
int index = this->findRec(owner);
if (index < 0) {