Make SampleApp build on Win32 (still requires glew, this needs to be fixed)
In fbo test funciton set min filter to nearest (for systems that don't support rendering to level of a texture that isn't mip map complete.)
Add a lot more sample slides to the win32 build
Fix texture red/blue color swap on windows.

git-svn-id: http://skia.googlecode.com/svn/trunk@677 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h
index 7fab1b5..b183892 100644
--- a/gpu/include/GrGLConfig.h
+++ b/gpu/include/GrGLConfig.h
@@ -190,9 +190,14 @@
     #error "unknown GR_TEXT_SCALAR type"
 #endif
 
-// Pick a pixel config for 32bit bitmaps. Our default is GL_RGBA
-#ifndef SK_GL_32BPP_COLOR_FORMAT    
-    #define SK_GL_32BPP_COLOR_FORMAT    GL_RGBA    
+// Pick a pixel config for 32bit bitmaps. Our default is GL_RGBA (expect on
+// Windows where we match GDI's order).
+#ifndef GR_GL_32BPP_COLOR_FORMAT
+    #if GR_WIN32_BUILD
+        #define GR_GL_32BPP_COLOR_FORMAT    GL_BGRA
+    #else 
+        #define GR_GL_32BPP_COLOR_FORMAT    GL_RGBA
+    #endif
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/gpu/include/GrUserConfig.h b/gpu/include/GrUserConfig.h
index b0ea58c..860d2cc 100644
--- a/gpu/include/GrUserConfig.h
+++ b/gpu/include/GrUserConfig.h
@@ -31,10 +31,11 @@
 //#define GR_FORCE_GLCHECKERR   1
 
 /*
- *  The default 32bit pixel config for texture upload is GL_RGBA. If your
- *  bitmaps map to a different GL enum, specify that with this define.
+ *  The default 32bit pixel config for texture upload is GL_RGBA on all
+ *  platforms except on Windows where it is GL_BGRA. If your bitmaps map to a
+ *  different GL enum, specify that with this define.
  */
-//#define SK_GL_32BPP_COLOR_FORMAT  GL_RGBA
+//#define GR_GL_32BPP_COLOR_FORMAT  GL_RGBA
 
 /*
  *  To diagnose texture cache performance, define this to 1 if you want to see
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 87d69bc..2130e58 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -17,6 +17,14 @@
 #include "GrGpuGL.h"
 #include "GrMemory.h"
 #include <stdio.h>
+#if GR_WIN32_BUILD
+    // need to get wglGetProcAddress
+    #undef WIN32_LEAN_AND_MEAN
+    #define WIN32_LEAN_AND_MEAN 1
+    #include <windows.h>
+    #undef WIN32_LEAN_AND_MEAN
+#endif
+
 
 static const GLuint GR_MAX_GLUINT = ~0;
 static const GLint  GR_INVAL_GLINT = ~0;
@@ -94,7 +102,9 @@
     GLuint testRTTex;
     GR_GL(GenTextures(1, &testRTTex));
     GR_GL(BindTexture(GL_TEXTURE_2D, testRTTex));
-
+    // some implementations require texture to be mip-map complete before
+    // FBO with level 0 bound as color attachment will be framebuffer complete.
+    GR_GL(TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
     GR_GL(TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h,
                      0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
     GR_GL(BindTexture(GL_TEXTURE_2D, 0));
@@ -290,6 +300,18 @@
     // Experiments to determine limitations that can't be queried. TODO: Make
     // these a preprocess that generate some compile time constants.
 
+    // sanity check to make sure we can at least create an FBO from a POT texture
+    if (fNPOTTextureSupport < kFull_NPOTTextureType) {
+        bool npotFBOSuccess = fbo_test(fExts, 128, 128);
+        if (gPrintStartupSpew) {
+            if (!npotFBOSuccess) {
+                GrPrintf("FBO Sanity Test: FAILED\n");
+            } else {
+                GrPrintf("FBO Sanity Test: PASSED\n");
+            }
+        }
+    }
+    
     /* Experimentation has found that some GLs that support NPOT textures
        do not support FBOs with a NPOT texture. They report "unsupported" FBO
        status. I don't know how to explicitly query for this. Do an
@@ -328,18 +350,6 @@
         }
     }
 
-    // sanity check to make sure we can at least create an FBO from a POT texture
-    if (fNPOTTextureSupport < kFull_NPOTTextureType) {
-        bool npotFBOSuccess = fbo_test(fExts, 128, 128);
-        if (gPrintStartupSpew) {
-            if (!npotFBOSuccess) {
-                GrPrintf("FBO Sanity Test: FAILED\n");
-            } else {
-                GrPrintf("FBO Sanity Test: PASSED\n");
-            }
-        }
-    }
-
     /* The iPhone 4 has a restriction that for an FBO with texture color
        attachment with height <= 8 then the width must be <= height. Here
        we look for such a limitation.
@@ -1628,7 +1638,7 @@
     switch (config) {
         case GrTexture::kRGBA_8888_PixelConfig:
         case GrTexture::kRGBX_8888_PixelConfig: // todo: can we tell it our X?
-            *format = SK_GL_32BPP_COLOR_FORMAT;
+            *format = GR_GL_32BPP_COLOR_FORMAT;
             *internalFormat = GL_RGBA;
             *type = GL_UNSIGNED_BYTE;
             break;
@@ -1714,7 +1724,7 @@
 
 void get_gl_proc(const char procName[], glProc *address) {
 #if GR_WIN32_BUILD
-    *address = wglGetProcAddress(procName);
+    *address = (glProc)wglGetProcAddress(procName);
     GrAssert(NULL != *address);
 #elif GR_MAC_BUILD || GR_IOS_BUILD
     GrAssert(!"Extensions don't need to be initialized!");
diff --git a/gpu/src/GrGpuGLShaders2.cpp b/gpu/src/GrGpuGLShaders2.cpp
index 2e41d56..c7b3cb9 100644
--- a/gpu/src/GrGpuGLShaders2.cpp
+++ b/gpu/src/GrGpuGLShaders2.cpp
@@ -96,12 +96,15 @@
         kNoPerspective_OptFlagBit  = 0x1,
         kIdentityMatrix_OptFlagBit = 0x2,
     };
-    int fOptFlags : 8;
-    bool fEnabled : 8;
+    unsigned fOptFlags : 8;
+
+    unsigned fEnabled : 8;
+    
     enum Modulation {
         kColor_Modulation,
         kAlpha_Modulation,
     } fModulation : 8;
+    
     enum CoordMapping {
         kIdentity_CoordMapping,
         kRadialGradient_CoordMapping,
@@ -113,13 +116,16 @@
 // must be tightly packed
 struct GrGpuGLShaders2::ProgramDesc {
     GrVertexLayout fVertexLayout;
+    GR_STATIC_ASSERT(2 == sizeof(GrVertexLayout)); // pack with next field
+
     enum {
         kNotPoints_OptFlagBit = 0x1,
         kVertexColorAllOnes_OptFlagBit = 0x2,
     };
     // we're assuming optflags and layout pack into 32 bits
-    GR_STATIC_ASSERT(2 == sizeof(GrVertexLayout));
-    int fOptFlags : 16;
+    // VS 2010 seems to require short rather than just unsigned
+    // for this to pack
+    unsigned short fOptFlags : 16;
 
     StageDesc fStages[NUM_STAGES];
 
@@ -389,9 +395,9 @@
             x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_OPTS));
             pdesc.fStages[s].fOptFlags = STAGE_OPTS[x];
             x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_MODULATES));
-            pdesc.fStages[s].fModulation = STAGE_MODULATES[x];
+            pdesc.fStages[s].fModulation = (StageDesc::Modulation) STAGE_MODULATES[x];
             x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_COORD_MAPPINGS));
-            pdesc.fStages[s].fCoordMapping = STAGE_COORD_MAPPINGS[x];
+            pdesc.fStages[s].fCoordMapping = (StageDesc::CoordMapping) STAGE_COORD_MAPPINGS[x];
         }
         Program program;
         GenProgram(pdesc, &program);
@@ -948,8 +954,8 @@
     for (int i = 1; i < NUM_STAGES; ++i) {
         desc->fStages[i].fEnabled       = false;
         desc->fStages[i].fOptFlags      = 0;
-        desc->fStages[i].fCoordMapping  = 0;
-        desc->fStages[i].fModulation    = 0;
+        desc->fStages[i].fCoordMapping  = (StageDesc::CoordMapping)0;
+        desc->fStages[i].fModulation    = (StageDesc::Modulation)0;
     }
 
     if (primType != kPoints_PrimitiveType) {
@@ -997,7 +1003,7 @@
             stage.fModulation = StageDesc::kColor_Modulation;
             break;
         case GrSamplerState::kSweep_SampleMode:
-            stage.fCoordMapping = StageDesc::StageDesc::kSweepGradient_CoordMapping;
+            stage.fCoordMapping = StageDesc::kSweepGradient_CoordMapping;
             stage.fModulation = StageDesc::kColor_Modulation;
             break;
         default:
@@ -1006,8 +1012,8 @@
         }
     } else {
         stage.fOptFlags     = 0;
-        stage.fCoordMapping = 0;
-        stage.fModulation   = 0;
+        stage.fCoordMapping = (StageDesc::CoordMapping)0;
+        stage.fModulation   = (StageDesc::Modulation)0;
     }
 }