aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Reed <>2009-04-03 08:58:22 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-03 08:58:22 -0700
commit049e2d4a53b95b3640d8ff158cd82729eecc6134 (patch)
treefedb1f500aebb95497430bc085fe7bf5126d07d5
parentdba38ba49760ccfd15b2f257f4345e1670f8398a (diff)
downloadexternal_skia-049e2d4a53b95b3640d8ff158cd82729eecc6134.zip
external_skia-049e2d4a53b95b3640d8ff158cd82729eecc6134.tar.gz
external_skia-049e2d4a53b95b3640d8ff158cd82729eecc6134.tar.bz2
AI 144454: pull from demetrius:
- use float wrappers for floorf() and pow() - fix obsolete type reference uint16 - move android backend for SkDebugf into /ports file Automated import of CL 144454
-rw-r--r--Android.mk2
-rw-r--r--include/core/SkFloatingPoint.h6
-rw-r--r--src/core/SkFP.h2
-rw-r--r--src/core/SkGraphics.cpp8
-rw-r--r--src/effects/SkEmbossMask.cpp2
-rw-r--r--src/ports/SkDebug_android.cpp (renamed from src/core/SkDebug_stdio.cpp)18
-rw-r--r--src/ports/SkDebug_stdio.cpp33
7 files changed, 46 insertions, 25 deletions
diff --git a/Android.mk b/Android.mk
index 162563b..7130313 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,7 +14,6 @@ LOCAL_SRC_FILES:= \
src/core/SkChunkAlloc.cpp \
src/core/SkCordic.cpp \
src/core/SkDebug.cpp \
- src/core/SkDebug_stdio.cpp \
src/core/SkFloatBits.cpp \
src/core/SkMath.cpp \
src/core/SkMatrix.cpp \
@@ -24,6 +23,7 @@ LOCAL_SRC_FILES:= \
src/core/SkRegion.cpp \
src/core/SkString.cpp \
src/core/SkUtils.cpp \
+ src/ports/SkDebug_android.cpp \
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h
index 68bf6ef..e6856cf 100644
--- a/include/core/SkFloatingPoint.h
+++ b/include/core/SkFloatingPoint.h
@@ -25,6 +25,12 @@
#include <float.h>
#include "SkFloatBits.h"
+// If math.h had powf(float, float), I could remove this wrapper
+static inline float sk_float_pow(float base, float exp) {
+ return static_cast<float>(pow(static_cast<double>(base),
+ static_cast<double>(exp)));
+}
+
#ifdef SK_BUILD_FOR_WINCE
#define sk_float_sqrt(x) (float)::sqrt(x)
#define sk_float_sin(x) (float)::sin(x)
diff --git a/src/core/SkFP.h b/src/core/SkFP.h
index 5e25d22..3aab411 100644
--- a/src/core/SkFP.h
+++ b/src/core/SkFP.h
@@ -41,7 +41,7 @@
#define SkFPDivInt(a, n) ((a) / (n))
#define SkFPInvert(x) SkScalarInvert(x)
#define SkFPSqrt(x) SkScalarSqrt(x)
- #define SkFPCubeRoot(x) static_cast<float>(pow(x, 0.33333333333))
+ #define SkFPCubeRoot(x) sk_float_pow(x, 0.3333333f)
#define SkFPLT(a, b) ((a) < (b))
#define SkFPLE(a, b) ((a) <= (b))
diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp
index 7e72c3f..649de1d 100644
--- a/src/core/SkGraphics.cpp
+++ b/src/core/SkGraphics.cpp
@@ -187,10 +187,10 @@ int time_math() {
f = dummy();
now = SkTime::GetMSecs();
for (i = repeat - 1; i >= 0; --i) {
- sum += (int)floorf(f + 0.5f); f = fast_inc(f);
- sum += (int)floorf(f + 0.5f); f = fast_inc(f);
- sum += (int)floorf(f + 0.5f); f = fast_inc(f);
- sum += (int)floorf(f + 0.5f); f = fast_inc(f);
+ sum += (int)sk_float_floor(f + 0.5f); f = fast_inc(f);
+ sum += (int)sk_float_floor(f + 0.5f); f = fast_inc(f);
+ sum += (int)sk_float_floor(f + 0.5f); f = fast_inc(f);
+ sum += (int)sk_float_floor(f + 0.5f); f = fast_inc(f);
}
SkDebugf("---- native round %d\n", SkTime::GetMSecs() - now);
diff --git a/src/effects/SkEmbossMask.cpp b/src/effects/SkEmbossMask.cpp
index 28e38a1..fd11f54 100644
--- a/src/effects/SkEmbossMask.cpp
+++ b/src/effects/SkEmbossMask.cpp
@@ -75,7 +75,7 @@ void SkEmbossMask_BuildTable()
if ((dy & 15) == 0)
::fprintf(file, "\t");
- U16 value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4));
+ uint16_t value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4));
::fprintf(file, "0x%04X", value);
if (dx * 128 + dy < 128*128-1)
diff --git a/src/core/SkDebug_stdio.cpp b/src/ports/SkDebug_android.cpp
index c8a0d81..f1fd34f 100644
--- a/src/core/SkDebug_stdio.cpp
+++ b/src/ports/SkDebug_android.cpp
@@ -19,8 +19,6 @@
static const size_t kBufferSize = 256;
-#ifdef ANDROID
-
#define LOG_TAG "skia"
#include <utils/Log.h>
@@ -42,20 +40,4 @@ void Android_SkDebugf(const char* file, int line, const char* function,
va_end(args);
}
-#else
-
-#include <stdarg.h>
-#include <stdio.h>
-
-void SkDebugf(const char format[], ...)
-{
- char buffer[kBufferSize + 1];
- va_list args;
- va_start(args, format);
- vsnprintf(buffer, kBufferSize, format, args);
- va_end(args);
- fprintf(stderr, buffer);
-}
-
-#endif
diff --git a/src/ports/SkDebug_stdio.cpp b/src/ports/SkDebug_stdio.cpp
new file mode 100644
index 0000000..f5bf687
--- /dev/null
+++ b/src/ports/SkDebug_stdio.cpp
@@ -0,0 +1,33 @@
+/* libs/corecg/SkDebug_stdio.cpp
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "SkTypes.h"
+
+static const size_t kBufferSize = 256;
+
+#include <stdarg.h>
+#include <stdio.h>
+
+void SkDebugf(const char format[], ...) {
+ char buffer[kBufferSize + 1];
+ va_list args;
+ va_start(args, format);
+ vsnprintf(buffer, kBufferSize, format, args);
+ va_end(args);
+ fprintf(stderr, buffer);
+}
+