Move writePatch() to private now that PatchWriter isn't subclassed

The HW stroke tessellator had subclassed PatchWriter and called
writePatch() directly. Now the fixed-count variants all just use
the trait templates to configure PatchWriter directly.

Bug: skia:13263, skia:13056
Change-Id: I51c674968fe46974b217069909d71446a0d829c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534568
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2022-05-05 09:38:54 -04:00 committed by SkCQ
parent 842383b985
commit a6d2bbfd3d

View File

@ -476,9 +476,27 @@ public:
}
}
protected:
// TODO: Exposed as protected for StrokeHardwareTessellator's patch writer. Can be made private
// if/when the hardware stroker is deleted.
private:
AI void emitPatchAttribs(VertexWriter vertexWriter,
const JoinAttrib& join,
float explicitCurveType) {
// NOTE: operator<< overrides automatically handle optional and disabled attribs.
vertexWriter << join << fFanPoint << fStrokeParams << fColor << fDepth
<< CurveTypeAttrib{fAttribs, explicitCurveType};
}
AI VertexWriter appendPatch() {
if constexpr (kTrackJoinControlPoints) {
if (fDeferredPatch.fMustDefer) {
SkASSERT(!fDeferredPatch.fHasPending);
SkASSERT(fPatchAllocator.stride() <= kMaxStride);
fDeferredPatch.fHasPending = true;
return {fDeferredPatch.fData, fPatchAllocator.stride()};
}
}
return fPatchAllocator.append();
}
AI void writePatch(float2 p0, float2 p1, float2 p2, float2 p3, float explicitCurveType) {
if (VertexWriter vw = this->appendPatch()) {
// NOTE: fJoin will be undefined if we're writing to a deferred patch. If that's the
@ -504,27 +522,6 @@ protected:
}
}
private:
AI void emitPatchAttribs(VertexWriter vertexWriter,
const JoinAttrib& join,
float explicitCurveType) {
// NOTE: operator<< overrides automatically handle optional and disabled attribs.
vertexWriter << join << fFanPoint << fStrokeParams << fColor << fDepth
<< CurveTypeAttrib{fAttribs, explicitCurveType};
}
AI VertexWriter appendPatch() {
if constexpr (kTrackJoinControlPoints) {
if (fDeferredPatch.fMustDefer) {
SkASSERT(!fDeferredPatch.fHasPending);
SkASSERT(fPatchAllocator.stride() <= kMaxStride);
fDeferredPatch.fHasPending = true;
return {fDeferredPatch.fData, fPatchAllocator.stride()};
}
}
return fPatchAllocator.append();
}
// Helpers that normalize curves to a generic patch, but do no other work.
AI void writeCubicPatch(float2 p0, float2 p1, float2 p2, float2 p3) {
this->writePatch(p0, p1, p2, p3, kCubicCurveType);