Rename GrStrokeGeometry -> GrStrokePatchBuilder
Bug: skia:10419
Change-Id: Iffd139c2d489deb9d57fa860c20158ee398b7c11
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305561
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 317215b..b3eeebf 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -458,8 +458,8 @@
"$_src/gpu/tessellate/GrResolveLevelCounter.h",
"$_src/gpu/tessellate/GrStencilPathShader.cpp",
"$_src/gpu/tessellate/GrStencilPathShader.h",
- "$_src/gpu/tessellate/GrStrokeGeometry.cpp",
- "$_src/gpu/tessellate/GrStrokeGeometry.h",
+ "$_src/gpu/tessellate/GrStrokePatchBuilder.cpp",
+ "$_src/gpu/tessellate/GrStrokePatchBuilder.h",
"$_src/gpu/tessellate/GrTessellatePathOp.cpp",
"$_src/gpu/tessellate/GrTessellatePathOp.h",
"$_src/gpu/tessellate/GrTessellateStrokeOp.cpp",
diff --git a/src/gpu/tessellate/GrStrokeGeometry.cpp b/src/gpu/tessellate/GrStrokePatchBuilder.cpp
similarity index 91%
rename from src/gpu/tessellate/GrStrokeGeometry.cpp
rename to src/gpu/tessellate/GrStrokePatchBuilder.cpp
index 196ae9d..30ba51f 100644
--- a/src/gpu/tessellate/GrStrokeGeometry.cpp
+++ b/src/gpu/tessellate/GrStrokePatchBuilder.cpp
@@ -5,13 +5,14 @@
* found in the LICENSE file.
*/
-#include "src/gpu/tessellate/GrStrokeGeometry.h"
+#include "src/gpu/tessellate/GrStrokePatchBuilder.h"
#include "include/core/SkStrokeRec.h"
#include "include/private/SkNx.h"
#include "src/core/SkGeometry.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkPathPriv.h"
+#include "src/gpu/tessellate/GrTessellateStrokeShader.h"
// This is the maximum distance in pixels that we can stray from the edge of a stroke when
// converting it to flat line segments.
@@ -44,7 +45,7 @@
return (dotprod[0] + dotprod[1]) * invlength[0] * invlength[1];
}
-void GrStrokeGeometry::allocVertexChunk(int minVertexAllocCount) {
+void GrStrokePatchBuilder::allocVertexChunk(int minVertexAllocCount) {
VertexChunk* chunk = &fVertexChunkArray->push_back();
fCurrChunkVertexData = (SkPoint*)fTarget->makeVertexSpaceAtLeast(
sizeof(SkPoint), minVertexAllocCount, minVertexAllocCount, &chunk->fVertexBuffer,
@@ -52,7 +53,7 @@
fCurrChunkMinVertexAllocCount = minVertexAllocCount;
}
-SkPoint* GrStrokeGeometry::reservePatch() {
+SkPoint* GrStrokePatchBuilder::reservePatch() {
constexpr static int kNumVerticesPerPatch = GrTessellateStrokeShader::kNumVerticesPerPatch;
if (fVertexChunkArray->back().fVertexCount + kNumVerticesPerPatch > fCurrChunkVertexCapacity) {
// No need to put back vertices; the buffer is full.
@@ -69,8 +70,8 @@
return patch;
}
-void GrStrokeGeometry::writeCubicSegment(float leftJoinType, const SkPoint pts[4],
- float overrideNumSegments) {
+void GrStrokePatchBuilder::writeCubicSegment(float leftJoinType, const SkPoint pts[4],
+ float overrideNumSegments) {
SkPoint c1 = (pts[1] == pts[0]) ? pts[2] : pts[1];
SkPoint c2 = (pts[2] == pts[3]) ? pts[1] : pts[2];
@@ -90,8 +91,9 @@
fCurrentPoint = pts[3];
}
-void GrStrokeGeometry::writeJoin(float joinType, const SkPoint& anchorPoint,
- const SkPoint& prevControlPoint, const SkPoint& nextControlPoint) {
+void GrStrokePatchBuilder::writeJoin(float joinType, const SkPoint& anchorPoint,
+ const SkPoint& prevControlPoint,
+ const SkPoint& nextControlPoint) {
if (SkPoint* joinPatch = this->reservePatch()) {
joinPatch[0] = anchorPoint;
joinPatch[1] = prevControlPoint;
@@ -101,7 +103,7 @@
}
}
-void GrStrokeGeometry::writeSquareCap(const SkPoint& endPoint, const SkPoint& controlPoint) {
+void GrStrokePatchBuilder::writeSquareCap(const SkPoint& endPoint, const SkPoint& controlPoint) {
SkVector v = (endPoint - controlPoint);
v.normalize();
SkPoint capPoint = endPoint + v*fCurrStrokeRadius;
@@ -119,7 +121,7 @@
}
}
-void GrStrokeGeometry::writeCaps() {
+void GrStrokePatchBuilder::writeCaps() {
if (!fHasPreviousSegment) {
// We don't have any control points to orient the caps. In this case, square and round caps
// are specified to be drawn as an axis-aligned square or circle respectively. Assign
@@ -145,7 +147,7 @@
}
}
-void GrStrokeGeometry::addPath(const SkPath& path, const SkStrokeRec& stroke) {
+void GrStrokePatchBuilder::addPath(const SkPath& path, const SkStrokeRec& stroke) {
this->beginPath(stroke, stroke.getWidth());
SkPathVerb previousVerb = SkPathVerb::kClose;
for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
@@ -196,7 +198,7 @@
SkUNREACHABLE;
}
-void GrStrokeGeometry::beginPath(const SkStrokeRec& stroke, float strokeDevWidth) {
+void GrStrokePatchBuilder::beginPath(const SkStrokeRec& stroke, float strokeDevWidth) {
// Client should have already converted the stroke to device space (i.e. width=1 for hairline).
SkASSERT(strokeDevWidth > 0);
@@ -212,16 +214,16 @@
fHasPreviousSegment = false;
}
-void GrStrokeGeometry::moveTo(const SkPoint& pt) {
+void GrStrokePatchBuilder::moveTo(const SkPoint& pt) {
fHasPreviousSegment = false;
fCurrContourStartPoint = pt;
}
-void GrStrokeGeometry::lineTo(const SkPoint& p0, const SkPoint& p1) {
+void GrStrokePatchBuilder::lineTo(const SkPoint& p0, const SkPoint& p1) {
this->lineTo(fCurrStrokeJoinType, p0, p1);
}
-void GrStrokeGeometry::lineTo(float leftJoinType, const SkPoint& pt0, const SkPoint& pt1) {
+void GrStrokePatchBuilder::lineTo(float leftJoinType, const SkPoint& pt0, const SkPoint& pt1) {
Sk2f p0 = Sk2f::Load(&pt0);
Sk2f p1 = Sk2f::Load(&pt1);
if ((p0 == p1).allTrue()) {
@@ -230,7 +232,7 @@
this->writeCubicSegment(leftJoinType, p0, lerp(p0, p1, 1/3.f), lerp(p0, p1, 2/3.f), p1, 1);
}
-void GrStrokeGeometry::quadraticTo(const SkPoint P[3]) {
+void GrStrokePatchBuilder::quadraticTo(const SkPoint P[3]) {
this->quadraticTo(fCurrStrokeJoinType, P, SkFindQuadMaxCurvature(P));
}
@@ -243,7 +245,8 @@
return SkScalarCeilToInt(f);
}
-void GrStrokeGeometry::quadraticTo(float leftJoinType, const SkPoint P[3], float maxCurvatureT) {
+void GrStrokePatchBuilder::quadraticTo(float leftJoinType, const SkPoint P[3],
+ float maxCurvatureT) {
Sk2f p0 = Sk2f::Load(P);
Sk2f p1 = Sk2f::Load(P+1);
Sk2f p2 = Sk2f::Load(P+2);
@@ -330,7 +333,7 @@
this->writeCubicSegment(leftJoinType, p0, lerp(p0, p1, 2/3.f), lerp(p1, p2, 1/3.f), p2);
}
-void GrStrokeGeometry::cubicTo(const SkPoint P[4]) {
+void GrStrokePatchBuilder::cubicTo(const SkPoint P[4]) {
float roots[3];
int numRoots = SkFindCubicMaxCurvature(P, roots);
this->cubicTo(fCurrStrokeJoinType, P,
@@ -350,8 +353,8 @@
return SkScalarCeilToInt(f);
}
-void GrStrokeGeometry::cubicTo(float leftJoinType, const SkPoint P[4], float maxCurvatureT,
- float leftMaxCurvatureT, float rightMaxCurvatureT) {
+void GrStrokePatchBuilder::cubicTo(float leftJoinType, const SkPoint P[4], float maxCurvatureT,
+ float leftMaxCurvatureT, float rightMaxCurvatureT) {
Sk2f p0 = Sk2f::Load(P);
Sk2f p1 = Sk2f::Load(P+1);
Sk2f p2 = Sk2f::Load(P+2);
@@ -479,8 +482,8 @@
this->writeCubicSegment(leftJoinType, p0, p1, p2, p3);
}
-void GrStrokeGeometry::rotateTo(float leftJoinType, const SkPoint& anchorPoint,
- const SkPoint& controlPoint) {
+void GrStrokePatchBuilder::rotateTo(float leftJoinType, const SkPoint& anchorPoint,
+ const SkPoint& controlPoint) {
// Effectively rotate the current normal by drawing a zero length, 1-segment cubic.
// writeCubicSegment automatically adds the necessary join and the zero length cubic serves as
// a glue that guarantees a water tight rasterized edge between the new join and the segment
@@ -489,7 +492,7 @@
this->writeCubicSegment(leftJoinType, pts, 1);
}
-void GrStrokeGeometry::close() {
+void GrStrokePatchBuilder::close() {
if (!fHasPreviousSegment) {
// Draw caps instead of closing if the subpath is zero length:
//
diff --git a/src/gpu/tessellate/GrStrokeGeometry.h b/src/gpu/tessellate/GrStrokePatchBuilder.h
similarity index 92%
rename from src/gpu/tessellate/GrStrokeGeometry.h
rename to src/gpu/tessellate/GrStrokePatchBuilder.h
index 2bc6340..a1642e9 100644
--- a/src/gpu/tessellate/GrStrokeGeometry.h
+++ b/src/gpu/tessellate/GrStrokePatchBuilder.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrGrStrokeGeometry_DEFINED
-#define GrGrStrokeGeometry_DEFINED
+#ifndef GrGrStrokePatchBuilder_DEFINED
+#define GrGrStrokePatchBuilder_DEFINED
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
@@ -21,14 +21,14 @@
// entire lifetime of this class. e.g.:
//
// void onPrepare(GrOpFlushState* target) {
-// GrStrokeGeometry g(target, &fMyVertexChunks, count); // Locks target.
+// GrStrokePatchBuilder builder(target, &fMyVertexChunks, count); // Locks target.
// for (...) {
-// g.addPath(path, stroke);
+// builder.addPath(path, stroke);
// }
// }
// ... target can now be used normally again.
// ... fMyVertexChunks now contains chunks that can be drawn during onExecute.
-class GrStrokeGeometry {
+class GrStrokePatchBuilder {
public:
// We generate vertex buffers in chunks. Normally there will only be one chunk, but in rare
// cases the first can run out of space if too many cubics needed to be subdivided.
@@ -41,8 +41,8 @@
// Stores raw pointers to the provided target and vertexChunkArray, which this class will use
// and push to as addPath is called. The caller is responsible to bind and draw each chunk that
// gets pushed to the array. (See GrTessellateStrokeShader.)
- GrStrokeGeometry(GrMeshDrawOp::Target* target, SkTArray<VertexChunk>* vertexChunkArray,
- int totalCombinedVerbCnt)
+ GrStrokePatchBuilder(GrMeshDrawOp::Target* target, SkTArray<VertexChunk>* vertexChunkArray,
+ int totalCombinedVerbCnt)
: fMaxTessellationSegments(target->caps().shaderCaps()->maxTessellationSegments())
, fTarget(target)
, fVertexChunkArray(vertexChunkArray) {
@@ -52,7 +52,7 @@
// "Releases" the target to be used externally again by putting back any unused pre-allocated
// vertices.
- ~GrStrokeGeometry() {
+ ~GrStrokePatchBuilder() {
fTarget->putBackVertices(fCurrChunkVertexCapacity - fVertexChunkArray->back().fVertexCount,
sizeof(SkPoint));
}
diff --git a/src/gpu/tessellate/GrTessellateStrokeOp.cpp b/src/gpu/tessellate/GrTessellateStrokeOp.cpp
index 854d4ab..cb2a713 100644
--- a/src/gpu/tessellate/GrTessellateStrokeOp.cpp
+++ b/src/gpu/tessellate/GrTessellateStrokeOp.cpp
@@ -8,13 +8,13 @@
#include "src/gpu/tessellate/GrTessellateStrokeOp.h"
#include "src/core/SkPathPriv.h"
-#include "src/gpu/tessellate/GrStrokeGeometry.h"
+#include "src/gpu/tessellate/GrStrokePatchBuilder.h"
#include "src/gpu/tessellate/GrTessellateStrokeShader.h"
static SkPath transform_path(const SkMatrix& viewMatrix, const SkPath& path) {
SkPath devPath;
// The provided matrix must be a similarity matrix for the time being. This is so we can
- // bootstrap this Op on top of GrStrokeGeometry with minimal modifications.
+ // bootstrap this Op on top of GrStrokePatchBuilder with minimal modifications.
SkASSERT(viewMatrix.isSimilarity());
path.transform(viewMatrix, &devPath);
return devPath;
@@ -109,9 +109,9 @@
}
void GrTessellateStrokeOp::onPrepare(GrOpFlushState* flushState) {
- GrStrokeGeometry strokeGeometry(flushState, &fVertexChunks, fTotalCombinedVerbCnt);
+ GrStrokePatchBuilder builder(flushState, &fVertexChunks, fTotalCombinedVerbCnt);
for (auto& [path, stroke] : fPathStrokes) {
- strokeGeometry.addPath(path, stroke);
+ builder.addPath(path, stroke);
}
}
diff --git a/src/gpu/tessellate/GrTessellateStrokeOp.h b/src/gpu/tessellate/GrTessellateStrokeOp.h
index 23b0f2e..629e433 100644
--- a/src/gpu/tessellate/GrTessellateStrokeOp.h
+++ b/src/gpu/tessellate/GrTessellateStrokeOp.h
@@ -11,7 +11,7 @@
#include "include/core/SkStrokeRec.h"
#include "src/gpu/GrSTArenaList.h"
#include "src/gpu/ops/GrDrawOp.h"
-#include "src/gpu/tessellate/GrStrokeGeometry.h"
+#include "src/gpu/tessellate/GrStrokePatchBuilder.h"
// Renders opaque, constant-color strokes by decomposing them into standalone tessellation patches.
// Each patch is either a "cubic" (single stroked bezier curve with butt caps) or a "join". Requires
@@ -55,7 +55,7 @@
GrProcessorSet fProcessors;
// S=1 because we will almost always fit everything into one single chunk.
- SkSTArray<1, GrStrokeGeometry::VertexChunk> fVertexChunks;
+ SkSTArray<1, GrStrokePatchBuilder::VertexChunk> fVertexChunks;
friend class GrOpMemoryPool; // For ctor.
};