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

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

Issue 278963002: add localmatrix parameter to shader's asNewEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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); 202 return shader->asNewEffect(context, paint, NULL);
203 } 203 }
204 204
205 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac tory, 205 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac tory,
206 const GrDrawEffect& drawEffect) 206 const GrDrawEffect& drawEffect)
207 : INHERITED(factory) 207 : INHERITED(factory)
208 , fVSVaryingName(NULL) 208 , fVSVaryingName(NULL)
209 , fFSVaryingName(NULL) 209 , fFSVaryingName(NULL)
210 , fCachedRadius(-SK_ScalarMax) 210 , fCachedRadius(-SK_ScalarMax)
211 , fCachedDiffRadius(-SK_ScalarMax) {} 211 , fCachedDiffRadius(-SK_ScalarMax) {}
212 212
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 SkColor colors[kMaxRandomGradientColors]; 463 SkColor colors[kMaxRandomGradientColors];
464 SkScalar stopsArray[kMaxRandomGradientColors]; 464 SkScalar stopsArray[kMaxRandomGradientColors];
465 SkScalar* stops = stopsArray; 465 SkScalar* stops = stopsArray;
466 SkShader::TileMode tm; 466 SkShader::TileMode tm;
467 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 467 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
468 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 468 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
469 center 2, radius2, 469 center 2, radius2,
470 colors , stops, colorCount, 470 colors , stops, colorCount,
471 tm)); 471 tm));
472 SkPaint paint; 472 SkPaint paint;
473 return shader->asNewEffect(context, paint); 473 return shader->asNewEffect(context, paint, NULL);
474 } 474 }
475 475
476 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEf fectFactory& factory, 476 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEf fectFactory& factory,
477 const GrDrawEffec t& drawEffect) 477 const GrDrawEffec t& drawEffect)
478 : INHERITED(factory) 478 : INHERITED(factory)
479 , fVSVaryingName(NULL) 479 , fVSVaryingName(NULL)
480 , fFSVaryingName(NULL) 480 , fFSVaryingName(NULL)
481 , fCachedFocal(SK_ScalarMax) { 481 , fCachedFocal(SK_ScalarMax) {
482 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid e2PtConicalEffect>(); 482 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid e2PtConicalEffect>();
483 fIsFlipped = data.isFlipped(); 483 fIsFlipped = data.isFlipped();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 SkColor colors[kMaxRandomGradientColors]; 672 SkColor colors[kMaxRandomGradientColors];
673 SkScalar stopsArray[kMaxRandomGradientColors]; 673 SkScalar stopsArray[kMaxRandomGradientColors];
674 SkScalar* stops = stopsArray; 674 SkScalar* stops = stopsArray;
675 SkShader::TileMode tm; 675 SkShader::TileMode tm;
676 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 676 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
677 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 677 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
678 center 2, radius2, 678 center 2, radius2,
679 colors , stops, colorCount, 679 colors , stops, colorCount,
680 tm)); 680 tm));
681 SkPaint paint; 681 SkPaint paint;
682 return shader->asNewEffect(context, paint); 682 return shader->asNewEffect(context, paint, NULL);
683 } 683 }
684 684
685 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffe ctFactory& factory, 685 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffe ctFactory& factory,
686 const GrDrawEffect& drawEffect) 686 const GrDrawEffect& drawEffect)
687 : INHERITED(factory) 687 : INHERITED(factory)
688 , fVSVaryingName(NULL) 688 , fVSVaryingName(NULL)
689 , fFSVaryingName(NULL) 689 , fFSVaryingName(NULL)
690 , fCachedFocal(SK_ScalarMax) {} 690 , fCachedFocal(SK_ScalarMax) {}
691 691
692 void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder, 692 void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 SkColor colors[kMaxRandomGradientColors]; 913 SkColor colors[kMaxRandomGradientColors];
914 SkScalar stopsArray[kMaxRandomGradientColors]; 914 SkScalar stopsArray[kMaxRandomGradientColors];
915 SkScalar* stops = stopsArray; 915 SkScalar* stops = stopsArray;
916 SkShader::TileMode tm; 916 SkShader::TileMode tm;
917 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 917 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
918 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 918 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
919 center 2, radius2, 919 center 2, radius2,
920 colors , stops, colorCount, 920 colors , stops, colorCount,
921 tm)); 921 tm));
922 SkPaint paint; 922 SkPaint paint;
923 return shader->asNewEffect(context, paint); 923 return shader->asNewEffect(context, paint, NULL);
924 } 924 }
925 925
926 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf fectFactory& factory, 926 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf fectFactory& factory,
927 const GrDrawEffec t& drawEffect) 927 const GrDrawEffec t& drawEffect)
928 : INHERITED(factory) 928 : INHERITED(factory)
929 , fVSVaryingName(NULL) 929 , fVSVaryingName(NULL)
930 , fFSVaryingName(NULL) 930 , fFSVaryingName(NULL)
931 , fCachedCenterX(SK_ScalarMax) 931 , fCachedCenterX(SK_ScalarMax)
932 , fCachedCenterY(SK_ScalarMax) 932 , fCachedCenterY(SK_ScalarMax)
933 , fCachedA(SK_ScalarMax) 933 , fCachedA(SK_ScalarMax)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 SkColor colors[kMaxRandomGradientColors]; 1141 SkColor colors[kMaxRandomGradientColors];
1142 SkScalar stopsArray[kMaxRandomGradientColors]; 1142 SkScalar stopsArray[kMaxRandomGradientColors];
1143 SkScalar* stops = stopsArray; 1143 SkScalar* stops = stopsArray;
1144 SkShader::TileMode tm; 1144 SkShader::TileMode tm;
1145 int colorCount = RandomGradientParams(random, colors, &stops, &tm); 1145 int colorCount = RandomGradientParams(random, colors, &stops, &tm);
1146 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 1146 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
1147 center 2, radius2, 1147 center 2, radius2,
1148 colors , stops, colorCount, 1148 colors , stops, colorCount,
1149 tm)); 1149 tm));
1150 SkPaint paint; 1150 SkPaint paint;
1151 return shader->asNewEffect(context, paint); 1151 return shader->asNewEffect(context, paint, NULL);
1152 } 1152 }
1153 1153
1154 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend EffectFactory& factory, 1154 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend EffectFactory& factory,
1155 const GrDrawEff ect& drawEffect) 1155 const GrDrawEff ect& drawEffect)
1156 : INHERITED(factory) 1156 : INHERITED(factory)
1157 , fVSVaryingName(NULL) 1157 , fVSVaryingName(NULL)
1158 , fFSVaryingName(NULL) 1158 , fFSVaryingName(NULL)
1159 , fCachedCenterX(SK_ScalarMax) 1159 , fCachedCenterX(SK_ScalarMax)
1160 , fCachedCenterY(SK_ScalarMax) 1160 , fCachedCenterY(SK_ScalarMax)
1161 , fCachedA(SK_ScalarMax) 1161 , fCachedA(SK_ScalarMax)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 if (drawEffect.castEffect<CircleOutside2PtConicalEffect>().isFlipped()) { 1260 if (drawEffect.castEffect<CircleOutside2PtConicalEffect>().isFlipped()) {
1261 key |= kIsFlipped; 1261 key |= kIsFlipped;
1262 } 1262 }
1263 return key; 1263 return key;
1264 } 1264 }
1265 1265
1266 ////////////////////////////////////////////////////////////////////////////// 1266 //////////////////////////////////////////////////////////////////////////////
1267 1267
1268 GrEffectRef* Gr2PtConicalGradientEffect::Create(GrContext* ctx, 1268 GrEffectRef* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
1269 const SkTwoPointConicalGradient& shader, 1269 const SkTwoPointConicalGradient& shader,
1270 SkShader::TileMode tm) { 1270 SkShader::TileMode tm,
1271 const SkMatrix* localMatrix) {
1271 SkMatrix matrix; 1272 SkMatrix matrix;
1272 if (!shader.getLocalMatrix().invert(&matrix)) { 1273 if (!shader.getLocalMatrix().invert(&matrix)) {
1273 return NULL; 1274 return NULL;
1274 } 1275 }
1276 if (localMatrix) {
1277 SkMatrix inv;
1278 if (!localMatrix->invert(&inv)) {
1279 return NULL;
1280 }
1281 matrix.postConcat(inv);
1282 }
1275 1283
1276 if (shader.getStartRadius() < kErrorTol) { 1284 if (shader.getStartRadius() < kErrorTol) {
1277 SkScalar focalX; 1285 SkScalar focalX;
1278 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); 1286 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
1279 if (type == kInside_ConicalType) { 1287 if (type == kInside_ConicalType) {
1280 return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1288 return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
1281 } else if(type == kEdge_ConicalType) { 1289 } else if(type == kEdge_ConicalType) {
1282 set_matrix_edge_conical(shader, &matrix); 1290 set_matrix_edge_conical(shader, &matrix);
1283 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1291 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
1284 } else { 1292 } else {
1285 return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1293 return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX);
1286 } 1294 }
1287 } 1295 }
1288 1296
1289 CircleConicalInfo info; 1297 CircleConicalInfo info;
1290 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); 1298 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
1291 1299
1292 if (type == kInside_ConicalType) { 1300 if (type == kInside_ConicalType) {
1293 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1301 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o);
1294 } else if (type == kEdge_ConicalType) { 1302 } else if (type == kEdge_ConicalType) {
1295 set_matrix_edge_conical(shader, &matrix); 1303 set_matrix_edge_conical(shader, &matrix);
1296 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1304 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
1297 } else { 1305 } else {
1298 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1306 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo);
1299 } 1307 }
1300 } 1308 }
1301 1309
1302 #endif 1310 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | src/effects/gradients/SkTwoPointRadialGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698