/////////////////////////////////////////////////////////////////////
-GrGradientEffect::GrGradientEffect(GrContext* ctx,
- const SkGradientShaderBase& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tileMode) {
+GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
+ const SkGradientShaderBase& shader(*args.fShader);
fIsOpaque = shader.isOpaque();
}
#if GR_GL_USE_ACCURATE_HARD_STOP_GRADIENTS
- fTileMode = tileMode;
+ fTileMode = args.fTileMode;
#endif
switch (fColorType) {
fPremulType = kAfterInterp_PremulType;
}
- fCoordTransform.reset(kCoordSet, matrix);
+ fCoordTransform.reset(kCoordSet, *args.fMatrix);
break;
case kTexture_ColorType:
desc.fWidth = bitmap.width();
desc.fHeight = 32;
desc.fRowHeight = bitmap.height();
- desc.fContext = ctx;
- desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *ctx->caps());
+ desc.fContext = args.fContext;
+ desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *args.fContext->caps());
fAtlas = GrTextureStripAtlas::GetAtlas(desc);
SkASSERT(fAtlas);
// y-clamp.
GrTextureParams params;
params.setFilterMode(GrTextureParams::kBilerp_FilterMode);
- params.setTileModeX(tileMode);
+ params.setTileModeX(args.fTileMode);
fRow = fAtlas->lockRow(bitmap);
if (-1 != fRow) {
fYCoord = fAtlas->getYOffset(fRow)+SK_ScalarHalf*fAtlas->getNormalizedTexelHeight();
- fCoordTransform.reset(kCoordSet, matrix, fAtlas->getTexture(), params.filterMode());
+ fCoordTransform.reset(kCoordSet, *args.fMatrix, fAtlas->getTexture(),
+ params.filterMode());
fTextureAccess.reset(fAtlas->getTexture(), params);
} else {
SkAutoTUnref<GrTexture> texture(
- GrRefCachedBitmapTexture(ctx, bitmap, params,
+ GrRefCachedBitmapTexture(args.fContext, bitmap, params,
SkSourceGammaTreatment::kRespect));
if (!texture) {
return;
}
- fCoordTransform.reset(kCoordSet, matrix, texture, params.filterMode());
+ fCoordTransform.reset(kCoordSet, *args.fMatrix, texture, params.filterMode());
fTextureAccess.reset(texture, params);
fYCoord = SK_ScalarHalf;
}
public:
class GLSLEdge2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
- return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader, matrix, tm));
+ static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
+ return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(args));
}
virtual ~Edge2PtConicalEffect() {}
this->fDiffRadius == s.fDiffRadius);
}
- Edge2PtConicalEffect(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm)
- : INHERITED(ctx, shader, matrix, tm),
- fCenterX1(shader.getCenterX1()),
- fRadius0(shader.getStartRadius()),
- fDiffRadius(shader.getDiffRadius()){
+ Edge2PtConicalEffect(const CreateArgs& args)
+ : INHERITED(args) {
+ const SkTwoPointConicalGradient& shader =
+ *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
+ fCenterX1 = shader.getCenterX1();
+ fRadius0 = shader.getStartRadius();
+ fDiffRadius = shader.getDiffRadius();
this->initClassID<Edge2PtConicalEffect>();
// We should only be calling this shader if we are degenerate case with touching circles
// When deciding if we are in edge case, we scaled by the end radius for cases when the
public:
class GLSLFocalOutside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
return sk_sp<GrFragmentProcessor>(
- new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
+ new FocalOutside2PtConicalEffect(args, focalX));
}
virtual ~FocalOutside2PtConicalEffect() { }
this->fIsFlipped == s.fIsFlipped);
}
- FocalOutside2PtConicalEffect(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX)
- : INHERITED(ctx, shader, matrix, tm)
+ FocalOutside2PtConicalEffect(const CreateArgs& args, SkScalar focalX)
+ : INHERITED(args)
, fFocalX(focalX)
- , fIsFlipped(shader.isFlippedGrad()) {
+ , fIsFlipped(static_cast<const SkTwoPointConicalGradient*>(args.fShader)->isFlippedGrad()) {
this->initClassID<FocalOutside2PtConicalEffect>();
}
public:
class GLSLFocalInside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar focalX) {
return sk_sp<GrFragmentProcessor>(
- new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX));
+ new FocalInside2PtConicalEffect(args, focalX));
}
virtual ~FocalInside2PtConicalEffect() {}
this->fFocalX == s.fFocalX);
}
- FocalInside2PtConicalEffect(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX)
- : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) {
+ FocalInside2PtConicalEffect(const CreateArgs& args, SkScalar focalX)
+ : INHERITED(args), fFocalX(focalX) {
this->initClassID<FocalInside2PtConicalEffect>();
}
public:
class GLSLCircleInside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
return sk_sp<GrFragmentProcessor>(
- new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info));
+ new CircleInside2PtConicalEffect(args, info));
}
virtual ~CircleInside2PtConicalEffect() {}
this->fInfo.fC == s.fInfo.fC);
}
- CircleInside2PtConicalEffect(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info)
- : INHERITED(ctx, shader, matrix, tm), fInfo(info) {
+ CircleInside2PtConicalEffect(const CreateArgs& args, const CircleConicalInfo& info)
+ : INHERITED(args), fInfo(info) {
this->initClassID<CircleInside2PtConicalEffect>();
}
public:
class GLSLCircleOutside2PtConicalProcessor;
- static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleConicalInfo& info) {
return sk_sp<GrFragmentProcessor>(
- new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info));
+ new CircleOutside2PtConicalEffect(args, info));
}
virtual ~CircleOutside2PtConicalEffect() {}
this->fIsFlipped == s.fIsFlipped);
}
- CircleOutside2PtConicalEffect(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info)
- : INHERITED(ctx, shader, matrix, tm), fInfo(info) {
+ CircleOutside2PtConicalEffect(const CreateArgs& args, const CircleConicalInfo& info)
+ : INHERITED(args), fInfo(info) {
this->initClassID<CircleOutside2PtConicalEffect>();
+ const SkTwoPointConicalGradient& shader =
+ *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
if (shader.getStartRadius() != shader.getEndRadius()) {
fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shader.getEndRadius());
} else {
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(
+ const GrGradientEffect::CreateArgs& args) {
+ const SkTwoPointConicalGradient& shader =
+ *static_cast<const SkTwoPointConicalGradient*>(args.fShader);
+
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return nullptr;
}
- if (localMatrix) {
+ if (args.fMatrix) {
SkMatrix inv;
- if (!localMatrix->invert(&inv)) {
+ if (!args.fMatrix->invert(&inv)) {
return nullptr;
}
matrix.postConcat(inv);
}
+ GrGradientEffect::CreateArgs newArgs(args.fContext, args.fShader, &matrix, args.fTileMode);
+
if (shader.getStartRadius() < kErrorTol) {
SkScalar focalX;
ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
if (type == kInside_ConicalType) {
- return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
+ return FocalInside2PtConicalEffect::Make(newArgs, focalX);
} else if(type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(newArgs);
} else {
- return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, focalX);
+ return FocalOutside2PtConicalEffect::Make(newArgs, focalX);
}
}
ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
if (type == kInside_ConicalType) {
- return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
+ return CircleInside2PtConicalEffect::Make(newArgs, info);
} else if (type == kEdge_ConicalType) {
set_matrix_edge_conical(shader, &matrix);
- return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
+ return Edge2PtConicalEffect::Make(newArgs);
} else {
- return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info);
+ return CircleOutside2PtConicalEffect::Make(newArgs, info);
}
}