Move more classes to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Iaa0349749a5d79d7915fb37ef1b30b46f0aa58d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448796
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ops/GrAtlasInstancedHelper.cpp b/src/gpu/ops/AtlasInstancedHelper.cpp
similarity index 91%
rename from src/gpu/ops/GrAtlasInstancedHelper.cpp
rename to src/gpu/ops/AtlasInstancedHelper.cpp
index 1a75a01..f5914a0 100644
--- a/src/gpu/ops/GrAtlasInstancedHelper.cpp
+++ b/src/gpu/ops/AtlasInstancedHelper.cpp
@@ -5,14 +5,16 @@
* found in the LICENSE file.
*/
-#include "src/gpu/ops/GrAtlasInstancedHelper.h"
+#include "src/gpu/ops/AtlasInstancedHelper.h"
#include "src/gpu/GrVertexWriter.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
-void GrAtlasInstancedHelper::appendInstanceAttribs(
+namespace skgpu::v1 {
+
+void AtlasInstancedHelper::appendInstanceAttribs(
SkTArray<GrGeometryProcessor::Attribute>* instanceAttribs) const {
instanceAttribs->emplace_back("locations", kFloat4_GrVertexAttribType, kFloat4_GrSLType);
if (fShaderFlags & ShaderFlags::kCheckBounds) {
@@ -20,8 +22,8 @@
}
}
-void GrAtlasInstancedHelper::writeInstanceData(GrVertexWriter* instanceWriter,
- const Instance* i) const {
+void AtlasInstancedHelper::writeInstanceData(GrVertexWriter* instanceWriter,
+ const Instance* i) const {
SkASSERT(i->fLocationInAtlas.x() >= 0);
SkASSERT(i->fLocationInAtlas.y() >= 0);
instanceWriter->write(
@@ -36,7 +38,7 @@
SkSize::Make(i->fPathDevIBounds.size())));
}
-void GrAtlasInstancedHelper::injectShaderCode(
+void AtlasInstancedHelper::injectShaderCode(
const GrGeometryProcessor::ProgramImpl::EmitArgs& args,
const GrShaderVar& devCoord,
GrGLSLUniformHandler::UniformHandle* atlasAdjustUniformHandle) const {
@@ -92,10 +94,12 @@
}
}
-void GrAtlasInstancedHelper::setUniformData(
+void AtlasInstancedHelper::setUniformData(
const GrGLSLProgramDataManager& pdman,
const GrGLSLUniformHandler::UniformHandle& atlasAdjustUniformHandle) const {
SkASSERT(fAtlasProxy->isInstantiated());
SkISize dimensions = fAtlasProxy->backingStoreDimensions();
pdman.set2f(atlasAdjustUniformHandle, 1.f / dimensions.width(), 1.f / dimensions.height());
}
+
+} // namespace skgpu::v1
diff --git a/src/gpu/ops/GrAtlasInstancedHelper.h b/src/gpu/ops/AtlasInstancedHelper.h
similarity index 90%
rename from src/gpu/ops/GrAtlasInstancedHelper.h
rename to src/gpu/ops/AtlasInstancedHelper.h
index b7ca2de..755cac2 100644
--- a/src/gpu/ops/GrAtlasInstancedHelper.h
+++ b/src/gpu/ops/AtlasInstancedHelper.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrGrAtlasInstancedHelper_DEFINED
-#define GrGrAtlasInstancedHelper_DEFINED
+#ifndef AtlasInstancedHelper_DEFINED
+#define AtlasInstancedHelper_DEFINED
#include "src/core/SkIPoint16.h"
#include "src/gpu/GrGeometryProcessor.h"
@@ -15,9 +15,11 @@
struct GrVertexWriter;
+namespace skgpu::v1 {
+
// This class encapsulates all the necessary steps for an instanced GrGeometryProcessor to clip
// against a path mask from an atlas.
-class GrAtlasInstancedHelper {
+class AtlasInstancedHelper {
public:
enum class ShaderFlags {
kNone = 0,
@@ -29,7 +31,7 @@
constexpr static int kNumShaderFlags = 2;
- GrAtlasInstancedHelper(GrSurfaceProxyView atlasView, ShaderFlags shaderFlags)
+ AtlasInstancedHelper(GrSurfaceProxyView atlasView, ShaderFlags shaderFlags)
: fAtlasProxy(atlasView.detachProxy())
, fAtlasSwizzle(atlasView.swizzle())
, fShaderFlags(shaderFlags) {
@@ -41,7 +43,7 @@
const GrSwizzle& atlasSwizzle() const { return fAtlasSwizzle; }
// Returns whether the two helpers can be batched together in a single draw.
- bool isCompatible(const GrAtlasInstancedHelper& helper) {
+ bool isCompatible(const AtlasInstancedHelper& helper) {
// TODO: We may want to consider two helpers compatible if they only differ in the
// kCheckBounds flag -- we can always promote one to checking its bounds.
SkASSERT(fAtlasProxy != helper.fAtlasProxy || fAtlasSwizzle == helper.fAtlasSwizzle);
@@ -95,6 +97,8 @@
const ShaderFlags fShaderFlags;
};
-GR_MAKE_BITFIELD_CLASS_OPS(GrAtlasInstancedHelper::ShaderFlags);
+GR_MAKE_BITFIELD_CLASS_OPS(AtlasInstancedHelper::ShaderFlags);
-#endif
+} // namespace skgpu::v1
+
+#endif // AtlasInstancedHelper_DEFINED
diff --git a/src/gpu/ops/DrawAtlasPathOp.cpp b/src/gpu/ops/DrawAtlasPathOp.cpp
index 6bc7e83..189997d 100644
--- a/src/gpu/ops/DrawAtlasPathOp.cpp
+++ b/src/gpu/ops/DrawAtlasPathOp.cpp
@@ -22,7 +22,7 @@
class DrawAtlasPathShader : public GrGeometryProcessor {
public:
DrawAtlasPathShader(bool usesLocalCoords,
- const GrAtlasInstancedHelper* atlasHelper,
+ const skgpu::v1::AtlasInstancedHelper* atlasHelper,
const GrShaderCaps& shaderCaps)
: GrGeometryProcessor(kDrawAtlasPathShader_ClassID)
, fUsesLocalCoords(usesLocalCoords)
@@ -61,7 +61,7 @@
std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
const bool fUsesLocalCoords;
- const GrAtlasInstancedHelper* const fAtlasHelper;
+ const skgpu::v1::AtlasInstancedHelper* const fAtlasHelper;
TextureSampler fAtlasAccess;
constexpr static int kMaxInstanceAttribs = 6;
SkSTArray<kMaxInstanceAttribs, GrGeometryProcessor::Attribute> fAttribs;
diff --git a/src/gpu/ops/DrawAtlasPathOp.h b/src/gpu/ops/DrawAtlasPathOp.h
index 9a16d2d..659686b 100644
--- a/src/gpu/ops/DrawAtlasPathOp.h
+++ b/src/gpu/ops/DrawAtlasPathOp.h
@@ -9,7 +9,7 @@
#define DrawAtlasPathOp_DEFINED
#include "src/core/SkIPoint16.h"
-#include "src/gpu/ops/GrAtlasInstancedHelper.h"
+#include "src/gpu/ops/AtlasInstancedHelper.h"
#include "src/gpu/ops/GrDrawOp.h"
namespace skgpu::v1 {
@@ -28,9 +28,9 @@
transposedInAtlas))
, fTailInstance(&fHeadInstance->fNext)
, fAtlasHelper(std::move(atlasView),
- isInverseFill ? GrAtlasInstancedHelper::ShaderFlags::kCheckBounds |
- GrAtlasInstancedHelper::ShaderFlags::kInvertCoverage
- : GrAtlasInstancedHelper::ShaderFlags::kNone)
+ isInverseFill ? AtlasInstancedHelper::ShaderFlags::kCheckBounds |
+ AtlasInstancedHelper::ShaderFlags::kInvertCoverage
+ : AtlasInstancedHelper::ShaderFlags::kNone)
, fProcessors(std::move(paint)) {
this->setBounds(SkRect::Make(fillBounds), HasAABloat::kYes, IsHairline::kNo);
}
@@ -68,14 +68,14 @@
SkIRect fFillBounds;
std::array<float, 6> fLocalToDeviceIfUsingLocalCoords;
SkPMColor4f fColor;
- GrAtlasInstancedHelper::Instance fAtlasInstance;
+ AtlasInstancedHelper::Instance fAtlasInstance;
Instance* fNext = nullptr;
};
Instance* fHeadInstance;
Instance** fTailInstance;
- GrAtlasInstancedHelper fAtlasHelper;
+ AtlasInstancedHelper fAtlasHelper;
bool fUsesLocalCoords = false;
int fInstanceCount = 1;
diff --git a/src/gpu/ops/FillRectOp.cpp b/src/gpu/ops/FillRectOp.cpp
index 3acdb00..b088991 100644
--- a/src/gpu/ops/FillRectOp.cpp
+++ b/src/gpu/ops/FillRectOp.cpp
@@ -21,14 +21,15 @@
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
-#include "src/gpu/ops/GrQuadPerEdgeAA.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
+#include "src/gpu/ops/QuadPerEdgeAA.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
namespace {
-using VertexSpec = GrQuadPerEdgeAA::VertexSpec;
-using ColorType = GrQuadPerEdgeAA::ColorType;
+using VertexSpec = skgpu::v1::QuadPerEdgeAA::VertexSpec;
+using ColorType = skgpu::v1::QuadPerEdgeAA::ColorType;
+using Subset = skgpu::v1::QuadPerEdgeAA::Subset;
#if GR_TEST_UTILS
SkString dump_quad_info(int index, const GrQuad* deviceQuad,
@@ -147,7 +148,7 @@
iter = fQuads.metadata();
SkPMColor4f colorOverride;
if (quadColors.isConstant(&colorOverride)) {
- fColorType = GrQuadPerEdgeAA::MinColorType(colorOverride);
+ fColorType = skgpu::v1::QuadPerEdgeAA::MinColorType(colorOverride);
while(iter.next()) {
iter->fColor = colorOverride;
}
@@ -155,7 +156,8 @@
// Otherwise compute the color type needed as the max over all quads.
fColorType = ColorType::kNone;
while(iter.next()) {
- fColorType = std::max(fColorType, GrQuadPerEdgeAA::MinColorType(iter->fColor));
+ fColorType = std::max(fColorType,
+ skgpu::v1::QuadPerEdgeAA::MinColorType(iter->fColor));
}
}
// Most SkShaders' FPs multiply their calculated color by the paint color or alpha. We want
@@ -186,12 +188,11 @@
#endif
VertexSpec vertexSpec() const {
- auto indexBufferOption = GrQuadPerEdgeAA::CalcIndexBufferOption(fHelper.aaType(),
- fQuads.count());
+ auto indexBufferOption = skgpu::v1::QuadPerEdgeAA::CalcIndexBufferOption(fHelper.aaType(),
+ fQuads.count());
return VertexSpec(fQuads.deviceQuadType(), fColorType, fQuads.localQuadType(),
- fHelper.usesLocalCoords(), GrQuadPerEdgeAA::Subset::kNo,
- fHelper.aaType(),
+ fHelper.usesLocalCoords(), Subset::kNo, fHelper.aaType(),
fHelper.compatibleWithCoverageAsAlpha(), indexBufferOption);
}
@@ -209,7 +210,7 @@
GrLoadOp colorLoadOp) override {
const VertexSpec vertexSpec = this->vertexSpec();
- GrGeometryProcessor* gp = GrQuadPerEdgeAA::MakeProcessor(arena, vertexSpec);
+ GrGeometryProcessor* gp = skgpu::v1::QuadPerEdgeAA::MakeProcessor(arena, vertexSpec);
SkASSERT(gp->vertexStride() == vertexSpec.vertexSize());
fProgramInfo = fHelper.createProgramInfoWithStencil(caps, arena, writeView, usesMSAASurface,
@@ -247,7 +248,7 @@
void tessellate(const VertexSpec& vertexSpec, char* dst) const {
static constexpr SkRect kEmptyDomain = SkRect::MakeEmpty();
- GrQuadPerEdgeAA::Tessellator tessellator(vertexSpec, dst);
+ skgpu::v1::QuadPerEdgeAA::Tessellator tessellator(vertexSpec, dst);
auto iter = fQuads.iterator();
while (iter.next()) {
// All entries should have local coords, or no entries should have local coords,
@@ -287,7 +288,8 @@
}
if (vertexSpec.needsIndexBuffer()) {
- fIndexBuffer = GrQuadPerEdgeAA::GetIndexBuffer(target, vertexSpec.indexBufferOption());
+ fIndexBuffer = skgpu::v1::QuadPerEdgeAA::GetIndexBuffer(target,
+ vertexSpec.indexBufferOption());
if (!fIndexBuffer) {
SkDebugf("Could not allocate indices\n");
return;
@@ -315,8 +317,9 @@
flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds);
flushState->bindBuffers(std::move(fIndexBuffer), nullptr, std::move(fVertexBuffer));
flushState->bindTextures(fProgramInfo->geomProc(), nullptr, fProgramInfo->pipeline());
- GrQuadPerEdgeAA::IssueDraw(flushState->caps(), flushState->opsRenderPass(), vertexSpec, 0,
- fQuads.count(), totalNumVertices, fBaseVertex);
+ skgpu::v1::QuadPerEdgeAA::IssueDraw(flushState->caps(), flushState->opsRenderPass(),
+ vertexSpec, 0, fQuads.count(), totalNumVertices,
+ fBaseVertex);
}
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override {
@@ -385,8 +388,9 @@
// be lifted to back to the requested type.
int quadCount = fQuads.count() + numQuads;
if (aaType != fHelper.aaType() && aaType != GrAAType::kNone) {
- auto indexBufferOption = GrQuadPerEdgeAA::CalcIndexBufferOption(aaType, quadCount);
- if (quadCount > GrQuadPerEdgeAA::QuadLimit(indexBufferOption)) {
+ auto indexBufferOption = skgpu::v1::QuadPerEdgeAA::CalcIndexBufferOption(aaType,
+ quadCount);
+ if (quadCount > skgpu::v1::QuadPerEdgeAA::QuadLimit(indexBufferOption)) {
// Promoting to the new aaType would've caused an overflow of the indexBuffer
// limit
return false;
@@ -396,9 +400,9 @@
SkASSERT(fHelper.aaType() == GrAAType::kNone);
fHelper.setAAType(aaType);
} else {
- auto indexBufferOption = GrQuadPerEdgeAA::CalcIndexBufferOption(fHelper.aaType(),
- quadCount);
- if (quadCount > GrQuadPerEdgeAA::QuadLimit(indexBufferOption)) {
+ auto indexBufferOption = skgpu::v1::QuadPerEdgeAA::CalcIndexBufferOption(
+ fHelper.aaType(), quadCount);
+ if (quadCount > skgpu::v1::QuadPerEdgeAA::QuadLimit(indexBufferOption)) {
return false; // This op can't grow any more
}
}
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.cpp b/src/gpu/ops/QuadPerEdgeAA.cpp
similarity index 89%
rename from src/gpu/ops/GrQuadPerEdgeAA.cpp
rename to src/gpu/ops/QuadPerEdgeAA.cpp
index 64b93ee..1fc3684 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.cpp
+++ b/src/gpu/ops/QuadPerEdgeAA.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "src/gpu/ops/GrQuadPerEdgeAA.h"
+#include "src/gpu/ops/QuadPerEdgeAA.h"
#include "include/private/SkVx.h"
#include "src/gpu/GrMeshDrawTarget.h"
@@ -26,30 +26,37 @@
namespace {
+using VertexSpec = skgpu::v1::QuadPerEdgeAA::VertexSpec;
+using CoverageMode = skgpu::v1::QuadPerEdgeAA::CoverageMode;
+using ColorType = skgpu::v1::QuadPerEdgeAA::ColorType;
+
// Generic WriteQuadProc that can handle any VertexSpec. It writes the 4 vertices in triangle strip
// order, although the data per-vertex is dependent on the VertexSpec.
-static void write_quad_generic(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_quad_generic(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
static constexpr auto If = GrVertexWriter::If<float>;
SkASSERT(!spec.hasLocalCoords() || localQuad);
- GrQuadPerEdgeAA::CoverageMode mode = spec.coverageMode();
+ CoverageMode mode = spec.coverageMode();
for (int i = 0; i < 4; ++i) {
// save position, this is a float2 or float3 or float4 depending on the combination of
// perspective and coverage mode.
vb->write(deviceQuad->x(i), deviceQuad->y(i),
If(spec.deviceQuadType() == GrQuad::Type::kPerspective, deviceQuad->w(i)),
- If(mode == GrQuadPerEdgeAA::CoverageMode::kWithPosition, coverage[i]));
+ If(mode == CoverageMode::kWithPosition, coverage[i]));
// save color
if (spec.hasVertexColors()) {
- bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kFloat;
- vb->write(GrVertexColor(
- color * (mode == GrQuadPerEdgeAA::CoverageMode::kWithColor ? coverage[i] : 1.f),
- wide));
+ bool wide = spec.colorType() == ColorType::kFloat;
+ vb->write(GrVertexColor(color * (mode == CoverageMode::kWithColor ? coverage[i] : 1.f),
+ wide));
}
// save local position
@@ -75,15 +82,19 @@
// 2D (XY), no explicit coverage, vertex color, no locals, no geometry subset, no texture subsetn
// This represents simple, solid color or shader, non-AA (or AA with cov. as alpha) rects.
-static void write_2d_color(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_color(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(!spec.hasLocalCoords());
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone ||
- spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor);
+ SkASSERT(spec.coverageMode() == CoverageMode::kNone ||
+ spec.coverageMode() == CoverageMode::kWithColor);
SkASSERT(spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(!spec.hasSubset());
@@ -91,25 +102,28 @@
// accumulate local coords conservatively (paint not trivial), and then after analysis realize
// the processors don't need local coordinates.
- bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kFloat;
+ bool wide = spec.colorType() == ColorType::kFloat;
for (int i = 0; i < 4; ++i) {
// If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor ||
- coverage[i] == 1.f);
+ SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f);
vb->write(deviceQuad->x(i), deviceQuad->y(i), GrVertexColor(color * coverage[i], wide));
}
}
// 2D (XY), no explicit coverage, UV locals, no color, no geometry subset, no texture subset
// This represents opaque, non AA, textured rects
-static void write_2d_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_uv(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone);
+ SkASSERT(spec.coverageMode() == CoverageMode::kNone);
SkASSERT(!spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(!spec.hasSubset());
@@ -122,25 +136,28 @@
// 2D (XY), no explicit coverage, UV locals, vertex color, no geometry or texture subsets
// This represents transparent, non AA (or AA with cov. as alpha), textured rects
-static void write_2d_color_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_color_uv(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone ||
- spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor);
+ SkASSERT(spec.coverageMode() == CoverageMode::kNone ||
+ spec.coverageMode() == CoverageMode::kWithColor);
SkASSERT(spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(!spec.hasSubset());
SkASSERT(localQuad);
- bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kFloat;
+ bool wide = spec.colorType() == ColorType::kFloat;
for (int i = 0; i < 4; ++i) {
// If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor ||
- coverage[i] == 1.f);
+ SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f);
vb->write(deviceQuad->x(i), deviceQuad->y(i), GrVertexColor(color * coverage[i], wide),
localQuad->x(i), localQuad->y(i));
}
@@ -148,14 +165,18 @@
// 2D (XY), explicit coverage, UV locals, no color, no geometry subset, no texture subset
// This represents opaque, AA, textured rects
-static void write_2d_cov_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_cov_uv(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithPosition);
+ SkASSERT(spec.coverageMode() == CoverageMode::kWithPosition);
SkASSERT(!spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(!spec.hasSubset());
@@ -175,14 +196,18 @@
// 2D (XY), no explicit coverage, UV locals, no color, tex subset but no geometry subset
// This represents opaque, non AA, textured rects with strict uv sampling
-static void write_2d_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_uv_strict(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone);
+ SkASSERT(spec.coverageMode() == CoverageMode::kNone);
SkASSERT(!spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(spec.hasSubset());
@@ -195,25 +220,28 @@
// 2D (XY), no explicit coverage, UV locals, vertex color, tex subset but no geometry subset
// This represents transparent, non AA (or AA with cov. as alpha), textured rects with strict sample
-static void write_2d_color_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_color_uv_strict(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone ||
- spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor);
+ SkASSERT(spec.coverageMode() == CoverageMode::kNone ||
+ spec.coverageMode() == CoverageMode::kWithColor);
SkASSERT(spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(spec.hasSubset());
SkASSERT(localQuad);
- bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kFloat;
+ bool wide = spec.colorType() == ColorType::kFloat;
for (int i = 0; i < 4; ++i) {
// If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor ||
- coverage[i] == 1.f);
+ SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f);
vb->write(deviceQuad->x(i), deviceQuad->y(i), GrVertexColor(color * coverage[i], wide),
localQuad->x(i), localQuad->y(i), texSubset);
}
@@ -221,14 +249,18 @@
// 2D (XY), explicit coverage, UV locals, no color, tex subset but no geometry subset
// This represents opaque, AA, textured rects with strict uv sampling
-static void write_2d_cov_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec,
- const GrQuad* deviceQuad, const GrQuad* localQuad,
- const float coverage[4], const SkPMColor4f& color,
- const SkRect& geomSubset, const SkRect& texSubset) {
+void write_2d_cov_uv_strict(GrVertexWriter* vb,
+ const VertexSpec& spec,
+ const GrQuad* deviceQuad,
+ const GrQuad* localQuad,
+ const float coverage[4],
+ const SkPMColor4f& color,
+ const SkRect& geomSubset,
+ const SkRect& texSubset) {
// Assert assumptions about VertexSpec
SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective);
SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective);
- SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithPosition);
+ SkASSERT(spec.coverageMode() == CoverageMode::kWithPosition);
SkASSERT(!spec.hasVertexColors());
SkASSERT(!spec.requiresGeometrySubset());
SkASSERT(spec.hasSubset());
@@ -242,7 +274,7 @@
} // anonymous namespace
-namespace GrQuadPerEdgeAA {
+namespace skgpu::v1::QuadPerEdgeAA {
IndexBufferOption CalcIndexBufferOption(GrAAType aa, int numQuads) {
if (aa == GrAAType::kCoverage) {
@@ -882,4 +914,4 @@
saturate);
}
-} // namespace GrQuadPerEdgeAA
+} // namespace skgpu::v1::QuadPerEdgeAA
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.h b/src/gpu/ops/QuadPerEdgeAA.h
similarity index 98%
rename from src/gpu/ops/GrQuadPerEdgeAA.h
rename to src/gpu/ops/QuadPerEdgeAA.h
index cd8eab7..f15838e 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.h
+++ b/src/gpu/ops/QuadPerEdgeAA.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrQuadPerEdgeAA_DEFINED
-#define GrQuadPerEdgeAA_DEFINED
+#ifndef QuadPerEdgeAA_DEFINED
+#define QuadPerEdgeAA_DEFINED
#include "include/core/SkPoint.h"
#include "include/core/SkPoint3.h"
@@ -25,7 +25,7 @@
class GrShaderCaps;
struct GrVertexWriter;
-namespace GrQuadPerEdgeAA {
+namespace skgpu::v1::QuadPerEdgeAA {
using Saturate = skgpu::v1::TextureOp::Saturate;
enum class CoverageMode { kNone, kWithPosition, kWithColor };
@@ -197,6 +197,6 @@
void IssueDraw(const GrCaps&, GrOpsRenderPass*, const VertexSpec&, int runningQuadCount,
int quadCount, int maxVerts, int absVertBufferOffset);
-} // namespace GrQuadPerEdgeAA
+} // namespace skgpu::v1::QuadPerEdgeAA
-#endif // GrQuadPerEdgeAA_DEFINED
+#endif // QuadPerEdgeAA_DEFINED
diff --git a/src/gpu/ops/TextureOp.cpp b/src/gpu/ops/TextureOp.cpp
index fbf6bf1..2e95cf7 100644
--- a/src/gpu/ops/TextureOp.cpp
+++ b/src/gpu/ops/TextureOp.cpp
@@ -39,16 +39,16 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/ops/FillRectOp.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
-#include "src/gpu/ops/GrQuadPerEdgeAA.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
+#include "src/gpu/ops/QuadPerEdgeAA.h"
#include "src/gpu/ops/TextureOp.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
namespace {
-using Subset = GrQuadPerEdgeAA::Subset;
-using VertexSpec = GrQuadPerEdgeAA::VertexSpec;
-using ColorType = GrQuadPerEdgeAA::ColorType;
+using Subset = skgpu::v1::QuadPerEdgeAA::Subset;
+using VertexSpec = skgpu::v1::QuadPerEdgeAA::VertexSpec;
+using ColorType = skgpu::v1::QuadPerEdgeAA::ColorType;
// Extracts lengths of vertical and horizontal edges of axis-aligned quad. "width" is the edge
// between v0 and v2 (or v1 and v3), "height" is the edge between v0 and v1 (or v2 and v3).
@@ -297,11 +297,11 @@
SkASSERT(fMetadata.colorType() == ColorType::kNone);
auto iter = fQuads.metadata();
while(iter.next()) {
- auto colorType = GrQuadPerEdgeAA::MinColorType(iter->fColor);
- colorType = std::max(static_cast<GrQuadPerEdgeAA::ColorType>(fMetadata.fColorType),
+ auto colorType = skgpu::v1::QuadPerEdgeAA::MinColorType(iter->fColor);
+ colorType = std::max(static_cast<ColorType>(fMetadata.fColorType),
colorType);
if (caps.reducedShaderMode()) {
- colorType = std::max(colorType, GrQuadPerEdgeAA::ColorType::kByte);
+ colorType = std::max(colorType, ColorType::kByte);
}
fMetadata.fColorType = static_cast<uint16_t>(colorType);
}
@@ -351,17 +351,17 @@
Metadata(const GrSwizzle& swizzle,
GrSamplerState::Filter filter,
GrSamplerState::MipmapMode mm,
- GrQuadPerEdgeAA::Subset subset,
+ Subset subset,
Saturate saturate)
- : fSwizzle(swizzle)
- , fProxyCount(1)
- , fTotalQuadCount(1)
- , fFilter(static_cast<uint16_t>(filter))
- , fMipmapMode(static_cast<uint16_t>(mm))
- , fAAType(static_cast<uint16_t>(GrAAType::kNone))
- , fColorType(static_cast<uint16_t>(ColorType::kNone))
- , fSubset(static_cast<uint16_t>(subset))
- , fSaturate(static_cast<uint16_t>(saturate)) {}
+ : fSwizzle(swizzle)
+ , fProxyCount(1)
+ , fTotalQuadCount(1)
+ , fFilter(static_cast<uint16_t>(filter))
+ , fMipmapMode(static_cast<uint16_t>(mm))
+ , fAAType(static_cast<uint16_t>(GrAAType::kNone))
+ , fColorType(static_cast<uint16_t>(ColorType::kNone))
+ , fSubset(static_cast<uint16_t>(subset))
+ , fSaturate(static_cast<uint16_t>(saturate)) {}
GrSwizzle fSwizzle; // sizeof(GrSwizzle) == uint16_t
uint16_t fProxyCount;
@@ -390,7 +390,7 @@
static_assert(GrSamplerState::kFilterCount <= 4);
static_assert(kGrAATypeCount <= 4);
- static_assert(GrQuadPerEdgeAA::kColorTypeCount <= 4);
+ static_assert(skgpu::v1::QuadPerEdgeAA::kColorTypeCount <= 4);
};
static_assert(sizeof(Metadata) == 8);
@@ -676,7 +676,7 @@
GrSamplerState samplerState = GrSamplerState(GrSamplerState::WrapMode::kClamp,
fMetadata.filter());
- gp = GrQuadPerEdgeAA::MakeTexturedProcessor(
+ gp = skgpu::v1::QuadPerEdgeAA::MakeTexturedProcessor(
arena, fDesc->fVertexSpec, *caps->shaderCaps(), backendFormat, samplerState,
fMetadata.fSwizzle, std::move(fTextureColorSpaceXform), fMetadata.saturate());
@@ -722,7 +722,7 @@
SkDEBUGCODE(int totVerticesSeen = 0;)
SkDEBUGCODE(const size_t vertexSize = desc->fVertexSpec.vertexSize());
- GrQuadPerEdgeAA::Tessellator tessellator(desc->fVertexSpec, vertexData);
+ skgpu::v1::QuadPerEdgeAA::Tessellator tessellator(desc->fVertexSpec, vertexData);
for (const auto& op : ChainRange<TextureOpImpl>(texOp)) {
auto iter = op.fQuads.iterator();
for (unsigned p = 0; p < op.fMetadata.fProxyCount; ++p) {
@@ -841,14 +841,14 @@
SkASSERT(!CombinedQuadCountWillOverflow(overallAAType, false, desc->fNumTotalQuads));
- auto indexBufferOption = GrQuadPerEdgeAA::CalcIndexBufferOption(overallAAType,
- maxQuadsPerMesh);
+ auto indexBufferOption = skgpu::v1::QuadPerEdgeAA::CalcIndexBufferOption(overallAAType,
+ maxQuadsPerMesh);
desc->fVertexSpec = VertexSpec(quadType, colorType, srcQuadType, /* hasLocal */ true,
subset, overallAAType, /* alpha as coverage */ true,
indexBufferOption);
- SkASSERT(desc->fNumTotalQuads <= GrQuadPerEdgeAA::QuadLimit(indexBufferOption));
+ SkASSERT(desc->fNumTotalQuads <= skgpu::v1::QuadPerEdgeAA::QuadLimit(indexBufferOption));
}
int totNumQuads() const {
@@ -902,7 +902,7 @@
}
if (fDesc->fVertexSpec.needsIndexBuffer()) {
- fDesc->fIndexBuffer = GrQuadPerEdgeAA::GetIndexBuffer(
+ fDesc->fIndexBuffer = skgpu::v1::QuadPerEdgeAA::GetIndexBuffer(
target, fDesc->fVertexSpec.indexBufferOption());
if (!fDesc->fIndexBuffer) {
SkDebugf("Could not allocate indices\n");
@@ -944,9 +944,9 @@
flushState->bindTextures(fDesc->fProgramInfo->geomProc(),
*op.fViewCountPairs[p].fProxy,
fDesc->fProgramInfo->pipeline());
- GrQuadPerEdgeAA::IssueDraw(flushState->caps(), flushState->opsRenderPass(),
- fDesc->fVertexSpec, totQuadsSeen, quadCnt,
- fDesc->totalNumVertices(), fDesc->fBaseVertex);
+ skgpu::v1::QuadPerEdgeAA::IssueDraw(flushState->caps(), flushState->opsRenderPass(),
+ fDesc->fVertexSpec, totQuadsSeen, quadCnt,
+ fDesc->totalNumVertices(), fDesc->fBaseVertex);
totQuadsSeen += quadCnt;
SkDEBUGCODE(++numDraws;)
}