Update copy and blitTexture calls to not query origin off of proxies.

Bug: skia:9556
Change-Id: I4042f1339844186b73b807e93b1a3701c32bf112
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269366
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-02-07 17:22:35 -05:00 committed by Skia Commit-Bot
parent 33c7a468c8
commit 573312e33e
9 changed files with 32 additions and 29 deletions

View File

@ -2604,21 +2604,19 @@ bool GrRenderTargetContext::setupDstProxyView(const GrClip& clip, const GrOp& op
return true;
}
bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, const SkIRect& srcRect,
bool GrRenderTargetContext::blitTexture(GrSurfaceProxyView view, const SkIRect& srcRect,
const SkIPoint& dstPoint) {
SkASSERT(view.asTextureProxy());
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
if (!GrClipSrcRectAndDstPoint(this->asSurfaceProxy()->dimensions(), src->dimensions(), srcRect,
dstPoint, &clippedSrcRect, &clippedDstPoint)) {
if (!GrClipSrcRectAndDstPoint(this->asSurfaceProxy()->dimensions(), view.proxy()->dimensions(),
srcRect, dstPoint, &clippedSrcRect, &clippedDstPoint)) {
return false;
}
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrSurfaceOrigin origin = src->origin();
GrSwizzle swizzle = src->textureSwizzle();
GrSurfaceProxyView view(sk_ref_sp(src), origin, swizzle);
auto fp = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType);
if (!fp) {
return false;

View File

@ -517,7 +517,7 @@ public:
* of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces
* respectively.
*/
bool blitTexture(GrTextureProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
bool blitTexture(GrSurfaceProxyView view, const SkIRect& srcRect, const SkIPoint& dstPoint);
/**
* Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the

View File

@ -426,7 +426,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
} else {
SkIRect srcRect = SkIRect::MakeWH(srcInfo.width(), srcInfo.height());
SkIPoint dstPoint = SkIPoint::Make(pt.fX, pt.fY);
if (!this->copy(tempProxy.get(), srcRect, dstPoint)) {
if (!this->copy(tempProxy.get(), tempOrigin, srcRect, dstPoint)) {
return false;
}
}
@ -470,7 +470,8 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
srcColorType, src, rowBytes);
}
bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
bool GrSurfaceContext::copy(GrSurfaceProxy* src, GrSurfaceOrigin origin, const SkIRect& srcRect,
const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
@ -479,9 +480,8 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
const GrCaps* caps = fContext->priv().caps();
SkASSERT(src->backendFormat().textureType() != GrTextureType::kExternal);
SkASSERT(src->origin() == this->asSurfaceProxy()->origin());
SkASSERT(src->textureSwizzle() == this->asSurfaceProxy()->textureSwizzle());
SkASSERT(src->backendFormat() == this->asSurfaceProxy()->backendFormat());
SkASSERT(origin == this->origin());
if (this->asSurfaceProxy()->framebufferOnly()) {
return false;
@ -493,7 +493,7 @@ bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const S
// The swizzle doesn't matter for copies and it is not used.
return this->drawingManager()->newCopyRenderTask(
GrSurfaceProxyView(sk_ref_sp(src), src->origin(), GrSwizzle()), srcRect,
GrSurfaceProxyView(sk_ref_sp(src), origin, GrSwizzle()), srcRect,
this->readSurfaceView(), dstPoint);
}

View File

@ -120,12 +120,13 @@ public:
const GrSurfaceContextPriv surfPriv() const;
#if GR_TEST_UTILS
bool testCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
return this->copy(src, srcRect, dstPoint);
bool testCopy(GrSurfaceProxy* src, GrSurfaceOrigin origin, const SkIRect& srcRect,
const SkIPoint& dstPoint) {
return this->copy(src, origin, srcRect, dstPoint);
}
bool testCopy(GrSurfaceProxy* src) {
return this->copy(src);
bool testCopy(GrSurfaceProxy* src, GrSurfaceOrigin origin) {
return this->copy(src, origin, SkIRect::MakeSize(src->dimensions()), SkIPoint::Make(0, 0));
}
#endif
@ -182,11 +183,8 @@ private:
* regions will not be shifted. The 'src' must have the same origin as the backing proxy
* of fSurfaceContext.
*/
bool copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
bool copy(GrSurfaceProxy* src) {
return this->copy(src, SkIRect::MakeSize(src->dimensions()), SkIPoint::Make(0, 0));
}
bool copy(GrSurfaceProxy* src, GrSurfaceOrigin origin, const SkIRect& srcRect,
const SkIPoint& dstPoint);
GrColorInfo fColorInfo;

View File

@ -313,7 +313,7 @@ GrSurfaceProxyView GrSurfaceProxy::Copy(GrRecordingContext* context,
GrRenderable::kNo, 1, mipMapped,
src->isProtected(), origin, srcColorType,
kUnknown_SkAlphaType, nullptr, fit, budgeted);
if (dstContext && dstContext->copy(src, srcRect, dstPoint)) {
if (dstContext && dstContext->copy(src, origin, srcRect, dstPoint)) {
return dstContext->readSurfaceView();
}
}
@ -322,7 +322,10 @@ GrSurfaceProxyView GrSurfaceProxy::Copy(GrRecordingContext* context,
{width, height}, format, 1,
mipMapped, src->isProtected(), origin,
budgeted, nullptr);
if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(src->backendFormat(),
srcColorType);
GrSurfaceProxyView view(sk_ref_sp(src), origin, swizzle);
if (dstContext && dstContext->blitTexture(std::move(view), srcRect, dstPoint)) {
return dstContext->readSurfaceView();
}
}

View File

@ -227,7 +227,7 @@ void SkGpuDevice::replaceRenderTargetContext(std::unique_ptr<GrRenderTargetConte
}
SkASSERT(fRenderTargetContext->asTextureProxy());
SkAssertResult(rtc->blitTexture(fRenderTargetContext->asTextureProxy(),
SkAssertResult(rtc->blitTexture(fRenderTargetContext->readSurfaceView(),
SkIRect::MakeWH(this->width(), this->height()),
SkIPoint::Make(0,0)));
}

View File

@ -115,11 +115,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
bool result = false;
if (sOrigin == dOrigin) {
result = dstContext->testCopy(src.get(), srcRect, dstPoint);
result = dstContext->testCopy(src.get(), sOrigin, srcRect,
dstPoint);
} else if (dRenderable == GrRenderable::kYes) {
SkASSERT(dstContext->asRenderTargetContext());
GrSwizzle srcSwizzle = context->priv().caps()->getReadSwizzle(
src->backendFormat(), grColorType);
GrSurfaceProxyView view(std::move(src), sOrigin, srcSwizzle);
result = dstContext->asRenderTargetContext()->blitTexture(
src.get(), srcRect, dstPoint);
std::move(view), srcRect, dstPoint);
}
bool expectedResult = true;

View File

@ -420,7 +420,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
auto[copySrc, grCT] = maker.view(GrMipMapped::kNo);
REPORTER_ASSERT(reporter, copySrc.proxy());
auto copyResult = surfContext->testCopy(copySrc.proxy());
auto copyResult = surfContext->testCopy(copySrc.proxy(), copySrc.origin());
REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
// Try the low level copy.
context->flush();
@ -815,7 +815,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleStateTest, reporter, contextInfo) {
auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(
std::move(idleTexture), GrColorType::kRGBA_8888, rtc->asSurfaceProxy()->origin());
context->flush();
SkAssertResult(rtc->testCopy(proxy.get()));
SkAssertResult(rtc->testCopy(proxy.get(), rtc->asSurfaceProxy()->origin()));
proxy.reset();
REPORTER_ASSERT(reporter, flags == 0);

View File

@ -119,7 +119,7 @@ static void test_copy_to_surface(skiatest::Reporter* reporter,
pixels.get(), 0);
// If this assert ever fails we can add a fallback to do copy as draw, but until then we can
// be more restrictive.
SkAssertResult(dstContext->testCopy(src.get()));
SkAssertResult(dstContext->testCopy(src.get(), origin));
TestReadPixels(reporter, dstContext, pixels.get(), testName);
}
}