• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:coverage

4  * Use of this source code is governed by a BSD-style license that can be
36 // order, although the data per-vertex is dependent on the VertexSpec.
41 const float coverage[4], in write_quad_generic()
52 // perspective and coverage mode. in write_quad_generic()
53 *vb << deviceQuad->x(i) in write_quad_generic()
54 << deviceQuad->y(i) in write_quad_generic()
55 << If(spec.deviceQuadType() == GrQuad::Type::kPerspective, deviceQuad->w(i)) in write_quad_generic()
56 << If(mode == CoverageMode::kWithPosition, coverage[i]); in write_quad_generic()
61 *vb << GrVertexColor(color * (mode == CoverageMode::kWithColor ? coverage[i] : 1.f), in write_quad_generic()
67 *vb << localQuad->x(i) in write_quad_generic()
68 << localQuad->y(i) in write_quad_generic()
69 << If(spec.localQuadType() == GrQuad::Type::kPerspective, localQuad->w(i)); in write_quad_generic()
87 // 2D (XY), no explicit coverage, vertex color, no locals, no geometry subset, no texture subsetn
88 // This represents simple, solid color or shader, non-AA (or AA with cov. as alpha) rects.
93 const float coverage[4], in write_2d_color()
111 // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything in write_2d_color()
112 SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f); in write_2d_color()
113 *vb << deviceQuad->x(i) in write_2d_color()
114 << deviceQuad->y(i) in write_2d_color()
115 << GrVertexColor(color * coverage[i], wide); in write_2d_color()
119 // 2D (XY), no explicit coverage, UV locals, no color, no geometry subset, no texture subset
125 const float coverage[4], in write_2d_uv()
139 *vb << deviceQuad->x(i) in write_2d_uv()
140 << deviceQuad->y(i) in write_2d_uv()
141 << localQuad->x(i) in write_2d_uv()
142 << localQuad->y(i); in write_2d_uv()
146 // 2D (XY), no explicit coverage, UV locals, vertex color, no geometry or texture subsets
152 const float coverage[4], in write_2d_color_uv()
168 // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything in write_2d_color_uv()
169 SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f); in write_2d_color_uv()
170 *vb << deviceQuad->x(i) in write_2d_color_uv()
171 << deviceQuad->y(i) in write_2d_color_uv()
172 << GrVertexColor(color * coverage[i], wide) in write_2d_color_uv()
173 << localQuad->x(i) in write_2d_color_uv()
174 << localQuad->y(i); in write_2d_color_uv()
178 // 2D (XY), explicit coverage, UV locals, no color, no geometry subset, no texture subset
184 const float coverage[4], in write_2d_cov_uv()
198 *vb << deviceQuad->x(i) in write_2d_cov_uv()
199 << deviceQuad->y(i) in write_2d_cov_uv()
200 << coverage[i] in write_2d_cov_uv()
201 << localQuad->x(i) in write_2d_cov_uv()
202 << localQuad->y(i); in write_2d_cov_uv()
206 // NOTE: The three _strict specializations below match the non-strict uv functions above, except
212 // 2D (XY), no explicit coverage, UV locals, no color, tex subset but no geometry subset
218 const float coverage[4], in write_2d_uv_strict()
232 *vb << deviceQuad->x(i) in write_2d_uv_strict()
233 << deviceQuad->y(i) in write_2d_uv_strict()
234 << localQuad->x(i) in write_2d_uv_strict()
235 << localQuad->y(i) in write_2d_uv_strict()
240 // 2D (XY), no explicit coverage, UV locals, vertex color, tex subset but no geometry subset
246 const float coverage[4], in write_2d_color_uv_strict()
262 // If this is not coverage-with-alpha, make sure coverage == 1 so it doesn't do anything in write_2d_color_uv_strict()
263 SkASSERT(spec.coverageMode() == CoverageMode::kWithColor || coverage[i] == 1.f); in write_2d_color_uv_strict()
264 *vb << deviceQuad->x(i) in write_2d_color_uv_strict()
265 << deviceQuad->y(i) in write_2d_color_uv_strict()
266 << GrVertexColor(color * coverage[i], wide) in write_2d_color_uv_strict()
267 << localQuad->x(i) in write_2d_color_uv_strict()
268 << localQuad->y(i) in write_2d_color_uv_strict()
273 // 2D (XY), explicit coverage, UV locals, no color, tex subset but no geometry subset
279 const float coverage[4], in write_2d_cov_uv_strict()
293 *vb << deviceQuad->x(i) in write_2d_cov_uv_strict()
294 << deviceQuad->y(i) in write_2d_cov_uv_strict()
295 << coverage[i] in write_2d_cov_uv_strict()
296 << localQuad->x(i) in write_2d_cov_uv_strict()
297 << localQuad->y(i) in write_2d_cov_uv_strict()
327 // the same as just checking device type vs. kRectilinear since non-AA general 2D quads do not in GetWriteQuadProc()
333 // Vertex colors, but no explicit coverage in GetWriteQuadProc()
335 // Non-UV with vertex colors (possibly with coverage folded into alpha) in GetWriteQuadProc()
338 // UV locals with vertex colors (possibly with coverage-as-alpha) in GetWriteQuadProc()
342 // Else fall through; this is a spec that requires vertex colors and explicit coverage, in GetWriteQuadProc()
343 // which means it's anti-aliased and the FPs don't support coverage as alpha, or in GetWriteQuadProc()
347 // UV locals with explicit coverage in GetWriteQuadProc()
372 SkASSERT(deviceQuad->quadType() <= fVertexSpec.deviceQuadType()); in append()
374 SkASSERT(!fVertexSpec.hasLocalCoords() || localQuad->quadType() <= fVertexSpec.localQuadType()); in append()
383 // Must calculate inner and outer quadrilaterals for the vertex coverage ramps, and possibly in append()
388 geomSubset = deviceQuad->bounds(); in append()
391 // Our GP code expects a 0.5 outset rect (coverage is computed as 0 at the values of in append()
397 geomSubset = deviceQuad->bounds().makeOutset(outset, outset); in append()
402 // Have to write the coverage AA vertex structure, but there's no math to be done for a in append()
403 // non-aa quad batched into a coverage AA op. in append()
407 // the coverage interpolation from 1 to 0 will not be visible. in append()
415 // is turned on, or 0.0 if the edge is not anti-aliased. in append()
427 float coverage[4]; in append() local
428 fAAHelper.inset(edgeDistances, deviceQuad, localQuad).store(coverage); in append()
429 fWriteProc(&fVertexWriter, fVertexSpec, deviceQuad, localQuad, coverage, color, in append()
432 // Then outer vertices, which use 0.f for their coverage. If the inset was degenerate in append()
436 coverage[0] < 1.f && in append()
437 coverage[1] < 1.f && in append()
438 coverage[2] < 1.f && in append()
439 coverage[3] < 1.f; in append()
447 // wh + 2e' = 2, so e' = (2 - wh) / 2 => e' = e * (2 - wh). But if w or h > 1, then in append()
448 // 2 - wh < 1 and represents the non-narrow axis so clamp to 1. in append()
449 edgeDistances *= max(1.f, 2.f - maxWH); in append()
456 // No outsetting needed, just write a single quad with full coverage in append()
466 auto resourceProvider = target->resourceProvider(); in GetIndexBuffer()
469 case IndexBufferOption::kPictureFramed: return resourceProvider->refAAQuadIndexBuffer(); in GetIndexBuffer()
470 case IndexBufferOption::kIndexedRects: return resourceProvider->refNonAAQuadIndexBuffer(); in GetIndexBuffer()
491 renderPass->draw(4, offset); in IssueDraw()
506 // Non-AA uses 4 vertices and 6 indices per quad in IssueDraw()
520 renderPass->drawIndexPattern(numIndicesPerQuad, quadsInDraw, maxNumQuads, numVertsPerQuad, in IssueDraw()
527 int maxVertex = (runningQuadCount + quadsInDraw) * numVertsPerQuad - 1; // inclusive in IssueDraw()
529 renderPass->drawIndexed(numIndicesToDraw, baseIndex, minVertex, maxVertex, in IssueDraw()
537 return this->deviceQuadType() == GrQuad::Type::kPerspective ? 3 : 2; in deviceDimensionality()
541 return fHasLocalCoords ? (this->localQuadType() == GrQuad::Type::kPerspective ? 3 : 2) : 0; in localDimensionality()
545 if (this->usesCoverageAA()) { in coverageMode()
546 if (this->compatibleWithCoverageAsAlpha() && this->hasVertexColors() && in coverageMode()
547 !this->requiresGeometrySubset()) { in coverageMode()
548 // Using a geometric subset acts as a second source of coverage and folding in coverageMode()
549 // the original coverage into color makes it impossible to apply the color's in coverageMode()
550 // alpha to the geometric subset's coverage when the original shape is clipped. in coverageMode()
562 bool needsPerspective = (this->deviceDimensionality() == 3); in vertexSize()
563 CoverageMode coverageMode = this->coverageMode(); in vertexSize()
582 if (this->requiresGeometrySubset()) { in vertexSize()
586 count += this->localDimensionality() * GrVertexAttribTypeSize(kFloat_GrVertexAttribType); in vertexSize()
588 if (ColorType::kByte == this->colorType()) { in vertexSize()
590 } else if (ColorType::kFloat == this->colorType()) { in vertexSize()
594 if (this->hasSubset()) { in vertexSize()
606 return arena->make([&](void* ptr) { in Make()
619 return arena->make([&](void* ptr) { in Make()
647 // texturing, device-dimensions are single bit flags in addToKey()
648 b->addBool(fTexSubset.isInitialized(), "subset"); in addToKey()
649 b->addBool(fSampler.isInitialized(), "textured"); in addToKey()
650 b->addBool(fNeedsPerspective, "perspective"); in addToKey()
651 b->addBool((fSaturate == Saturate::kYes), "saturate"); in addToKey()
653 b->addBool(fLocalCoord.isInitialized(), "hasLocalCoords"); in addToKey()
656 b->addBits(1, (kFloat3_GrVertexAttribType == fLocalCoord.cpuType()), "localCoordsType"); in addToKey()
658 b->addBool(fColor.isInitialized(), "hasColor"); in addToKey()
661 b->addBits(1, (kFloat4_GrVertexAttribType == fColor.cpuType()), "colorType"); in addToKey()
663 // and coverage mode, 00 for none, 01 for withposition, 10 for withcolor, 11 for in addToKey()
672 b->addBits(2, coverageKey, "coverageMode"); in addToKey()
674 b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get()), "colorSpaceXform"); in addToKey()
695 args.fVaryingHandler->emitAttributes(gp); in makeProgramImpl()
698 // Strip last channel from the vertex attribute to remove coverage and get the in makeProgramImpl()
701 args.fVertBuilder->codeAppendf("float3 position = %s.xyz;", in makeProgramImpl()
704 args.fVertBuilder->codeAppendf("float2 position = %s.xy;", in makeProgramImpl()
707 gpArgs->fPositionVar = {"position", in makeProgramImpl()
712 // No coverage to eliminate in makeProgramImpl()
713 gpArgs->fPositionVar = gp.fPosition.asShaderVar(); in makeProgramImpl()
719 gpArgs->fLocalCoordVar = gp.fLocalCoord.asShaderVar(); in makeProgramImpl()
725 // The color cannot be flat if the varying coverage has been modulated into it in makeProgramImpl()
726 args.fFragBuilder->codeAppendf("half4 %s;", args.fOutputColor); in makeProgramImpl()
727 args.fVaryingHandler->addPassThroughAttribute( in makeProgramImpl()
736 args.fFragBuilder->codeAppendf("half4 %s = half4(1);", args.fOutputColor); in makeProgramImpl()
745 args.fFragBuilder->codeAppend("float2 texCoord;"); in makeProgramImpl()
749 args.fVaryingHandler->addVarying(gp.fLocalCoord.name(), &v); in makeProgramImpl()
750 args.fVertBuilder->codeAppendf("%s = %s;", in makeProgramImpl()
752 args.fFragBuilder->codeAppendf("texCoord = %s.xy / %s.z;", in makeProgramImpl()
755 args.fVaryingHandler->addPassThroughAttribute(gp.fLocalCoord.asShaderVar(), in makeProgramImpl()
761 args.fFragBuilder->codeAppend("float4 subset;"); in makeProgramImpl()
762 args.fVaryingHandler->addPassThroughAttribute(gp.fTexSubset.asShaderVar(), in makeProgramImpl()
765 args.fFragBuilder->codeAppend( in makeProgramImpl()
770 args.fFragBuilder->codeAppendf( in makeProgramImpl()
774 args.fFragBuilder->appendTextureLookupAndBlend( in makeProgramImpl()
777 args.fFragBuilder->codeAppend(");"); in makeProgramImpl()
784 // And lastly, output the coverage calculation code in makeProgramImpl()
786 GrGLSLVarying coverage(kFloat_GrSLType); in makeProgramImpl() local
787 args.fVaryingHandler->addVarying("coverage", &coverage); in makeProgramImpl()
790 // the fragment shader to get screen-space linear coverage. in makeProgramImpl()
791 args.fVertBuilder->codeAppendf("%s = %s.w * %s.z;", in makeProgramImpl()
792 coverage.vsOut(), gp.fPosition.name(), in makeProgramImpl()
794 args.fFragBuilder->codeAppendf("float coverage = %s * sk_FragCoord.w;", in makeProgramImpl()
795 coverage.fsIn()); in makeProgramImpl()
797 args.fVertBuilder->codeAppendf("%s = %s;", in makeProgramImpl()
798 coverage.vsOut(), gp.fCoverage.name()); in makeProgramImpl()
799 args.fFragBuilder->codeAppendf("float coverage = %s;", coverage.fsIn()); in makeProgramImpl()
805 // coverage. This only has to be done in the exterior triangles, the in makeProgramImpl()
807 args.fFragBuilder->codeAppend("float4 geoSubset;"); in makeProgramImpl()
808 args.fVaryingHandler->addPassThroughAttribute(gp.fGeomSubset.asShaderVar(), in makeProgramImpl()
812 args.fFragBuilder->codeAppend( in makeProgramImpl()
813 "if (coverage < 0.5) {" in makeProgramImpl()
814 " float4 dists4 = clamp(float4(1, 1, -1, -1) * " in makeProgramImpl()
815 "(sk_FragCoord.xyxy - geoSubset), 0, 1);" in makeProgramImpl()
817 " coverage = min(coverage, dists2.x * dists2.y);" in makeProgramImpl()
820 args.fFragBuilder->codeAppend( in makeProgramImpl()
823 "half4 dists4 = clamp(half4(1, 1, -1, -1) * " in makeProgramImpl()
824 "half4(sk_FragCoord.xyxy - geoSubset), 0, 1);\n" in makeProgramImpl()
825 "half2 dists2 = dists4.xy + dists4.zw - 1;\n" in makeProgramImpl()
827 "coverage = min(coverage, subsetCoverage);"); in makeProgramImpl()
831 args.fFragBuilder->codeAppendf("half4 %s = half4(half(coverage));", in makeProgramImpl()
834 // Set coverage to 1, since it's either non-AA or the coverage was already in makeProgramImpl()
837 args.fFragBuilder->codeAppendf("const half4 %s = half4(1);", in makeProgramImpl()
855 this->initializeAttrs(spec); in QuadPerEdgeAAGeometryProcessor()
856 this->setTextureSamplerCnt(0); in QuadPerEdgeAAGeometryProcessor()
871 this->initializeAttrs(spec); in QuadPerEdgeAAGeometryProcessor()
872 this->setTextureSamplerCnt(1); in QuadPerEdgeAAGeometryProcessor()
885 fCoverage = {"coverage", kFloat_GrVertexAttribType, kFloat_GrSLType}; in initializeAttrs()
916 this->setVertexAttributes(&fPosition, 6); in initializeAttrs()
921 Attribute fPosition; // May contain coverage as last channel
922 Attribute fCoverage; // Used for non-perspective position to avoid Intel Metal issues
923 Attribute fColor; // May have coverage modulated in if the FPs support it
925 Attribute fGeomSubset; // Screen-space bounding box on geometry+aa outset
926 Attribute fTexSubset; // Texture-space bounding box on local coords
928 // The positions attribute may have coverage built into it, so float3 is an ambiguous type
929 // and may mean 2d with coverage, or 3d with no coverage