22 float m00 = localToDevice.
rc(0,0), m01 = localToDevice.
rc(0,1);
23 float m10 = localToDevice.
rc(1,0), m11 = localToDevice.
rc(1,1);
25 float det = m00*m11 - m01*m10;
33 float tx = localToDevice.
rc(0,3), ty = localToDevice.
rc(1,3);
35 return (invT.xy() + invT.zw()) / det;
44 Flags::kOutsetBoundsForAA,
79 return "float4 devPosition = coverage_mask_vertex_fn("
80 "float2(sk_VertexID >> 1, sk_VertexID & 1), "
81 "maskToDeviceRemainder, drawBounds, maskBoundsIn, deviceOrigin, "
82 "depth, float3x3(mat0, mat1, mat2), "
83 "maskBounds, textureCoords, invert, stepLocalCoords);\n";
88 return EmitSamplerLayout(bindingReqs, nextBindingIndex) +
" sampler2D pathAtlas;";
93 half c = sample(pathAtlas, clamp(textureCoords, maskBounds.LT, maskBounds.RB)).r;
94 outputCoverage = half4(mix(c, 1 - c, invert));
110 const auto& maskToDevice =
params.transform().matrix();
122 drawBounds =
params.clip().drawBounds().makeOffset(-deviceOrigin).ltrb();
126 SkASSERT(!
params.clip().transformedShapeBounds().isEmptyNegativeOrNaN() ^
127 all(maskBounds == 0.f));
129 if (
params.clip().transformedShapeBounds().isEmptyNegativeOrNaN()) {
141 maskBounds = skvx::shuffle<2,3,0,1>(maskBounds);
154 drawBounds = maskBounds;
161 maskBounds += textureOrigin.xyxy();
162 drawBounds += textureOrigin.xyxy();
163 deviceOrigin -= textureOrigin;
169 drawBounds *= atlasSizeInv.xyxy();
170 maskBounds *= atlasSizeInv.xyxy();
171 deviceOrigin *= atlasSizeInv;
175 SkASSERT(
all((maskBounds >= 0.f) & (maskBounds <= 1.f)));
176 maskBounds = 65535.f * maskBounds + 0.5f;
179 instances.append(1) << drawBounds << skvx::cast<uint16_t>(maskBounds) << deviceOrigin
180 <<
params.order().depthAsFloat() << ssboIndices
181 <<
m.rc(0,0) <<
m.rc(1,0) <<
m.rc(3,0)
182 <<
m.rc(0,1) <<
m.rc(1,1) <<
m.rc(3,1)
183 <<
m.rc(0,3) <<
m.rc(1,3) <<
m.rc(3,3);
191 const TextureProxy* proxy = coverageMask.textureProxy();
200 maskToDevice.
preTranslate(-deviceOrigin.x(), -deviceOrigin.y());
207 gatherer->
write(maskToDevice);
210 const bool pixelAligned =
212 params.transform().maxScaleFactor() == 1.f &&
sk_sp< T > sk_ref_sp(T *obj)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
#define SK_ScalarNearlyZero
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
SkScalar rc(int r, int c) const
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
std::string texturesAndSamplersSkSL(const ResourceBindingRequirements &, int *nextBindingIndex) const override
std::string vertexSkSL() const override
const char * fragmentCoverageSkSL() const override
void writeUniformsAndTextures(const DrawParams &, PipelineDataGatherer *) const override
void writeVertices(DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const override
const TextureProxy * textureProxy() const
const half2 & textureOrigin() const
const SkM44 & deviceToLocal() const
AI bool isEmptyNegativeOrNaN() const
SkSpan< const Uniform > uniforms() const
SkISize dimensions() const
const EmbeddedViewParams * params
static constexpr DepthStencilSettings kDirectDepthGreaterPass
static skvx::float2 get_device_translation(const SkM44 &localToDevice)
std::string EmitSamplerLayout(const ResourceBindingRequirements &bindingReqs, int *binding)
SIT bool all(const Vec< 1, T > &x)
SIN Vec< N, float > floor(const Vec< N, float > &x)
constexpr int32_t width() const
constexpr int32_t height() const