From 33f8315b746693bf200f305f46740e5d4b1fb161 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 18 May 2017 20:57:43 +0000 Subject: Revert "Update clearOp for split-OpList world" This reverts commit 7f1ce29c9bb9be8b2d8dbf9a99f14f74d5dc6d80. Reason for revert: Maybe causing problems in imagemakewithfilter & dropshadowimagefilter Original change's description: > Update clearOp for split-OpList world > > It would reduce a lot of noise if the GrRenderTargetOpList kept a pointer to the GrCaps but, for now, I'm trying to shrink the GrRTOpList, not expand it. > > Change-Id: Ieed56fa2a41a3fb20234e26552ae2d301147e4f2 > Reviewed-on: https://skia-review.googlesource.com/17323 > Reviewed-by: Brian Salomon > Commit-Queue: Robert Phillips > TBR=bsalomon@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ib23ce4515d9427759ebd2b6d4c9d3a670f00a153 Reviewed-on: https://skia-review.googlesource.com/17326 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- src/gpu/ops/GrClearOp.h | 57 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 13 deletions(-) (limited to 'src/gpu/ops') diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h index dca7afc04d..b18332fa21 100644 --- a/src/gpu/ops/GrClearOp.h +++ b/src/gpu/ops/GrClearOp.h @@ -9,30 +9,49 @@ #define GrClearOp_DEFINED #include "GrFixedClip.h" +#include "GrGpu.h" #include "GrGpuCommandBuffer.h" #include "GrOp.h" #include "GrOpFlushState.h" +#include "GrRenderTarget.h" +#include "GrRenderTargetContext.h" #include "GrResourceProvider.h" class GrClearOp final : public GrOp { public: DEFINE_OP_CLASS_ID + // MDB TODO: replace the renderTargetContext with just the renderTargetProxy. + // For now, we need the renderTargetContext for its accessRenderTarget powers. static std::unique_ptr Make(const GrFixedClip& clip, GrColor color, - GrSurfaceProxy* dstProxy) { - const SkIRect rect = SkIRect::MakeWH(dstProxy->width(), dstProxy->height()); - if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) { + GrRenderTargetContext* rtc) { + const SkIRect rtRect = SkIRect::MakeWH(rtc->width(), rtc->height()); + if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rtRect)) { return nullptr; } - return std::unique_ptr(new GrClearOp(clip, color, dstProxy)); + // MDB TODO: remove this. In this hybrid state we need to be sure the RT is instantiable + // so it can carry the IO refs. In the future we will just get the proxy and + // it carry the IO refs. + if (!rtc->accessRenderTarget()) { + return nullptr; + } + + return std::unique_ptr(new GrClearOp(clip, color, rtc)); } + // MDB TODO: replace the renderTargetContext with just the renderTargetProxy. static std::unique_ptr Make(const SkIRect& rect, GrColor color, + GrRenderTargetContext* rtc, bool fullScreen) { SkASSERT(fullScreen || !rect.isEmpty()); - return std::unique_ptr(new GrClearOp(rect, color, fullScreen)); + // MDB TODO: remove this. See above comment. + if (!rtc->accessRenderTarget()) { + return nullptr; + } + + return std::unique_ptr(new GrClearOp(rect, color, rtc, fullScreen)); } const char* name() const override { return "Clear"; } @@ -40,7 +59,9 @@ public: SkString dumpInfo() const override { SkString string; string.append(INHERITED::dumpInfo()); - string.appendf("Scissor [ "); + string.appendf("rtID: %d proxyID: %d Scissor [", + fRenderTarget.get()->uniqueID().asUInt(), + fProxyUniqueID.asUInt()); if (fClip.scissorEnabled()) { const SkIRect& r = fClip.scissorRect(); string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); @@ -55,11 +76,13 @@ public: void setColor(GrColor color) { fColor = color; } private: - GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* proxy) + GrClearOp(const GrFixedClip& clip, GrColor color, GrRenderTargetContext* rtc) : INHERITED(ClassID()) , fClip(clip) - , fColor(color) { + , fColor(color) + , fProxyUniqueID(rtc->asSurfaceProxy()->uniqueID()) { + GrSurfaceProxy* proxy = rtc->asSurfaceProxy(); const SkIRect rtRect = SkIRect::MakeWH(proxy->width(), proxy->height()); if (fClip.scissorEnabled()) { // Don't let scissors extend outside the RT. This may improve op combining. @@ -74,17 +97,20 @@ private: } this->setBounds(SkRect::Make(fClip.scissorEnabled() ? fClip.scissorRect() : rtRect), HasAABloat::kNo, IsZeroArea::kNo); + fRenderTarget.reset(rtc->accessRenderTarget()); } - GrClearOp(const SkIRect& rect, GrColor color, bool fullScreen) + GrClearOp(const SkIRect& rect, GrColor color, GrRenderTargetContext* rtc, bool fullScreen) : INHERITED(ClassID()) , fClip(GrFixedClip(rect)) - , fColor(color) { + , fColor(color) + , fProxyUniqueID(rtc->asSurfaceProxy()->uniqueID()) { if (fullScreen) { fClip.disableScissor(); } this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsZeroArea::kNo); + fRenderTarget.reset(rtc->accessRenderTarget()); } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { @@ -92,6 +118,8 @@ private: // contains the old clear, or when the new clear is a subset of the old clear and is the // same color. GrClearOp* cb = t->cast(); + SkASSERT(cb->fRenderTarget == fRenderTarget); + SkASSERT(cb->fProxyUniqueID == fProxyUniqueID); if (fClip.windowRectsState() != cb->fClip.windowRectsState()) { return false; } @@ -116,14 +144,17 @@ private: void onPrepare(GrOpFlushState*) override {} void onExecute(GrOpFlushState* state) override { - SkASSERT(state->drawOpArgs().fRenderTarget); - - state->commandBuffer()->clear(state->drawOpArgs().fRenderTarget, fClip, fColor); + // MDB TODO: instantiate the renderTarget from the proxy in here + state->commandBuffer()->clear(fRenderTarget.get(), fClip, fColor); } GrFixedClip fClip; GrColor fColor; + // MDB TODO: remove this. When the renderTargetProxy carries the refs this will be redundant. + GrSurfaceProxy::UniqueID fProxyUniqueID; + GrPendingIOResource fRenderTarget; + typedef GrOp INHERITED; }; -- cgit v1.2.3