aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 18:58:35 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 18:58:35 +0000
commitefbe8e9bedda21a3e061ebf3d96431a0f250a654 (patch)
tree4841675c513e4756e18bcba29f16943ff28fec05
parent365d78762d0878bb3c9d4bfc90c99eab5f2c896a (diff)
Fix errors when compiling with -Wall -Werror on Android.
This CL also turns those features on by default on Android Review URL: https://codereview.appspot.com/7313049 git-svn-id: http://skia.googlecode.com/svn/trunk@7645 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/BlurRectBench.cpp21
-rw-r--r--gyp/common_conditions.gypi2
-rw-r--r--gyp/jsoncpp.gyp6
-rw-r--r--gyp/libjpeg.gyp2
-rw-r--r--gyp/utils.gyp8
-rw-r--r--include/core/SkFloatingPoint.h6
-rw-r--r--include/utils/SkRandom.h2
-rw-r--r--samplecode/SamplePolyToPoly.cpp5
-rw-r--r--src/core/SkAdvancedTypefaceMetrics.cpp3
-rw-r--r--src/core/SkPictureFlat.h2
-rw-r--r--src/images/SkMovie_gif.cpp3
-rw-r--r--src/opts/SkBitmapProcState_matrixProcs_neon.cpp1
-rw-r--r--src/opts/SkBitmapProcState_matrix_clamp_neon.h23
-rw-r--r--src/opts/SkBitmapProcState_matrix_repeat_neon.h4
-rw-r--r--src/opts/SkBlitRow_opts_arm_neon.cpp10
-rw-r--r--src/ports/FontHostConfiguration_android.cpp1
-rw-r--r--src/ports/SkFontHost_android.cpp8
-rw-r--r--src/utils/android/ashmem.cpp (renamed from src/utils/android/ashmem.c)0
-rw-r--r--tests/PaintTest.cpp4
-rw-r--r--tests/ReadWriteAlphaTest.cpp4
20 files changed, 55 insertions, 60 deletions
diff --git a/bench/BlurRectBench.cpp b/bench/BlurRectBench.cpp
index b0b06e65ec..a3825be678 100644
--- a/bench/BlurRectBench.cpp
+++ b/bench/BlurRectBench.cpp
@@ -19,12 +19,21 @@
#define REALBIG SkFloatToScalar(30.5f)
class BlurRectBench: public SkBenchmark {
+ int fLoopCount;
SkScalar fRadius;
SkString fName;
public:
BlurRectBench(void *param, SkScalar rad) : INHERITED(param) {
fRadius = rad;
+
+ if (fRadius > SkIntToScalar(25)) {
+ fLoopCount = 100;
+ } else if (fRadius > SkIntToScalar(5)) {
+ fLoopCount = 1000;
+ } else {
+ fLoopCount = 10000;
+ }
}
protected:
@@ -49,19 +58,9 @@ protected:
SkScalar pad = fRadius*3/2 + SK_Scalar1;
SkRect r = SkRect::MakeWH(2 * pad + SK_Scalar1, 2 * pad + SK_Scalar1);
- int loop_count;
-
- if (fRadius > SkIntToScalar(25)) {
- loop_count = 100;
- } else if (fRadius > SkIntToScalar(5)) {
- loop_count = 1000;
- } else {
- loop_count = 10000;
- }
-
preBenchSetup(r);
- for (int i = 0; i < SkBENCHLOOP(loop_count); i++) {
+ for (int i = 0; i < SkBENCHLOOP(fLoopCount); i++) {
makeBlurryRect(r);
}
}
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index d61cc94169..d1368ddacb 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -311,8 +311,10 @@
'-llog',
],
'cflags': [
+ '-Wall',
'-fno-exceptions',
'-fno-rtti',
+ '-fstrict-aliasing',
'-fuse-ld=gold',
],
'conditions': [
diff --git a/gyp/jsoncpp.gyp b/gyp/jsoncpp.gyp
index 1ee33fdb96..07507d4954 100644
--- a/gyp/jsoncpp.gyp
+++ b/gyp/jsoncpp.gyp
@@ -61,6 +61,12 @@
},
},
}],
+ [ 'skia_os == "android"', {
+ 'cflags!': [
+ '-Wall',
+ '-Werror',
+ ],
+ }],
],
},
],
diff --git a/gyp/libjpeg.gyp b/gyp/libjpeg.gyp
index 5780b27e44..a9d6aefa0b 100644
--- a/gyp/libjpeg.gyp
+++ b/gyp/libjpeg.gyp
@@ -89,6 +89,8 @@
['OS=="android"', {
'cflags!': [
'-fno-rtti', # supresses warnings about invalid option of non-C++ code
+ '-Wall',
+ '-Werror',
],
}],
],
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index c62657de7b..7c445d04b3 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -199,7 +199,7 @@
}],
[ 'skia_os == "android"', {
'sources': [
- '../src/utils/android/ashmem.c',
+ '../src/utils/android/ashmem.cpp',
],
}],
],
@@ -242,6 +242,12 @@
},
},
}],
+ [ 'skia_os == "android"', {
+ 'cflags!': [
+ '-Wall',
+ '-Werror',
+ ],
+ }],
],
},
],
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h
index 96270b09e2..02880f3d23 100644
--- a/include/core/SkFloatingPoint.h
+++ b/include/core/SkFloatingPoint.h
@@ -91,7 +91,7 @@ extern const uint32_t gIEEENotANumber;
extern const uint32_t gIEEEInfinity;
extern const uint32_t gIEEENegativeInfinity;
-#define SK_FloatNaN (*reinterpret_cast<const float*>(&gIEEENotANumber))
-#define SK_FloatInfinity (*reinterpret_cast<const float*>(&gIEEEInfinity))
-#define SK_FloatNegativeInfinity (*reinterpret_cast<const float*>(&gIEEENegativeInfinity))
+#define SK_FloatNaN (*SkTCast<const float*>(&gIEEENotANumber))
+#define SK_FloatInfinity (*SkTCast<const float*>(&gIEEEInfinity))
+#define SK_FloatNegativeInfinity (*SkTCast<const float*>(&gIEEENegativeInfinity))
#endif
diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h
index 150384de0f..6ab1cd1723 100644
--- a/include/utils/SkRandom.h
+++ b/include/utils/SkRandom.h
@@ -197,7 +197,7 @@ public:
*/
float nextF() {
unsigned int floatint = 0x3f800000 | (this->nextU() >> 9);
- float f = *(float*)(&floatint) - 1.0f;
+ float f = *SkTCast<float*>(&floatint) - 1.0f;
return f;
}
diff --git a/samplecode/SamplePolyToPoly.cpp b/samplecode/SamplePolyToPoly.cpp
index 93a535186e..a0401f6339 100644
--- a/samplecode/SamplePolyToPoly.cpp
+++ b/samplecode/SamplePolyToPoly.cpp
@@ -27,9 +27,8 @@ public:
{ 2*SK_Scalar1, 0 },
{ 0, 2*SK_Scalar1 } };
SkMatrix m1, m2;
- bool success;
- success = m1.setPolyToPoly(src, dst, 3);
+ (void) m1.setPolyToPoly(src, dst, 3);
m2.reset();
m2.set(SkMatrix::kMScaleX, dst[1].fX - dst[0].fX);
@@ -49,7 +48,7 @@ public:
SkFloatToScalar(158), SkFloatToScalar(604.5f), SkFloatToScalar(158), SkFloatToScalar(-177.5f)
};
- success = m2.setPolyToPoly((const SkPoint*)src1, (SkPoint*)dst1, 4);
+ (void) m2.setPolyToPoly((const SkPoint*)src1, (SkPoint*)dst1, 4);
{
const SkPoint src[] = {
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp
index b647ada260..e41bb810b5 100644
--- a/src/core/SkAdvancedTypefaceMetrics.cpp
+++ b/src/core/SkAdvancedTypefaceMetrics.cpp
@@ -153,7 +153,6 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
Data lastAdvance = kInvalidAdvance;
int repeatedAdvances = 0;
int wildCardsInRun = 0;
- int leadingWildCards = 0;
int trailingWildCards = 0;
uint32_t subsetIndex = 0;
@@ -200,7 +199,6 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
}
repeatedAdvances = 0;
wildCardsInRun = trailingWildCards;
- leadingWildCards = trailingWildCards;
trailingWildCards = 0;
} else {
if (lastAdvance == 0 &&
@@ -236,7 +234,6 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
}
repeatedAdvances = 0;
wildCardsInRun = trailingWildCards;
- leadingWildCards = trailingWildCards;
trailingWildCards = 0;
}
curRange->fAdvance.append(1, &advance);
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 6354e9fc2a..e577f79348 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -362,7 +362,7 @@ private:
// marks fTopBot[] as unrecorded
void setTopBotUnwritten() {
- this->fTopBot[0] = this->fTopBot[1] = SK_ScalarNaN; // initial to sentinel values
+ this->fTopBot[0] = SK_ScalarNaN; // initial to sentinel values
}
// From here down is the data we look at in the search/sort. We always begin
diff --git a/src/images/SkMovie_gif.cpp b/src/images/SkMovie_gif.cpp
index cda152519f..cda53d8047 100644
--- a/src/images/SkMovie_gif.cpp
+++ b/src/images/SkMovie_gif.cpp
@@ -188,9 +188,6 @@ static void blitNormal(SkBitmap* bm, const SavedImage* frame, const ColorMapObje
copyHeight = height - frame->ImageDesc.Top;
}
- int srcPad, dstPad;
- dstPad = width - copyWidth;
- srcPad = frame->ImageDesc.Width - copyWidth;
for (; copyHeight > 0; copyHeight--) {
copyLine(dst, src, cmap, transparent, copyWidth);
src += frame->ImageDesc.Width;
diff --git a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
index e9684e2860..7d75143e20 100644
--- a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
+++ b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
@@ -47,7 +47,6 @@ void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count
/* now build fx/fx+dx/fx+2dx/fx+3dx */
SkFixed fx1, fx2, fx3;
- int32x2_t lower, upper;
int32x4_t lbase, hbase;
uint16_t *dst16 = (uint16_t *)dst;
diff --git a/src/opts/SkBitmapProcState_matrix_clamp_neon.h b/src/opts/SkBitmapProcState_matrix_clamp_neon.h
index 4f47d4748c..5af7a52ca4 100644
--- a/src/opts/SkBitmapProcState_matrix_clamp_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_clamp_neon.h
@@ -106,7 +106,6 @@ static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
/* now build fx/fx+dx/fx+2dx/fx+3dx */
SkFixed fx1, fx2, fx3;
- int32x2_t lower, upper;
int32x4_t lbase, hbase;
int16_t *dst16 = (int16_t *)xy;
@@ -324,8 +323,8 @@ static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
*/
do {
- int16x4_t xlo, xhi, ylo, yhi;
- int16x4_t x2lo, x2hi, y2lo, y2hi;
+ int16x4_t xhi, yhi;
+ int16x4_t x2hi, y2hi;
/* vld4 does the de-interleaving for us */
{
@@ -338,9 +337,7 @@ static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
: "=w" (t_xlo), "=w" (t_xhi), "=w" (t_ylo), "=w" (t_yhi)
: "r" (mysrc)
);
- xlo = t_xlo;
xhi = t_xhi;
- ylo = t_ylo;
yhi = t_yhi;
}
@@ -364,9 +361,7 @@ static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
: "=w" (t_xlo), "=w" (t_xhi), "=w" (t_ylo), "=w" (t_yhi)
: "r" (mysrc+16)
);
- x2lo = t_xlo;
x2hi = t_xhi;
- y2lo = t_ylo;
y2hi = t_yhi;
}
@@ -517,8 +512,7 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s,
#endif
if (count >= 4) {
- int32x4_t wide_dx, wide_one;
- int32x4_t wide_fx, wide_fx1, wide_i, wide_lo;
+ int32x4_t wide_one, wide_fx, wide_fx1, wide_i, wide_lo;
#if 0
/* verification hooks -- see below */
SkFixed debug_fx = fx;
@@ -530,7 +524,6 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s,
wide_fx = vsetq_lane_s32(fx+dx+dx, wide_fx, 2);
wide_fx = vsetq_lane_s32(fx+dx+dx+dx, wide_fx, 3);
- wide_dx = vdupq_n_s32(dx);
wide_one = vdupq_n_s32(one);
while (count >= 4) {
@@ -617,9 +610,9 @@ static void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
unsigned maxY = s.fBitmap->height() - 1;
if (count >= 4) {
- int32x4_t wide_one, wide_i, wide_lo;
- int32x4_t wide_dx, wide_fx, wide_onex, wide_fx1;
- int32x4_t wide_dy, wide_fy, wide_oney, wide_fy1;
+ int32x4_t wide_i, wide_lo;
+ int32x4_t wide_fx, wide_onex, wide_fx1;
+ int32x4_t wide_fy, wide_oney, wide_fy1;
#undef AFFINE_DEBUG
#if defined(AFFINE_DEBUG)
@@ -633,13 +626,11 @@ static void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
wide_fx = vsetq_lane_s32(fx+dx, wide_fx, 1);
wide_fx = vsetq_lane_s32(fx+dx+dx, wide_fx, 2);
wide_fx = vsetq_lane_s32(fx+dx+dx+dx, wide_fx, 3);
- wide_dx = vdupq_n_s32(dx);
wide_fy = vdupq_n_s32(fy);
wide_fy = vsetq_lane_s32(fy+dy, wide_fy, 1);
wide_fy = vsetq_lane_s32(fy+dy+dy, wide_fy, 2);
wide_fy = vsetq_lane_s32(fy+dy+dy+dy, wide_fy, 3);
- wide_dy = vdupq_n_s32(dy);
wide_onex = vdupq_n_s32(oneX);
wide_oney = vdupq_n_s32(oneY);
@@ -774,7 +765,7 @@ static void PERSP_FILTER_NAME(const SkBitmapProcState& s,
const SkFixed* SK_RESTRICT srcXY = iter.getXY();
if (count >= 4) {
- int32x4_t wide_one, wide_i, wide_lo;
+ int32x4_t wide_i, wide_lo;
int32x4_t wide_fx1;
int32x4_t wide_fy1;
int32x4_t wide_x, wide_y;
diff --git a/src/opts/SkBitmapProcState_matrix_repeat_neon.h b/src/opts/SkBitmapProcState_matrix_repeat_neon.h
index 615f3ffd72..a0eb0a9e84 100644
--- a/src/opts/SkBitmapProcState_matrix_repeat_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_repeat_neon.h
@@ -103,7 +103,6 @@ static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
/* now build fx/fx+dx/fx+2dx/fx+3dx */
SkFixed fx1, fx2, fx3;
- int32x2_t lower, upper;
int32x4_t lbase, hbase;
int16_t *dst16 = (int16_t *)xy;
@@ -179,7 +178,7 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
int maxX = s.fBitmap->width() - 1;
int maxY = s.fBitmap->height() - 1;
-#if 1
+#if 0
int ocount = count;
uint32_t *oxy = xy;
SkFixed bfx = fx, bfy=fy, bdx=dx, bdy=dy;
@@ -199,7 +198,6 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
SkFixed dy4 = dy*4;
/* now build fx/fx+dx/fx+2dx/fx+3dx */
- int32x2_t lower, upper;
int32x4_t xbase, ybase;
int16_t *dst16 = (int16_t *)xy;
diff --git a/src/opts/SkBlitRow_opts_arm_neon.cpp b/src/opts/SkBlitRow_opts_arm_neon.cpp
index 14d59682e1..22785be610 100644
--- a/src/opts/SkBlitRow_opts_arm_neon.cpp
+++ b/src/opts/SkBlitRow_opts_arm_neon.cpp
@@ -24,7 +24,7 @@ void S32A_D565_Opaque_neon(uint16_t* SK_RESTRICT dst,
SkASSERT(255 == alpha);
if (count >= 8) {
- uint16_t* SK_RESTRICT keep_dst;
+ uint16_t* SK_RESTRICT keep_dst = 0;
asm volatile (
"ands ip, %[count], #7 \n\t"
@@ -104,7 +104,7 @@ void S32A_D565_Opaque_neon(uint16_t* SK_RESTRICT dst,
}
else
{ // handle count < 8
- uint16_t* SK_RESTRICT keep_dst;
+ uint16_t* SK_RESTRICT keep_dst = 0;
asm volatile (
"vmov.u8 d31, #1<<7 \n\t"
@@ -889,8 +889,8 @@ void S32_D565_Opaque_Dither_neon(uint16_t* SK_RESTRICT dst,
d = vld1_u8(dstart);
while (count >= UNROLL) {
- uint8x8_t sr, sg, sb, sa;
- uint16x8_t dr, dg, db, da;
+ uint8x8_t sr, sg, sb;
+ uint16x8_t dr, dg, db;
uint16x8_t dst8;
/* source is in ABGR ordering (R == lsb) */
@@ -904,7 +904,7 @@ void S32_D565_Opaque_Dither_neon(uint16_t* SK_RESTRICT dst,
: "=w" (d0), "=w" (d1), "=w" (d2), "=w" (d3)
: "r" (src)
);
- sr = d0; sg = d1; sb = d2; sa = d3;
+ sr = d0; sg = d1; sb = d2;
}
/* XXX: if we want to prefetch, hide it in the above asm()
* using the gcc __builtin_prefetch(), the prefetch will
diff --git a/src/ports/FontHostConfiguration_android.cpp b/src/ports/FontHostConfiguration_android.cpp
index 6d03414b08..ef5a742a18 100644
--- a/src/ports/FontHostConfiguration_android.cpp
+++ b/src/ports/FontHostConfiguration_android.cpp
@@ -82,7 +82,6 @@ void startElementHandler(void *data, const char *tag, const char **atts) {
// The Family tag has an optional "order" attribute with an integer value >= 0
// If this attribute does not exist, the default value is -1
for (int i = 0; atts[i] != NULL; i += 2) {
- const char* attribute = atts[i];
const char* valueString = atts[i+1];
int value;
int len = sscanf(valueString, "%d", &value);
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 12357f149e..bbde313ab6 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -451,6 +451,7 @@ static SkTypeface* gDefaultNormal;
static char** gDefaultNames = NULL;
static uint32_t *gFallbackFonts;
+#if SK_DEBUG_FONTS
static void dump_globals() {
SkDebugf("gDefaultNormal=%p id=%u refCnt=%d", gDefaultNormal,
gDefaultNormal ? gDefaultNormal->uniqueID() : 0,
@@ -506,6 +507,7 @@ static void dump_globals() {
}
}
+#endif
/* Load info from a configuration file that populates the system/fallback font structures
@@ -519,10 +521,8 @@ static void load_font_info() {
}
SkTDArray<FontInitRec> fontInfo;
- bool firstInFamily = false;
for (int i = 0; i < fontFamilies.count(); ++i) {
FontFamily *family = fontFamilies[i];
- firstInFamily = true;
for (int j = 0; j < family->fFileNames.count(); ++j) {
FontInitRec fontInfoRecord;
fontInfoRecord.fFileName = family->fFileNames[j];
@@ -672,7 +672,9 @@ static void init_system_fonts() {
// now terminate our fallback list with the sentinel value
gFallbackFonts[fallbackCount] = 0;
-// SkDEBUGCODE(dump_globals());
+#if SK_DEBUG_FONTS
+ SkDEBUGCODE(dump_globals());
+#endif
}
static size_t find_uniqueID(const char* filename) {
diff --git a/src/utils/android/ashmem.c b/src/utils/android/ashmem.cpp
index 0e1e81669d..0e1e81669d 100644
--- a/src/utils/android/ashmem.c
+++ b/src/utils/android/ashmem.cpp
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index 2a84e4cdbb..ed790764ab 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -29,8 +29,8 @@ static void test_copy(skiatest::Reporter* reporter) {
#ifdef SK_BUILD_FOR_ANDROID
// the copy constructor should preserve the Generation ID
- int32_t paintGenID = paint.getGenerationID();
- int32_t copiedPaintGenID = copiedPaint.getGenerationID();
+ uint32_t paintGenID = paint.getGenerationID();
+ uint32_t copiedPaintGenID = copiedPaint.getGenerationID();
REPORTER_ASSERT(reporter, paintGenID == copiedPaintGenID);
REPORTER_ASSERT(reporter, !memcmp(&paint, &copiedPaint, sizeof(paint)));
#endif
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index a3bf5dee98..78306693db 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -7,7 +7,7 @@
*/
// This test is specific to the GPU backend.
-#if SK_SUPPORT_GPU
+#if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID)
#include "Test.h"
#include "SkGpuDevice.h"
@@ -110,9 +110,7 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* f
}
}
-#ifndef SK_BUILD_FOR_ANDROID
#include "TestClassDef.h"
DEFINE_GPUTESTCLASS("ReadWriteAlpha", ReadWriteAlphaTestClass, ReadWriteAlphaTest)
#endif
-#endif