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

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkColorShader refactor and fix Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkTwoPointConicalGradient_gpu.h" 9 #include "SkTwoPointConicalGradient_gpu.h"
10 10
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 SkColor colors[kMaxRandomGradientColors]; 192 SkColor colors[kMaxRandomGradientColors];
193 SkScalar stopsArray[kMaxRandomGradientColors]; 193 SkScalar stopsArray[kMaxRandomGradientColors];
194 SkScalar* stops = stopsArray; 194 SkScalar* stops = stopsArray;
195 SkShader::TileMode tm; 195 SkShader::TileMode tm;
196 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 196 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
197 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 197 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
198 center 2, radius2, 198 center 2, radius2,
199 colors , stops, colorCount, 199 colors , stops, colorCount,
200 tm)); 200 tm));
201 SkPaint paint; 201 SkPaint paint;
202 return shader->asNewEffect(context, paint, NULL); 202 GrEffectRef* effect;
203 GrColor grColor;
204 shader->asNewEffect(context, paint, NULL, &grColor, &effect);
205 return effect;
203 } 206 }
204 207
205 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac tory, 208 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac tory,
206 const GrDrawEffect& drawEffect) 209 const GrDrawEffect& drawEffect)
207 : INHERITED(factory) 210 : INHERITED(factory)
208 , fVSVaryingName(NULL) 211 , fVSVaryingName(NULL)
209 , fFSVaryingName(NULL) 212 , fFSVaryingName(NULL)
210 , fCachedRadius(-SK_ScalarMax) 213 , fCachedRadius(-SK_ScalarMax)
211 , fCachedDiffRadius(-SK_ScalarMax) {} 214 , fCachedDiffRadius(-SK_ScalarMax) {}
212 215
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 SkColor colors[kMaxRandomGradientColors]; 466 SkColor colors[kMaxRandomGradientColors];
464 SkScalar stopsArray[kMaxRandomGradientColors]; 467 SkScalar stopsArray[kMaxRandomGradientColors];
465 SkScalar* stops = stopsArray; 468 SkScalar* stops = stopsArray;
466 SkShader::TileMode tm; 469 SkShader::TileMode tm;
467 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 470 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
468 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 471 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
469 center 2, radius2, 472 center 2, radius2,
470 colors , stops, colorCount, 473 colors , stops, colorCount,
471 tm)); 474 tm));
472 SkPaint paint; 475 SkPaint paint;
473 return shader->asNewEffect(context, paint, NULL); 476 GrEffectRef* effect;
477 GrColor grColor;
478 shader->asNewEffect(context, paint, NULL, &grColor, &effect);
479 return effect;
474 } 480 }
475 481
476 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEf fectFactory& factory, 482 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEf fectFactory& factory,
477 const GrDrawEffec t& drawEffect) 483 const GrDrawEffec t& drawEffect)
478 : INHERITED(factory) 484 : INHERITED(factory)
479 , fVSVaryingName(NULL) 485 , fVSVaryingName(NULL)
480 , fFSVaryingName(NULL) 486 , fFSVaryingName(NULL)
481 , fCachedFocal(SK_ScalarMax) { 487 , fCachedFocal(SK_ScalarMax) {
482 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid e2PtConicalEffect>(); 488 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid e2PtConicalEffect>();
483 fIsFlipped = data.isFlipped(); 489 fIsFlipped = data.isFlipped();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 SkColor colors[kMaxRandomGradientColors]; 678 SkColor colors[kMaxRandomGradientColors];
673 SkScalar stopsArray[kMaxRandomGradientColors]; 679 SkScalar stopsArray[kMaxRandomGradientColors];
674 SkScalar* stops = stopsArray; 680 SkScalar* stops = stopsArray;
675 SkShader::TileMode tm; 681 SkShader::TileMode tm;
676 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 682 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
677 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 683 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
678 center 2, radius2, 684 center 2, radius2,
679 colors , stops, colorCount, 685 colors , stops, colorCount,
680 tm)); 686 tm));
681 SkPaint paint; 687 SkPaint paint;
682 return shader->asNewEffect(context, paint, NULL); 688 GrColor grColor;
689 GrEffectRef* grEffect;
690 shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
691 return grEffect;
683 } 692 }
684 693
685 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffe ctFactory& factory, 694 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffe ctFactory& factory,
686 const GrDrawEffect& drawEffect) 695 const GrDrawEffect& drawEffect)
687 : INHERITED(factory) 696 : INHERITED(factory)
688 , fVSVaryingName(NULL) 697 , fVSVaryingName(NULL)
689 , fFSVaryingName(NULL) 698 , fFSVaryingName(NULL)
690 , fCachedFocal(SK_ScalarMax) {} 699 , fCachedFocal(SK_ScalarMax) {}
691 700
692 void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder, 701 void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 SkColor colors[kMaxRandomGradientColors]; 922 SkColor colors[kMaxRandomGradientColors];
914 SkScalar stopsArray[kMaxRandomGradientColors]; 923 SkScalar stopsArray[kMaxRandomGradientColors];
915 SkScalar* stops = stopsArray; 924 SkScalar* stops = stopsArray;
916 SkShader::TileMode tm; 925 SkShader::TileMode tm;
917 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 926 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
918 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 927 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
919 center 2, radius2, 928 center 2, radius2,
920 colors , stops, colorCount, 929 colors , stops, colorCount,
921 tm)); 930 tm));
922 SkPaint paint; 931 SkPaint paint;
923 return shader->asNewEffect(context, paint, NULL); 932 GrColor grColor;
933 GrEffectRef* grEffect;
934 shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
935 return grEffect;
924 } 936 }
925 937
926 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf fectFactory& factory, 938 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf fectFactory& factory,
927 const GrDrawEffec t& drawEffect) 939 const GrDrawEffec t& drawEffect)
928 : INHERITED(factory) 940 : INHERITED(factory)
929 , fVSVaryingName(NULL) 941 , fVSVaryingName(NULL)
930 , fFSVaryingName(NULL) 942 , fFSVaryingName(NULL)
931 , fCachedCenterX(SK_ScalarMax) 943 , fCachedCenterX(SK_ScalarMax)
932 , fCachedCenterY(SK_ScalarMax) 944 , fCachedCenterY(SK_ScalarMax)
933 , fCachedA(SK_ScalarMax) 945 , fCachedA(SK_ScalarMax)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 SkColor colors[kMaxRandomGradientColors]; 1153 SkColor colors[kMaxRandomGradientColors];
1142 SkScalar stopsArray[kMaxRandomGradientColors]; 1154 SkScalar stopsArray[kMaxRandomGradientColors];
1143 SkScalar* stops = stopsArray; 1155 SkScalar* stops = stopsArray;
1144 SkShader::TileMode tm; 1156 SkShader::TileMode tm;
1145 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 1157 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
1146 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 1158 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
1147 center 2, radius2, 1159 center 2, radius2,
1148 colors , stops, colorCount, 1160 colors , stops, colorCount,
1149 tm)); 1161 tm));
1150 SkPaint paint; 1162 SkPaint paint;
1151 return shader->asNewEffect(context, paint, NULL); 1163 GrColor grColor;
1164 GrEffectRef* grEffect;
1165 shader->asNewEffect(context, paint, NULL, &grColor, &grEffect);
1166 return grEffect;
1152 } 1167 }
1153 1168
1154 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend EffectFactory& factory, 1169 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend EffectFactory& factory,
1155 const GrDrawEff ect& drawEffect) 1170 const GrDrawEff ect& drawEffect)
1156 : INHERITED(factory) 1171 : INHERITED(factory)
1157 , fVSVaryingName(NULL) 1172 , fVSVaryingName(NULL)
1158 , fFSVaryingName(NULL) 1173 , fFSVaryingName(NULL)
1159 , fCachedCenterX(SK_ScalarMax) 1174 , fCachedCenterX(SK_ScalarMax)
1160 , fCachedCenterY(SK_ScalarMax) 1175 , fCachedCenterY(SK_ScalarMax)
1161 , fCachedA(SK_ScalarMax) 1176 , fCachedA(SK_ScalarMax)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1316 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o);
1302 } else if (type == kEdge_ConicalType) { 1317 } else if (type == kEdge_ConicalType) {
1303 set_matrix_edge_conical(shader, &matrix); 1318 set_matrix_edge_conical(shader, &matrix);
1304 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1319 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
1305 } else { 1320 } else {
1306 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1321 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo);
1307 } 1322 }
1308 } 1323 }
1309 1324
1310 #endif 1325 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698