Add method to iterate over a GrOp's GrSurfaceProxies
The extra generality of having a std::function is for MDB reordering. In the current MDB reordering world there is one pass through the surfaceProxies at creation time and a second pass after flush to create the usage intervals. Change-Id: I3f548417eddc1dad7503d919241301e404255ffe Reviewed-on: https://skia-review.googlesource.com/46200 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
08cda14d61
commit
b493eebca1
@ -33,6 +33,10 @@ public:
|
||||
return analysis.requiresDstTexture() ? RequiresDstTexture::kYes : RequiresDstTexture::kNo;
|
||||
}
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessorSet.visitProxies(func);
|
||||
}
|
||||
|
||||
protected:
|
||||
BezierTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color, int32_t classID)
|
||||
: INHERITED(classID)
|
||||
|
@ -42,12 +42,16 @@ class PolyBoundsOp : public GrMeshDrawOp {
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
const char* name() const override { return "PolyBoundsOp"; }
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& rect) {
|
||||
return std::unique_ptr<GrDrawOp>(new PolyBoundsOp(std::move(paint), rect));
|
||||
}
|
||||
|
||||
const char* name() const override { return "PolyBoundsOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessors.visitProxies(func);
|
||||
}
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
|
||||
|
||||
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
|
||||
|
@ -82,6 +82,12 @@ public:
|
||||
}
|
||||
bool operator!=(const GrAppliedClip& that) const { return !(*this == that); }
|
||||
|
||||
void visitProxies(std::function<void(GrSurfaceProxy*)> func) const {
|
||||
if (fClipCoverageFP) {
|
||||
fClipCoverageFP->visitProxies(func);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GrScissorState fScissorState;
|
||||
GrWindowRectsState fWindowRectsState;
|
||||
|
@ -241,6 +241,13 @@ public:
|
||||
&GrResourceIOProcessor::numTextureSamplers,
|
||||
&GrResourceIOProcessor::textureSampler>;
|
||||
|
||||
void visitProxies(std::function<void(GrSurfaceProxy*)> func) {
|
||||
GrFragmentProcessor::TextureAccessIter iter(this);
|
||||
while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
|
||||
func(sampler->proxy());
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
enum OptimizationFlags : uint32_t {
|
||||
kNone_OptimizationFlags,
|
||||
|
@ -36,9 +36,6 @@ public:
|
||||
int numCoverageFragmentProcessors() const {
|
||||
return this->numFragmentProcessors() - fColorFragmentProcessorCnt;
|
||||
}
|
||||
int numFragmentProcessors() const {
|
||||
return fFragmentProcessors.count() - fFragmentProcessorOffset;
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* colorFragmentProcessor(int idx) const {
|
||||
SkASSERT(idx < fColorFragmentProcessorCnt);
|
||||
@ -155,9 +152,26 @@ public:
|
||||
|
||||
SkString dumpProcessors() const;
|
||||
|
||||
void visitProxies(std::function<void(GrSurfaceProxy*)> func) const {
|
||||
for (int i = 0; i < this->numFragmentProcessors(); ++i) {
|
||||
GrFragmentProcessor::TextureAccessIter iter(this->fragmentProcessor(i));
|
||||
while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
|
||||
func(sampler->proxy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GrProcessorSet(Empty) : fXP((const GrXferProcessor*)nullptr), fFlags(kFinalized_Flag) {}
|
||||
|
||||
int numFragmentProcessors() const {
|
||||
return fFragmentProcessors.count() - fFragmentProcessorOffset;
|
||||
}
|
||||
|
||||
const GrFragmentProcessor* fragmentProcessor(int idx) const {
|
||||
return fFragmentProcessors[idx + fFragmentProcessorOffset].get();
|
||||
}
|
||||
|
||||
// This absurdly large limit allows Analysis and this to pack fields together.
|
||||
static constexpr int kMaxColorProcessors = UINT8_MAX;
|
||||
|
||||
|
@ -68,12 +68,28 @@ public:
|
||||
bool onExecute(GrOpFlushState* flushState) override;
|
||||
|
||||
uint32_t addOp(std::unique_ptr<GrOp> op, const GrCaps& caps) {
|
||||
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
|
||||
this->addDependency(p, caps);
|
||||
};
|
||||
|
||||
op->visitProxies(addDependency);
|
||||
|
||||
this->recordOp(std::move(op), caps, nullptr, nullptr);
|
||||
|
||||
return this->uniqueID();
|
||||
}
|
||||
|
||||
uint32_t addOp(std::unique_ptr<GrOp> op, const GrCaps& caps,
|
||||
GrAppliedClip&& clip, const DstProxy& dstProxy) {
|
||||
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p) {
|
||||
this->addDependency(p, caps);
|
||||
};
|
||||
|
||||
op->visitProxies(addDependency);
|
||||
clip.visitProxies(addDependency);
|
||||
|
||||
this->recordOp(std::move(op), caps, clip.doesClip() ? &clip : nullptr, &dstProxy);
|
||||
|
||||
return this->uniqueID();
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,10 @@ public:
|
||||
~InstancedOp() override;
|
||||
const char* name() const override { return "InstancedOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessors.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.printf(
|
||||
|
@ -733,6 +733,7 @@ private:
|
||||
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix,
|
||||
const SkPath& path,
|
||||
const GrUserStencilSettings* stencilSettings) {
|
||||
@ -750,6 +751,10 @@ public:
|
||||
|
||||
const char* name() const override { return "AAConvexPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Count: %d\n", fPaths.count());
|
||||
|
@ -201,6 +201,10 @@ public:
|
||||
|
||||
const char* name() const override { return "AAFillRectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
str.append(INHERITED::dumpInfo());
|
||||
|
@ -785,6 +785,10 @@ public:
|
||||
|
||||
const char* name() const override { return "AAHairlineOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Color: 0x%08x Coverage: 0x%02x, Count: %d\n", fColor, fCoverage,
|
||||
|
@ -177,6 +177,10 @@ public:
|
||||
|
||||
const char* name() const override { return "AAFlatteningConvexPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& path : fPaths) {
|
||||
|
@ -171,6 +171,10 @@ public:
|
||||
|
||||
const char* name() const override { return "AAStrokeRect"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& info : fRects) {
|
||||
|
@ -97,6 +97,17 @@ public:
|
||||
|
||||
const char* name() const override { return "AtlasTextOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessors.visitProxies(func);
|
||||
|
||||
const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(this->maskFormat());
|
||||
for (int i = 0; i < kMaxTextures; ++i) {
|
||||
if (proxies[i]) {
|
||||
func(proxies[i].get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override;
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override;
|
||||
|
@ -243,6 +243,7 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor,
|
||||
class DashOp final : public GrMeshDrawOp {
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
struct LineData {
|
||||
SkMatrix fViewMatrix;
|
||||
SkMatrix fSrcRotInv;
|
||||
@ -263,6 +264,10 @@ public:
|
||||
|
||||
const char* name() const override { return "DashOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessorSet.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& geo : fLines) {
|
||||
|
@ -343,6 +343,10 @@ public:
|
||||
|
||||
const char* name() const override { return "DefaultPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Color: 0x%08x Count: %d\n", fColor, fPaths.count());
|
||||
|
@ -33,6 +33,10 @@ public:
|
||||
|
||||
const char* name() const override { return "DrawAtlasOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override;
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override;
|
||||
|
@ -24,6 +24,7 @@ class GrDrawPathOpBase : public GrDrawOp {
|
||||
protected:
|
||||
GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrPaint&&,
|
||||
GrPathRendering::FillType, GrAAType);
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override {
|
||||
if (GrAATypeIsHW(fAAType)) {
|
||||
return FixedFunctionFlags::kUsesHWAA | FixedFunctionFlags::kUsesStencil;
|
||||
@ -35,6 +36,10 @@ protected:
|
||||
: RequiresDstTexture::kNo;
|
||||
}
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fProcessorSet.visitProxies(func);
|
||||
}
|
||||
|
||||
protected:
|
||||
const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
||||
GrColor color() const { return fInputColor; }
|
||||
|
@ -46,6 +46,10 @@ public:
|
||||
|
||||
const char* name() const override { return "DrawVerticesOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override;
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override;
|
||||
|
@ -60,6 +60,10 @@ public:
|
||||
|
||||
const char* name() const override { return "NonAALatticeOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
|
||||
|
@ -222,6 +222,7 @@ private:
|
||||
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkPath& path, GrAAType aaType,
|
||||
const SkMatrix& viewMatrix, const SkRect& devBounds,
|
||||
const GrUserStencilSettings* stencilSettings) {
|
||||
@ -243,6 +244,10 @@ public:
|
||||
|
||||
const char* name() const override { return "MSAAPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Indexed: %d\n", fIsIndexed);
|
||||
|
@ -139,6 +139,10 @@ public:
|
||||
|
||||
const char* name() const override { return "NonAAFillRectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
str.append(GrMeshDrawOp::dumpInfo());
|
||||
@ -258,6 +262,10 @@ public:
|
||||
|
||||
const char* name() const override { return "NonAAFillRectPerspectiveOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
str.appendf("# combined: %d\n", fRects.count());
|
||||
|
@ -63,6 +63,10 @@ public:
|
||||
|
||||
const char* name() const override { return "NonAAStrokeRectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf(
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
typedef std::function<void(GrSurfaceProxy*)> VisitProxyFunc;
|
||||
|
||||
virtual void visitProxies(VisitProxyFunc) const {
|
||||
// This default implementation assumes the op has no proxies
|
||||
}
|
||||
|
||||
bool combineIfPossible(GrOp* that, const GrCaps& caps) {
|
||||
if (this->classID() != that->classID()) {
|
||||
return false;
|
||||
|
@ -785,6 +785,10 @@ public:
|
||||
|
||||
const char* name() const override { return "CircleOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (int i = 0; i < fCircles.count(); ++i) {
|
||||
@ -1160,6 +1164,7 @@ private:
|
||||
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix,
|
||||
const SkRect& ellipse, const SkStrokeRec& stroke) {
|
||||
DeviceSpaceParams params;
|
||||
@ -1247,6 +1252,10 @@ public:
|
||||
|
||||
const char* name() const override { return "EllipseOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Stroked: %d\n", fStroked);
|
||||
@ -1473,6 +1482,10 @@ public:
|
||||
|
||||
const char* name() const override { return "DIEllipseOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& geo : fEllipses) {
|
||||
@ -1787,6 +1800,10 @@ public:
|
||||
|
||||
const char* name() const override { return "CircularRRectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (int i = 0; i < fRRects.count(); ++i) {
|
||||
@ -2140,6 +2157,10 @@ public:
|
||||
|
||||
const char* name() const override { return "EllipticalRRectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Stroked: %d\n", fStroked);
|
||||
|
@ -79,6 +79,10 @@ public:
|
||||
|
||||
const char* name() const override { return "GrRegionOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
str.appendf("# combined: %d\n", fRegions.count());
|
||||
|
@ -97,6 +97,12 @@ public:
|
||||
friend class GrSimpleMeshDrawOpHelper;
|
||||
};
|
||||
|
||||
void visitProxies(std::function<void(GrSurfaceProxy*)> func) const {
|
||||
if (fProcessors) {
|
||||
fProcessors->visitProxies(func);
|
||||
}
|
||||
}
|
||||
|
||||
SkString dumpInfo() const;
|
||||
|
||||
protected:
|
||||
@ -127,6 +133,7 @@ class GrSimpleMeshDrawOpHelperWithStencil : private GrSimpleMeshDrawOpHelper {
|
||||
public:
|
||||
using MakeArgs = GrSimpleMeshDrawOpHelper::MakeArgs;
|
||||
using Flags = GrSimpleMeshDrawOpHelper::Flags;
|
||||
using GrSimpleMeshDrawOpHelper::visitProxies;
|
||||
|
||||
// using declarations can't be templated, so this is a pass through function instead.
|
||||
template <typename Op, typename... OpArgs>
|
||||
|
@ -192,6 +192,17 @@ public:
|
||||
|
||||
const char* name() const override { return "SmallPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
|
||||
const sk_sp<GrTextureProxy>* proxies = fAtlas->getProxies();
|
||||
for (int i = 0; i < GrDrawOpAtlas::kMaxPages; ++i) {
|
||||
if (proxies[i].get()) {
|
||||
func(proxies[i].get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& geo : fShapes) {
|
||||
|
@ -177,6 +177,10 @@ public:
|
||||
|
||||
const char* name() const override { return "TessellatingPathOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
string.appendf("Color 0x%08x, aa: %d\n", fColor, fAntiAlias);
|
||||
|
@ -245,6 +245,13 @@ public:
|
||||
|
||||
const char* name() const override { return "TextureOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
auto proxies = this->proxies();
|
||||
for (int i = 0; i < fProxyCnt; ++i) {
|
||||
func(proxies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SkString dumpInfo() const override {
|
||||
SkString str;
|
||||
str.appendf("AllowSRGBInputs: %d\n", fAllowSRGBInputs);
|
||||
@ -482,6 +489,7 @@ private:
|
||||
for (int i = 0; i < that->fProxyCnt; ++i) {
|
||||
if (map[i] < 0) {
|
||||
thatProxies[i]->addPendingRead();
|
||||
|
||||
thisProxies[-map[i]] = thatProxies[i];
|
||||
thisFilters[-map[i]] = thatFilters[i];
|
||||
map[i] = -map[i];
|
||||
|
@ -29,7 +29,6 @@ protected:
|
||||
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
const char* name() const override { return "NonAARectOp"; }
|
||||
|
||||
// This creates an instance of a simple non-AA solid color rect-drawing Op
|
||||
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& r) {
|
||||
@ -57,6 +56,12 @@ public:
|
||||
this->setBounds(r, HasAABloat::kYes, IsZeroArea::kYes);
|
||||
}
|
||||
|
||||
const char* name() const override { return "NonAARectOp"; }
|
||||
|
||||
void visitProxies(VisitProxyFunc func) const override {
|
||||
fHelper.visitProxies(func);
|
||||
}
|
||||
|
||||
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
|
||||
|
||||
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip*) override {
|
||||
|
Loading…
Reference in New Issue
Block a user