Fix ImageNewSurface test on S4.
authorbsalomon <bsalomon@google.com>
Thu, 23 Jul 2015 18:45:02 +0000 (11:45 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 23 Jul 2015 18:45:02 +0000 (11:45 -0700)
This still leaves the SkImage_NewFromTexture broken.

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

src/gpu/GrTextureProvider.cpp
src/gpu/gl/GrGLGpu.cpp

index cfa6994..cf93209 100644 (file)
@@ -73,10 +73,10 @@ GrTexture* GrTextureProvider::internalRefScratchTexture(const GrSurfaceDesc& inD
     if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
         if (!(kExact_ScratchTextureFlag & flags)) {
             // bin by pow2 with a reasonable min
-            static const int MIN_SIZE = 16;
+            const int minSize = SkTMin(16, fGpu->caps()->minTextureSize());
             GrSurfaceDesc* wdesc = desc.writable();
-            wdesc->fWidth  = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth));
-            wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight));
+            wdesc->fWidth  = SkTMax(minSize, GrNextPow2(desc->fWidth));
+            wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight));
         }
 
         GrScratchKey key;
index e8dc788..101bb21 100644 (file)
@@ -1686,6 +1686,12 @@ static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL
         return false;
     }
 
+    // If the read is really small or smaller than the min texture size, don't force a draw.
+    int minSize = SkTMax(32, caps.minTextureSize());
+    if (width < minSize || height < minSize) {
+        return false;
+    }
+
     // if GL can do the flip then we'll never pay for it.
     if (caps.packFlipYSupport()) {
         return false;
@@ -1726,7 +1732,9 @@ bool GrGLGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, si
     tempDrawInfo->fTempSurfaceDesc.fHeight = height;
     tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0;
     tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
-    tempDrawInfo->fUseExactScratch = SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL);
+    tempDrawInfo->fUseExactScratch = SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL) &&
+                                     width >= this->caps()->minTextureSize() &&
+                                     height >= this->caps()->minTextureSize();
 
     // Start off assuming that any temp draw should be to the readConfig, then check if that will
     // be inefficient.