Attempt to simplify NPOT texture caps. Also fixes case where textures would unnecessarily be bloated to POT. Adds setting of sampler's filter setting in paint conversion.

git-svn-id: http://skia.googlecode.com/svn/trunk@751 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index bcccc4e..f966c2c 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -260,22 +260,21 @@
         return false;

     }

 

-    bool needsRepeat = sampler.getWrapX() != GrSamplerState::kClamp_WrapMode ||

-                       sampler.getWrapY() != GrSamplerState::kClamp_WrapMode;

+

     bool isPow2 = GrIsPow2(width) && GrIsPow2(height);

 

-    switch (fGpu->npotTextureSupport()) {

-        case GrGpu::kNone_NPOTTextureType:

-            return isPow2;

-        case GrGpu::kNoRepeat_NPOTTextureType:

-            return isPow2 || !needsRepeat;

-        case GrGpu::kNonRendertarget_NPOTTextureType:

-        case GrGpu::kFull_NPOTTextureType:

-            return true;

+    if (!isPow2) {

+        if (!fGpu->npotTextureSupport()) {

+            return false;

+        }

+

+        bool tiled = sampler.getWrapX() != GrSamplerState::kClamp_WrapMode ||

+                     sampler.getWrapY() != GrSamplerState::kClamp_WrapMode;

+        if (tiled && !fGpu->npotTextureTileSupport()) {

+            return false;

+        }

     }

-    // should never get here

-    GrAssert(!"Bad enum from fGpu->npotTextureSupport");

-    return false;

+    return true;

 }

 

 ////////////////////////////////////////////////////////////////////////////////

@@ -1141,10 +1140,15 @@
     uint32_t bits = 0;

     uint16_t width = key->width();

     uint16_t height = key->height();

-    if (fGpu->npotTextureSupport() < GrGpu::kNonRendertarget_NPOTTextureType) {

-        if ((sampler.getWrapX() != GrSamplerState::kClamp_WrapMode ||

-             sampler.getWrapY() != GrSamplerState::kClamp_WrapMode) &&

-            (!GrIsPow2(width) || !GrIsPow2(height))) {

+    

+

+    if (!fGpu->npotTextureTileSupport()) {

+        bool isPow2 = GrIsPow2(width) && GrIsPow2(height);

+

+        bool tiled = (sampler.getWrapX() != GrSamplerState::kClamp_WrapMode) ||

+                     (sampler.getWrapY() != GrSamplerState::kClamp_WrapMode);

+

+        if (tiled && !isPow2) {

             bits |= 1;

             bits |= sampler.isFilter() ? 2 : 0;

         }