Remove min texture size support

BUG=skia:4524

Review URL: https://codereview.chromium.org/1430643002
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 71afc0e..bf9bea0 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -287,8 +287,6 @@
     }
 
 protected:
-    GrTexture* peekOriginalTexture() override { return nullptr; }
-
     // TODO: consider overriding this, for the case where the underlying generator might be
     //       able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
     //    GrTexture* generateTextureForParams(GrContext*, const SkGrStretch&) override;
@@ -309,10 +307,6 @@
         }
     }
 
-    bool getROBitmap(SkBitmap* bitmap) override {
-        return fCacher->lockAsBitmap(bitmap, fClient);
-    }
-
 private:
     SkImageCacherator*      fCacher;
     const SkImage*          fClient;
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index cab44b9..4095f1a 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -106,7 +106,6 @@
 
     fMaxRenderTargetSize = 1;
     fMaxTextureSize = 1;
-    fMinTextureSize = 1;
     fMaxSampleCount = 0;
 
     memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
@@ -122,7 +121,6 @@
 
 void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
     fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride);
-    fMinTextureSize = SkTMax(fMinTextureSize, options.fMinTextureSizeOverride);
 }
 
 static SkString map_flags_to_string(uint32_t flags) {
@@ -172,7 +170,6 @@
     }
 
     r.appendf("Max Texture Size                   : %d\n", fMaxTextureSize);
-    r.appendf("Min Texture Size                   : %d\n", fMinTextureSize);
     r.appendf("Max Render Target Size             : %d\n", fMaxRenderTargetSize);
     r.appendf("Max Sample Count                   : %d\n", fMaxSampleCount);
 
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 48fc740..4970a63 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -57,21 +57,11 @@
 
 bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParams& textureParams,
                                      GrTextureParamsAdjuster::CopyParams* copyParams) const {
-    bool doCopy = false;
     const GrCaps& caps = *this->caps();
     if (textureParams.isTiled() && !caps.npotTextureTileSupport() &&
         (!SkIsPow2(width) || !SkIsPow2(height))) {
-        doCopy = true;
-        copyParams->fWidth = GrNextPow2(SkTMax(width, caps.minTextureSize()));
-        copyParams->fHeight = GrNextPow2(SkTMax(height, caps.minTextureSize()));
-    } else if (width < caps.minTextureSize() || height < caps.minTextureSize()) {
-        // The small texture issues appear to be with tiling. Hence it seems ok to scale
-        // them up using the GPU. If issues persist we may need to CPU-stretch.
-        doCopy = true;
-        copyParams->fWidth = SkTMax(width, caps.minTextureSize());
-        copyParams->fHeight = SkTMax(height, caps.minTextureSize());
-    }
-    if (doCopy) {
+        copyParams->fWidth = GrNextPow2(width);
+        copyParams->fHeight = GrNextPow2(height);
         switch (textureParams.filterMode()) {
             case GrTextureParams::kNone_FilterMode:
                 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
@@ -82,8 +72,9 @@
                 copyParams->fFilter = GrTextureParams::kBilerp_FilterMode;
                 break;
         }
+        return true;
     }
-    return doCopy;
+    return false;
 }
 
 static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) {
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 9940f9e..ee3d135 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -79,28 +79,6 @@
     return copy.detach();
 }
 
-static SkBitmap copy_on_cpu(const SkBitmap& bmp, const CopyParams& copyParams) {
-    SkBitmap stretched;
-    stretched.allocN32Pixels(copyParams.fWidth, copyParams.fHeight);
-    SkCanvas canvas(stretched);
-    SkPaint paint;
-    switch (copyParams.fFilter) {
-        case GrTextureParams::kNone_FilterMode:
-            paint.setFilterQuality(kNone_SkFilterQuality);
-            break;
-        case GrTextureParams::kBilerp_FilterMode:
-            paint.setFilterQuality(kLow_SkFilterQuality);
-            break;
-        case GrTextureParams::kMipMap_FilterMode:
-            paint.setFilterQuality(kMedium_SkFilterQuality);
-            break;
-    }
-    SkRect dstRect = SkRect::MakeWH(SkIntToScalar(copyParams.fWidth),
-                                    SkIntToScalar(copyParams.fHeight));
-    canvas.drawBitmapRect(bmp, dstRect, &paint);
-    return stretched;
-}
-
 GrTexture* GrTextureParamsAdjuster::refTextureForParams(GrContext* ctx,
                                                         const GrTextureParams& params) {
     CopyParams copyParams;
@@ -131,22 +109,9 @@
 
 GrTexture* GrTextureParamsAdjuster::generateTextureForParams(GrContext* ctx,
                                                              const CopyParams& copyParams) {
-    if ((this->width() < ctx->caps()->minTextureSize() ||
-         this->height() < ctx->caps()->minTextureSize()) && !this->peekOriginalTexture())
-    {
-        // we can't trust our ability to use HW to perform the stretch, so we request
-        // a raster instead, and perform the stretch on the CPU.
-        SkBitmap bitmap;
-        if (!this->getROBitmap(&bitmap)) {
-            return nullptr;
-        }
-        SkBitmap stretchedBmp = copy_on_cpu(bitmap, copyParams);
-        return GrUploadBitmapToTexture(ctx, stretchedBmp);
-    } else {
-        SkAutoTUnref<GrTexture> original(this->refOriginalTexture(ctx));
-        if (!original) {
-            return nullptr;
-        }
-        return copy_on_gpu(original, copyParams);
+    SkAutoTUnref<GrTexture> original(this->refOriginalTexture(ctx));
+    if (!original) {
+        return nullptr;
     }
+    return copy_on_gpu(original, copyParams);
 }
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index c244aaf..bc08c71 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -43,10 +43,6 @@
     GrTexture* refTextureForParams(GrContext*, const GrTextureParams&);
 
 protected:
-    /** If the original is a inherently texture that can be returned for "free" then return it
-        without ref'ing it. Otherwise, return null. */
-    virtual GrTexture* peekOriginalTexture() = 0;
-
     /**
      *  Return the maker's "original" texture. It is the responsibility of the maker
      *  to make this efficient ... if the texture is being generated, the maker must handle
@@ -66,9 +62,8 @@
      *  Return a new (uncached) texture that is the stretch of the maker's original.
      *
      *  The base-class handles general logic for this, and only needs access to the following
-     *  methods:
-     *  - onRefOriginalTexture()
-     *  - onGetROBitmap()
+     *  method:
+     *  - refOriginalTexture()
      *
      *  Subclass may override this if they can handle creating the texture more directly than
      *  by copying.
@@ -82,13 +77,6 @@
      */
     virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0;
 
-    /**
-     *  Some GPUs are unreliable w/ very small texture sizes. If we run into that case, this
-     *  method will be called (in service of onGenerateParamsTexture) to return a raster version
-     *  of the original texture.
-     */
-    virtual bool getROBitmap(SkBitmap*) = 0;
-
     /** Helper for creating a key for a copy from an original key. */
     static void MakeCopyKeyFromOrigKey(const GrUniqueKey& origKey,
                                        const CopyParams& copyParams,
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index 26384ab..cb652f7 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -70,10 +70,10 @@
     if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
         if (!(kExact_ScratchTextureFlag & flags)) {
             // bin by pow2 with a reasonable min
-            const int minSize = SkTMin(16, fGpu->caps()->minTextureSize());
+            const int kMinSize = 16;
             GrSurfaceDesc* wdesc = desc.writable();
-            wdesc->fWidth  = SkTMax(minSize, GrNextPow2(desc->fWidth));
-            wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight));
+            wdesc->fWidth  = SkTMax(kMinSize, GrNextPow2(desc->fWidth));
+            wdesc->fHeight = SkTMax(kMinSize, GrNextPow2(desc->fHeight));
         }
 
         GrScratchKey key;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 3c3f3e8..1ffd256 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -217,11 +217,6 @@
 GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bmp) {
     SkASSERT(!bmp.getTexture());
 
-    if (bmp.width() < ctx->caps()->minTextureSize() ||
-        bmp.height() < ctx->caps()->minTextureSize()) {
-        return nullptr;
-    }
-
     SkBitmap tmpBitmap;
     const SkBitmap* bitmap = &bmp;
 
@@ -291,8 +286,6 @@
     }
 
 protected:
-    GrTexture* peekOriginalTexture() override { return fBitmap.getTexture();  }
-
     GrTexture* refOriginalTexture(GrContext* ctx) override {
         GrTexture* tex = fBitmap.getTexture();
         if (tex) {
@@ -324,12 +317,6 @@
         InstallInvalidator(copyKey, fBitmap.pixelRef());
     }
 
-    bool getROBitmap(SkBitmap* bitmap) override {
-        SkASSERT(!fBitmap.getTexture());
-        *bitmap = fBitmap;
-        return true;
-    }
-
 private:
     static void InstallInvalidator(const GrUniqueKey& key, SkPixelRef* pixelRef) {
         class Invalidator : public SkPixelRef::GenIDChangeListener {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index ec945ea..9879846 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -424,11 +424,6 @@
     // attachment, hence this min:
     fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize);
 
-    // This GPU seems to have problems when tiling small textures
-    if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer()) {
-        fMinTextureSize = 16;
-    }
-
     fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
 
     // Disable scratch texture reuse on Mali and Adreno devices
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index feeac93..a0809c1 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1184,7 +1184,7 @@
 }
 
 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
-    int size = this->caps()->minTextureSize();
+    static const int kSize = 16;
     if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) {
         // Default to unsupported
         fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
@@ -1226,8 +1226,8 @@
         CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
         GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
                                                       0, internalFormat,
-                                                      size,
-                                                      size,
+                                                      kSize,
+                                                      kSize,
                                                       0,
                                                       externalFormat,
                                                       externalType,
@@ -1266,7 +1266,7 @@
             CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
             GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERBUFFER,
                                                                    sFmt.fInternalFormat,
-                                                                   size, size));
+                                                                   kSize, kSize));
             if (GR_GL_NO_ERROR == GR_GL_GET_ERROR(this->glInterface())) {
                 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
                                                 GR_GL_STENCIL_ATTACHMENT,
@@ -1818,8 +1818,8 @@
     }
 
     // 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) {
+    static const int kMinSize = 32;
+    if (width < kMinSize || height < kMinSize) {
         return false;
     }
 
@@ -1857,9 +1857,7 @@
     tempDrawInfo->fTempSurfaceDesc.fHeight = height;
     tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0;
     tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
-    tempDrawInfo->fUseExactScratch = this->glCaps().partialFBOReadIsSlow() &&
-                                     width >= this->caps()->minTextureSize() &&
-                                     height >= this->caps()->minTextureSize();
+    tempDrawInfo->fUseExactScratch = this->glCaps().partialFBOReadIsSlow();
 
     // Start off assuming that any temp draw should be to the readConfig, then check if that will
     // be inefficient.
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index e5f3aee..8e5ce45 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -87,8 +87,6 @@
     {}
 
 protected:
-    GrTexture* peekOriginalTexture() override { return fOriginal; }
-
     GrTexture* refOriginalTexture(GrContext* ctx) override {
         return SkRef(fOriginal);
     }
@@ -101,10 +99,6 @@
         as_IB(fImage)->notifyAddedToCache();
     }
 
-    bool getROBitmap(SkBitmap* bitmap) override {
-        return as_IB(fImage)->getROPixels(bitmap);
-    }
-
 private:
     const SkImage*  fImage;
     GrTexture*      fOriginal;