Move default init of tmp draw params out of subclasses into GrGpu

I want to move srgb conversion logic to GrGpu from subclasses and I think it will make more sense if the temp draw info is fully initialized before invoking the subclass.

Change-Id: Icfc4d564fc0d3c7c12f78c77f5ea921d979e290d
Reviewed-on: https://skia-review.googlesource.com/106260
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2018-02-09 14:18:24 -05:00 committed by Skia Commit-Bot
parent 1617899b67
commit dfb3a16960
3 changed files with 23 additions and 59 deletions

View File

@ -202,6 +202,18 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin,
SkASSERT(srcSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
// Default values for intermediate draws. The intermediate texture config matches the src's
// config, is approx sized to the read rect, no swizzling or spoofing of the dst config.
tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fTempSurfaceDesc.fConfig = srcSurface->config();
tempDrawInfo->fTempSurfaceFit = SkBackingFit::kApprox;
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
tempDrawInfo->fReadConfig = readConfig;
// We currently do not support reading into the packed formats 565 or 4444 as they are not
// required to have read back support on all devices and backends.
if (kRGB_565_GrPixelConfig == readConfig || kRGBA_4444_GrPixelConfig == readConfig) {
@ -234,6 +246,17 @@ bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin,
SkASSERT(dstSurface);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
// Default values for intermediate draws. The intermediate texture config matches the dst's
// config, is approx sized to the write rect, no swizzling or sppofing of the src config.
tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
tempDrawInfo->fWriteConfig = srcConfig;
if (!this->onGetWritePixelsInfo(dstSurface, dstOrigin, width, height, srcConfig, drawPreference,
tempDrawInfo)) {
return false;

View File

@ -698,19 +698,6 @@ bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOri
ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
}
// Start off assuming no swizzling
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
tempDrawInfo->fWriteConfig = srcConfig;
// These settings we will always want if a temp draw is performed. Initially set the config
// to srcConfig, though that may be modified if we decide to do a R/G swap.
tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
bool configsAreRBSwaps = GrPixelConfigSwapRAndB(srcConfig) == dstSurface->config();
if (configsAreRBSwaps) {
@ -2191,23 +2178,8 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrig
ReadPixelTempDrawInfo* tempDrawInfo) {
GrPixelConfig srcConfig = srcSurface->config();
// These settings we will always want if a temp draw is performed.
tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fTempSurfaceFit = this->glCaps().partialFBOReadIsSlow() ? SkBackingFit::kExact
: SkBackingFit::kApprox;
// For now assume no swizzling, we may change that below.
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
// Depends on why we need/want a temp draw. Start off assuming no change, the surface we read
// from will be srcConfig and we will read readConfig pixels from it.
// Note that if we require a draw and return a non-renderable format for the temp surface the
// base class will fail for us.
tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
tempDrawInfo->fReadConfig = readConfig;
if (requires_srgb_conversion(srcConfig, readConfig)) {
if (!this->readPixelsSupported(readConfig, readConfig)) {

View File

@ -342,19 +342,6 @@ bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOri
WritePixelTempDrawInfo* tempDrawInfo) {
GrRenderTarget* renderTarget = dstSurface->asRenderTarget();
// Start off assuming no swizzling
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
tempDrawInfo->fWriteConfig = srcConfig;
// These settings we will always want if a temp draw is performed. Initially set the config
// to srcConfig, though that may be modified if we decide to do a R/B swap
tempDrawInfo->fTempSurfaceDesc.fFlags = kNone_GrSurfaceFlags;
tempDrawInfo->fTempSurfaceDesc.fConfig = srcConfig;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
if (dstSurface->config() == srcConfig) {
// We only support writing pixels to textures. Forcing a draw lets us write to pure RTs.
if (!dstSurface->asTexture()) {
@ -1876,24 +1863,6 @@ bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrig
int width, int height, size_t rowBytes,
GrPixelConfig readConfig, DrawPreference* drawPreference,
ReadPixelTempDrawInfo* tempDrawInfo) {
// These settings we will always want if a temp draw is performed.
tempDrawInfo->fTempSurfaceDesc.fFlags = kRenderTarget_GrSurfaceFlag;
tempDrawInfo->fTempSurfaceDesc.fWidth = width;
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 1;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fTempSurfaceFit = SkBackingFit::kApprox;
// For now assume no swizzling, we may change that below.
tempDrawInfo->fSwizzle = GrSwizzle::RGBA();
// Depends on why we need/want a temp draw. Start off assuming no change, the surface we read
// from will be srcConfig and we will read readConfig pixels from it.
// Note that if we require a draw and return a non-renderable format for the temp surface the
// base class will fail for us.
tempDrawInfo->fTempSurfaceDesc.fConfig = srcSurface->config();
tempDrawInfo->fReadConfig = readConfig;
if (srcSurface->config() == readConfig) {
return true;
}