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