From 03d3bb00bb9934feb453a6d367b84c8576a69acc Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 5 Dec 2014 12:14:43 -0800 Subject: [PATCH] get rid of static gps This may cause a perf regression TBR= BUG=skia: Review URL: https://codereview.chromium.org/749413003 --- src/gpu/GrAAConvexPathRenderer.cpp | 4 +--- src/gpu/GrDefaultGeoProcFactory.cpp | 38 +------------------------------------ src/gpu/GrOvalRenderer.cpp | 37 +++--------------------------------- src/gpu/effects/GrBezierEffect.h | 36 +++++++++-------------------------- 4 files changed, 14 insertions(+), 101 deletions(-) diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 4008fe2..f7c6e7f 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -506,9 +506,7 @@ class QuadEdgeEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create() { - GR_CREATE_STATIC_PROCESSOR(gQuadEdgeEffect, QuadEdgeEffect, ()); - gQuadEdgeEffect->ref(); - return gQuadEdgeEffect; + return SkNEW(QuadEdgeEffect); } virtual ~QuadEdgeEffect() {} diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 0df519d..6b9d2c2 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -22,43 +22,7 @@ typedef GrDefaultGeoProcFactory Flag; class DefaultGeoProc : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(uint32_t gpTypeFlags) { - switch (gpTypeFlags) { - case Flag::kColor_GPType | Flag::kCoverage_GPType | Flag::kLocalCoord_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcColLocCov, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcColLocCov); - } - case Flag::kColor_GPType | Flag::kLocalCoord_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcColLoc, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcColLoc); - } - case Flag::kColor_GPType | Flag::kCoverage_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcColCov, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcColCov); - } - case Flag::kColor_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcCol, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcCol); - } - case Flag::kLocalCoord_GPType | Flag::kCoverage_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcLocCov, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcLocCov); - } - case Flag::kLocalCoord_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcLoc, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcLoc); - } - case Flag::kCoverage_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProcCov, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProcCov); - } - case Flag::kPosition_GPType: { - GR_CREATE_STATIC_PROCESSOR(gDefaultGeoProc, DefaultGeoProc, (gpTypeFlags)); - return SkRef(gDefaultGeoProc); - } - default: - SkFAIL("Incomplete Switch"); - return NULL; - } + return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags)); } virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index f392b90..4d7912a 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -60,16 +60,7 @@ inline bool circle_stays_circle(const SkMatrix& m) { class CircleEdgeEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(bool stroke) { - GR_CREATE_STATIC_PROCESSOR(gCircleStrokeEdge, CircleEdgeEffect, (true)); - GR_CREATE_STATIC_PROCESSOR(gCircleFillEdge, CircleEdgeEffect, (false)); - - if (stroke) { - gCircleStrokeEdge->ref(); - return gCircleStrokeEdge; - } else { - gCircleFillEdge->ref(); - return gCircleFillEdge; - } + return SkNEW_ARGS(CircleEdgeEffect, (stroke)); } const GrAttribute* inPosition() const { return fInPosition; } @@ -188,16 +179,7 @@ GrGeometryProcessor* CircleEdgeEffect::TestCreate(SkRandom* random, class EllipseEdgeEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(bool stroke) { - GR_CREATE_STATIC_PROCESSOR(gEllipseStrokeEdge, EllipseEdgeEffect, (true)); - GR_CREATE_STATIC_PROCESSOR(gEllipseFillEdge, EllipseEdgeEffect, (false)); - - if (stroke) { - gEllipseStrokeEdge->ref(); - return gEllipseStrokeEdge; - } else { - gEllipseFillEdge->ref(); - return gEllipseFillEdge; - } + return SkNEW_ARGS(EllipseEdgeEffect, (stroke)); } virtual ~EllipseEdgeEffect() {} @@ -347,20 +329,7 @@ public: enum Mode { kStroke = 0, kHairline, kFill }; static GrGeometryProcessor* Create(Mode mode) { - GR_CREATE_STATIC_PROCESSOR(gEllipseStrokeEdge, DIEllipseEdgeEffect, (kStroke)); - GR_CREATE_STATIC_PROCESSOR(gEllipseHairlineEdge, DIEllipseEdgeEffect, (kHairline)); - GR_CREATE_STATIC_PROCESSOR(gEllipseFillEdge, DIEllipseEdgeEffect, (kFill)); - - if (kStroke == mode) { - gEllipseStrokeEdge->ref(); - return gEllipseStrokeEdge; - } else if (kHairline == mode) { - gEllipseHairlineEdge->ref(); - return gEllipseHairlineEdge; - } else { - gEllipseFillEdge->ref(); - return gEllipseFillEdge; - } + return SkNEW_ARGS(DIEllipseEdgeEffect, (mode)); } virtual ~DIEllipseEdgeEffect() {} diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h index 7b171a1..dfab3a9 100644 --- a/src/gpu/effects/GrBezierEffect.h +++ b/src/gpu/effects/GrBezierEffect.h @@ -60,25 +60,19 @@ class GrConicEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, const GrDrawTargetCaps& caps) { - GR_CREATE_STATIC_PROCESSOR(gConicFillAA, GrConicEffect, (kFillAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gConicHairAA, GrConicEffect, (kHairlineAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gConicFillBW, GrConicEffect, (kFillBW_GrProcessorEdgeType)); switch (edgeType) { case kFillAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gConicFillAA->ref(); - return gConicFillAA; + return SkNEW_ARGS(GrConicEffect, (kFillAA_GrProcessorEdgeType)); case kHairlineAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gConicHairAA->ref(); - return gConicHairAA; + return SkNEW_ARGS(GrConicEffect, (kHairlineAA_GrProcessorEdgeType)); case kFillBW_GrProcessorEdgeType: - gConicFillBW->ref(); - return gConicFillBW; + return SkNEW_ARGS(GrConicEffect, (kFillBW_GrProcessorEdgeType));; default: return NULL; } @@ -133,25 +127,19 @@ class GrQuadEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, const GrDrawTargetCaps& caps) { - GR_CREATE_STATIC_PROCESSOR(gQuadFillAA, GrQuadEffect, (kFillAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gQuadHairAA, GrQuadEffect, (kHairlineAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gQuadFillBW, GrQuadEffect, (kFillBW_GrProcessorEdgeType)); switch (edgeType) { case kFillAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gQuadFillAA->ref(); - return gQuadFillAA; + return SkNEW_ARGS(GrQuadEffect, (kFillAA_GrProcessorEdgeType)); case kHairlineAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gQuadHairAA->ref(); - return gQuadHairAA; + return SkNEW_ARGS(GrQuadEffect, (kHairlineAA_GrProcessorEdgeType)); case kFillBW_GrProcessorEdgeType: - gQuadFillBW->ref(); - return gQuadFillBW; + return SkNEW_ARGS(GrQuadEffect, (kFillBW_GrProcessorEdgeType)); default: return NULL; } @@ -208,25 +196,19 @@ class GrCubicEffect : public GrGeometryProcessor { public: static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType, const GrDrawTargetCaps& caps) { - GR_CREATE_STATIC_PROCESSOR(gCubicFillAA, GrCubicEffect, (kFillAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gCubicHairAA, GrCubicEffect, (kHairlineAA_GrProcessorEdgeType)); - GR_CREATE_STATIC_PROCESSOR(gCubicFillBW, GrCubicEffect, (kFillBW_GrProcessorEdgeType)); switch (edgeType) { case kFillAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gCubicFillAA->ref(); - return gCubicFillAA; + return SkNEW_ARGS(GrCubicEffect, (kFillAA_GrProcessorEdgeType)); case kHairlineAA_GrProcessorEdgeType: if (!caps.shaderDerivativeSupport()) { return NULL; } - gCubicHairAA->ref(); - return gCubicHairAA; + return SkNEW_ARGS(GrCubicEffect, (kHairlineAA_GrProcessorEdgeType)); case kFillBW_GrProcessorEdgeType: - gCubicFillBW->ref(); - return gCubicFillBW; + return SkNEW_ARGS(GrCubicEffect, (kFillBW_GrProcessorEdgeType)); default: return NULL; } -- 2.7.4