Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp

Issue 2332213007: Bundle common arguments to GrGradientEffect creation (Closed)
Patch Set: Fix non-GPU compile errors Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index e89193ff550974069c2f79fecdd4615f3346b5b1..b7cacc48ff46b93eb6389ecd6ccfc70d4d39b6ab 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include "SkTwoPointConicalGradient_gpu.h"
#include "SkTwoPointConicalGradient.h"
@@ -16,6 +15,8 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "SkTwoPointConicalGradient_gpu.h"
+
// For brevity
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
@@ -62,11 +63,8 @@ class Edge2PtConicalEffect : public GrGradientEffect {
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() {}
@@ -93,14 +91,13 @@ private:
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
@@ -376,13 +373,9 @@ class FocalOutside2PtConicalEffect : public GrGradientEffect {
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() { }
@@ -406,14 +399,10 @@ private:
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>();
}
@@ -591,13 +580,9 @@ class FocalInside2PtConicalEffect : public GrGradientEffect {
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() {}
@@ -621,12 +606,8 @@ private:
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>();
}
@@ -837,13 +818,9 @@ class CircleInside2PtConicalEffect : public GrGradientEffect {
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() {}
@@ -871,12 +848,8 @@ private:
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>();
}
@@ -1060,13 +1033,9 @@ class CircleOutside2PtConicalEffect : public GrGradientEffect {
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() {}
@@ -1097,13 +1066,11 @@ private:
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 {
@@ -1322,32 +1289,35 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey
//////////////////////////////////////////////////////////////////////////////
-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);
}
}
@@ -1355,12 +1325,12 @@ sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx,
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);
}
}
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698