Remove GrAALevel enum, use explicit sample count

Review URL: http://codereview.appspot.com/5600045/



git-svn-id: http://skia.googlecode.com/svn/trunk@3106 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 975f6d0..1e87cab 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -167,6 +167,7 @@
                             GrContext::TextureKey clientKey,
                             int width,
                             int height,
+                            int sampleCnt,
                             bool scratch,
                             uint32_t v[4]) {
     GR_STATIC_ASSERT(sizeof(GrContext::TextureKey) == sizeof(uint64_t));
@@ -178,7 +179,9 @@
     v[1] = (clientKey >> 32) & 0xffffffffUL;
     v[2] = width | (height << 16);
 
-    v[3] = 0;
+    v[3] = (sampleCnt << 24);
+    GrAssert(sampleCnt >= 0 && sampleCnt < 256);
+
     if (!gpu->getCaps().fNPOTTextureTileSupport) {
         bool isPow2 = GrIsPow2(width) && GrIsPow2(height);
 
@@ -227,7 +230,7 @@
         int height,
         const GrSamplerState* sampler) {
     uint32_t v[4];
-    gen_texture_key_values(fGpu, sampler, key, width, height, false, v);
+    gen_texture_key_values(fGpu, sampler, key, width, height, 0, false, v);
     GrResourceKey resourceKey(v);
     return TextureCacheEntry(fTextureCache->findAndLock(resourceKey,
                                             GrResourceCache::kNested_LockType));
@@ -238,7 +241,7 @@
                                  int height,
                                  const GrSamplerState* sampler) const {
     uint32_t v[4];
-    gen_texture_key_values(fGpu, sampler, key, width, height, false, v);
+    gen_texture_key_values(fGpu, sampler, key, width, height, 0, false, v);
     GrResourceKey resourceKey(v);
     return fTextureCache->hasKey(resourceKey);
 }
@@ -313,7 +316,8 @@
     TextureCacheEntry entry;
     uint32_t v[4];
     bool special = gen_texture_key_values(fGpu, sampler, key,
-                                          desc.fWidth, desc.fHeight, false, v);
+                                          desc.fWidth, desc.fHeight,
+                                          desc.fSampleCnt, false, v);
     GrResourceKey resourceKey(v);
 
     if (special) {
@@ -417,13 +421,12 @@
                                        uint32_t v[4]) {
     // Instead of a client-provided key of the texture contents
     // we create a key of from the descriptor.
-    GrContext::TextureKey descKey = desc.fAALevel |
-                                    (desc.fFlags << 8) |
+    GrContext::TextureKey descKey = (desc.fFlags << 8) |
                                     ((uint64_t) desc.fConfig << 32);
     // this code path isn't friendly to tiling with NPOT restricitons
     // We just pass ClampNoFilter()
     gen_texture_key_values(gpu, NULL, descKey, desc.fWidth,
-                           desc.fHeight, true, v);
+                           desc.fHeight, desc.fSampleCnt, true, v);
 }
 }
 
@@ -439,9 +442,6 @@
         desc.fHeight = GrMax(MIN_SIZE, GrNextPow2(desc.fHeight));
     }
 
-    uint32_t p0 = desc.fConfig;
-    uint32_t p1 = (desc.fAALevel << 16) | desc.fFlags;
-    
     GrResourceEntry* entry;
     int origWidth = desc.fWidth;
     int origHeight = desc.fHeight;
@@ -713,13 +713,15 @@
     if (PREFER_MSAA_OFFSCREEN_AA && fGpu->getCaps().fFSAASupport) {
         record->fDownsample = OffscreenRecord::kFSAA_Downsample;
         record->fScale = 1;
-        desc.fAALevel = kMed_GrAALevel;
+        // 16 samples matches what the skia sw rasterizer uses. (There is no
+        // accessible constant to reference from sw code).
+        desc.fSampleCnt = 16;
     } else {
         record->fDownsample = OffscreenRecord::k4x4SinglePass_Downsample;
         record->fScale = OFFSCREEN_SSAA_SCALE;
         // both downsample paths assume this
         GR_STATIC_ASSERT(4 == OFFSCREEN_SSAA_SCALE);
-        desc.fAALevel = kNone_GrAALevel;
+        desc.fSampleCnt = 0;
     }
     
     desc.fWidth *= record->fScale;
@@ -1547,10 +1549,10 @@
 
     const GrTextureDesc desc = {
         kNone_GrTextureFlags,
-        kNone_GrAALevel,
         bounds.fRight,
         bounds.fBottom,
-        kAlpha_8_GrPixelConfig
+        kAlpha_8_GrPixelConfig,
+        {0} // samples
     };
 
     tex->set(context, desc);
@@ -1844,9 +1846,9 @@
         // readTexturePixels as of yet (it calls this function).
         const GrTextureDesc desc = {
             kRenderTarget_GrTextureFlagBit,
-            kNone_GrAALevel,
             width, height,
-            config
+            config,
+            {0}, // samples
         };
 
         // When a full readback is faster than a partial we could always make
@@ -1964,7 +1966,7 @@
     }
 
     const GrTextureDesc desc = {
-        kNone_GrTextureFlags, kNone_GrAALevel, width, height, config
+        kNone_GrTextureFlags, width, height, config, {0}
     };
     GrAutoScratchTexture ast(this, desc);
     GrTexture* texture = ast.texture();