fix warnings on Mac in src/gpu and include/gpu

Fix these class of warnings:
- unused functions
- unused locals
- sign mismatch
- missing function prototypes
- missing newline at end of file
- 64 to 32 bit truncation

The changes prefer to link in dead code in the debug build
with 'if (false)' than to comment it out, but trivial cases
are commented out or sometimes deleted if it appears to be
a copy/paste error.
Review URL: https://codereview.appspot.com/6296044

git-svn-id: http://skia.googlecode.com/svn/trunk@4180 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrProgramStageFactory.h b/include/gpu/GrProgramStageFactory.h
index 0fac7db..c01b3f0 100644
--- a/include/gpu/GrProgramStageFactory.h
+++ b/include/gpu/GrProgramStageFactory.h
@@ -84,7 +84,7 @@
         StageKey stageID = GLProgramStage::GenKey(stage);
 #if GR_DEBUG
         static const StageKey kIllegalIDMask =
-            ~((1 << kProgramStageKeyBits) - 1);
+            (uint16_t) (~((1U << kProgramStageKeyBits) - 1));
         GrAssert(!(kIllegalIDMask & stageID));
 #endif
         return fStageClassID | stageID;
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index 9e6d83e..8780104 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -152,7 +152,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // Helper functions
 
-static const GrTexture::TextureKey gUNCACHED_KEY = ~0;
+static const GrTexture::TextureKey gUNCACHED_KEY = ~0U;
 GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx,
                                                 GrTexture::TextureKey key,
                                                 const GrSamplerState* sampler,
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 27e3fa8..e0f36a3 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -307,7 +307,7 @@
             case kClose_PathCmd:
                 break;
             case kEnd_PathCmd:
-                uint16_t currIdx = (uint16_t) (vert - base);
+             // uint16_t currIdx = (uint16_t) (vert - base);
                 goto FINISHED;
         }
         first = false;
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 5342d9a..23d05bc 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -804,7 +804,7 @@
                sizeof(fPodEndMarker);
     }
 
-    static const StageMask kIllegalStageMaskBits = ~((1 << kNumStages)-1);
+    static const StageMask kIllegalStageMaskBits = ~((1U << kNumStages)-1);
     // @{ these fields can be initialized with memset to 0
     union {
         GrColor             fBlendConstant;
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 35d50e9..2f7bf84 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -723,7 +723,6 @@
 }
 
 void GrDrawTarget::popGeometrySource() {
-    const GeometrySrcState& geoSrc = this->getGeomSrc();
     // if popping last element then pops are unbalanced with pushes
     GrAssert(fGeoSrcStateStack.count() > 1);
     
diff --git a/src/gpu/GrMemory.cpp b/src/gpu/GrMemory.cpp
index fa6ee2f..f6d3c7f 100644
--- a/src/gpu/GrMemory.cpp
+++ b/src/gpu/GrMemory.cpp
@@ -9,6 +9,7 @@
 
 
 #include <stdlib.h>
+#include "GrTypes.h"
 
 void* GrMalloc(size_t bytes) {
     void* ptr = ::malloc(bytes);
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index ba6452d..848a922 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -292,15 +292,13 @@
 void GrResourceCache::removeAll() {
     GrAutoResourceCacheValidate atcv(this);
 
-    GrResourceEntry* entry = fHead;
-
     // we can have one GrResource holding a lock on another
     // so we don't want to just do a simple loop kicking each
     // entry out. Instead change the budget and purge.
 
     int savedMaxBytes = fMaxBytes;
     int savedMaxCount = fMaxCount;
-    fMaxBytes = -1;
+    fMaxBytes = (size_t) -1;
     fMaxCount = 0;
     this->purgeAsNeeded();
 
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index e05b62b..8dd0b0b 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -124,8 +124,8 @@
     // assert that texture creation will fail anyway if this assumption
     // would cause key collisions.
     GrAssert(gpu->getCaps().fMaxTextureSize <= SK_MaxU16);
-    v[0] = clientKey & 0xffffffffUL;
-    v[1] = (clientKey >> 32) & 0xffffffffUL;
+    v[0] = (uint32_t) (clientKey & 0xffffffffUL);
+    v[1] = (uint32_t) ((clientKey >> 32) & 0xffffffffUL);
     v[2] = desc.fWidth | (desc.fHeight << 16);
 
     v[3] = (desc.fSampleCnt << 24);
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 9296ecc..14e817f 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -84,8 +84,8 @@
                                    const char* inputColor,
                                    const char* samplerName) {
     GrStringBuilder* code = &state->fFSCode;
-    const char* texFunc = "texture2D";
-    bool complexCoord = false;
+ // const char* texFunc = "texture2D";
+ // bool complexCoord = false;
 
     state->fFSCode.appendf("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
 
diff --git a/src/gpu/effects/GrMorphologyEffect.cpp b/src/gpu/effects/GrMorphologyEffect.cpp
index 906758d..991e11b 100644
--- a/src/gpu/effects/GrMorphologyEffect.cpp
+++ b/src/gpu/effects/GrMorphologyEffect.cpp
@@ -82,8 +82,8 @@
                                    const char* inputColor,
                                    const char* samplerName) {
     GrStringBuilder* code = &state->fFSCode;
-    const char* texFunc = "texture2D";
-    bool complexCoord = false;
+    // const char* texFunc = "texture2D";
+    // bool complexCoord = false;
 
     const char* func;
     switch (fType) {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index b23a1f8..7b2bb35 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -98,7 +98,6 @@
         fBGRAFormatSupport = version >= GR_GL_VER(1,2) ||
                              ctxInfo.hasExtension("GL_EXT_bgra");
     } else {
-        bool hasBGRAExt = false;
         if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
             fBGRAFormatSupport = true;
         } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
@@ -256,7 +255,7 @@
         gS16   = {GR_GL_STENCIL_INDEX16,  16,               16,               false},
         gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8,                32,               true },
         gS4    = {GR_GL_STENCIL_INDEX4,   4,                4,                false},
-        gS     = {GR_GL_STENCIL_INDEX,    kUnknownBitCount, kUnknownBitCount, false},
+    //  gS     = {GR_GL_STENCIL_INDEX,    kUnknownBitCount, kUnknownBitCount, false},
         gDS    = {GR_GL_DEPTH_STENCIL,    kUnknownBitCount, kUnknownBitCount, true };
 
     if (kDesktop_GrGLBinding == ctxInfo.binding()) {
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index 57b7851..70e9cee 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -10,6 +10,8 @@
 #include "GrTDArray.h"
 #include "GrGLDefines.h"
 
+namespace { // added to suppress 'no previous prototype' warning
+
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLActiveTexture(GrGLenum texture) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLAttachShader(GrGLuint program, GrGLuint shader) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {}
@@ -376,6 +378,8 @@
     return ++gUniLocation;
 }
 
+} // end anonymous namespace
+
 const GrGLInterface* GrGLCreateNullInterface() {
     // The gl functions are not context-specific so we create one global 
     // interface
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 8c12ad6..b1d6d4f 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -1229,9 +1229,9 @@
 
     GrStringBuilder samplerName;
     sampler_name(stageNum, &samplerName);
-    const GrGLShaderVar* sampler = &segments->addUniform(
-        GrGLShaderBuilder::kFragment_VariableLifetime, kSampler2D_GrSLType,
-        samplerName.c_str());
+    // const GrGLShaderVar* sampler = &
+        segments->addUniform(GrGLShaderBuilder::kFragment_VariableLifetime,
+        kSampler2D_GrSLType, samplerName.c_str());
     locations->fSamplerUni = kUseUniform;
 
     const char *varyingVSName, *varyingFSName;
@@ -1251,8 +1251,8 @@
                                   vector_all_coords(segments->fVaryingDims));
     }
 
-    GrGLShaderVar* kernel = NULL;
-    const char* imageIncrementName = NULL;
+    // GrGLShaderVar* kernel = NULL;
+    // const char* imageIncrementName = NULL;
     if (NULL != customStage) {
         segments->fVSCode.appendf("\t{ // stage %d %s\n",
                                   stageNum, customStage->name());
@@ -1284,8 +1284,8 @@
     if (desc.fOptFlags & StageDesc::kCustomTextureDomain_OptFlagBit) {
         GrStringBuilder texDomainName;
         tex_domain_name(stageNum, &texDomainName);
-        const GrGLShaderVar* texDomain =
-            &segments->addUniform(
+        // const GrGLShaderVar* texDomain = &
+            segments->addUniform(
                 GrGLShaderBuilder::kFragment_VariableLifetime,
                 kVec4f_GrSLType, texDomainName.c_str());
         GrStringBuilder coordVar("clampCoord");
diff --git a/src/gpu/gl/GrGLStencilBuffer.h b/src/gpu/gl/GrGLStencilBuffer.h
index 87bdb4a..7b3da4f 100644
--- a/src/gpu/gl/GrGLStencilBuffer.h
+++ b/src/gpu/gl/GrGLStencilBuffer.h
@@ -14,8 +14,8 @@
 
 class GrGLStencilBuffer : public GrStencilBuffer {
 public:
-    static const GrGLenum kUnknownInternalFormat = ~0;
-    static const GrGLuint kUnknownBitCount = ~0;
+    static const GrGLenum kUnknownInternalFormat = ~0U;
+    static const GrGLuint kUnknownBitCount = ~0U;
     struct Format {
         GrGLenum  fInternalFormat;
         GrGLuint  fStencilBits;
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 3d40eb3..f9d4cbb 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -11,7 +11,7 @@
 #include "GrTypes.h"
 #include "SkTemplates.h"
 
-static const GrGLuint GR_MAX_GLUINT = ~0;
+static const GrGLuint GR_MAX_GLUINT = ~0U;
 static const GrGLint  GR_INVAL_GLINT = ~0;
 
 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
@@ -176,6 +176,9 @@
 
     fLastSuccessfulStencilFmtIdx = 0;
     fCanPreserveUnpremulRoundtrip = kUnknown_CanPreserveUnpremulRoundtrip;
+    if (false) { // avoid bit rot, suppress warning
+        fbo_test(this->glInterface(), 0, 0);
+    }
 }
 
 GrGpuGL::~GrGpuGL() {
@@ -526,7 +529,7 @@
         GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
     }
 
-    fHWGeometryState.fVertexOffset = ~0;
+    fHWGeometryState.fVertexOffset = ~0U;
 
     // Third party GL code may have left vertex attributes enabled. Some GL
     // implementations (osmesa) may read vetex attributes that are not required
@@ -989,7 +992,7 @@
     return NULL;
 }
 
-#if GR_DEBUG
+#if 0 && GR_DEBUG
 static size_t as_size_t(int x) {
     return x;
 }
@@ -1443,7 +1446,7 @@
     }
     this->flushRenderTarget(&GrIRect::EmptyIRect());
     this->enableScissoring(rect);
-    GL_CALL(StencilMask(clipStencilMask));
+    GL_CALL(StencilMask((uint32_t) clipStencilMask));
     GL_CALL(ClearStencil(value));
     GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
     fHWStencilSettings.invalidate();
@@ -1583,7 +1586,7 @@
     } else {
         GrAssert(readDst != buffer);        GrAssert(rowBytes != tightRowBytes);
         // copy from readDst to buffer while flipping y
-        const int halfY = height >> 1;
+        // const int halfY = height >> 1;
         const char* src = reinterpret_cast<const char*>(readDst);
         char* dst = reinterpret_cast<char*>(buffer);
         if (!invertY) {
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index f383ffc..581a22a 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -249,7 +249,7 @@
 
 
 void GrGpuGL::flushColorMatrix() {
-    const ProgramDesc& desc = fCurrentProgram.getDesc();
+    // const ProgramDesc& desc = fCurrentProgram.getDesc();
     int matrixUni = fProgramData->fUniLocations.fColorMatrixUni;
     int vecUni = fProgramData->fUniLocations.fColorMatrixVecUni;
     if (GrGLProgram::kUnusedUniform != matrixUni
@@ -330,7 +330,7 @@
 
 void GrGpuGL::flushCoverage(GrColor coverage) {
     const ProgramDesc& desc = fCurrentProgram.getDesc();
-    const GrDrawState& drawState = this->getDrawState();
+    // const GrDrawState& drawState = this->getDrawState();
 
 
     if (this->getVertexLayout() & kCoverage_VertexLayoutBit) {
diff --git a/src/gpu/gl/GrGpuGL_unittest.cpp b/src/gpu/gl/GrGpuGL_unittest.cpp
index 3543830..9dbb708 100644
--- a/src/gpu/gl/GrGpuGL_unittest.cpp
+++ b/src/gpu/gl/GrGpuGL_unittest.cpp
@@ -113,7 +113,7 @@
 
 bool GrGpuGL::programUnitTest() {
 
-    GrGLSLGeneration glslGeneration = 
+    // GrGLSLGeneration glslGeneration = 
             GrGetGLSLGeneration(this->glBinding(), this->glInterface());
     static const int STAGE_OPTS[] = {
         0,
@@ -206,9 +206,6 @@
             stage.fOptFlags = STAGE_OPTS[random_int(&random, GR_ARRAY_COUNT(STAGE_OPTS))];
             stage.fInConfigFlags = IN_CONFIG_FLAGS[random_int(&random, GR_ARRAY_COUNT(IN_CONFIG_FLAGS))];
             stage.setEnabled(VertexUsesStage(s, pdesc.fVertexLayout));
-            static const uint32_t kMulByAlphaMask =
-                StageDesc::kMulRGBByAlpha_RoundUp_InConfigFlag |
-                StageDesc::kMulRGBByAlpha_RoundDown_InConfigFlag;
 
             bool useCustomEffect = random_bool(&random);
             if (useCustomEffect) {
diff --git a/src/gpu/gl/debug/GrFrameBufferObj.cpp b/src/gpu/gl/debug/GrFrameBufferObj.cpp
index 331be8a..24ab120 100644
--- a/src/gpu/gl/debug/GrFrameBufferObj.cpp
+++ b/src/gpu/gl/debug/GrFrameBufferObj.cpp
@@ -64,4 +64,4 @@
         GrAlwaysAssert(!fStencilBuffer->getStencilBound(this));
         fStencilBuffer->setStencilBound(this);
     }
-}
\ No newline at end of file
+}
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 4a04a38..ffeaf89 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -30,6 +30,8 @@
 // the OpenGLES 2.0 spec says this must be >= 8
 static const GrGLint kDefaultMaxVaryingVectors = 8;
 
+namespace { // suppress no previsous prototype warning
+
 ////////////////////////////////////////////////////////////////////////////////
 GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) {
     
@@ -862,6 +864,8 @@
     return ++gUniLocation;
 }
 
+} // end of namespace
+
 ////////////////////////////////////////////////////////////////////////////////
 struct GrDebugGLInterface : public GrGLInterface {
 
diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
index d08d602..2ae8782 100644
--- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
+++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
@@ -15,7 +15,7 @@
 
 #include <dlfcn.h>
 
-void* GetProcAddress(const char* name) {
+static void* GetProcAddress(const char* name) {
     return dlsym(RTLD_DEFAULT, name);
 }
 
diff --git a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp
index 18b36a5..2dcf8ae 100644
--- a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp
+++ b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp
@@ -33,7 +33,7 @@
 
 const GrGLInterface* SkNativeGLContext::createGLContext() {
     GLint major, minor;
-    AGLContext ctx;
+    // AGLContext ctx;
 
     aglGetVersion(&major, &minor);
     //SkDebugf("---- agl version %d %d\n", major, minor);
diff --git a/src/gpu/gr_unittests.cpp b/src/gpu/gr_unittests.cpp
index 4adc7e9..d554861 100644
--- a/src/gpu/gr_unittests.cpp
+++ b/src/gpu/gr_unittests.cpp
@@ -14,6 +14,9 @@
 #include "GrRedBlackTree.h"
 #include "GrTDArray.h"
 
+// FIXME: needs to be in a header
+void gr_run_unittests();
+
 // If we aren't inheriting these as #defines from elsewhere,
 // clang demands they be declared before we #include the template
 // that relies on them.