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;
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;
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.