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

Side by Side Diff: src/gpu/effects/GrRRectEffect.cpp

Issue 345083002: Stop referencing gl_FragCoord z and w components. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix circle effect 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
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrRRectEffect.h" 8 #include "GrRRectEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // correctly produce an alpha value of 1 at all four corners. We take the mi n of all the alphas. 192 // correctly produce an alpha value of 1 at all four corners. We take the mi n of all the alphas.
193 // The code below is a simplified version of the above that performs maxs on the vector 193 // The code below is a simplified version of the above that performs maxs on the vector
194 // components before computing distances and alpha values so that only one d istance computation 194 // components before computing distances and alpha values so that only one d istance computation
195 // need be computed to determine the min alpha. 195 // need be computed to determine the min alpha.
196 // 196 //
197 // For the cases where one half of the rrect is rectangular we drop one of t he x or y 197 // For the cases where one half of the rrect is rectangular we drop one of t he x or y
198 // computations, compute a separate rect edge alpha for the rect side, and m ul the two computed 198 // computations, compute a separate rect edge alpha for the rect side, and m ul the two computed
199 // alphas together. 199 // alphas together.
200 switch (crre.getCircularCornerFlags()) { 200 switch (crre.getCircularCornerFlags()) {
201 case CircularRRectEffect::kAll_CornerFlags: 201 case CircularRRectEffect::kAll_CornerFlags:
202 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos); 202 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s;\n", rectName, fr agmentPos);
203 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentP os, rectName); 203 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s - %s.zw;\n", fragmentPos, rectName);
204 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ; 204 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ;
205 builder->fsCodeAppendf("\t\tfloat alpha = clamp(%s - length(dxy), 0. 0, 1.0);\n", 205 builder->fsCodeAppendf("\t\tfloat alpha = clamp(%s - length(dxy), 0. 0, 1.0);\n",
206 radiusPlusHalfName); 206 radiusPlusHalfName);
207 break; 207 break;
208 case CircularRRectEffect::kTopLeft_CornerFlag: 208 case CircularRRectEffect::kTopLeft_CornerFlag:
209 builder->fsCodeAppendf("\t\tvec2 dxy = max(%s.xy - %s.xy, 0.0);\n", 209 builder->fsCodeAppendf("\t\tvec2 dxy = max(%s.xy - %s.xy, 0.0);\n",
210 rectName, fragmentPos); 210 rectName, fragmentPos);
211 builder->fsCodeAppendf("\t\tfloat rightAlpha = clamp(%s.z - %s.x, 0. 0, 1.0);\n", 211 builder->fsCodeAppendf("\t\tfloat rightAlpha = clamp(%s.z - %s.x, 0. 0, 1.0);\n",
212 rectName, fragmentPos); 212 rectName, fragmentPos);
213 builder->fsCodeAppendf("\t\tfloat bottomAlpha = clamp(%s.w - %s.y, 0 .0, 1.0);\n", 213 builder->fsCodeAppendf("\t\tfloat bottomAlpha = clamp(%s.w - %s.y, 0 .0, 1.0);\n",
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // to the ellipse center. The vector is pinned in x and y to be in the quart er-plane relevant 530 // to the ellipse center. The vector is pinned in x and y to be in the quart er-plane relevant
531 // to that corner. This means that points near the interior near the rrect t op edge will have 531 // to that corner. This means that points near the interior near the rrect t op edge will have
532 // a vector that points straight up for both the TL left and TR corners. Com puting an 532 // a vector that points straight up for both the TL left and TR corners. Com puting an
533 // alpha from this vector at either the TR or TL corner will give the correc t result. Similarly, 533 // alpha from this vector at either the TR or TL corner will give the correc t result. Similarly,
534 // fragments near the other three edges will get the correct AA. Fragments i n the interior of 534 // fragments near the other three edges will get the correct AA. Fragments i n the interior of
535 // the rrect will have a (0,0) vector at all four corners. So long as the ra dii > 0.5 they will 535 // the rrect will have a (0,0) vector at all four corners. So long as the ra dii > 0.5 they will
536 // correctly produce an alpha value of 1 at all four corners. We take the mi n of all the alphas. 536 // correctly produce an alpha value of 1 at all four corners. We take the mi n of all the alphas.
537 // The code below is a simplified version of the above that performs maxs on the vector 537 // The code below is a simplified version of the above that performs maxs on the vector
538 // components before computing distances and alpha values so that only one d istance computation 538 // components before computing distances and alpha values so that only one d istance computation
539 // need be computed to determine the min alpha. 539 // need be computed to determine the min alpha.
540 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmen tPos); 540 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s;\n", rectName, fragmentPo s);
541 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rect Name); 541 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s - %s.zw;\n", fragmentPos, rectNam e);
542 switch (erre.getRRect().getType()) { 542 switch (erre.getRRect().getType()) {
543 case SkRRect::kSimple_Type: { 543 case SkRRect::kSimple_Type: {
544 const char *invRadiiXYSqdName; 544 const char *invRadiiXYSqdName;
545 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme nt_Visibility, 545 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme nt_Visibility,
546 kVec2f_GrSLType, 546 kVec2f_GrSLType,
547 "invRadiiXY", 547 "invRadiiXY",
548 &invRadiiXYSqdName); 548 &invRadiiXYSqdName);
549 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ; 549 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ;
550 // Z is the x/y offsets divided by squared radii. 550 // Z is the x/y offsets divided by squared radii.
551 builder->fsCodeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName ); 551 builder->fsCodeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName );
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (rrect.isNinePatch()) { 721 if (rrect.isNinePatch()) {
722 return EllipticalRRectEffect::Create(edgeType, rrect); 722 return EllipticalRRectEffect::Create(edgeType, rrect);
723 } 723 }
724 return NULL; 724 return NULL;
725 } 725 }
726 } 726 }
727 } 727 }
728 728
729 return NULL; 729 return NULL;
730 } 730 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698