Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Michael Ludwig | fd4f4df | 2019-05-29 09:51:09 -0400 | [diff] [blame] | 8 | #include "src/gpu/ops/GrQuadPerEdgeAA.h" |
| 9 | |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 10 | #include "include/private/SkVx.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/SkGr.h" |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 12 | #include "src/gpu/geometry/GrQuadUtils.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h" |
| 14 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 15 | #include "src/gpu/glsl/GrGLSLGeometryProcessor.h" |
| 16 | #include "src/gpu/glsl/GrGLSLPrimitiveProcessor.h" |
| 17 | #include "src/gpu/glsl/GrGLSLVarying.h" |
| 18 | #include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h" |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 19 | |
Michael Ludwig | f995c05 | 2018-11-26 15:24:29 -0500 | [diff] [blame] | 20 | |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 21 | namespace { |
| 22 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 23 | // Generic WriteQuadProc that can handle any VertexSpec. It writes the 4 vertices in triangle strip |
| 24 | // order, although the data per-vertex is dependent on the VertexSpec. |
| 25 | static void write_quad_generic(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 26 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 27 | const float coverage[4], const SkPMColor4f& color, |
| 28 | const SkRect& geomDomain, const SkRect& texDomain) { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 29 | static constexpr auto If = GrVertexWriter::If<float>; |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 30 | GrQuadPerEdgeAA::CoverageMode mode = spec.coverageMode(); |
Michael Ludwig | 553e9a9 | 2018-11-29 12:38:35 -0500 | [diff] [blame] | 31 | for (int i = 0; i < 4; ++i) { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 32 | // save position, this is a float2 or float3 or float4 depending on the combination of |
| 33 | // perspective and coverage mode. |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 34 | vb->write(deviceQuad.x(i), deviceQuad.y(i), |
| 35 | If(spec.deviceQuadType() == GrQuad::Type::kPerspective, deviceQuad.w(i)), |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 36 | If(mode == GrQuadPerEdgeAA::CoverageMode::kWithPosition, coverage[i])); |
Michael Ludwig | 4921dc3 | 2018-12-03 14:57:29 +0000 | [diff] [blame] | 37 | |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 38 | // save color |
| 39 | if (spec.hasVertexColors()) { |
Brian Salomon | 1d83542 | 2019-03-13 16:11:44 -0400 | [diff] [blame] | 40 | bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kHalf; |
Michael Ludwig | e6266a2 | 2019-03-07 11:24:32 -0500 | [diff] [blame] | 41 | vb->write(GrVertexColor( |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 42 | color * (mode == GrQuadPerEdgeAA::CoverageMode::kWithColor ? coverage[i] : 1.f), |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 43 | wide)); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | // save local position |
| 47 | if (spec.hasLocalCoords()) { |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 48 | vb->write(localQuad.x(i), localQuad.y(i), |
| 49 | If(spec.localQuadType() == GrQuad::Type::kPerspective, localQuad.w(i))); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 50 | } |
| 51 | |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 52 | // save the geometry domain |
| 53 | if (spec.requiresGeometryDomain()) { |
| 54 | vb->write(geomDomain); |
| 55 | } |
| 56 | |
| 57 | // save the texture domain |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 58 | if (spec.hasDomain()) { |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 59 | vb->write(texDomain); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 64 | // Specialized WriteQuadProcs for particular VertexSpecs that show up frequently (determined |
| 65 | // experimentally through recorded GMs, SKPs, and SVGs, as well as SkiaRenderer's usage patterns): |
| 66 | |
| 67 | // 2D (XY), no explicit coverage, vertex color, no locals, no geometry domain, no texture domain |
| 68 | // This represents simple, solid color or shader, non-AA (or AA with cov. as alpha) rects. |
| 69 | static void write_2d_color(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 70 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 71 | const float coverage[4], const SkPMColor4f& color, |
| 72 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 73 | // Assert assumptions about VertexSpec |
| 74 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 75 | SkASSERT(!spec.hasLocalCoords()); |
| 76 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone || |
| 77 | spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor); |
| 78 | SkASSERT(spec.hasVertexColors()); |
| 79 | SkASSERT(!spec.requiresGeometryDomain()); |
| 80 | SkASSERT(!spec.hasDomain()); |
| 81 | |
| 82 | bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kHalf; |
| 83 | for (int i = 0; i < 4; ++i) { |
| 84 | // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything |
| 85 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor || |
| 86 | coverage[i] == 1.f); |
| 87 | vb->write(deviceQuad.x(i), deviceQuad.y(i), GrVertexColor(color * coverage[i], wide)); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // 2D (XY), no explicit coverage, UV locals, no color, no geometry domain, no texture domain |
| 92 | // This represents opaque, non AA, textured rects |
| 93 | static void write_2d_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 94 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 95 | const float coverage[4], const SkPMColor4f& color, |
| 96 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 97 | // Assert assumptions about VertexSpec |
| 98 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 99 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 100 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone); |
| 101 | SkASSERT(!spec.hasVertexColors()); |
| 102 | SkASSERT(!spec.requiresGeometryDomain()); |
| 103 | SkASSERT(!spec.hasDomain()); |
| 104 | |
| 105 | for (int i = 0; i < 4; ++i) { |
| 106 | vb->write(deviceQuad.x(i), deviceQuad.y(i), localQuad.x(i), localQuad.y(i)); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // 2D (XY), no explicit coverage, UV locals, vertex color, no geometry or texture domains |
| 111 | // This represents transparent, non AA (or AA with cov. as alpha), textured rects |
| 112 | static void write_2d_color_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 113 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 114 | const float coverage[4], const SkPMColor4f& color, |
| 115 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 116 | // Assert assumptions about VertexSpec |
| 117 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 118 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 119 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone || |
| 120 | spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor); |
| 121 | SkASSERT(spec.hasVertexColors()); |
| 122 | SkASSERT(!spec.requiresGeometryDomain()); |
| 123 | SkASSERT(!spec.hasDomain()); |
| 124 | |
| 125 | bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kHalf; |
| 126 | for (int i = 0; i < 4; ++i) { |
| 127 | // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything |
| 128 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor || |
| 129 | coverage[i] == 1.f); |
| 130 | vb->write(deviceQuad.x(i), deviceQuad.y(i), GrVertexColor(color * coverage[i], wide), |
| 131 | localQuad.x(i), localQuad.y(i)); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // 2D (XY), explicit coverage, UV locals, no color, no geometry domain, no texture domain |
| 136 | // This represents opaque, AA, textured rects |
| 137 | static void write_2d_cov_uv(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 138 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 139 | const float coverage[4], const SkPMColor4f& color, |
| 140 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 141 | // Assert assumptions about VertexSpec |
| 142 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 143 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 144 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithPosition); |
| 145 | SkASSERT(!spec.hasVertexColors()); |
| 146 | SkASSERT(!spec.requiresGeometryDomain()); |
| 147 | SkASSERT(!spec.hasDomain()); |
| 148 | |
| 149 | for (int i = 0; i < 4; ++i) { |
| 150 | vb->write(deviceQuad.x(i), deviceQuad.y(i), coverage[i], localQuad.x(i), localQuad.y(i)); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // NOTE: The three _strict specializations below match the non-strict uv functions above, except |
| 155 | // that they also write the UV domain. These are included to benefit SkiaRenderer, which must make |
| 156 | // use of both fast and strict constrained domains. When testing _strict was not that common across |
| 157 | // GMS, SKPs, and SVGs but we have little visibility into actual SkiaRenderer statistics. If |
| 158 | // SkiaRenderer can avoid domains more, these 3 functions should probably be removed for simplicity. |
| 159 | |
| 160 | // 2D (XY), no explicit coverage, UV locals, no color, tex domain but no geometry domain |
| 161 | // This represents opaque, non AA, textured rects with strict uv sampling |
| 162 | static void write_2d_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 163 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 164 | const float coverage[4], const SkPMColor4f& color, |
| 165 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 166 | // Assert assumptions about VertexSpec |
| 167 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 168 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 169 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone); |
| 170 | SkASSERT(!spec.hasVertexColors()); |
| 171 | SkASSERT(!spec.requiresGeometryDomain()); |
| 172 | SkASSERT(spec.hasDomain()); |
| 173 | |
| 174 | for (int i = 0; i < 4; ++i) { |
| 175 | vb->write(deviceQuad.x(i), deviceQuad.y(i), localQuad.x(i), localQuad.y(i), texDomain); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // 2D (XY), no explicit coverage, UV locals, vertex color, tex domain but no geometry domain |
| 180 | // This represents transparent, non AA (or AA with cov. as alpha), textured rects with strict sample |
| 181 | static void write_2d_color_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 182 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 183 | const float coverage[4], const SkPMColor4f& color, |
| 184 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 185 | // Assert assumptions about VertexSpec |
| 186 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 187 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 188 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kNone || |
| 189 | spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor); |
| 190 | SkASSERT(spec.hasVertexColors()); |
| 191 | SkASSERT(!spec.requiresGeometryDomain()); |
| 192 | SkASSERT(spec.hasDomain()); |
| 193 | |
| 194 | bool wide = spec.colorType() == GrQuadPerEdgeAA::ColorType::kHalf; |
| 195 | for (int i = 0; i < 4; ++i) { |
| 196 | // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything |
| 197 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithColor || |
| 198 | coverage[i] == 1.f); |
| 199 | vb->write(deviceQuad.x(i), deviceQuad.y(i), GrVertexColor(color * coverage[i], wide), |
| 200 | localQuad.x(i), localQuad.y(i), texDomain); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // 2D (XY), explicit coverage, UV locals, no color, tex domain but no geometry domain |
| 205 | // This represents opaque, AA, textured rects with strict uv sampling |
| 206 | static void write_2d_cov_uv_strict(GrVertexWriter* vb, const GrQuadPerEdgeAA::VertexSpec& spec, |
| 207 | const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 208 | const float coverage[4], const SkPMColor4f& color, |
| 209 | const SkRect& geomDomain, const SkRect& texDomain) { |
| 210 | // Assert assumptions about VertexSpec |
| 211 | SkASSERT(spec.deviceQuadType() != GrQuad::Type::kPerspective); |
| 212 | SkASSERT(spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective); |
| 213 | SkASSERT(spec.coverageMode() == GrQuadPerEdgeAA::CoverageMode::kWithPosition); |
| 214 | SkASSERT(!spec.hasVertexColors()); |
| 215 | SkASSERT(!spec.requiresGeometryDomain()); |
| 216 | SkASSERT(spec.hasDomain()); |
| 217 | |
| 218 | for (int i = 0; i < 4; ++i) { |
| 219 | vb->write(deviceQuad.x(i), deviceQuad.y(i), coverage[i], |
| 220 | localQuad.x(i), localQuad.y(i), texDomain); |
| 221 | } |
| 222 | } |
| 223 | |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 224 | } // anonymous namespace |
| 225 | |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 226 | namespace GrQuadPerEdgeAA { |
| 227 | |
Robert Phillips | c554dcf | 2019-10-28 11:43:55 -0400 | [diff] [blame] | 228 | IndexBufferOption CalcIndexBufferOption(GrAAType aa, int numQuads) { |
| 229 | if (aa == GrAAType::kCoverage) { |
| 230 | return IndexBufferOption::kPictureFramed; |
| 231 | } else if (numQuads > 1) { |
| 232 | return IndexBufferOption::kIndexedRects; |
| 233 | } else { |
| 234 | return IndexBufferOption::kTriStrips; |
| 235 | } |
| 236 | } |
| 237 | |
Brian Osman | 8fa7ab4 | 2019-03-18 10:22:42 -0400 | [diff] [blame] | 238 | // This is a more elaborate version of SkPMColor4fNeedsWideColor that allows "no color" for white |
| 239 | ColorType MinColorType(SkPMColor4f color, GrClampType clampType, const GrCaps& caps) { |
Brian Salomon | 1d83542 | 2019-03-13 16:11:44 -0400 | [diff] [blame] | 240 | if (color == SK_PMColor4fWHITE) { |
| 241 | return ColorType::kNone; |
Brian Salomon | 1d83542 | 2019-03-13 16:11:44 -0400 | [diff] [blame] | 242 | } else { |
Brian Osman | 8fa7ab4 | 2019-03-18 10:22:42 -0400 | [diff] [blame] | 243 | return SkPMColor4fNeedsWideColor(color, clampType, caps) ? ColorType::kHalf |
| 244 | : ColorType::kByte; |
Brian Salomon | 1d83542 | 2019-03-13 16:11:44 -0400 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 248 | ////////////////// Tessellator Implementation |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 249 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 250 | Tessellator::WriteQuadProc Tessellator::GetWriteQuadProc(const VertexSpec& spec) { |
| 251 | // All specialized writing functions requires 2D geometry and no geometry domain. This is not |
| 252 | // the same as just checking device type vs. kRectilinear since non-AA general 2D quads do not |
| 253 | // require a geometry domain and could then go through a fast path. |
| 254 | if (spec.deviceQuadType() != GrQuad::Type::kPerspective && !spec.requiresGeometryDomain()) { |
| 255 | CoverageMode mode = spec.coverageMode(); |
| 256 | if (spec.hasVertexColors()) { |
| 257 | if (mode != CoverageMode::kWithPosition) { |
| 258 | // Vertex colors, but no explicit coverage |
| 259 | if (!spec.hasLocalCoords()) { |
| 260 | // Non-UV with vertex colors (possibly with coverage folded into alpha) |
| 261 | return write_2d_color; |
| 262 | } else if (spec.localQuadType() != GrQuad::Type::kPerspective) { |
| 263 | // UV locals with vertex colors (possibly with coverage-as-alpha) |
| 264 | return spec.hasDomain() ? write_2d_color_uv_strict : write_2d_color_uv; |
| 265 | } |
| 266 | } |
| 267 | // Else fall through; this is a spec that requires vertex colors and explicit coverage, |
| 268 | // which means it's anti-aliased and the FPs don't support coverage as alpha, or |
| 269 | // it uses 3D local coordinates. |
| 270 | } else if (spec.hasLocalCoords() && spec.localQuadType() != GrQuad::Type::kPerspective) { |
| 271 | if (mode == CoverageMode::kWithPosition) { |
| 272 | // UV locals with explicit coverage |
| 273 | return spec.hasDomain() ? write_2d_cov_uv_strict : write_2d_cov_uv; |
| 274 | } else { |
| 275 | SkASSERT(mode == CoverageMode::kNone); |
| 276 | return spec.hasDomain() ? write_2d_uv_strict : write_2d_uv; |
| 277 | } |
| 278 | } |
| 279 | // Else fall through to generic vertex function; this is a spec that has no vertex colors |
| 280 | // and [no|uvr] local coords, which doesn't happen often enough to warrant specialization. |
| 281 | } |
Michael Ludwig | 41f395d | 2019-05-23 13:59:45 -0400 | [diff] [blame] | 282 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 283 | // Arbitrary spec hits the slow path |
| 284 | return write_quad_generic; |
| 285 | } |
| 286 | |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 287 | Tessellator::Tessellator(const VertexSpec& spec, char* vertices) |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 288 | : fVertexSpec(spec) |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 289 | , fVertexWriter{vertices} |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 290 | , fWriteProc(Tessellator::GetWriteQuadProc(spec)) {} |
| 291 | |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 292 | void Tessellator::append(const GrQuad& deviceQuad, const GrQuad& localQuad, |
| 293 | const SkPMColor4f& color, const SkRect& uvDomain, GrQuadAAFlags aaFlags) { |
| 294 | // We allow Tessellator to be created with a null vertices pointer for convenience, but it is |
| 295 | // assumed it will never actually be used in those cases. |
| 296 | SkASSERT(fVertexWriter.fPtr); |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 297 | SkASSERT(deviceQuad.quadType() <= fVertexSpec.deviceQuadType()); |
| 298 | SkASSERT(!fVertexSpec.hasLocalCoords() || localQuad.quadType() <= fVertexSpec.localQuadType()); |
| 299 | |
| 300 | static const float kFullCoverage[4] = {1.f, 1.f, 1.f, 1.f}; |
| 301 | static const float kZeroCoverage[4] = {0.f, 0.f, 0.f, 0.f}; |
| 302 | static const SkRect kIgnoredDomain = SkRect::MakeEmpty(); |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 303 | |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 304 | if (fVertexSpec.usesCoverageAA()) { |
| 305 | SkASSERT(fVertexSpec.coverageMode() == CoverageMode::kWithColor || |
| 306 | fVertexSpec.coverageMode() == CoverageMode::kWithPosition); |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 307 | // Must calculate inner and outer quadrilaterals for the vertex coverage ramps, and possibly |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 308 | // a geometry domain if corners are not right angles |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 309 | SkRect geomDomain; |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 310 | if (fVertexSpec.requiresGeometryDomain()) { |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 311 | geomDomain = deviceQuad.bounds(); |
| 312 | geomDomain.outset(0.5f, 0.5f); // account for AA expansion |
Michael Ludwig | e6266a2 | 2019-03-07 11:24:32 -0500 | [diff] [blame] | 313 | } |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 314 | |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 315 | if (aaFlags == GrQuadAAFlags::kNone) { |
| 316 | // Have to write the coverage AA vertex structure, but there's no math to be done for a |
| 317 | // non-aa quad batched into a coverage AA op. |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 318 | fWriteProc(&fVertexWriter, fVertexSpec, deviceQuad, localQuad, kFullCoverage, color, |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 319 | geomDomain, uvDomain); |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 320 | // Since we pass the same corners in, the outer vertex structure will have 0 area and |
| 321 | // the coverage interpolation from 1 to 0 will not be visible. |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 322 | fWriteProc(&fVertexWriter, fVertexSpec, deviceQuad, localQuad, kZeroCoverage, color, |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 323 | geomDomain, uvDomain); |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 324 | } else { |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 325 | // Reset the tessellation helper to match the current geometry |
| 326 | fAAHelper.reset(deviceQuad, fVertexSpec.hasLocalCoords() ? &localQuad : nullptr); |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 327 | |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 328 | // Edge inset/outset distance ordered LBTR, set to 0.5 for a half pixel if the AA flag |
| 329 | // is turned on, or 0.0 if the edge is not anti-aliased. |
| 330 | skvx::Vec<4, float> edgeDistances; |
| 331 | if (aaFlags == GrQuadAAFlags::kAll) { |
| 332 | edgeDistances = 0.5f; |
| 333 | } else { |
| 334 | edgeDistances = { (aaFlags & GrQuadAAFlags::kLeft) ? 0.5f : 0.f, |
| 335 | (aaFlags & GrQuadAAFlags::kBottom) ? 0.5f : 0.f, |
| 336 | (aaFlags & GrQuadAAFlags::kTop) ? 0.5f : 0.f, |
| 337 | (aaFlags & GrQuadAAFlags::kRight) ? 0.5f : 0.f }; |
| 338 | } |
Michael Ludwig | fb7ba52 | 2019-10-29 15:33:34 -0400 | [diff] [blame] | 339 | |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 340 | GrQuad aaDeviceQuad, aaLocalQuad; |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 341 | |
| 342 | // Write inner vertices first |
| 343 | float coverage[4]; |
| 344 | fAAHelper.inset(edgeDistances, &aaDeviceQuad, &aaLocalQuad).store(coverage); |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 345 | fWriteProc(&fVertexWriter, fVertexSpec, aaDeviceQuad, aaLocalQuad, coverage, color, |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 346 | geomDomain, uvDomain); |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 347 | |
| 348 | // Then outer vertices, which use 0.f for their coverage |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 349 | fAAHelper.outset(edgeDistances, &aaDeviceQuad, &aaLocalQuad); |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 350 | fWriteProc(&fVertexWriter, fVertexSpec, aaDeviceQuad, aaLocalQuad, kZeroCoverage, color, |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 351 | geomDomain, uvDomain); |
Michael Ludwig | d84dd4b | 2019-11-05 12:03:12 -0500 | [diff] [blame] | 352 | } |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 353 | } else { |
| 354 | // No outsetting needed, just write a single quad with full coverage |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 355 | SkASSERT(fVertexSpec.coverageMode() == CoverageMode::kNone && |
| 356 | !fVertexSpec.requiresGeometryDomain()); |
Michael Ludwig | 189c980 | 2019-11-21 11:21:12 -0500 | [diff] [blame] | 357 | fWriteProc(&fVertexWriter, fVertexSpec, deviceQuad, localQuad, kFullCoverage, color, |
Michael Ludwig | 73dbea6 | 2019-11-19 14:55:36 -0500 | [diff] [blame] | 358 | kIgnoredDomain, uvDomain); |
Michael Ludwig | 460eb5e | 2018-10-29 11:09:29 -0400 | [diff] [blame] | 359 | } |
| 360 | } |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 361 | |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 362 | sk_sp<const GrBuffer> GetIndexBuffer(GrMeshDrawOp::Target* target, |
| 363 | IndexBufferOption indexBufferOption) { |
Robert Phillips | ee08d52 | 2019-10-28 16:34:44 -0400 | [diff] [blame] | 364 | auto resourceProvider = target->resourceProvider(); |
| 365 | |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 366 | switch (indexBufferOption) { |
| 367 | case IndexBufferOption::kPictureFramed: return resourceProvider->refAAQuadIndexBuffer(); |
| 368 | case IndexBufferOption::kIndexedRects: return resourceProvider->refNonAAQuadIndexBuffer(); |
| 369 | case IndexBufferOption::kTriStrips: // fall through |
| 370 | default: return nullptr; |
| 371 | } |
| 372 | } |
Robert Phillips | c554dcf | 2019-10-28 11:43:55 -0400 | [diff] [blame] | 373 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 374 | int QuadLimit(IndexBufferOption option) { |
| 375 | switch (option) { |
| 376 | case IndexBufferOption::kPictureFramed: return GrResourceProvider::MaxNumAAQuads(); |
| 377 | case IndexBufferOption::kIndexedRects: return GrResourceProvider::MaxNumNonAAQuads(); |
| 378 | case IndexBufferOption::kTriStrips: return SK_MaxS32; // not limited by an indexBuffer |
| 379 | } |
| 380 | |
| 381 | SkUNREACHABLE; |
| 382 | } |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 383 | |
Robert Phillips | 2f05a48 | 2019-11-25 09:54:43 -0500 | [diff] [blame^] | 384 | void ConfigureMesh(const GrCaps& caps, GrMesh* mesh, const VertexSpec& spec, |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 385 | int runningQuadCount, int quadsInDraw, int maxVerts, |
| 386 | sk_sp<const GrBuffer> vertexBuffer, |
| 387 | sk_sp<const GrBuffer> indexBuffer, int absVertBufferOffset) { |
| 388 | SkASSERT(vertexBuffer); |
Robert Phillips | c554dcf | 2019-10-28 11:43:55 -0400 | [diff] [blame] | 389 | |
Robert Phillips | cea290f | 2019-11-06 11:21:03 -0500 | [diff] [blame] | 390 | mesh->setPrimitiveType(spec.primitiveType()); |
| 391 | |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 392 | if (spec.indexBufferOption() == IndexBufferOption::kTriStrips) { |
| 393 | SkASSERT(!indexBuffer); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 394 | |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 395 | mesh->setNonIndexedNonInstanced(4); |
| 396 | int offset = absVertBufferOffset + |
| 397 | runningQuadCount * GrResourceProvider::NumVertsPerNonAAQuad(); |
| 398 | mesh->setVertexData(std::move(vertexBuffer), offset); |
| 399 | return; |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 400 | } |
| 401 | |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 402 | SkASSERT(spec.indexBufferOption() == IndexBufferOption::kPictureFramed || |
| 403 | spec.indexBufferOption() == IndexBufferOption::kIndexedRects); |
| 404 | SkASSERT(indexBuffer); |
| 405 | |
Robert Phillips | 2f05a48 | 2019-11-25 09:54:43 -0500 | [diff] [blame^] | 406 | int maxNumQuads, numIndicesPerQuad, numVertsPerQuad; |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 407 | |
| 408 | if (spec.indexBufferOption() == IndexBufferOption::kPictureFramed) { |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 409 | // AA uses 8 vertices and 30 indices per quad, basically nested rectangles |
Robert Phillips | 2f05a48 | 2019-11-25 09:54:43 -0500 | [diff] [blame^] | 410 | maxNumQuads = GrResourceProvider::MaxNumAAQuads(); |
| 411 | numIndicesPerQuad = GrResourceProvider::NumIndicesPerAAQuad(); |
| 412 | numVertsPerQuad = GrResourceProvider::NumVertsPerAAQuad(); |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 413 | } else { |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 414 | // Non-AA uses 4 vertices and 6 indices per quad |
Robert Phillips | 2f05a48 | 2019-11-25 09:54:43 -0500 | [diff] [blame^] | 415 | maxNumQuads = GrResourceProvider::MaxNumNonAAQuads(); |
| 416 | numIndicesPerQuad = GrResourceProvider::NumIndicesPerNonAAQuad(); |
| 417 | numVertsPerQuad = GrResourceProvider::NumVertsPerNonAAQuad(); |
Robert Phillips | fd0c3b5 | 2019-11-01 08:44:42 -0400 | [diff] [blame] | 418 | } |
| 419 | |
Robert Phillips | 2f05a48 | 2019-11-25 09:54:43 -0500 | [diff] [blame^] | 420 | SkASSERT(runningQuadCount + quadsInDraw <= maxNumQuads); |
| 421 | |
| 422 | if (caps.avoidLargeIndexBufferDraws()) { |
| 423 | // When we need to avoid large index buffer draws we modify the base vertex of the draw |
| 424 | // which, in GL, requires rebinding all vertex attrib arrays, so a base index is generally |
| 425 | // preferred. |
| 426 | int offset = absVertBufferOffset + runningQuadCount * numVertsPerQuad; |
| 427 | |
| 428 | mesh->setIndexedPatterned(std::move(indexBuffer), numIndicesPerQuad, |
| 429 | numVertsPerQuad, quadsInDraw, maxNumQuads); |
| 430 | mesh->setVertexData(std::move(vertexBuffer), offset); |
| 431 | } else { |
| 432 | int baseIndex = runningQuadCount * numIndicesPerQuad; |
| 433 | int numIndicesToDraw = quadsInDraw * numIndicesPerQuad; |
| 434 | |
| 435 | int minVertex = runningQuadCount * numVertsPerQuad; |
| 436 | int maxVertex = (runningQuadCount + quadsInDraw) * numVertsPerQuad; |
| 437 | |
| 438 | mesh->setIndexed(std::move(indexBuffer), numIndicesToDraw, |
| 439 | baseIndex, minVertex, maxVertex, GrPrimitiveRestart::kNo); |
| 440 | mesh->setVertexData(std::move(vertexBuffer), absVertBufferOffset); |
| 441 | } |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 442 | } |
| 443 | |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 444 | ////////////////// VertexSpec Implementation |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 445 | |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 446 | int VertexSpec::deviceDimensionality() const { |
Michael Ludwig | de4c58c | 2019-06-04 09:12:59 -0400 | [diff] [blame] | 447 | return this->deviceQuadType() == GrQuad::Type::kPerspective ? 3 : 2; |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | int VertexSpec::localDimensionality() const { |
Michael Ludwig | de4c58c | 2019-06-04 09:12:59 -0400 | [diff] [blame] | 451 | return fHasLocalCoords ? (this->localQuadType() == GrQuad::Type::kPerspective ? 3 : 2) : 0; |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 452 | } |
| 453 | |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 454 | CoverageMode VertexSpec::coverageMode() const { |
| 455 | if (this->usesCoverageAA()) { |
| 456 | if (this->compatibleWithCoverageAsAlpha() && this->hasVertexColors() && |
| 457 | !this->requiresGeometryDomain()) { |
| 458 | // Using a geometric domain acts as a second source of coverage and folding |
| 459 | // the original coverage into color makes it impossible to apply the color's |
| 460 | // alpha to the geometric domain's coverage when the original shape is clipped. |
| 461 | return CoverageMode::kWithColor; |
| 462 | } else { |
| 463 | return CoverageMode::kWithPosition; |
| 464 | } |
| 465 | } else { |
| 466 | return CoverageMode::kNone; |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | // This needs to stay in sync w/ QuadPerEdgeAAGeometryProcessor::initializeAttrs |
| 471 | size_t VertexSpec::vertexSize() const { |
| 472 | bool needsPerspective = (this->deviceDimensionality() == 3); |
| 473 | CoverageMode coverageMode = this->coverageMode(); |
| 474 | |
| 475 | size_t count = 0; |
| 476 | |
| 477 | if (coverageMode == CoverageMode::kWithPosition) { |
| 478 | if (needsPerspective) { |
| 479 | count += GrVertexAttribTypeSize(kFloat4_GrVertexAttribType); |
| 480 | } else { |
| 481 | count += GrVertexAttribTypeSize(kFloat2_GrVertexAttribType) + |
| 482 | GrVertexAttribTypeSize(kFloat_GrVertexAttribType); |
| 483 | } |
| 484 | } else { |
| 485 | if (needsPerspective) { |
| 486 | count += GrVertexAttribTypeSize(kFloat3_GrVertexAttribType); |
| 487 | } else { |
| 488 | count += GrVertexAttribTypeSize(kFloat2_GrVertexAttribType); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | if (this->requiresGeometryDomain()) { |
| 493 | count += GrVertexAttribTypeSize(kFloat4_GrVertexAttribType); |
| 494 | } |
| 495 | |
| 496 | count += this->localDimensionality() * GrVertexAttribTypeSize(kFloat_GrVertexAttribType); |
| 497 | |
| 498 | if (ColorType::kByte == this->colorType()) { |
| 499 | count += GrVertexAttribTypeSize(kUByte4_norm_GrVertexAttribType); |
| 500 | } else if (ColorType::kHalf == this->colorType()) { |
| 501 | count += GrVertexAttribTypeSize(kHalf4_GrVertexAttribType); |
| 502 | } |
| 503 | |
| 504 | if (this->hasDomain()) { |
| 505 | count += GrVertexAttribTypeSize(kFloat4_GrVertexAttribType); |
| 506 | } |
| 507 | |
| 508 | return count; |
| 509 | } |
| 510 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 511 | ////////////////// Geometry Processor Implementation |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 512 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 513 | class QuadPerEdgeAAGeometryProcessor : public GrGeometryProcessor { |
| 514 | public: |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 515 | using Saturate = GrTextureOp::Saturate; |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 516 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 517 | static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& spec) { |
| 518 | return arena->make<QuadPerEdgeAAGeometryProcessor>(spec); |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 519 | } |
| 520 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 521 | static GrGeometryProcessor* Make(SkArenaAlloc* arena, const VertexSpec& vertexSpec, |
| 522 | const GrShaderCaps& caps, |
| 523 | const GrBackendFormat& backendFormat, |
| 524 | const GrSamplerState& samplerState, |
| 525 | const GrSwizzle& swizzle, |
| 526 | sk_sp<GrColorSpaceXform> textureColorSpaceXform, |
| 527 | Saturate saturate) { |
| 528 | return arena->make<QuadPerEdgeAAGeometryProcessor>( |
Robert Phillips | 323471e | 2019-11-11 11:33:37 -0500 | [diff] [blame] | 529 | vertexSpec, caps, backendFormat, samplerState, swizzle, |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 530 | std::move(textureColorSpaceXform), saturate); |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 531 | } |
| 532 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 533 | const char* name() const override { return "QuadPerEdgeAAGeometryProcessor"; } |
Michael Ludwig | 024e262 | 2018-11-30 13:25:55 -0500 | [diff] [blame] | 534 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 535 | void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override { |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 536 | // texturing, device-dimensions are single bit flags |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 537 | uint32_t x = (fTexDomain.isInitialized() ? 0 : 0x1) |
| 538 | | (fSampler.isInitialized() ? 0 : 0x2) |
| 539 | | (fNeedsPerspective ? 0 : 0x4) |
| 540 | | (fSaturate == Saturate::kNo ? 0 : 0x8); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 541 | // local coords require 2 bits (3 choices), 00 for none, 01 for 2d, 10 for 3d |
| 542 | if (fLocalCoord.isInitialized()) { |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 543 | x |= kFloat3_GrVertexAttribType == fLocalCoord.cpuType() ? 0x10 : 0x20; |
Brian Osman | 78dc72c | 2018-12-03 13:20:43 +0000 | [diff] [blame] | 544 | } |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 545 | // similar for colors, 00 for none, 01 for bytes, 10 for half-floats |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 546 | if (fColor.isInitialized()) { |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 547 | x |= kUByte4_norm_GrVertexAttribType == fColor.cpuType() ? 0x40 : 0x80; |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 548 | } |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 549 | // and coverage mode, 00 for none, 01 for withposition, 10 for withcolor, 11 for |
| 550 | // position+geomdomain |
| 551 | SkASSERT(!fGeomDomain.isInitialized() || fCoverageMode == CoverageMode::kWithPosition); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 552 | if (fCoverageMode != CoverageMode::kNone) { |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 553 | x |= fGeomDomain.isInitialized() |
| 554 | ? 0x300 |
| 555 | : (CoverageMode::kWithPosition == fCoverageMode ? 0x100 : 0x200); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get())); |
| 559 | b->add32(x); |
Brian Osman | 78dc72c | 2018-12-03 13:20:43 +0000 | [diff] [blame] | 560 | } |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 561 | |
| 562 | GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override { |
| 563 | class GLSLProcessor : public GrGLSLGeometryProcessor { |
| 564 | public: |
| 565 | void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc, |
| 566 | FPCoordTransformIter&& transformIter) override { |
| 567 | const auto& gp = proc.cast<QuadPerEdgeAAGeometryProcessor>(); |
| 568 | if (gp.fLocalCoord.isInitialized()) { |
| 569 | this->setTransformDataHelper(SkMatrix::I(), pdman, &transformIter); |
| 570 | } |
| 571 | fTextureColorSpaceXformHelper.setData(pdman, gp.fTextureColorSpaceXform.get()); |
| 572 | } |
| 573 | |
| 574 | private: |
| 575 | void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
| 576 | using Interpolation = GrGLSLVaryingHandler::Interpolation; |
| 577 | |
| 578 | const auto& gp = args.fGP.cast<QuadPerEdgeAAGeometryProcessor>(); |
| 579 | fTextureColorSpaceXformHelper.emitCode(args.fUniformHandler, |
| 580 | gp.fTextureColorSpaceXform.get()); |
| 581 | |
| 582 | args.fVaryingHandler->emitAttributes(gp); |
| 583 | |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 584 | if (gp.fCoverageMode == CoverageMode::kWithPosition) { |
| 585 | // Strip last channel from the vertex attribute to remove coverage and get the |
| 586 | // actual position |
| 587 | if (gp.fNeedsPerspective) { |
| 588 | args.fVertBuilder->codeAppendf("float3 position = %s.xyz;", |
| 589 | gp.fPosition.name()); |
| 590 | } else { |
| 591 | args.fVertBuilder->codeAppendf("float2 position = %s.xy;", |
| 592 | gp.fPosition.name()); |
| 593 | } |
| 594 | gpArgs->fPositionVar = {"position", |
| 595 | gp.fNeedsPerspective ? kFloat3_GrSLType |
| 596 | : kFloat2_GrSLType, |
| 597 | GrShaderVar::kNone_TypeModifier}; |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 598 | } else { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 599 | // No coverage to eliminate |
| 600 | gpArgs->fPositionVar = gp.fPosition.asShaderVar(); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 601 | } |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 602 | |
| 603 | // Handle local coordinates if they exist |
| 604 | if (gp.fLocalCoord.isInitialized()) { |
| 605 | // NOTE: If the only usage of local coordinates is for the inline texture fetch |
| 606 | // before FPs, then there are no registered FPCoordTransforms and this ends up |
| 607 | // emitting nothing, so there isn't a duplication of local coordinates |
| 608 | this->emitTransforms(args.fVertBuilder, |
| 609 | args.fVaryingHandler, |
| 610 | args.fUniformHandler, |
| 611 | gp.fLocalCoord.asShaderVar(), |
| 612 | args.fFPCoordTransformHandler); |
| 613 | } |
| 614 | |
| 615 | // Solid color before any texturing gets modulated in |
| 616 | if (gp.fColor.isInitialized()) { |
Michael Ludwig | 3d2753e | 2019-03-29 14:36:32 -0400 | [diff] [blame] | 617 | SkASSERT(gp.fCoverageMode != CoverageMode::kWithColor || !gp.fNeedsPerspective); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 618 | // The color cannot be flat if the varying coverage has been modulated into it |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 619 | args.fVaryingHandler->addPassThroughAttribute(gp.fColor, args.fOutputColor, |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 620 | gp.fCoverageMode == CoverageMode::kWithColor ? |
| 621 | Interpolation::kInterpolated : Interpolation::kCanBeFlat); |
| 622 | } else { |
| 623 | // Output color must be initialized to something |
| 624 | args.fFragBuilder->codeAppendf("%s = half4(1);", args.fOutputColor); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | // If there is a texture, must also handle texture coordinates and reading from |
| 628 | // the texture in the fragment shader before continuing to fragment processors. |
| 629 | if (gp.fSampler.isInitialized()) { |
| 630 | // Texture coordinates clamped by the domain on the fragment shader; if the GP |
| 631 | // has a texture, it's guaranteed to have local coordinates |
| 632 | args.fFragBuilder->codeAppend("float2 texCoord;"); |
| 633 | if (gp.fLocalCoord.cpuType() == kFloat3_GrVertexAttribType) { |
| 634 | // Can't do a pass through since we need to perform perspective division |
| 635 | GrGLSLVarying v(gp.fLocalCoord.gpuType()); |
| 636 | args.fVaryingHandler->addVarying(gp.fLocalCoord.name(), &v); |
| 637 | args.fVertBuilder->codeAppendf("%s = %s;", |
| 638 | v.vsOut(), gp.fLocalCoord.name()); |
| 639 | args.fFragBuilder->codeAppendf("texCoord = %s.xy / %s.z;", |
| 640 | v.fsIn(), v.fsIn()); |
| 641 | } else { |
| 642 | args.fVaryingHandler->addPassThroughAttribute(gp.fLocalCoord, "texCoord"); |
| 643 | } |
| 644 | |
| 645 | // Clamp the now 2D localCoordName variable by the domain if it is provided |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 646 | if (gp.fTexDomain.isInitialized()) { |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 647 | args.fFragBuilder->codeAppend("float4 domain;"); |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 648 | args.fVaryingHandler->addPassThroughAttribute(gp.fTexDomain, "domain", |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 649 | Interpolation::kCanBeFlat); |
| 650 | args.fFragBuilder->codeAppend( |
| 651 | "texCoord = clamp(texCoord, domain.xy, domain.zw);"); |
| 652 | } |
| 653 | |
| 654 | // Now modulate the starting output color by the texture lookup |
| 655 | args.fFragBuilder->codeAppendf("%s = ", args.fOutputColor); |
| 656 | args.fFragBuilder->appendTextureLookupAndModulate( |
| 657 | args.fOutputColor, args.fTexSamplers[0], "texCoord", kFloat2_GrSLType, |
| 658 | &fTextureColorSpaceXformHelper); |
| 659 | args.fFragBuilder->codeAppend(";"); |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 660 | if (gp.fSaturate == Saturate::kYes) { |
| 661 | args.fFragBuilder->codeAppendf("%s = saturate(%s);", |
| 662 | args.fOutputColor, args.fOutputColor); |
| 663 | } |
| 664 | } else { |
| 665 | // Saturate is only intended for use with a proxy to account for the fact |
| 666 | // that GrTextureOp skips SkPaint conversion, which normally handles this. |
| 667 | SkASSERT(gp.fSaturate == Saturate::kNo); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | // And lastly, output the coverage calculation code |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 671 | if (gp.fCoverageMode == CoverageMode::kWithPosition) { |
| 672 | GrGLSLVarying coverage(kFloat_GrSLType); |
| 673 | args.fVaryingHandler->addVarying("coverage", &coverage); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 674 | if (gp.fNeedsPerspective) { |
Michael Ludwig | 3d2753e | 2019-03-29 14:36:32 -0400 | [diff] [blame] | 675 | // Multiply by "W" in the vertex shader, then by 1/w (sk_FragCoord.w) in |
| 676 | // the fragment shader to get screen-space linear coverage. |
| 677 | args.fVertBuilder->codeAppendf("%s = %s.w * %s.z;", |
| 678 | coverage.vsOut(), gp.fPosition.name(), |
| 679 | gp.fPosition.name()); |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 680 | args.fFragBuilder->codeAppendf("float coverage = %s * sk_FragCoord.w;", |
| 681 | coverage.fsIn()); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 682 | } else { |
Jim Van Verth | d5d9c21 | 2019-05-02 10:22:10 -0400 | [diff] [blame] | 683 | args.fVertBuilder->codeAppendf("%s = %s;", |
| 684 | coverage.vsOut(), gp.fCoverage.name()); |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 685 | args.fFragBuilder->codeAppendf("float coverage = %s;", coverage.fsIn()); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 686 | } |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 687 | |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 688 | if (gp.fGeomDomain.isInitialized()) { |
| 689 | // Calculate distance from sk_FragCoord to the 4 edges of the domain |
| 690 | // and clamp them to (0, 1). Use the minimum of these and the original |
| 691 | // coverage. This only has to be done in the exterior triangles, the |
| 692 | // interior of the quad geometry can never be clipped by the domain box. |
| 693 | args.fFragBuilder->codeAppend("float4 geoDomain;"); |
| 694 | args.fVaryingHandler->addPassThroughAttribute(gp.fGeomDomain, "geoDomain", |
| 695 | Interpolation::kCanBeFlat); |
| 696 | args.fFragBuilder->codeAppend( |
| 697 | "if (coverage < 0.5) {" |
| 698 | " float4 dists4 = clamp(float4(1, 1, -1, -1) * " |
| 699 | "(sk_FragCoord.xyxy - geoDomain), 0, 1);" |
| 700 | " float2 dists2 = dists4.xy * dists4.zw;" |
| 701 | " coverage = min(coverage, dists2.x * dists2.y);" |
| 702 | "}"); |
| 703 | } |
| 704 | |
| 705 | args.fFragBuilder->codeAppendf("%s = half4(half(coverage));", |
| 706 | args.fOutputCoverage); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 707 | } else { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 708 | // Set coverage to 1, since it's either non-AA or the coverage was already |
| 709 | // folded into the output color |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 710 | SkASSERT(!gp.fGeomDomain.isInitialized()); |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 711 | args.fFragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 712 | } |
| 713 | } |
| 714 | GrGLSLColorSpaceXformHelper fTextureColorSpaceXformHelper; |
| 715 | }; |
| 716 | return new GLSLProcessor; |
| 717 | } |
| 718 | |
| 719 | private: |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 720 | friend class ::SkArenaAlloc; // for access to ctor |
| 721 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 722 | QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec) |
| 723 | : INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID) |
| 724 | , fTextureColorSpaceXform(nullptr) { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 725 | SkASSERT(!spec.hasDomain()); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 726 | this->initializeAttrs(spec); |
| 727 | this->setTextureSamplerCnt(0); |
| 728 | } |
| 729 | |
Brian Salomon | 67529b2 | 2019-08-13 15:31:04 -0400 | [diff] [blame] | 730 | QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec, |
| 731 | const GrShaderCaps& caps, |
Robert Phillips | f272bea | 2019-10-17 08:56:16 -0400 | [diff] [blame] | 732 | const GrBackendFormat& backendFormat, |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 733 | const GrSamplerState& samplerState, |
Greg Daniel | 2c3398d | 2019-06-19 11:58:01 -0400 | [diff] [blame] | 734 | const GrSwizzle& swizzle, |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 735 | sk_sp<GrColorSpaceXform> textureColorSpaceXform, |
| 736 | Saturate saturate) |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 737 | : INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID) |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 738 | , fSaturate(saturate) |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 739 | , fTextureColorSpaceXform(std::move(textureColorSpaceXform)) |
Robert Phillips | 323471e | 2019-11-11 11:33:37 -0500 | [diff] [blame] | 740 | , fSampler(samplerState, backendFormat, swizzle) { |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 741 | SkASSERT(spec.hasLocalCoords()); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 742 | this->initializeAttrs(spec); |
| 743 | this->setTextureSamplerCnt(1); |
| 744 | } |
| 745 | |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 746 | // This needs to stay in sync w/ VertexSpec::vertexSize |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 747 | void initializeAttrs(const VertexSpec& spec) { |
| 748 | fNeedsPerspective = spec.deviceDimensionality() == 3; |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 749 | fCoverageMode = spec.coverageMode(); |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 750 | |
| 751 | if (fCoverageMode == CoverageMode::kWithPosition) { |
| 752 | if (fNeedsPerspective) { |
| 753 | fPosition = {"positionWithCoverage", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; |
| 754 | } else { |
Jim Van Verth | d5d9c21 | 2019-05-02 10:22:10 -0400 | [diff] [blame] | 755 | fPosition = {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; |
| 756 | fCoverage = {"coverage", kFloat_GrVertexAttribType, kFloat_GrSLType}; |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 757 | } |
| 758 | } else { |
| 759 | if (fNeedsPerspective) { |
| 760 | fPosition = {"position", kFloat3_GrVertexAttribType, kFloat3_GrSLType}; |
| 761 | } else { |
| 762 | fPosition = {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; |
| 763 | } |
| 764 | } |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 765 | |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 766 | // Need a geometry domain when the quads are AA and not rectilinear, since their AA |
| 767 | // outsetting can go beyond a half pixel. |
| 768 | if (spec.requiresGeometryDomain()) { |
| 769 | fGeomDomain = {"geomDomain", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; |
| 770 | } |
| 771 | |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 772 | int localDim = spec.localDimensionality(); |
| 773 | if (localDim == 3) { |
| 774 | fLocalCoord = {"localCoord", kFloat3_GrVertexAttribType, kFloat3_GrSLType}; |
| 775 | } else if (localDim == 2) { |
| 776 | fLocalCoord = {"localCoord", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; |
| 777 | } // else localDim == 0 and attribute remains uninitialized |
| 778 | |
| 779 | if (ColorType::kByte == spec.colorType()) { |
| 780 | fColor = {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}; |
| 781 | } else if (ColorType::kHalf == spec.colorType()) { |
| 782 | fColor = {"color", kHalf4_GrVertexAttribType, kHalf4_GrSLType}; |
| 783 | } |
| 784 | |
| 785 | if (spec.hasDomain()) { |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 786 | fTexDomain = {"texDomain", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 787 | } |
| 788 | |
Jim Van Verth | d5d9c21 | 2019-05-02 10:22:10 -0400 | [diff] [blame] | 789 | this->setVertexAttributes(&fPosition, 6); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | const TextureSampler& onTextureSampler(int) const override { return fSampler; } |
| 793 | |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 794 | Attribute fPosition; // May contain coverage as last channel |
Jim Van Verth | d5d9c21 | 2019-05-02 10:22:10 -0400 | [diff] [blame] | 795 | Attribute fCoverage; // Used for non-perspective position to avoid Intel Metal issues |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 796 | Attribute fColor; // May have coverage modulated in if the FPs support it |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 797 | Attribute fLocalCoord; |
Michael Ludwig | dcfbe32 | 2019-04-01 14:55:54 -0400 | [diff] [blame] | 798 | Attribute fGeomDomain; // Screen-space bounding box on geometry+aa outset |
| 799 | Attribute fTexDomain; // Texture-space bounding box on local coords |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 800 | |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 801 | // The positions attribute may have coverage built into it, so float3 is an ambiguous type |
| 802 | // and may mean 2d with coverage, or 3d with no coverage |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 803 | bool fNeedsPerspective; |
Brian Salomon | f19f9ca | 2019-09-18 15:54:26 -0400 | [diff] [blame] | 804 | // Should saturate() be called on the color? Only relevant when created with a texture. |
| 805 | Saturate fSaturate = Saturate::kNo; |
Michael Ludwig | 93aeba0 | 2018-12-21 09:50:31 -0500 | [diff] [blame] | 806 | CoverageMode fCoverageMode; |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 807 | |
| 808 | // Color space will be null and fSampler.isInitialized() returns false when the GP is configured |
| 809 | // to skip texturing. |
| 810 | sk_sp<GrColorSpaceXform> fTextureColorSpaceXform; |
| 811 | TextureSampler fSampler; |
| 812 | |
| 813 | typedef GrGeometryProcessor INHERITED; |
| 814 | }; |
| 815 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 816 | GrGeometryProcessor* MakeProcessor(SkArenaAlloc* arena, const VertexSpec& spec) { |
| 817 | return QuadPerEdgeAAGeometryProcessor::Make(arena, spec); |
Michael Ludwig | 467994d | 2018-12-03 14:58:31 +0000 | [diff] [blame] | 818 | } |
| 819 | |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 820 | GrGeometryProcessor* MakeTexturedProcessor(SkArenaAlloc* arena, const VertexSpec& spec, |
| 821 | const GrShaderCaps& caps, |
| 822 | const GrBackendFormat& backendFormat, |
| 823 | const GrSamplerState& samplerState, |
| 824 | const GrSwizzle& swizzle, |
| 825 | sk_sp<GrColorSpaceXform> textureColorSpaceXform, |
| 826 | Saturate saturate) { |
| 827 | return QuadPerEdgeAAGeometryProcessor::Make(arena, spec, caps, backendFormat, samplerState, |
| 828 | swizzle, std::move(textureColorSpaceXform), |
| 829 | saturate); |
Michael Ludwig | 20e909e | 2018-10-30 10:43:57 -0400 | [diff] [blame] | 830 | } |
Michael Ludwig | c182b94 | 2018-11-16 10:27:51 -0500 | [diff] [blame] | 831 | |
| 832 | } // namespace GrQuadPerEdgeAA |