Add "GrMipMapped" parameter to visitProxies
This will allow us to detect textures that need their mipmap levels
regenerated, and resolve them before executing the command buffer.
Bug: skia:
Change-Id: I65a1cd2b2d5ba2247d1c4a613ce9ba85b8d02377
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215142
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h
index d40377b..5e6e4ca 100644
--- a/src/gpu/GrAppliedClip.h
+++ b/src/gpu/GrAppliedClip.h
@@ -125,7 +125,7 @@
}
bool operator!=(const GrAppliedClip& that) const { return !(*this == that); }
- void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
+ void visitProxies(const GrOp::VisitProxyFunc& func) const {
for (const std::unique_ptr<GrFragmentProcessor>& fp : fClipCoverageFPs) {
if (fp) { // This might be called after detach.
fp->visitProxies(func);
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index b571724..217d56e 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -282,7 +282,7 @@
#ifdef SK_DEBUG
// OnFlush callbacks are already invoked during flush, and are therefore expected to
// handle resource allocation & usage on their own. (No deferred or lazy proxies!)
- onFlushOpList->visitProxies_debugOnly([](GrSurfaceProxy* p) {
+ onFlushOpList->visitProxies_debugOnly([](GrSurfaceProxy* p, GrMipMapped) {
SkASSERT(!p->asTextureProxy() || !p->asTextureProxy()->texPriv().isDeferred());
SkASSERT(GrSurfaceProxy::LazyState::kNot == p->lazyInstantiationState());
});
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 7205f08..a0bf114 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -47,10 +47,11 @@
return true;
}
-void GrFragmentProcessor::visitProxies(const std::function<void(GrSurfaceProxy*)>& func) {
+void GrFragmentProcessor::visitProxies(const GrOp::VisitProxyFunc& func) {
GrFragmentProcessor::TextureAccessIter iter(this);
while (const TextureSampler* sampler = iter.next()) {
- func(sampler->proxy());
+ bool mipped = (GrSamplerState::Filter::kMipMap == sampler->samplerState().filter());
+ func(sampler->proxy(), GrMipMapped(mipped));
}
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 434d888..9ba35af 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -10,6 +10,7 @@
#include "include/private/GrProxyRef.h"
#include "src/gpu/GrProcessor.h"
+#include "src/gpu/ops/GrOp.h"
class GrCoordTransform;
class GrGLSLFragmentProcessor;
@@ -242,7 +243,7 @@
&GrFragmentProcessor::numTextureSamplers,
&GrFragmentProcessor::textureSampler>;
- void visitProxies(const std::function<void(GrSurfaceProxy*)>& func);
+ void visitProxies(const GrOp::VisitProxyFunc& func);
protected:
enum OptimizationFlags : uint32_t {
diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h
index 6ac464e..cd67fd3 100644
--- a/src/gpu/GrProcessorSet.h
+++ b/src/gpu/GrProcessorSet.h
@@ -152,11 +152,12 @@
SkString dumpProcessors() const;
#endif
- void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
+ void visitProxies(const GrOp::VisitProxyFunc& func) const {
for (int i = 0; i < this->numFragmentProcessors(); ++i) {
GrFragmentProcessor::TextureAccessIter iter(this->fragmentProcessor(i));
while (const GrFragmentProcessor::TextureSampler* sampler = iter.next()) {
- func(sampler->proxy());
+ bool mipped = (GrSamplerState::Filter::kMipMap == sampler->samplerState().filter());
+ func(sampler->proxy(), GrMipMapped(mipped));
}
}
}
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 20f625b..8ce412c 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -138,7 +138,7 @@
op.visitProxies(func);
}
if (fDstProxy.proxy()) {
- func(fDstProxy.proxy());
+ func(fDstProxy.proxy(), GrMipMapped::kNo);
}
if (fAppliedClip) {
fAppliedClip->visitProxies(func);
@@ -593,7 +593,7 @@
void GrRenderTargetOpList::purgeOpsWithUninstantiatedProxies() {
bool hasUninstantiatedProxy = false;
- auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p) {
+ auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p, GrMipMapped) {
if (!p->isInstantiated()) {
hasUninstantiatedProxy = true;
}
@@ -611,7 +611,7 @@
bool GrRenderTargetOpList::onIsUsed(GrSurfaceProxy* proxyToCheck) const {
bool used = false;
- auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p) {
+ auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p, GrMipMapped) {
if (p == proxyToCheck) {
used = true;
}
@@ -650,7 +650,7 @@
alloc->incOps();
}
- auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p) {
+ auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipMapped) {
alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes
SkDEBUGCODE(, fTarget.get() == p));
};
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 475c088..8d266b3 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -62,7 +62,7 @@
bool onExecute(GrOpFlushState* flushState) override;
void addOp(std::unique_ptr<GrOp> op, const GrCaps& caps) {
- auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
+ auto addDependency = [ &caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, caps);
};
@@ -78,14 +78,14 @@
void addDrawOp(std::unique_ptr<GrDrawOp> op, const GrProcessorSet::Analysis& processorAnalysis,
GrAppliedClip&& clip, const DstProxy& dstProxy, const GrCaps& caps) {
- auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
+ auto addDependency = [ &caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, caps);
};
op->visitProxies(addDependency);
clip.visitProxies(addDependency);
if (dstProxy.proxy()) {
- addDependency(dstProxy.proxy());
+ addDependency(dstProxy.proxy(), GrMipMapped::kNo);
}
this->recordOp(std::move(op), processorAnalysis, clip.doesClip() ? &clip : nullptr,
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index c6d41c4..843537e 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -150,7 +150,7 @@
}
const GrCaps* caps = context->priv().caps();
- auto addDependency = [ caps, this ] (GrSurfaceProxy* p) {
+ auto addDependency = [ caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, *caps);
};
op->visitProxies(addDependency);
@@ -161,7 +161,7 @@
void GrTextureOpList::purgeOpsWithUninstantiatedProxies() {
bool hasUninstantiatedProxy = false;
- auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p) {
+ auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p, GrMipMapped) {
if (!p->isInstantiated()) {
hasUninstantiatedProxy = true;
}
@@ -182,7 +182,7 @@
bool GrTextureOpList::onIsUsed(GrSurfaceProxy* proxyToCheck) const {
bool used = false;
- auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p) {
+ auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p, GrMipMapped) {
if (p == proxyToCheck) {
used = true;
}
@@ -214,7 +214,7 @@
alloc->incOps();
}
- auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p) {
+ auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipMapped) {
alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes
SkDEBUGCODE(, p == fTarget.get()));
};
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.h b/src/gpu/ccpr/GrCCDrawPathsOp.h
index b61c8e3..45d1103 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.h
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.h
@@ -40,7 +40,7 @@
CombineResult onCombineIfPossible(GrOp*, const GrCaps&) override;
void visitProxies(const VisitProxyFunc& fn) const override {
for (const auto& range : fInstanceRanges) {
- fn(range.fAtlasProxy);
+ fn(range.fAtlasProxy, GrMipMapped::kNo);
}
fProcessors.visitProxies(fn);
}
diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp
index 11cd8e3..beeba6d 100644
--- a/src/gpu/ccpr/GrCCPerFlushResources.cpp
+++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp
@@ -72,7 +72,10 @@
}
const char* name() const override { return "CopyAtlasOp (CCPR)"; }
- void visitProxies(const VisitProxyFunc& fn) const override { fn(fSrcProxy.get()); }
+
+ void visitProxies(const VisitProxyFunc& fn) const override {
+ fn(fSrcProxy.get(), GrMipMapped::kNo);
+ }
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
SkASSERT(fSrcProxy);
diff --git a/src/gpu/ops/GrCopySurfaceOp.h b/src/gpu/ops/GrCopySurfaceOp.h
index 0b7f532..794a7f5 100644
--- a/src/gpu/ops/GrCopySurfaceOp.h
+++ b/src/gpu/ops/GrCopySurfaceOp.h
@@ -25,7 +25,9 @@
const char* name() const override { return "CopySurface"; }
- void visitProxies(const VisitProxyFunc& func) const override { func(fSrc.get()); }
+ void visitProxies(const VisitProxyFunc& func) const override {
+ func(fSrc.get(), GrMipMapped::kNo);
+ }
#ifdef SK_DEBUG
SkString dumpInfo() const override {
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 79cbc61..c133de4 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -171,7 +171,8 @@
const char* name() const override { return "NonAALatticeOp"; }
void visitProxies(const VisitProxyFunc& func) const override {
- func(fProxy.get());
+ bool mipped = (GrSamplerState::Filter::kMipMap == fFilter);
+ func(fProxy.get(), GrMipMapped(mipped));
fHelper.visitProxies(func);
}
diff --git a/src/gpu/ops/GrOp.h b/src/gpu/ops/GrOp.h
index 1c6f6e0..92a35a2 100644
--- a/src/gpu/ops/GrOp.h
+++ b/src/gpu/ops/GrOp.h
@@ -69,7 +69,7 @@
virtual const char* name() const = 0;
- typedef std::function<void(GrSurfaceProxy*)> VisitProxyFunc;
+ using VisitProxyFunc = std::function<void(GrSurfaceProxy*, GrMipMapped)>;
virtual void visitProxies(const VisitProxyFunc&) const {
// This default implementation assumes the op has no proxies
diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
index 9bd3902..3650fc5 100644
--- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
+++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
@@ -107,7 +107,7 @@
friend class GrSimpleMeshDrawOpHelper;
};
- void visitProxies(const std::function<void(GrSurfaceProxy*)>& func) const {
+ void visitProxies(const GrOp::VisitProxyFunc& func) const {
if (fProcessors) {
fProcessors->visitProxies(func);
}
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index e7f6a5a..db62c17 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -278,7 +278,7 @@
const sk_sp<GrTextureProxy>* proxies = fAtlas->getProxies();
for (uint32_t i = 0; i < fAtlas->numActivePages(); ++i) {
SkASSERT(proxies[i]);
- func(proxies[i].get());
+ func(proxies[i].get(), GrMipMapped::kNo);
}
}
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 11ee9e2..330ee88 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -193,7 +193,8 @@
void visitProxies(const VisitProxyFunc& func) const override {
for (unsigned p = 0; p < fProxyCnt; ++p) {
- func(fProxies[p].fProxy);
+ bool mipped = (GrSamplerState::Filter::kMipMap == this->filter());
+ func(fProxies[p].fProxy, GrMipMapped(mipped));
}
}
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 70ec43c..b5a60b3 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -67,7 +67,7 @@
}
void visitProxies(const VisitProxyFunc& func) const override {
- func(fProxy.get());
+ func(fProxy.get(), GrMipMapped::kNo);
}
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override {
@@ -320,7 +320,7 @@
}
void visitProxies(const VisitProxyFunc& func) const override {
- func(fLazyProxy.get());
+ func(fLazyProxy.get(), GrMipMapped::kNo);
}
private:
@@ -415,7 +415,7 @@
}
void visitProxies(const VisitProxyFunc& func) const override {
- func(fLazyProxy.get());
+ func(fLazyProxy.get(), GrMipMapped::kNo);
}
private: