Hide more GrBatch Geometry structs.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2110903002 Review-Url: https://codereview.chromium.org/2110903002
This commit is contained in:
parent
7f06c6947a
commit
f17030906d
@ -743,13 +743,13 @@ static sk_sp<GrGeometryProcessor> create_fill_gp(bool tweakAlphaForCoverage,
|
||||
class AAConvexPathBatch : public GrVertexBatch {
|
||||
public:
|
||||
DEFINE_BATCH_CLASS_ID
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPath fPath;
|
||||
};
|
||||
|
||||
static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPathBatch(geometry); }
|
||||
AAConvexPathBatch(GrColor color, const SkMatrix& viewMatrix, const SkPath& path)
|
||||
: INHERITED(ClassID()) {
|
||||
fGeoData.emplace_back(Geometry{color, viewMatrix, path});
|
||||
// compute bounds
|
||||
fBounds = path.getBounds();
|
||||
viewMatrix.mapRect(&fBounds);
|
||||
}
|
||||
|
||||
const char* name() const override { return "AAConvexBatch"; }
|
||||
|
||||
@ -931,16 +931,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
|
||||
|
||||
AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
|
||||
fGeoData.push_back(geometry);
|
||||
|
||||
// compute bounds
|
||||
fBounds = geometry.fPath.getBounds();
|
||||
geometry.fViewMatrix.mapRect(&fBounds);
|
||||
}
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
|
||||
AAConvexPathBatch* that = t->cast<AAConvexPathBatch>();
|
||||
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
|
||||
@ -967,7 +957,7 @@ private:
|
||||
fBatch.fCanTweakAlphaForCoverage = false;
|
||||
}
|
||||
|
||||
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
|
||||
fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin());
|
||||
this->joinBounds(that->bounds());
|
||||
return true;
|
||||
}
|
||||
@ -988,6 +978,12 @@ private:
|
||||
bool fCanTweakAlphaForCoverage;
|
||||
};
|
||||
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPath fPath;
|
||||
};
|
||||
|
||||
BatchTracker fBatch;
|
||||
SkSTArray<1, Geometry, true> fGeoData;
|
||||
|
||||
@ -1000,12 +996,10 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
SkASSERT(!args.fDrawContext->isUnifiedMultisampled());
|
||||
SkASSERT(!args.fShape->isEmpty());
|
||||
|
||||
AAConvexPathBatch::Geometry geometry;
|
||||
geometry.fColor = args.fColor;
|
||||
geometry.fViewMatrix = *args.fViewMatrix;
|
||||
args.fShape->asPath(&geometry.fPath);
|
||||
SkPath path;
|
||||
args.fShape->asPath(&path);
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(AAConvexPathBatch::Create(geometry));
|
||||
SkAutoTUnref<GrDrawBatch> batch(new AAConvexPathBatch(args.fColor, *args.fViewMatrix, path));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
@ -1021,12 +1015,11 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
#ifdef GR_TEST_UTILS
|
||||
|
||||
DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) {
|
||||
AAConvexPathBatch::Geometry geometry;
|
||||
geometry.fColor = GrRandomColor(random);
|
||||
geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
|
||||
geometry.fPath = GrTest::TestPathConvex(random);
|
||||
GrColor color = GrRandomColor(random);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
||||
SkPath path = GrTest::TestPathConvex(random);
|
||||
|
||||
return AAConvexPathBatch::Create(geometry);
|
||||
return new AAConvexPathBatch(color, viewMatrix, path);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -128,17 +128,26 @@ public:
|
||||
typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache;
|
||||
typedef GrAADistanceFieldPathRenderer::ShapeDataList ShapeDataList;
|
||||
|
||||
struct Geometry {
|
||||
GrShape fShape;
|
||||
GrColor fColor;
|
||||
bool fAntiAlias;
|
||||
};
|
||||
AADistanceFieldPathBatch(GrColor color,
|
||||
const GrShape& shape,
|
||||
bool antiAlias,
|
||||
const SkMatrix& viewMatrix,
|
||||
GrBatchAtlas* atlas,
|
||||
ShapeCache* shapeCache, ShapeDataList* shapeList,
|
||||
bool gammaCorrect)
|
||||
: INHERITED(ClassID()) {
|
||||
SkASSERT(shape.hasUnstyledKey());
|
||||
fBatch.fViewMatrix = viewMatrix;
|
||||
fGeoData.emplace_back(Geometry{color, shape, antiAlias});
|
||||
|
||||
static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
|
||||
GrBatchAtlas* atlas, ShapeCache* shapeCache,
|
||||
ShapeDataList* shapeList, bool gammaCorrect) {
|
||||
return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, shapeCache, shapeList,
|
||||
gammaCorrect);
|
||||
fAtlas = atlas;
|
||||
fShapeCache = shapeCache;
|
||||
fShapeList = shapeList;
|
||||
fGammaCorrect = gammaCorrect;
|
||||
|
||||
// Compute bounds
|
||||
fBounds = shape.bounds();
|
||||
viewMatrix.mapRect(&fBounds);
|
||||
}
|
||||
|
||||
const char* name() const override { return "AADistanceFieldPathBatch"; }
|
||||
@ -278,27 +287,6 @@ private:
|
||||
this->flush(target, &flushInfo);
|
||||
}
|
||||
|
||||
AADistanceFieldPathBatch(const Geometry& geometry,
|
||||
const SkMatrix& viewMatrix,
|
||||
GrBatchAtlas* atlas,
|
||||
ShapeCache* shapeCache, ShapeDataList* shapeList,
|
||||
bool gammaCorrect)
|
||||
: INHERITED(ClassID()) {
|
||||
SkASSERT(geometry.fShape.hasUnstyledKey());
|
||||
fBatch.fViewMatrix = viewMatrix;
|
||||
fGeoData.push_back(geometry);
|
||||
SkASSERT(fGeoData[0].fShape.hasUnstyledKey());
|
||||
|
||||
fAtlas = atlas;
|
||||
fShapeCache = shapeCache;
|
||||
fShapeList = shapeList;
|
||||
fGammaCorrect = gammaCorrect;
|
||||
|
||||
// Compute bounds
|
||||
fBounds = geometry.fShape.bounds();
|
||||
viewMatrix.mapRect(&fBounds);
|
||||
}
|
||||
|
||||
bool addPathToAtlas(GrVertexBatch::Target* target,
|
||||
FlushInfo* flushInfo,
|
||||
GrBatchAtlas* atlas,
|
||||
@ -507,6 +495,12 @@ private:
|
||||
bool fCoverageIgnored;
|
||||
};
|
||||
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
GrShape fShape;
|
||||
bool fAntiAlias;
|
||||
};
|
||||
|
||||
BatchTracker fBatch;
|
||||
SkSTArray<1, Geometry> fGeoData;
|
||||
GrBatchAtlas* fAtlas;
|
||||
@ -537,15 +531,10 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
}
|
||||
|
||||
AADistanceFieldPathBatch::Geometry geometry;
|
||||
geometry.fShape = *args.fShape;
|
||||
geometry.fColor = args.fColor;
|
||||
geometry.fAntiAlias = args.fAntiAlias;
|
||||
|
||||
SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
|
||||
*args.fViewMatrix, fAtlas,
|
||||
&fShapeCache, &fShapeList,
|
||||
args.fGammaCorrect));
|
||||
SkAutoTUnref<GrDrawBatch> batch(new AADistanceFieldPathBatch(args.fColor, *args.fShape,
|
||||
args.fAntiAlias, *args.fViewMatrix,
|
||||
fAtlas, &fShapeCache, &fShapeList,
|
||||
args.fGammaCorrect));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
@ -619,18 +608,18 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathBatch) {
|
||||
GrColor color = GrRandomColor(random);
|
||||
bool gammaCorrect = random->nextBool();
|
||||
|
||||
AADistanceFieldPathBatch::Geometry geometry;
|
||||
// This path renderer only allows fill styles.
|
||||
GrShape shape(GrTest::TestPath(random), GrStyle::SimpleFill());
|
||||
geometry.fShape = shape;
|
||||
geometry.fColor = color;
|
||||
geometry.fAntiAlias = random->nextBool();
|
||||
bool antiAlias = random->nextBool();
|
||||
|
||||
return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
|
||||
gTestStruct.fAtlas,
|
||||
&gTestStruct.fShapeCache,
|
||||
&gTestStruct.fShapeList,
|
||||
gammaCorrect);
|
||||
return new AADistanceFieldPathBatch(color,
|
||||
shape,
|
||||
antiAlias,
|
||||
viewMatrix,
|
||||
gTestStruct.fAtlas,
|
||||
&gTestStruct.fShapeCache,
|
||||
&gTestStruct.fShapeList,
|
||||
gammaCorrect);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -676,15 +676,21 @@ class AAHairlineBatch : public GrVertexBatch {
|
||||
public:
|
||||
DEFINE_BATCH_CLASS_ID
|
||||
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
uint8_t fCoverage;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPath fPath;
|
||||
SkIRect fDevClipBounds;
|
||||
};
|
||||
AAHairlineBatch(GrColor color,
|
||||
uint8_t coverage,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath& path,
|
||||
SkIRect devClipBounds) : INHERITED(ClassID()) {
|
||||
fGeoData.emplace_back(Geometry{color, coverage, viewMatrix, path, devClipBounds});
|
||||
|
||||
static GrDrawBatch* Create(const Geometry& geometry) { return new AAHairlineBatch(geometry); }
|
||||
// compute bounds
|
||||
fBounds = path.getBounds();
|
||||
viewMatrix.mapRect(&fBounds);
|
||||
|
||||
// This is b.c. hairlines are notionally infinitely thin so without expansion
|
||||
// two overlapping lines could be reordered even though they hit the same pixels.
|
||||
fBounds.outset(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
const char* name() const override { return "AAHairlineBatch"; }
|
||||
|
||||
@ -712,26 +718,12 @@ private:
|
||||
fBatch.fCoverage = fGeoData[0].fCoverage;
|
||||
}
|
||||
|
||||
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
|
||||
|
||||
void onPrepareDraws(Target*) const override;
|
||||
|
||||
typedef SkTArray<SkPoint, true> PtArray;
|
||||
typedef SkTArray<int, true> IntArray;
|
||||
typedef SkTArray<float, true> FloatArray;
|
||||
|
||||
AAHairlineBatch(const Geometry& geometry) : INHERITED(ClassID()) {
|
||||
fGeoData.push_back(geometry);
|
||||
|
||||
// compute bounds
|
||||
fBounds = geometry.fPath.getBounds();
|
||||
geometry.fViewMatrix.mapRect(&fBounds);
|
||||
|
||||
// This is b.c. hairlines are notionally infinitely thin so without expansion
|
||||
// two overlapping lines could be reordered even though they hit the same pixels.
|
||||
fBounds.outset(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
|
||||
AAHairlineBatch* that = t->cast<AAHairlineBatch>();
|
||||
|
||||
@ -766,7 +758,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
|
||||
fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin());
|
||||
this->joinBounds(that->bounds());
|
||||
return true;
|
||||
}
|
||||
@ -777,6 +769,15 @@ private:
|
||||
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
|
||||
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
|
||||
|
||||
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
uint8_t fCoverage;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPath fPath;
|
||||
SkIRect fDevClipBounds;
|
||||
};
|
||||
|
||||
struct BatchTracker {
|
||||
GrColor fColor;
|
||||
uint8_t fCoverage;
|
||||
@ -953,14 +954,7 @@ static GrDrawBatch* create_hairline_batch(GrColor color,
|
||||
newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
|
||||
}
|
||||
|
||||
AAHairlineBatch::Geometry geometry;
|
||||
geometry.fColor = color;
|
||||
geometry.fCoverage = newCoverage;
|
||||
geometry.fViewMatrix = viewMatrix;
|
||||
geometry.fPath = path;
|
||||
geometry.fDevClipBounds = devClipBounds;
|
||||
|
||||
return AAHairlineBatch::Create(geometry);
|
||||
return new AAHairlineBatch(color, newCoverage, viewMatrix, path, devClipBounds);
|
||||
}
|
||||
|
||||
bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
|
Loading…
Reference in New Issue
Block a user