From 0eed945294fa0b2dee7d971c16dc9beefab2ec1c Mon Sep 17 00:00:00 2001 From: kjlubick Date: Thu, 11 Feb 2016 12:05:24 -0800 Subject: Revert of Make copySurface work for texture dsts, return a bool, & add unit test. (patchset #6 id:100001 of https://codereview.chromium.org/1684313002/ ) Reason for revert: Copy surface tests are not happy for Windows, Android and probably others: https://uberchromegw.corp.google.com/i/client.skia.android/builders/Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Release/builds/4161 https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Win8-MSVC-ShuttleA-GPU-GTX960-x86_64-Release/builds/3694 Original issue's description: > Make copySurface work for texture dsts, return a bool, & add unit test. > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1684313002 > > Committed: https://skia.googlesource.com/skia/+/7ea5e28065e5eb797e95f5d81c1a65cf3209d741 TBR=robertphillips@google.com,bsalomon@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1690053002 --- src/gpu/GrContext.cpp | 35 +++++++++++++--------------------- src/gpu/GrDrawContext.cpp | 6 +++--- src/gpu/GrDrawTarget.cpp | 14 ++++++-------- src/gpu/GrDrawTarget.h | 2 +- src/gpu/SkGrPixelRef.cpp | 6 +++--- src/gpu/batches/GrCopySurfaceBatch.cpp | 19 +++++++++++------- src/gpu/batches/GrCopySurfaceBatch.h | 10 ---------- src/image/SkImage_Gpu.cpp | 3 +-- 8 files changed, 39 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 296dfb9e70..187a3ca37a 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -18,7 +18,6 @@ #include "SkConfig8888.h" #include "SkGrPriv.h" -#include "batches/GrCopySurfaceBatch.h" #include "effects/GrConfigConversionEffect.h" #include "text/GrTextBlobCache.h" @@ -510,42 +509,34 @@ void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) { } } -bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, - const SkIPoint& dstPoint) { +void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, + const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { ASSERT_SINGLE_OWNER - RETURN_FALSE_IF_ABANDONED + RETURN_IF_ABANDONED GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface"); if (!src || !dst) { - return false; + return; } ASSERT_OWNED_RESOURCE(src); ASSERT_OWNED_RESOURCE(dst); + // Since we're going to the draw target and not GPU, no need to check kNoFlush + // here. if (!dst->asRenderTarget()) { - SkIRect clippedSrcRect; - SkIPoint clippedDstPoint; - if (!GrCopySurfaceBatch::ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, - &clippedSrcRect, &clippedDstPoint)) { - return false; - } - // If we don't have an RT for the dst then we won't have a GrDrawContext to insert the - // the copy surface into. In the future we plan to have a more limited Context type - // (GrCopyContext?) that has the subset of GrDrawContext operations that should be - // allowed on textures that aren't render targets. - // For now we just flush any writes to the src and issue an immediate copy to the dst. - src->flushWrites(); - return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint); + return; } + SkAutoTUnref drawContext(this->drawContext(dst->asRenderTarget())); if (!drawContext) { - return false; + return; } - if (!drawContext->copySurface(src, srcRect, dstPoint)) { - return false; + drawContext->copySurface(src, srcRect, dstPoint); + + if (kFlushWrites_PixelOp & pixelOpsFlags) { + this->flush(); } - return true; } void GrContext::flushSurfaceWrites(GrSurface* surface) { diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index d971f58ece..f37c48c9f3 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -97,13 +97,13 @@ GrDrawTarget* GrDrawContext::getDrawTarget() { return fDrawTarget; } -bool GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { +void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { ASSERT_SINGLE_OWNER - RETURN_FALSE_IF_ABANDONED + RETURN_IF_ABANDONED SkDEBUGCODE(this->validate();) GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface"); - return this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint); + this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint); } void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 9f15c11508..b9dc794526 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -406,21 +406,19 @@ void GrDrawTarget::discard(GrRenderTarget* renderTarget) { //////////////////////////////////////////////////////////////////////////////// -bool GrDrawTarget::copySurface(GrSurface* dst, +void GrDrawTarget::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint); - if (!batch) { - return false; - } + if (batch) { #ifdef ENABLE_MDB - this->addDependency(src); + this->addDependency(src); #endif - this->recordBatch(batch); - batch->unref(); - return true; + this->recordBatch(batch); + batch->unref(); + } } template static bool intersect(const Left& a, const Right& b) { diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index a850efd842..55c11da667 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -144,7 +144,7 @@ public: * depending on the type of surface, configs, etc, and the backend-specific * limitations. */ - bool copySurface(GrSurface* dst, + void copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint); diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp index e48cbf5d15..3876f17411 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -84,10 +84,10 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp } // Blink is relying on the above copy being sent to GL immediately in the case when the source - // is a WebGL canvas backing store. We could have a TODO to remove this flush, but we have + // is a WebGL canvas backing store. We could have a TODO to remove this flush flag, but we have // a larger TODO to remove SkGrPixelRef entirely. - context->copySurface(dst, texture, srcRect, SkIPoint::Make(0,0)); - context->flushSurfaceWrites(dst); + context->copySurface(dst->asRenderTarget(), texture, srcRect, SkIPoint::Make(0,0), + GrContext::kFlushWrites_PixelOp); SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType, dstPT); diff --git a/src/gpu/batches/GrCopySurfaceBatch.cpp b/src/gpu/batches/GrCopySurfaceBatch.cpp index a59ed38f51..098f7c7704 100644 --- a/src/gpu/batches/GrCopySurfaceBatch.cpp +++ b/src/gpu/batches/GrCopySurfaceBatch.cpp @@ -9,12 +9,12 @@ #include "GrCopySurfaceBatch.h" // returns true if the read/written rect intersects the src/dst and false if not. -bool GrCopySurfaceBatch::ClipSrcRectAndDstPoint(const GrSurface* dst, - const GrSurface* src, - const SkIRect& srcRect, - const SkIPoint& dstPoint, - SkIRect* clippedSrcRect, - SkIPoint* clippedDstPoint) { +static bool clip_srcrect_and_dstpoint(const GrSurface* dst, + const GrSurface* src, + const SkIRect& srcRect, + const SkIPoint& dstPoint, + SkIRect* clippedSrcRect, + SkIPoint* clippedDstPoint) { *clippedSrcRect = srcRect; *clippedDstPoint = dstPoint; @@ -67,7 +67,12 @@ GrBatch* GrCopySurfaceBatch::Create(GrSurface* dst, GrSurface* src, const SkIRec SkIRect clippedSrcRect; SkIPoint clippedDstPoint; // If the rect is outside the src or dst then we've already succeeded. - if (!ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, &clippedSrcRect, &clippedDstPoint)) { + if (!clip_srcrect_and_dstpoint(dst, + src, + srcRect, + dstPoint, + &clippedSrcRect, + &clippedDstPoint)) { return nullptr; } return new GrCopySurfaceBatch(dst, src, clippedSrcRect, clippedDstPoint); diff --git a/src/gpu/batches/GrCopySurfaceBatch.h b/src/gpu/batches/GrCopySurfaceBatch.h index 3926643f8a..7bf8d8d8c2 100644 --- a/src/gpu/batches/GrCopySurfaceBatch.h +++ b/src/gpu/batches/GrCopySurfaceBatch.h @@ -17,16 +17,6 @@ class GrCopySurfaceBatch final : public GrBatch { public: DEFINE_BATCH_CLASS_ID - /** This should not really be exposed as Create() will apply this clipping, but there is - * currently a workaround in GrContext::copySurface() for non-render target dsts that relies - * on it. */ - static bool ClipSrcRectAndDstPoint(const GrSurface* dst, - const GrSurface* src, - const SkIRect& srcRect, - const SkIPoint& dstPoint, - SkIRect* clippedSrcRect, - SkIPoint* clippedDstPoint); - static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint); diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index c502fc0092..04939e36f1 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -326,8 +326,7 @@ GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); const SkIPoint dstP = SkIPoint::Make(0, 0); - ctx->copySurface(dst, src, srcR, dstP); - ctx->flushSurfaceWrites(dst); + ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); return dst; } -- cgit v1.2.3