| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a
0 .. 1 range. | 193 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a
0 .. 1 range. |
| 194 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n"); | 194 builder->fsCodeAppend("\tfloat spanW = insetW + outset;\n"); |
| 195 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n"); | 195 builder->fsCodeAppend("\tfloat spanH = insetH + outset;\n"); |
| 196 // For rects < 1 pixel wide or tall, these scale factors are used to
cap the maximum | 196 // For rects < 1 pixel wide or tall, these scale factors are used to
cap the maximum |
| 197 // value of coverage that is used. In other words it is the coverage
that is | 197 // value of coverage that is used. In other words it is the coverage
that is |
| 198 // used in the interior of the rect after the ramp. | 198 // used in the interior of the rect after the ramp. |
| 199 builder->fsCodeAppend("\tfloat scaleW = min(1.0, 2.0*insetW/spanW);\
n"); | 199 builder->fsCodeAppend("\tfloat scaleW = min(1.0, 2.0*insetW/spanW);\
n"); |
| 200 builder->fsCodeAppend("\tfloat scaleH = min(1.0, 2.0*insetH/spanH);\
n"); | 200 builder->fsCodeAppend("\tfloat scaleH = min(1.0, 2.0*insetH/spanH);\
n"); |
| 201 | 201 |
| 202 // Compute the coverage for the rect's width | 202 // Compute the coverage for the rect's width |
| 203 builder->fsCodeAppendf("\tvec2 offset = %s - %s.xy;\n", | 203 builder->fsCodeAppendf("\tvec2 offset = %s.xy - %s.xy;\n", |
| 204 builder->fragmentPosition(), fsRectEdgeName); | 204 builder->fragmentPosition(), fsRectEdgeName); |
| 205 builder->fsCodeAppendf("\tfloat perpDot = abs(offset.x * %s.w - offs
et.y * %s.z);\n", | 205 builder->fsCodeAppendf("\tfloat perpDot = abs(offset.x * %s.w - offs
et.y * %s.z);\n", |
| 206 fsRectEdgeName, fsRectEdgeName); | 206 fsRectEdgeName, fsRectEdgeName); |
| 207 builder->fsCodeAppendf( | 207 builder->fsCodeAppendf( |
| 208 "\tfloat coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0)
;\n", | 208 "\tfloat coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0)
;\n", |
| 209 fsWidthHeightName); | 209 fsWidthHeightName); |
| 210 | 210 |
| 211 // Compute the coverage for the rect's height and merge with the wid
th | 211 // Compute the coverage for the rect's height and merge with the wid
th |
| 212 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n", | 212 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n", |
| 213 fsRectEdgeName); | 213 fsRectEdgeName); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 923 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 924 | 924 |
| 925 if (devInside.isEmpty()) { | 925 if (devInside.isEmpty()) { |
| 926 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); | 926 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use
VertexCoverage); |
| 927 return; | 927 return; |
| 928 } | 928 } |
| 929 | 929 |
| 930 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, | 930 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, |
| 931 devInside, useVertexCoverage, true); | 931 devInside, useVertexCoverage, true); |
| 932 } | 932 } |
| OLD | NEW |