Fix errors when compiling with -Wall -Werror on Android.
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 7 Feb 2013 18:58:35 +0000 (18:58 +0000)
committerdjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 7 Feb 2013 18:58:35 +0000 (18:58 +0000)
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

20 files changed:
bench/BlurRectBench.cpp
gyp/common_conditions.gypi
gyp/jsoncpp.gyp
gyp/libjpeg.gyp
gyp/utils.gyp
include/core/SkFloatingPoint.h
include/utils/SkRandom.h
samplecode/SamplePolyToPoly.cpp
src/core/SkAdvancedTypefaceMetrics.cpp
src/core/SkPictureFlat.h
src/images/SkMovie_gif.cpp
src/opts/SkBitmapProcState_matrixProcs_neon.cpp
src/opts/SkBitmapProcState_matrix_clamp_neon.h
src/opts/SkBitmapProcState_matrix_repeat_neon.h
src/opts/SkBlitRow_opts_arm_neon.cpp
src/ports/FontHostConfiguration_android.cpp
src/ports/SkFontHost_android.cpp
src/utils/android/ashmem.cpp [moved from src/utils/android/ashmem.c with 100% similarity]
tests/PaintTest.cpp
tests/ReadWriteAlphaTest.cpp

index b0b06e6..a3825be 100644 (file)
 #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);
         }
     }
index d61cc94..d1368dd 100644 (file)
           '-llog',
         ],
         'cflags': [
+          '-Wall',
           '-fno-exceptions',
           '-fno-rtti',
+          '-fstrict-aliasing',
           '-fuse-ld=gold',
         ],
         'conditions': [
index 1ee33fd..07507d4 100644 (file)
             },
           },
         }],
+        [ 'skia_os == "android"', {
+          'cflags!': [
+            '-Wall',
+            '-Werror',
+          ],
+        }],
       ],
     },
   ],
index 5780b27..a9d6aef 100644 (file)
@@ -89,6 +89,8 @@
             ['OS=="android"', {
               'cflags!': [
                '-fno-rtti', # supresses warnings about invalid option of non-C++ code
+               '-Wall',
+               '-Werror',
               ],
             }],
           ],
index c62657d..7c445d0 100644 (file)
         }],
         [ 'skia_os == "android"', {
           'sources': [
-            '../src/utils/android/ashmem.c',
+            '../src/utils/android/ashmem.cpp',
           ],
         }],
       ],
             },
           },
         }],
+        [ 'skia_os == "android"', {
+          'cflags!': [
+            '-Wall',
+            '-Werror',
+          ],
+        }],
       ],
     },
   ],
index 96270b0..02880f3 100644 (file)
@@ -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
index 150384d..6ab1cd1 100644 (file)
@@ -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;
     }
 
index 93a5351..a0401f6 100644 (file)
@@ -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[] = {
index b647ada..e41bb81 100644 (file)
@@ -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);
index 6354e9f..e577f79 100644 (file)
@@ -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
index cda1525..cda53d8 100644 (file)
@@ -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;
index e9684e2..7d75143 100644 (file)
@@ -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;
 
index 4f47d47..5af7a52 100644 (file)
@@ -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;
index 615f3ff..a0eb0a9 100644 (file)
@@ -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;
 
index 14d5968..22785be 100644 (file)
@@ -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
index 6d03414..ef5a742 100644 (file)
@@ -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);
index 12357f1..bbde313 100644 (file)
@@ -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) {
index 2a84e4c..ed79076 100644 (file)
@@ -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
index a3bf5de..7830669 100644 (file)
@@ -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