how to use SkArenaAlloc with no friends
No more
friend class ::SkArenaAlloc; // for access to ctor
Change-Id: I76fa3319498a965623e6865b75d1fb507ab845a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344236
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 21d700e..7ef0f02 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -39,8 +39,10 @@
const SkMatrix& localMatrix,
bool localCoordsWillBeRead,
uint8_t coverage) {
- return arena->make<DefaultGeoProc>(gpTypeFlags, color, viewMatrix, localMatrix, coverage,
- localCoordsWillBeRead);
+ return arena->make([&](void* ptr) {
+ return new (ptr) DefaultGeoProc(gpTypeFlags, color, viewMatrix, localMatrix, coverage,
+ localCoordsWillBeRead);
+ });
}
const char* name() const override { return "DefaultGeometryProcessor"; }
@@ -194,8 +196,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
DefaultGeoProc(uint32_t gpTypeFlags,
const SkPMColor4f& color,
const SkMatrix& viewMatrix,
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index bbe28fe..b177ede 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -69,8 +69,10 @@
return nullptr;
}
- return arena->make<GrConicEffect>(color, viewMatrix, coverage, localMatrix,
- usesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrConicEffect(color, viewMatrix, coverage, localMatrix,
+ usesLocalCoords);
+ });
}
~GrConicEffect() override;
@@ -92,8 +94,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrConicEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage,
const SkMatrix& localMatrix, bool usesLocalCoords);
@@ -136,7 +136,10 @@
return nullptr;
}
- return arena->make<GrQuadEffect>(color, viewMatrix, coverage, localMatrix, usesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrQuadEffect(color, viewMatrix, coverage, localMatrix,
+ usesLocalCoords);
+ });
}
~GrQuadEffect() override;
@@ -158,8 +161,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrQuadEffect(const SkPMColor4f&, const SkMatrix& viewMatrix, uint8_t coverage,
const SkMatrix& localMatrix, bool usesLocalCoords);
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index 84f2edd..309dbc1 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -35,8 +35,10 @@
GrMaskFormat format,
const SkMatrix& localMatrix,
bool usesW) {
- return arena->make<GrBitmapTextGeoProc>(caps, color, wideColor, views, numActiveViews,
- p, format, localMatrix, usesW);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrBitmapTextGeoProc(caps, color, wideColor, views, numActiveViews,
+ p, format, localMatrix, usesW);
+ });
}
~GrBitmapTextGeoProc() override {}
@@ -60,8 +62,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrBitmapTextGeoProc(const GrShaderCaps&, const SkPMColor4f&, bool wideColor,
const GrSurfaceProxyView* views, int numViews, GrSamplerState params,
GrMaskFormat format, const SkMatrix& localMatrix, bool usesW);
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index 1a546d2..dd0e5e9 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -66,8 +66,10 @@
float lum,
uint32_t flags,
const SkMatrix& localMatrixIfUsesLocalCoords) {
- return arena->make<GrDistanceFieldA8TextGeoProc>(
- caps, views, numActiveViews, params, lum, flags, localMatrixIfUsesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrDistanceFieldA8TextGeoProc(
+ caps, views, numActiveViews, params, lum, flags, localMatrixIfUsesLocalCoords);
+ });
}
#else
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
@@ -77,8 +79,10 @@
GrSamplerState params,
uint32_t flags,
const SkMatrix& localMatrixIfUsesLocalCoords) {
- return arena->make<GrDistanceFieldA8TextGeoProc>(
- caps, views, numActiveViews, params, flags, localMatrixIfUsesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrDistanceFieldA8TextGeoProc(
+ caps, views, numActiveViews, params, flags, localMatrixIfUsesLocalCoords);
+ });
}
#endif
@@ -103,8 +107,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrDistanceFieldA8TextGeoProc(const GrShaderCaps& caps,
const GrSurfaceProxyView* views,
int numActiveViews,
@@ -148,8 +150,10 @@
const SkMatrix& matrix, bool wideColor,
const GrSurfaceProxyView* views, int numActiveViews,
GrSamplerState params, uint32_t flags) {
- return arena->make<GrDistanceFieldPathGeoProc>(caps, matrix, wideColor, views,
- numActiveViews, params, flags);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrDistanceFieldPathGeoProc(caps, matrix, wideColor, views,
+ numActiveViews, params, flags);
+ });
}
~GrDistanceFieldPathGeoProc() override {}
@@ -170,8 +174,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrDistanceFieldPathGeoProc(const GrShaderCaps& caps,
const SkMatrix& matrix,
bool wideColor,
@@ -228,9 +230,11 @@
DistanceAdjust distanceAdjust,
uint32_t flags,
const SkMatrix& localMatrixIfUsesLocalCoords) {
- return arena->make<GrDistanceFieldLCDTextGeoProc>(caps, views, numActiveViews, params,
- distanceAdjust, flags,
- localMatrixIfUsesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrDistanceFieldLCDTextGeoProc(caps, views, numActiveViews, params,
+ distanceAdjust, flags,
+ localMatrixIfUsesLocalCoords);
+ });
}
~GrDistanceFieldLCDTextGeoProc() override {}
@@ -252,8 +256,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& caps, const GrSurfaceProxyView* views,
int numActiveViews, GrSamplerState params, DistanceAdjust wa,
uint32_t flags, const SkMatrix& localMatrix);
diff --git a/src/gpu/effects/GrShadowGeoProc.h b/src/gpu/effects/GrShadowGeoProc.h
index 9d3e3e9..683fd93 100644
--- a/src/gpu/effects/GrShadowGeoProc.h
+++ b/src/gpu/effects/GrShadowGeoProc.h
@@ -22,7 +22,9 @@
class GrRRectShadowGeoProc : public GrGeometryProcessor {
public:
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrSurfaceProxyView& lutView) {
- return arena->make<GrRRectShadowGeoProc>(lutView);
+ return arena->make([&](void* ptr) {
+ return new (ptr) GrRRectShadowGeoProc(lutView);
+ });
}
const char* name() const override { return "RRectShadow"; }
@@ -37,8 +39,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView);
const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; }
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index c165e06..aec5bc6 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -548,7 +548,9 @@
const SkMatrix& localMatrix,
bool usesLocalCoords,
bool wideColor) {
- return arena->make<QuadEdgeEffect>(localMatrix, usesLocalCoords, wideColor);
+ return arena->make([&](void* ptr) {
+ return new (ptr) QuadEdgeEffect(localMatrix, usesLocalCoords, wideColor);
+ });
}
~QuadEdgeEffect() override {}
@@ -639,8 +641,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
QuadEdgeEffect(const SkMatrix& localMatrix, bool usesLocalCoords, bool wideColor)
: INHERITED(kQuadEdgeEffect_ClassID)
, fLocalMatrix(localMatrix)
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 1716bbc..a75cb70 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -837,7 +837,6 @@
private:
friend class GLDashingCircleEffect;
- friend class ::SkArenaAlloc; // for access to ctor
DashingCircleEffect(const SkPMColor4f&, AAMode aaMode, const SkMatrix& localMatrix,
bool usesLocalCoords);
@@ -969,7 +968,9 @@
AAMode aaMode,
const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return arena->make<DashingCircleEffect>(color, aaMode, localMatrix, usesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords);
+ });
}
void DashingCircleEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
@@ -1047,7 +1048,6 @@
private:
friend class GLDashingLineEffect;
- friend class ::SkArenaAlloc; // for access to ctor
DashingLineEffect(const SkPMColor4f&, AAMode aaMode, const SkMatrix& localMatrix,
bool usesLocalCoords);
@@ -1195,7 +1195,9 @@
AAMode aaMode,
const SkMatrix& localMatrix,
bool usesLocalCoords) {
- return arena->make<DashingLineEffect>(color, aaMode, localMatrix, usesLocalCoords);
+ return arena->make([&](void* ptr) {
+ return new (ptr) DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords);
+ });
}
void DashingLineEffect::getGLSLProcessorKey(const GrShaderCaps& caps,
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index be70164..dc6a031 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -118,9 +118,11 @@
const SkVertices::Attribute* attrs,
int attrCount,
const MarkedMatrices* customMatrices) {
- return arena->make<VerticesGP>(localCoordsType, colorArrayType, color,
- std::move(colorSpaceXform), viewMatrix, attrs, attrCount,
- customMatrices);
+ return arena->make([&](void* ptr) {
+ return new (ptr) VerticesGP(localCoordsType, colorArrayType, color,
+ std::move(colorSpaceXform), viewMatrix, attrs, attrCount,
+ customMatrices);
+ });
}
const char* name() const override { return "VerticesGP"; }
@@ -375,8 +377,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
VerticesGP(LocalCoordsType localCoordsType,
ColorArrayType colorArrayType,
const SkPMColor4f& color,
diff --git a/src/gpu/ops/GrFillRRectOp.cpp b/src/gpu/ops/GrFillRRectOp.cpp
index f3cd8e3..62a132d 100644
--- a/src/gpu/ops/GrFillRRectOp.cpp
+++ b/src/gpu/ops/GrFillRRectOp.cpp
@@ -299,7 +299,9 @@
class FillRRectOp::Processor : public GrGeometryProcessor {
public:
static GrGeometryProcessor* Make(SkArenaAlloc* arena, GrAAType aaType, ProcessorFlags flags) {
- return arena->make<Processor>(aaType, flags);
+ return arena->make([&](void* ptr) {
+ return new (ptr) Processor(aaType, flags);
+ });
}
const char* name() const final { return "GrFillRRectOp::Processor"; }
@@ -311,8 +313,6 @@
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const final;
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
Processor(GrAAType aaType, ProcessorFlags flags)
: INHERITED(kGrFillRRectOp_Processor_ClassID)
, fAAType(aaType)
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index adcc9bb..90aa7b4 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -34,7 +34,9 @@
sk_sp<GrColorSpaceXform> csxf,
GrSamplerState::Filter filter,
bool wideColor) {
- return arena->make<LatticeGP>(view, std::move(csxf), filter, wideColor);
+ return arena->make([&](void* ptr) {
+ return new (ptr) LatticeGP(view, std::move(csxf), filter, wideColor);
+ });
}
const char* name() const override { return "LatticeGP"; }
@@ -88,8 +90,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
LatticeGP(const GrSurfaceProxyView& view, sk_sp<GrColorSpaceXform> csxf,
GrSamplerState::Filter filter, bool wideColor)
: INHERITED(kLatticeGP_ClassID)
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 9e8bb8b..1467bdd 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -67,8 +67,10 @@
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool clipPlane,
bool isectPlane, bool unionPlane, bool roundCaps,
bool wideColor, const SkMatrix& localMatrix) {
- return arena->make<CircleGeometryProcessor>(stroke, clipPlane, isectPlane, unionPlane,
- roundCaps, wideColor, localMatrix);
+ return arena->make([&](void* ptr) {
+ return new (ptr) CircleGeometryProcessor(stroke, clipPlane, isectPlane, unionPlane,
+ roundCaps, wideColor, localMatrix);
+ });
}
const char* name() const override { return "CircleGeometryProcessor"; }
@@ -82,8 +84,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
CircleGeometryProcessor(bool stroke, bool clipPlane, bool isectPlane, bool unionPlane,
bool roundCaps, bool wideColor, const SkMatrix& localMatrix)
: INHERITED(kCircleGeometryProcessor_ClassID)
@@ -267,7 +267,9 @@
public:
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor,
const SkMatrix& localMatrix) {
- return arena->make<ButtCapDashedCircleGeometryProcessor>(wideColor, localMatrix);
+ return arena->make([&](void* ptr) {
+ return new (ptr) ButtCapDashedCircleGeometryProcessor(wideColor, localMatrix);
+ });
}
~ButtCapDashedCircleGeometryProcessor() override {}
@@ -283,8 +285,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
ButtCapDashedCircleGeometryProcessor(bool wideColor, const SkMatrix& localMatrix)
: INHERITED(kButtCapStrokedCircleGeometryProcessor_ClassID)
, fLocalMatrix(localMatrix) {
@@ -522,7 +522,9 @@
public:
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool wideColor,
bool useScale, const SkMatrix& localMatrix) {
- return arena->make<EllipseGeometryProcessor>(stroke, wideColor, useScale, localMatrix);
+ return arena->make([&](void* ptr) {
+ return new (ptr) EllipseGeometryProcessor(stroke, wideColor, useScale, localMatrix);
+ });
}
~EllipseGeometryProcessor() override {}
@@ -538,8 +540,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
EllipseGeometryProcessor(bool stroke, bool wideColor, bool useScale,
const SkMatrix& localMatrix)
: INHERITED(kEllipseGeometryProcessor_ClassID)
@@ -719,7 +719,9 @@
public:
static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor, bool useScale,
const SkMatrix& viewMatrix, DIEllipseStyle style) {
- return arena->make<DIEllipseGeometryProcessor>(wideColor, useScale, viewMatrix, style);
+ return arena->make([&](void* ptr) {
+ return new (ptr) DIEllipseGeometryProcessor(wideColor, useScale, viewMatrix, style);
+ });
}
~DIEllipseGeometryProcessor() override {}
@@ -735,8 +737,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
DIEllipseGeometryProcessor(bool wideColor, bool useScale, const SkMatrix& viewMatrix,
DIEllipseStyle style)
: INHERITED(kDIEllipseGeometryProcessor_ClassID)
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.cpp b/src/gpu/ops/GrQuadPerEdgeAA.cpp
index 6833342..e3167cf 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.cpp
+++ b/src/gpu/ops/GrQuadPerEdgeAA.cpp
@@ -533,7 +533,9 @@
using Saturate = GrTextureOp::Saturate;
static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& spec) {
- return arena->make<QuadPerEdgeAAGeometryProcessor>(spec);
+ return arena->make([&](void* ptr) {
+ return new (ptr) QuadPerEdgeAAGeometryProcessor(spec);
+ });
}
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
@@ -544,9 +546,11 @@
const GrSwizzle& swizzle,
sk_sp<GrColorSpaceXform> textureColorSpaceXform,
Saturate saturate) {
- return arena->make<QuadPerEdgeAAGeometryProcessor>(
- vertexSpec, caps, backendFormat, samplerState, swizzle,
- std::move(textureColorSpaceXform), saturate);
+ return arena->make([&](void* ptr) {
+ return new (ptr) QuadPerEdgeAAGeometryProcessor(
+ vertexSpec, caps, backendFormat, samplerState, swizzle,
+ std::move(textureColorSpaceXform), saturate);
+ });
}
const char* name() const override { return "QuadPerEdgeAAGeometryProcessor"; }
@@ -726,8 +730,6 @@
}
private:
- friend class ::SkArenaAlloc; // for access to ctor
-
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec)
: INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID)
, fTextureColorSpaceXform(nullptr) {