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