Use explicitly-sized enums in GrGLProgramDesc::KeyHeader

Uses enums explicitly sized to 8 bits in GrGLProgramDesc::KeyHeader,
instead of storing them as uint8_t values. This avoids the need to
static_cast them.

R=bsalomon@google.com

Author: cdalton@nvidia.com

Review URL: https://codereview.chromium.org/23875048

git-svn-id: http://skia.googlecode.com/svn/trunk@11560 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index f10e895..2f8e807 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -228,7 +228,7 @@
     SkXfermode::Coeff colorCoeff;
     SkXfermode::Coeff filterColorCoeff;
     SkAssertResult(
-        SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode>(header.fColorFilterXfermode),
+        SkXfermode::ModeAsCoeff(header.fColorFilterXfermode,
                                 &filterColorCoeff,
                                 &colorCoeff));
     bool needColor, needFilterColor;
@@ -311,9 +311,7 @@
         }
     }
 
-    GrGLProgramDesc::CoverageOutput coverageOutput =
-        static_cast<GrGLProgramDesc::CoverageOutput>(header.fCoverageOutput);
-    if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(coverageOutput)) {
+    if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutput)) {
         const char* secondaryOutputName = builder.enableSecondaryOutput();
 
         // default coeff to ones for kCoverage_DualSrcOutput
@@ -333,7 +331,7 @@
                                                  kOnes_GrSLConstantVec,
                                                  knownColorValue,
                                                  true);
-        } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == coverageOutput) {
+        } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == header.fCoverageOutput) {
             // Get (1-RGBA) into coeff
             knownCoeffValue = GrGLSLSubtractf<4>(&coeff,
                                                  NULL,
@@ -365,7 +363,7 @@
                                                              knownCoverageValue,
                                                              true);
     // Now tack on "+(1-coverage)dst onto the frag color if we were asked to do so.
-    if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == coverageOutput) {
+    if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == header.fCoverageOutput) {
         SkString dstCoeff;
         GrSLConstantVec knownDstCoeffValue = GrGLSLSubtractf<4>(&dstCoeff,
                                                                 NULL,
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 308b0c7..e160438 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -154,13 +154,13 @@
         // should the FS discard if the coverage is zero (to avoid stencil manipulation)
         SkBool8                     fDiscardIfZeroCoverage;
 
-        uint8_t                     fColorInput;            // casts to enum ColorInput
-        uint8_t                     fCoverageInput;         // casts to enum ColorInput
-        uint8_t                     fCoverageOutput;        // casts to enum CoverageOutput
+        ColorInput                  fColorInput : 8;
+        ColorInput                  fCoverageInput : 8;
+        CoverageOutput              fCoverageOutput : 8;
 
         SkBool8                     fHasVertexCode;
         SkBool8                     fEmitsPointSize;
-        uint8_t                     fColorFilterXfermode;   // casts to enum SkXfermode::Mode
+        SkXfermode::Mode            fColorFilterXfermode : 8;
 
         // To enable experimental geometry shader code (not for use in
         // production)
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 10380f7..fe17f88 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -44,7 +44,8 @@
     // if the effects have used up all off the available attributes,
     // don't try to use color or coverage attributes as input
     do {
-        header->fColorInput = random->nextULessThan(kColorInputCnt);
+        header->fColorInput = static_cast<GrGLProgramDesc::ColorInput>(
+                                  random->nextULessThan(kColorInputCnt));
     } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex &&
              kAttribute_ColorInput == header->fColorInput);
     header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput) ?
@@ -52,14 +53,16 @@
                                         -1;
 
     do {
-        header->fCoverageInput = random->nextULessThan(kColorInputCnt);
+        header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>(
+                                     random->nextULessThan(kColorInputCnt));
     } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex  &&
              kAttribute_ColorInput == header->fCoverageInput);
     header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_ColorInput) ?
                                         currAttribIndex++ :
                                         -1;
 
-    header->fColorFilterXfermode = random->nextULessThan(SkXfermode::kLastCoeffMode + 1);
+    header->fColorFilterXfermode = static_cast<SkXfermode::Mode>(
+                                       random->nextULessThan(SkXfermode::kLastCoeffMode + 1));
 
 #if GR_GL_EXPERIMENTAL_GS
     header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->nextBool();