aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-06 11:08:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-06 21:59:04 +0000
commitb9a02a131eba272fbcae320c2bd6c0d668162c2e (patch)
tree2b9c50ff2ff0e1944b7150a6bc2d153a534d0d9e /src/gpu
parent21bd3e4b11b001748d5533eb3d7ee5682b89aa68 (diff)
Update stencil ops to have a parallel proxyID
Change-Id: I842c7f2011c8b9d4487cec4349de8b77f326a381 Reviewed-on: https://skia-review.googlesource.com/11360 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrRenderTargetContext.cpp17
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp9
-rw-r--r--src/gpu/GrRenderTargetOpList.h5
-rw-r--r--src/gpu/GrResourceProvider.cpp7
-rw-r--r--src/gpu/GrResourceProvider.h2
-rw-r--r--src/gpu/ops/GrClearStencilClipOp.h39
-rw-r--r--src/gpu/ops/GrStencilPathOp.h37
7 files changed, 69 insertions, 47 deletions
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 76a67c083e..e7a9022c0c 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -25,6 +25,7 @@
#include "effects/GrRRectEffect.h"
#include "instanced/InstancedRendering.h"
#include "ops/GrClearOp.h"
+#include "ops/GrClearStencilClipOp.h"
#include "ops/GrDrawOp.h"
#include "ops/GrDrawAtlasOp.h"
#include "ops/GrDrawVerticesOp.h"
@@ -656,12 +657,13 @@ void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i
"GrRenderTargetContextPriv::clearStencilClip");
AutoCheckFlush acf(fRenderTargetContext->drawingManager());
- // TODO: This needs to be fixed up since it ends the deferral of the GrRenderTarget.
- if (!fRenderTargetContext->accessRenderTarget()) {
+
+ std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make(clip, insideStencilMask,
+ fRenderTargetContext));
+ if (!op) {
return;
}
- fRenderTargetContext->getOpList()->clearStencilClip(clip, insideStencilMask,
- fRenderTargetContext);
+ fRenderTargetContext->getOpList()->addOp(std::move(op), fRenderTargetContext);
}
void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
@@ -713,10 +715,13 @@ void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
appliedClip.hasStencilClip(),
stencilAttachment->bits(),
appliedClip.scissorState(),
- fRenderTargetContext->accessRenderTarget(),
+ fRenderTargetContext,
path);
+ if (!op) {
+ return;
+ }
op->setClippedBounds(bounds);
- fRenderTargetContext->getOpList()->recordOp(std::move(op), fRenderTargetContext);
+ fRenderTargetContext->getOpList()->addOp(std::move(op), fRenderTargetContext);
}
void GrRenderTargetContextPriv::stencilRect(const GrClip& clip,
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index bbe1055f20..daf03227ee 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -401,12 +401,3 @@ void GrRenderTargetOpList::forwardCombine() {
}
}
-///////////////////////////////////////////////////////////////////////////////
-
-void GrRenderTargetOpList::clearStencilClip(const GrFixedClip& clip,
- bool insideStencilMask,
- GrRenderTargetContext* renderTargetContext) {
- this->recordOp(GrClearStencilClipOp::Make(clip, insideStencilMask,
- renderTargetContext->accessRenderTarget()),
- renderTargetContext);
-}
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index b527b64b95..8e00df8c16 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -115,7 +115,7 @@ public:
SkDEBUGCODE(void validateTargetsSingleRenderTarget() const;)
private:
- friend class GrRenderTargetContextPriv; // for clearStencilClip and stencil clip state.
+ friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive
struct RecordedOp {
RecordedOp(std::unique_ptr<GrOp> op, GrRenderTarget* rt, const GrAppliedClip* appliedClip,
@@ -139,9 +139,6 @@ private:
void forwardCombine();
- // Used only via GrRenderTargetContextPriv.
- void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTargetContext*);
-
// If this returns true then b has been merged into a's op.
bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
const DstTexture* bDstTexture);
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 5c4ab9c457..dafa27bcf2 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -139,12 +139,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk
GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(0 == flags || kNoPendingIO_Flag == flags);
- return this->internalCreateApproxTexture(desc, flags);
-}
-GrTexture* GrResourceProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc,
- uint32_t scratchFlags) {
- ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
return nullptr;
}
@@ -152,7 +147,7 @@ GrTexture* GrResourceProvider::internalCreateApproxTexture(const GrSurfaceDesc&
if (GrPixelConfigIsCompressed(desc.fConfig)) {
return nullptr;
} else {
- return this->refScratchTexture(desc, scratchFlags);
+ return this->refScratchTexture(desc, flags);
}
}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 5cb64e092e..91dd09f01d 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -237,8 +237,6 @@ public:
const GrCaps* caps() const { return fCaps.get(); }
private:
- GrTexture* internalCreateApproxTexture(const GrSurfaceDesc& desc, uint32_t scratchTextureFlags);
-
GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key);
void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) {
SkASSERT(key.isValid());
diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h
index ef46a4c6a9..1b7d103998 100644
--- a/src/gpu/ops/GrClearStencilClipOp.h
+++ b/src/gpu/ops/GrClearStencilClipOp.h
@@ -19,9 +19,19 @@ class GrClearStencilClipOp 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<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask,
- GrRenderTarget* rt) {
- return std::unique_ptr<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, rt));
+ GrRenderTargetContext* rtc) {
+
+ // 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"; }
@@ -32,21 +42,27 @@ public:
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("], IC: %d, RT: %d", fInsideStencilMask,
- fRenderTarget.get()->uniqueID().asUInt());
+ string.appendf("], IC: %d, rtID: %d proxyID: %d",
+ fInsideStencilMask,
+ fRenderTarget.get()->uniqueID().asUInt(),
+ fProxyUniqueID.asUInt());
string.append(INHERITED::dumpInfo());
return string;
}
private:
- GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, GrRenderTarget* rt)
+ GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
+ GrRenderTargetContext* rtc)
: INHERITED(ClassID())
, fClip(clip)
, fInsideStencilMask(insideStencilMask)
- , fRenderTarget(rt) {
- const SkRect& bounds = fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect())
- : SkRect::MakeIWH(rt->width(), rt->height());
+ , fProxyUniqueID(rtc->asSurfaceProxy()->uniqueID()) {
+ const SkRect& bounds = fClip.scissorEnabled()
+ ? SkRect::Make(fClip.scissorRect())
+ : SkRect::MakeIWH(rtc->width(), rtc->height());
this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
+
+ fRenderTarget.reset(rtc->accessRenderTarget());
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
@@ -54,11 +70,14 @@ private:
void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state) override {
+ // MDB TODO: instantiate the renderTarget from the proxy in here
state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask);
}
- const GrFixedClip fClip;
- const bool fInsideStencilMask;
+ const GrFixedClip fClip;
+ 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;
diff --git a/src/gpu/ops/GrStencilPathOp.h b/src/gpu/ops/GrStencilPathOp.h
index ac19b5abec..93357f74fc 100644
--- a/src/gpu/ops/GrStencilPathOp.h
+++ b/src/gpu/ops/GrStencilPathOp.h
@@ -20,24 +20,36 @@ class GrStencilPathOp 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<GrOp> Make(const SkMatrix& viewMatrix,
bool useHWAA,
GrPathRendering::FillType fillType,
bool hasStencilClip,
int numStencilBits,
const GrScissorState& scissor,
- GrRenderTarget* renderTarget,
+ GrRenderTargetContext* renderTargetContext,
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,
hasStencilClip, numStencilBits, scissor,
- renderTarget, path));
+ renderTargetContext, path));
}
const char* name() const override { return "StencilPathOp"; }
SkString dumpInfo() const override {
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());
return string;
}
@@ -49,7 +61,7 @@ private:
bool hasStencilClip,
int numStencilBits,
const GrScissorState& scissor,
- GrRenderTarget* renderTarget,
+ GrRenderTargetContext* renderTargetContext,
const GrPath* path)
: INHERITED(ClassID())
, fViewMatrix(viewMatrix)
@@ -57,9 +69,11 @@ private:
, fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip,
numStencilBits)
, fScissor(scissor)
- , fRenderTarget(renderTarget)
+ , fProxyUniqueID(renderTargetContext->asSurfaceProxy()->uniqueID())
, fPath(path) {
this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
+
+ fRenderTarget.reset(renderTargetContext->accessRenderTarget());
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
@@ -67,17 +81,20 @@ private:
void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state) override {
+ // MDB TODO: instantiate the renderTarget from the proxy in here
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
&fScissor, &fStencil);
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
}
- SkMatrix fViewMatrix;
- bool fUseHWAA;
- GrStencilSettings fStencil;
- GrScissorState fScissor;
+ SkMatrix fViewMatrix;
+ bool fUseHWAA;
+ GrStencilSettings fStencil;
+ GrScissorState fScissor;
+ // MDB TODO: remove this. When the renderTargetProxy carries the refs this will be redundant.
+ GrSurfaceProxy::UniqueID fProxyUniqueID;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
- GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
+ GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
typedef GrOp INHERITED;
};