| OLD | NEW |
| 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 "GrConvexPolyEffect.h" | 10 #include "GrConvexPolyEffect.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // half a pixel. | 169 // half a pixel. |
| 170 fInnerRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, | 170 fInnerRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, |
| 171 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, | 171 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, |
| 172 "innerRect", | 172 "innerRect", |
| 173 &rectName); | 173 &rectName); |
| 174 fRadiusPlusHalfUniform = builder->addUniform(GrGLProgramBuilder::kFragment_V
isibility, | 174 fRadiusPlusHalfUniform = builder->addUniform(GrGLProgramBuilder::kFragment_V
isibility, |
| 175 kFloat_GrSLType, kDefault_GrSLP
recision, | 175 kFloat_GrSLType, kDefault_GrSLP
recision, |
| 176 "radiusPlusHalf", | 176 "radiusPlusHalf", |
| 177 &radiusPlusHalfName); | 177 &radiusPlusHalfName); |
| 178 | 178 |
| 179 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 179 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 180 const char* fragmentPos = fsBuilder->fragmentPosition(); | 180 const char* fragmentPos = fsBuilder->fragmentPosition(); |
| 181 // At each quarter-circle corner we compute a vector that is the offset of t
he fragment position | 181 // At each quarter-circle corner we compute a vector that is the offset of t
he fragment position |
| 182 // from the circle center. The vector is pinned in x and y to be in the quar
ter-plane relevant | 182 // from the circle center. The vector is pinned in x and y to be in the quar
ter-plane relevant |
| 183 // to that corner. This means that points near the interior near the rrect t
op edge will have | 183 // to that corner. This means that points near the interior near the rrect t
op edge will have |
| 184 // a vector that points straight up for both the TL left and TR corners. Com
puting an | 184 // a vector that points straight up for both the TL left and TR corners. Com
puting an |
| 185 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, | 185 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, |
| 186 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of | 186 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of |
| 187 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dius > 0.5 they will | 187 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dius > 0.5 they will |
| 188 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. | 188 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. |
| 189 // The code below is a simplified version of the above that performs maxs on
the vector | 189 // The code below is a simplified version of the above that performs maxs on
the vector |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 const TransformedCoordsArray&, | 518 const TransformedCoordsArray&, |
| 519 const TextureSamplerArray& samplers) { | 519 const TextureSamplerArray& samplers) { |
| 520 const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>(); | 520 const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>(); |
| 521 const char *rectName; | 521 const char *rectName; |
| 522 // The inner rect is the rrect bounds inset by the x/y radii | 522 // The inner rect is the rrect bounds inset by the x/y radii |
| 523 fInnerRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, | 523 fInnerRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, |
| 524 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, | 524 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, |
| 525 "innerRect", | 525 "innerRect", |
| 526 &rectName); | 526 &rectName); |
| 527 | 527 |
| 528 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 528 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 529 const char* fragmentPos = fsBuilder->fragmentPosition(); | 529 const char* fragmentPos = fsBuilder->fragmentPosition(); |
| 530 // At each quarter-ellipse corner we compute a vector that is the offset of
the fragment pos | 530 // At each quarter-ellipse corner we compute a vector that is the offset of
the fragment pos |
| 531 // to the ellipse center. The vector is pinned in x and y to be in the quart
er-plane relevant | 531 // to the ellipse center. The vector is pinned in x and y to be in the quart
er-plane relevant |
| 532 // to that corner. This means that points near the interior near the rrect t
op edge will have | 532 // to that corner. This means that points near the interior near the rrect t
op edge will have |
| 533 // a vector that points straight up for both the TL left and TR corners. Com
puting an | 533 // a vector that points straight up for both the TL left and TR corners. Com
puting an |
| 534 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, | 534 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, |
| 535 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of | 535 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of |
| 536 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dii > 0.5 they will | 536 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dii > 0.5 they will |
| 537 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. | 537 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. |
| 538 // The code below is a simplified version of the above that performs maxs on
the vector | 538 // The code below is a simplified version of the above that performs maxs on
the vector |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 if (rrect.isNinePatch()) { | 733 if (rrect.isNinePatch()) { |
| 734 return EllipticalRRectEffect::Create(edgeType, rrect); | 734 return EllipticalRRectEffect::Create(edgeType, rrect); |
| 735 } | 735 } |
| 736 return NULL; | 736 return NULL; |
| 737 } | 737 } |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 return NULL; | 741 return NULL; |
| 742 } | 742 } |
| OLD | NEW |