diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp index f1f0d864347b2..e033ffad5e83c 100644 --- a/src/gpu/GrContextPriv.cpp +++ b/src/gpu/GrContextPriv.cpp @@ -40,8 +40,7 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO fContext->addOnFlushCallbackObject(onFlushCBObject); } -GrSemaphoresSubmitted GrContextPriv::flushSurfaces(GrSurfaceProxy* proxies[], - GrSurfaceOrigin origins[], int numProxies, +GrSemaphoresSubmitted GrContextPriv::flushSurfaces(GrSurfaceProxy* proxies[], int numProxies, const GrFlushInfo& info) { ASSERT_SINGLE_OWNER RETURN_VALUE_IF_ABANDONED(GrSemaphoresSubmitted::kNo) @@ -53,12 +52,11 @@ GrSemaphoresSubmitted GrContextPriv::flushSurfaces(GrSurfaceProxy* proxies[], ASSERT_OWNED_PROXY(proxies[i]); } return fContext->drawingManager()->flushSurfaces( - proxies, origins, numProxies, SkSurface::BackendSurfaceAccess::kNoAccess, info); + proxies, numProxies, SkSurface::BackendSurfaceAccess::kNoAccess, info); } -void GrContextPriv::flushSurface(GrSurfaceProxy* proxy, GrSurfaceOrigin origin) { - SkASSERT(proxy); - this->flushSurfaces(&proxy, &origin, 1, {}); +void GrContextPriv::flushSurface(GrSurfaceProxy* proxy) { + this->flushSurfaces(proxy ? &proxy : nullptr, proxy ? 1 : 0, {}); } void GrContextPriv::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) { diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index 28201ae7beee0..8e78956a5eeb2 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -86,16 +86,11 @@ class GrContextPriv { * GrContext will detect when it must perform a resolve before reading pixels back from the * surface or using it as a texture. */ - GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy*[], GrSurfaceOrigin[], int numProxies, - const GrFlushInfo&); + GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy*[], int numProxies, const GrFlushInfo&); - /** Version of above that flushes for a single proxy and uses a default GrFlushInfo. Null is not - * allowed for the proxy. */ - void flushSurface(GrSurfaceProxy*, GrSurfaceOrigin); - - void flushSurface() { - this->flushSurfaces(nullptr, nullptr, 0, {}); - } + /** Version of above that flushes for a single proxy and uses a default GrFlushInfo. Null is + * allowed. */ + void flushSurface(GrSurfaceProxy*); /** * Returns true if createPMToUPMEffect and createUPMToPMEffect will succeed. In other words, diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 961c603c2b175..68f57f1acd5ba 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -494,8 +494,7 @@ bool GrDrawingManager::executeRenderTasks(int startIndex, int stopIndex, GrOpFlu return anyRenderTasksExecuted; } -GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[], - GrSurfaceOrigin origins[], int numProxies, +GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[], int numProxies, SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) { if (this->wasAbandoned()) { @@ -535,7 +534,7 @@ GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[], if (rtProxy->isMSAADirty()) { SkASSERT(rtProxy->peekRenderTarget()); gpu->resolveRenderTarget(rtProxy->peekRenderTarget(), rtProxy->msaaDirtyRect(), - origins[i], GrGpu::ForExternalIO::kYes); + rtProxy->origin(), GrGpu::ForExternalIO::kYes); rtProxy->markMSAAResolved(); } } diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index 752973afc9cb8..8bb64e3fbdd5f 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -93,14 +93,13 @@ class GrDrawingManager { static bool ProgramUnitTest(GrContext* context, int maxStages, int maxLevels); GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy* proxies[], - GrSurfaceOrigin origins[], int cnt, SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info); - GrSemaphoresSubmitted flushSurface(GrSurfaceProxy* proxy, GrSurfaceOrigin origin, + GrSemaphoresSubmitted flushSurface(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) { - return this->flushSurfaces(&proxy, &origin, 1, access, info); + return this->flushSurfaces(&proxy, 1, access, info); } void addOnFlushCallbackObject(GrOnFlushCallbackObject*); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 65abda8a7a7a1..6a08e46381781 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -2164,8 +2164,7 @@ GrSemaphoresSubmitted GrRenderTargetContext::flush(SkSurface::BackendSurfaceAcce SkDEBUGCODE(this->validate();) GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "flush", fContext); - return this->drawingManager()->flushSurface(this->asSurfaceProxy(), this->origin(), access, - info); + return this->drawingManager()->flushSurface(this->asSurfaceProxy(), access, info); } bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores, diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp index 88b5962341121..5c4e04a21a738 100644 --- a/src/gpu/GrSurfaceContext.cpp +++ b/src/gpu/GrSurfaceContext.cpp @@ -240,7 +240,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz return tempCtx->readPixels(dstInfo, dst, rowBytes, {0, 0}, direct); } - bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin; + bool flip = srcProxy->origin() == kBottomLeft_GrSurfaceOrigin; auto supportedRead = caps->supportedReadPixelsColorType( this->colorInfo().colorType(), srcProxy->backendFormat(), dstInfo.colorType()); @@ -267,7 +267,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz pt.fY = flip ? srcSurface->height() - pt.fY - dstInfo.height() : pt.fY; } - direct->priv().flushSurface(srcProxy, this->origin()); + direct->priv().flushSurface(srcProxy); if (!direct->priv().getGpu()->readPixels(srcSurface, pt.fX, pt.fY, dstInfo.width(), dstInfo.height(), this->colorInfo().colorType(), @@ -378,7 +378,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s // we can use a draw instead which doesn't have this origin restriction. Thus for render // targets we will use top left and otherwise we will make the origins match. GrSurfaceOrigin tempOrigin = - this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : this->origin(); + this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : dstProxy->origin(); auto tempProxy = direct->priv().proxyProvider()->createProxy( format, srcInfo.dimensions(), tempReadSwizzle, GrRenderable::kNo, 1, tempOrigin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo); @@ -436,7 +436,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s caps->supportedWritePixelsColorType(this->colorInfo().colorType(), dstProxy->backendFormat(), srcInfo.colorType()).fColorType; - bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin; + bool flip = dstProxy->origin() == kBottomLeft_GrSurfaceOrigin; bool makeTight = !caps->writePixelsRowBytesSupport() && rowBytes != tightRowBytes; bool convert = premul || unpremul || needColorConversion || makeTight || (srcInfo.colorType() != allowedColorType) || flip; @@ -462,11 +462,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s // giving the drawing manager the chance of skipping the flush (i.e., by passing in the // destination proxy) // TODO: should this policy decision just be moved into the drawing manager? - if (caps->preferVRAMUseOverFlushes()) { - direct->priv().flushSurface(dstProxy, this->origin()); - } else { - direct->priv().flushSurface(); - } + direct->priv().flushSurface(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr); return direct->priv().getGpu()->writePixels(dstSurface, pt.fX, pt.fY, srcInfo.width(), srcInfo.height(), this->colorInfo().colorType(), diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index b8a7595137b4e..18728a449cbfc 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -71,8 +71,7 @@ GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrContext* context, const GrFlushInfo } GrSurfaceProxy* p[1] = {fView.proxy()}; - GrSurfaceOrigin origin = fView.origin(); - return context->priv().flushSurfaces(p, &origin, 1, info); + return context->priv().flushSurfaces(p, 1, info); } sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* context, @@ -561,7 +560,7 @@ sk_sp SkImage::MakeCrossContextFromPixmap(GrContext* context, sk_sp texture = sk_ref_sp(view.proxy()->peekTexture()); // Flush any writes or uploads - context->priv().flushSurface(view.proxy(), view.origin()); + context->priv().flushSurface(view.proxy()); GrGpu* gpu = context->priv().getGpu(); std::unique_ptr sema = gpu->prepareTextureForCrossContextUsage(texture.get()); @@ -698,11 +697,8 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx, return false; } - const GrSurfaceProxyView* view = as_IB(image)->view(ctx); - SkASSERT(view); - // Flush any pending IO on the texture. - ctx->priv().flushSurface(view->proxy(), view->origin()); + ctx->priv().flushSurface(as_IB(image)->peekProxy()); // We must make a copy of the image if the image is not unique, if the GrTexture owned by the // image is not unique, or if the texture wraps an external object. @@ -719,11 +715,8 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx, return false; } - view = as_IB(image)->view(ctx); - SkASSERT(view); - // Flush to ensure that the copy is completed before we return the texture. - ctx->priv().flushSurface(view->proxy(), view->origin()); + ctx->priv().flushSurface(as_IB(image)->peekProxy()); } SkASSERT(!texture->resourcePriv().refsWrappedObjects()); diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp index 3d0f3c78463ba..563d2905a2fca 100644 --- a/src/image/SkImage_GpuBase.cpp +++ b/src/image/SkImage_GpuBase.cpp @@ -221,7 +221,7 @@ GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContext GrTexture* texture = proxy->peekTexture(); if (texture) { if (flushPendingGrContextIO) { - direct->priv().flushSurface(proxy, view->origin()); + direct->priv().flushSurface(proxy); } if (origin) { *origin = proxy->origin(); diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index 1c0505f06cd4b..2f7ced04ccb6c 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -119,18 +119,15 @@ GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrContext* context, const GrFlush GrSurfaceProxy* proxies[4] = {fViews[0].proxy(), fViews[1].proxy(), fViews[2].proxy(), fViews[3].proxy()}; - GrSurfaceOrigin origins[4] = {fViews[0].origin(), fViews[1].origin(), fViews[2].origin(), - fViews[3].origin()}; int numProxies = fNumViews; if (fRGBView.proxy()) { // Either we've already flushed the flattening draw or the flattening is unflushed. In the // latter case it should still be ok to just pass fRGBView proxy because it in turn depends // on the planar proxies and will cause all of their work to flush as well. proxies[0] = fRGBView.proxy(); - origins[0] = fRGBView.origin(); numProxies = 1; } - return context->priv().flushSurfaces(proxies, origins, numProxies, info); + return context->priv().flushSurfaces(proxies, numProxies, info); } GrTextureProxy* SkImage_GpuYUVA::peekProxy() const { return fRGBView.asTextureProxy(); }