| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
| 9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 // Compute the coverage for the rect's width | 78 // Compute the coverage for the rect's width |
| 79 builder->fsCodeAppendf( | 79 builder->fsCodeAppendf( |
| 80 "\tfloat coverage = scaleW*clamp((%s.z-abs(%s.x))/spanW, 0.0, 1.
0);\n", fsRectName, | 80 "\tfloat coverage = scaleW*clamp((%s.z-abs(%s.x))/spanW, 0.0, 1.
0);\n", fsRectName, |
| 81 fsRectName); | 81 fsRectName); |
| 82 // Compute the coverage for the rect's height and merge with the wid
th | 82 // Compute the coverage for the rect's height and merge with the wid
th |
| 83 builder->fsCodeAppendf( | 83 builder->fsCodeAppendf( |
| 84 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0,
1.0);\n", | 84 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0,
1.0);\n", |
| 85 fsRectName, fsRectName); | 85 fsRectName, fsRectName); |
| 86 | 86 |
| 87 SkString modulate; | 87 |
| 88 GrGLSLModulatef<4>(&modulate, inputColor, "coverage"); | 88 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
| 89 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str()
); | 89 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("c
overage")).c_str()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { | 92 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { |
| 93 return 0; | 93 return 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
) SK_OVERRIDE {} | 96 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
) SK_OVERRIDE {} |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 typedef GrGLVertexEffect INHERITED; | 99 typedef GrGLVertexEffect INHERITED; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 "\tfloat coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0)
;\n", | 210 "\tfloat coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0)
;\n", |
| 211 fsWidthHeightName); | 211 fsWidthHeightName); |
| 212 | 212 |
| 213 // Compute the coverage for the rect's height and merge with the wid
th | 213 // Compute the coverage for the rect's height and merge with the wid
th |
| 214 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n", | 214 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n", |
| 215 fsRectEdgeName); | 215 fsRectEdgeName); |
| 216 builder->fsCodeAppendf( | 216 builder->fsCodeAppendf( |
| 217 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0.
0, 1.0);\n", | 217 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0.
0, 1.0);\n", |
| 218 fsWidthHeightName); | 218 fsWidthHeightName); |
| 219 | 219 |
| 220 SkString modulate; | 220 |
| 221 GrGLSLModulatef<4>(&modulate, inputColor, "coverage"); | 221 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
| 222 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str()
); | 222 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("c
overage")).c_str()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { | 225 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { |
| 226 return 0; | 226 return 0; |
| 227 } | 227 } |
| 228 | 228 |
| 229 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
) SK_OVERRIDE {} | 229 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
) SK_OVERRIDE {} |
| 230 | 230 |
| 231 private: | 231 private: |
| 232 typedef GrGLVertexEffect INHERITED; | 232 typedef GrGLVertexEffect INHERITED; |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 // can't call mapRect for devInside since it calls sort | 806 // can't call mapRect for devInside since it calls sort |
| 807 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 807 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 808 | 808 |
| 809 if (devInside.isEmpty()) { | 809 if (devInside.isEmpty()) { |
| 810 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); | 810 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); |
| 811 return; | 811 return; |
| 812 } | 812 } |
| 813 | 813 |
| 814 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove
rage); | 814 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove
rage); |
| 815 } | 815 } |
| OLD | NEW |