From cd657f1d9708c04cd67cfc753464accc6bc3cb5c Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 4 Apr 2019 14:24:28 +0000 Subject: [PATCH] Revert "Stop using pendingIO in read/writeSurfacePixels" This reverts commit 76cf552e2854e78a430fb51de040e5eb70387bfe. Reason for revert: Maybe breaking some bots Original change's description: > Stop using pendingIO in read/writeSurfacePixels > > This changes the implementation to always flush for these operations. > Once partial DAG flushes are implemented this behavior will be better than the old method. > > Change-Id: I1f9edd33dcf5aa15cc5dcdf8f0e06a3b3cd88f48 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205584 > Reviewed-by: Brian Salomon > Commit-Queue: Robert Phillips TBR=bsalomon@google.com,robertphillips@google.com Change-Id: If3e8cc9a6e92b98f85bc3faf2b99fba7395ec946 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206067 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- src/gpu/GrContextPriv.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp index 98820c37a9..2b9d1e7ca1 100644 --- a/src/gpu/GrContextPriv.cpp +++ b/src/gpu/GrContextPriv.cpp @@ -304,13 +304,12 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top, ASSERT_OWNED_PROXY_PRIV(src->asSurfaceProxy()); GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "readSurfacePixels", fContext); - GrSurfaceProxy* srcProxy = src->asSurfaceProxy(); - // MDB TODO: delay this instantiation until later in the method - if (!srcProxy->instantiate(this->resourceProvider())) { + if (!src->asSurfaceProxy()->instantiate(this->resourceProvider(), true)) { return false; } + GrSurfaceProxy* srcProxy = src->asSurfaceProxy(); GrSurface* srcSurface = srcProxy->peekSurface(); if (!GrSurfacePriv::AdjustReadPixelParams(srcSurface->width(), srcSurface->height(), @@ -451,7 +450,9 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top, sk_bzero(buffer, tempPixmap.computeByteSize()); } - this->flush(srcProxy); + if (srcSurface->surfacePriv().hasPendingWrite()) { + this->flush(nullptr); // MDB TODO: tighten this + } if (!fContext->fGpu->readPixels(srcSurface, left, top, width, height, allowedColorType, buffer, rowBytes)) { @@ -492,11 +493,11 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top, return false; } - GrSurfaceProxy* dstProxy = dst->asSurfaceProxy(); - if (!dstProxy->instantiate(this->resourceProvider())) { + if (!dst->asSurfaceProxy()->instantiate(this->resourceProvider(), true)) { return false; } + GrSurfaceProxy* dstProxy = dst->asSurfaceProxy(); GrSurface* dstSurface = dstProxy->peekSurface(); if (!GrSurfacePriv::AdjustWritePixelParams(dstSurface->width(), dstSurface->height(), @@ -579,13 +580,10 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top, dst->asRenderTargetContext()->fillRectToRect( GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), SkRect::MakeXYWH(left, top, width, height), SkRect::MakeWH(width, height)); + return true; } else { - if (!dst->copy(tempProxy.get(), SkIRect::MakeWH(width, height), {left, top})) { - return false; - } + return dst->copy(tempProxy.get(), SkIRect::MakeWH(width, height), {left, top}); } - - return true; } bool convert = premul || needColorConversion; @@ -647,7 +645,9 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top, top = dstSurface->height() - top - height; } - this->flush(dstProxy); + if (dstSurface->surfacePriv().hasPendingIO()) { + this->flush(nullptr); // MDB TODO: tighten this + } return this->getGpu()->writePixels(dstSurface, left, top, width, height, srcColorType, buffer, rowBytes);