Skip to content

Commit

Permalink
Revert "Pass origins through the flushSurfaces calls."
Browse files Browse the repository at this point in the history
This reverts commit ec34081.

Reason for revert: This change actually isn't needed since a follow on change removes the use of origin from flushSurface anyways

Original change's description:
> Pass origins through the flushSurfaces calls.
> 
> Bug: skia:9556
> Change-Id: Ie4a0b33dd35e50b93c30cb0010f60c2893140661
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270439
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,robertphillips@google.com

Change-Id: I4ea086d13d0bbef16c59e0abe2c42eb1eb6bf747
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9556
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270640
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
  • Loading branch information
egdaniel authored and Skia Commit-Bot committed Feb 13, 2020
1 parent ec34081 commit 55f040b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 48 deletions.
10 changes: 4 additions & 6 deletions src/gpu/GrContextPriv.cpp
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
13 changes: 4 additions & 9 deletions src/gpu/GrContextPriv.h
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/gpu/GrDrawingManager.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/gpu/GrDrawingManager.h
Expand Up @@ -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*);
Expand Down
3 changes: 1 addition & 2 deletions src/gpu/GrRenderTargetContext.cpp
Expand Up @@ -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,
Expand Down
14 changes: 5 additions & 9 deletions src/gpu/GrSurfaceContext.cpp
Expand Up @@ -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());
Expand All @@ -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(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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(),
Expand Down
15 changes: 4 additions & 11 deletions src/image/SkImage_Gpu.cpp
Expand Up @@ -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> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* context,
Expand Down Expand Up @@ -561,7 +560,7 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromPixmap(GrContext* context,
sk_sp<GrTexture> 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<GrSemaphore> sema = gpu->prepareTextureForCrossContextUsage(texture.get());
Expand Down Expand Up @@ -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.
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/image/SkImage_GpuBase.cpp
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/image/SkImage_GpuYUVA.cpp
Expand Up @@ -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(); }
Expand Down

0 comments on commit 55f040b

Please sign in to comment.