bool swapRAndB, const SkMatrix&);
const GrFragmentProcessor* createUPMToPMEffect(GrProcessorDataManager*, GrTexture*,
bool swapRAndB, const SkMatrix&);
+ /** Returns true if we've already determined that createPMtoUPMEffect and createUPMToPMEffect
+ will fail. In such cases fall back to SW conversion. */
+ bool didFailPMUPMConversionTest() const;
/**
* This callback allows the resource cache to callback into the GrContext
}
applyPremulToSrc = true;
}
- GrGpu::DrawPreference drawPreference = applyPremulToSrc ?
- GrGpu::kCallerPrefersDraw_DrawPreference :
- GrGpu::kNoDraw_DrawPreference;
+
+ GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
+ // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
+ // we've already determined that there isn't a roundtrip preserving conversion processor pair.
+ if (applyPremulToSrc && !this->didFailPMUPMConversionTest()) {
+ drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
+ }
+
GrGpu::WritePixelTempDrawInfo tempDrawInfo;
if (!fGpu->getWritePixelsInfo(surface, width, height, rowBytes, srcConfig, &drawPreference,
&tempDrawInfo)) {
return false;
}
- GrGpu::DrawPreference drawPreference = unpremul ? GrGpu::kCallerPrefersDraw_DrawPreference :
- GrGpu::kNoDraw_DrawPreference;
+ GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
+ // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
+ // we've already determined that there isn't a roundtrip preserving conversion processor pair.
+ if (unpremul && !this->didFailPMUPMConversionTest()) {
+ drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
+ }
+
GrGpu::ReadPixelTempDrawInfo tempDrawInfo;
if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawPreference,
&tempDrawInfo)) {
}
}
+bool GrContext::didFailPMUPMConversionTest() const {
+ // The PM<->UPM tests fail or succeed together so we only need to check one.
+ return fDidTestPMConversions &&
+ GrConfigConversionEffect::kNone_PMConversion == fPMToUPMConversion;
+}
+
//////////////////////////////////////////////////////////////////////////////
void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const {