Update more GrOps to split-opList world

Change-Id: I568e52f58372597abc2920aaee346a9731452d18
Reviewed-on: https://skia-review.googlesource.com/17324
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Robert Phillips 2017-06-01 08:48:19 -04:00 committed by Skia Commit-Bot
parent baf41bd1c8
commit 2f4ddf6964
4 changed files with 30 additions and 78 deletions

View File

@ -605,8 +605,9 @@ void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i
AutoCheckFlush acf(fRenderTargetContext->drawingManager()); AutoCheckFlush acf(fRenderTargetContext->drawingManager());
std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make(clip, insideStencilMask, std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make(
fRenderTargetContext)); clip, insideStencilMask,
fRenderTargetContext->fRenderTargetProxy.get()));
if (!op) { if (!op) {
return; return;
} }
@ -662,7 +663,6 @@ void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
appliedClip.hasStencilClip(), appliedClip.hasStencilClip(),
stencilAttachment->bits(), stencilAttachment->bits(),
appliedClip.scissorState(), appliedClip.scissorState(),
fRenderTargetContext,
path); path);
if (!op) { if (!op) {
return; return;

View File

@ -9,30 +9,17 @@
#define GrClearStencilClipOp_DEFINED #define GrClearStencilClipOp_DEFINED
#include "GrFixedClip.h" #include "GrFixedClip.h"
#include "GrGpu.h"
#include "GrGpuCommandBuffer.h" #include "GrGpuCommandBuffer.h"
#include "GrOp.h" #include "GrOp.h"
#include "GrOpFlushState.h" #include "GrOpFlushState.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetContext.h"
class GrClearStencilClipOp final : public GrOp { class GrClearStencilClipOp final : public GrOp {
public: public:
DEFINE_OP_CLASS_ID 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<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask, static std::unique_ptr<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask,
GrRenderTargetContext* rtc) { GrRenderTargetProxy* proxy) {
return std::unique_ptr<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, proxy));
// 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<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, rtc));
} }
const char* name() const override { return "ClearStencilClip"; } const char* name() const override { return "ClearStencilClip"; }
@ -42,28 +29,24 @@ public:
if (fClip.scissorEnabled()) { if (fClip.scissorEnabled()) {
const SkIRect& r = fClip.scissorRect(); const SkIRect& r = fClip.scissorRect();
string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
} else {
string.append("disabled");
} }
string.appendf("], IC: %d, rtID: %d proxyID: %d", string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false");
fInsideStencilMask,
fRenderTarget.get()->uniqueID().asUInt(),
fProxyUniqueID.asUInt());
string.append(INHERITED::dumpInfo()); string.append(INHERITED::dumpInfo());
return string; return string;
} }
private: private:
GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
GrRenderTargetContext* rtc) GrRenderTargetProxy* proxy)
: INHERITED(ClassID()) : INHERITED(ClassID())
, fClip(clip) , fClip(clip)
, fInsideStencilMask(insideStencilMask) , fInsideStencilMask(insideStencilMask) {
, fProxyUniqueID(rtc->asSurfaceProxy()->uniqueID()) {
const SkRect& bounds = fClip.scissorEnabled() const SkRect& bounds = fClip.scissorEnabled()
? SkRect::Make(fClip.scissorRect()) ? SkRect::Make(fClip.scissorRect())
: SkRect::MakeIWH(rtc->width(), rtc->height()); : SkRect::MakeIWH(proxy->width(), proxy->height());
this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
fRenderTarget.reset(rtc->accessRenderTarget());
} }
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
@ -71,15 +54,14 @@ private:
void onPrepare(GrOpFlushState*) override {} void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state) override { void onExecute(GrOpFlushState* state) override {
// MDB TODO: instantiate the renderTarget from the proxy in here SkASSERT(state->drawOpArgs().fRenderTarget);
state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask);
state->commandBuffer()->clearStencilClip(state->drawOpArgs().fRenderTarget,
fClip, fInsideStencilMask);
} }
const GrFixedClip fClip; const GrFixedClip fClip;
const bool fInsideStencilMask; const bool fInsideStencilMask;
// MDB TODO: remove this. When the renderTargetProxy carries the refs this will be redundant.
GrSurfaceProxy::UniqueID fProxyUniqueID;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
typedef GrOp INHERITED; typedef GrOp INHERITED;
}; };

View File

@ -26,14 +26,11 @@ public:
SkString dumpInfo() const override { SkString dumpInfo() const override {
SkString string; SkString string;
string.append(INHERITED::dumpInfo()); string.append(INHERITED::dumpInfo());
string.printf("proxyID: %d\n", fRenderTargetProxy.get()->uniqueID().asUInt());
return string; return string;
} }
private: private:
GrDiscardOp(GrRenderTargetProxy* proxy) GrDiscardOp(GrRenderTargetProxy* proxy) : INHERITED(ClassID()) {
: INHERITED(ClassID())
, fRenderTargetProxy(proxy) {
this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()), this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()),
HasAABloat::kNo, IsZeroArea::kNo); HasAABloat::kNo, IsZeroArea::kNo);
} }
@ -43,17 +40,11 @@ private:
void onPrepare(GrOpFlushState*) override {} void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state) override { void onExecute(GrOpFlushState* state) override {
GrRenderTarget* rt = fRenderTargetProxy.get()->instantiateRenderTarget( SkASSERT(state->drawOpArgs().fRenderTarget);
state->resourceProvider());
if (!rt) {
return;
}
state->commandBuffer()->discard(rt); state->commandBuffer()->discard(state->drawOpArgs().fRenderTarget);
} }
GrPendingIOResource<GrRenderTargetProxy, kWrite_GrIOType> fRenderTargetProxy;
typedef GrOp INHERITED; typedef GrOp INHERITED;
}; };

View File

@ -8,40 +8,27 @@
#ifndef GrStencilPathOp_DEFINED #ifndef GrStencilPathOp_DEFINED
#define GrStencilPathOp_DEFINED #define GrStencilPathOp_DEFINED
#include "GrGpu.h"
#include "GrOp.h" #include "GrOp.h"
#include "GrOpFlushState.h" #include "GrOpFlushState.h"
#include "GrPath.h" #include "GrPath.h"
#include "GrPathRendering.h" #include "GrPathRendering.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetContext.h"
#include "GrStencilSettings.h" #include "GrStencilSettings.h"
class GrStencilPathOp final : public GrOp { class GrStencilPathOp final : public GrOp {
public: public:
DEFINE_OP_CLASS_ID 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<GrOp> Make(const SkMatrix& viewMatrix, static std::unique_ptr<GrOp> Make(const SkMatrix& viewMatrix,
bool useHWAA, bool useHWAA,
GrPathRendering::FillType fillType, GrPathRendering::FillType fillType,
bool hasStencilClip, bool hasStencilClip,
int numStencilBits, int numStencilBits,
const GrScissorState& scissor, const GrScissorState& scissor,
GrRenderTargetContext* renderTargetContext,
const GrPath* path) { const GrPath* path) {
// 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 will carry the IO refs.
if (!renderTargetContext->accessRenderTarget()) {
return nullptr;
}
return std::unique_ptr<GrOp>(new GrStencilPathOp(viewMatrix, useHWAA, fillType, return std::unique_ptr<GrOp>(new GrStencilPathOp(viewMatrix, useHWAA, fillType,
hasStencilClip, numStencilBits, scissor, hasStencilClip, numStencilBits, scissor,
renderTargetContext, path)); path));
} }
const char* name() const override { return "StencilPathOp"; } const char* name() const override { return "StencilPathOp"; }
@ -49,8 +36,6 @@ public:
SkString dumpInfo() const override { SkString dumpInfo() const override {
SkString string; SkString string;
string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA); string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA);
string.appendf("rtID: %d proxyID: %d",
fRenderTarget.get()->uniqueID().asUInt(), fProxyUniqueID.asUInt());
string.append(INHERITED::dumpInfo()); string.append(INHERITED::dumpInfo());
return string; return string;
} }
@ -62,7 +47,6 @@ private:
bool hasStencilClip, bool hasStencilClip,
int numStencilBits, int numStencilBits,
const GrScissorState& scissor, const GrScissorState& scissor,
GrRenderTargetContext* renderTargetContext,
const GrPath* path) const GrPath* path)
: INHERITED(ClassID()) : INHERITED(ClassID())
, fViewMatrix(viewMatrix) , fViewMatrix(viewMatrix)
@ -70,11 +54,8 @@ private:
, fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip, , fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip,
numStencilBits) numStencilBits)
, fScissor(scissor) , fScissor(scissor)
, fProxyUniqueID(renderTargetContext->asSurfaceProxy()->uniqueID())
, fPath(path) { , fPath(path) {
this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo); this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
fRenderTarget.reset(renderTargetContext->accessRenderTarget());
} }
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; } bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
@ -82,20 +63,18 @@ private:
void onPrepare(GrOpFlushState*) override {} void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state) override { void onExecute(GrOpFlushState* state) override {
// MDB TODO: instantiate the renderTarget from the proxy in here SkASSERT(state->drawOpArgs().fRenderTarget);
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
&fScissor, &fStencil); GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fRenderTarget,
&fViewMatrix, &fScissor, &fStencil);
state->gpu()->pathRendering()->stencilPath(args, fPath.get()); state->gpu()->pathRendering()->stencilPath(args, fPath.get());
} }
SkMatrix fViewMatrix; SkMatrix fViewMatrix;
bool fUseHWAA; bool fUseHWAA;
GrStencilSettings fStencil; GrStencilSettings fStencil;
GrScissorState fScissor; GrScissorState fScissor;
// MDB TODO: remove this. When the renderTargetProxy carries the refs this will be redundant. GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
GrSurfaceProxy::UniqueID fProxyUniqueID;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
typedef GrOp INHERITED; typedef GrOp INHERITED;
}; };