77 bool skipColorXform) {
81 auto dstCS = skipColorXform ? nullptr :
sk_ref_sp(deviceCS);
111 auto computeT = [](
float curr,
float next) {
114 float t = curr / (curr -
next);
120 return curr + t * (
next - curr);
123 constexpr float tol = 0.05f;
130 return lerp(curr,
next, computeT(curr.fZ - tol,
next.fZ - tol));
136 auto clipTriangle = [&](
SkPoint dst[],
const int idx[3],
const SkPoint3 pts[]) ->
int {
140 for (
int i = 0;
i < 3; ++
i) {
142 int next = idx[(
i + 1) % 3];
143 if (pts[curr].fZ > tol) {
145 if (pts[
next].fZ <= tol) {
146 *outP++ =
clip(pts[curr], pts[
next]);
149 if (pts[
next].fZ > tol) {
150 *outP++ =
clip(pts[curr], pts[
next]);
155 const int count = SkTo<int>(outP - outPoints);
166 if (
int n = clipTriangle(tmp, idx, dev3)) {
187void SkDraw::drawFixedVertices(
const SkVertices* vertices,
194 bool skipColorXform)
const {
197 const int vertexCount =
info.vertexCount();
198 const int indexCount =
info.indexCount();
201 const uint16_t* indices =
info.indices();
208 texCoords = positions;
214 bool blenderIsDst =
false;
217 if (std::optional<SkBlendMode> bm =
as_BB(blender)->asBlendMode(); bm.has_value() &&
colors) {
225 paintShader =
nullptr;
232 SkASSERT((texCoords !=
nullptr) == (paintShader !=
nullptr));
260 shaderWithWhichToBlend =
sk_ref_sp(shader);
264 std::move(shaderWithWhichToBlend));
272 if (texCoords && texCoords != positions) {
280 finalPaint.setShader(std::move(blenderShader));
295 while (vertProc(&
state)) {
296 if (triColorShader && !triColorShader->
update(ctmInverse, positions, dstColors,
312 bool skipColorXform)
const {
314 const int vertexCount =
info.vertexCount();
315 const int indexCount =
info.indexCount();
318 if (vertexCount < 3 || (indexCount > 0 && indexCount < 3) ||
fRC->
isEmpty()) {
326 constexpr size_t kDefVertexCount = 16;
347 bounds.setBounds(dev2, vertexCount);
353 this->drawFixedVertices(
354 vertices, std::move(blender),
paint, ctmInv, dev2, dev3, &outerAlloc, skipColorXform);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SkPoint lerp(const SkPoint &a, const SkPoint &b, float t)
static float next(float f)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
SkBlenderBase * as_BB(SkBlender *blend)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
SkRGBA4f< kUnpremul_SkAlphaType > SkColor4f
#define SkColorGetA(color)
bool SkConvertPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, const SkImageInfo &srcInfo, const void *srcPixels, size_t srcRB)
SkBlitter * SkCreateRasterPipelineBlitter(const SkPixmap &, const SkPaint &, const SkMatrix &ctm, SkArenaAlloc *, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
static SkPMColor4f * convert_colors(const SkColor src[], int count, SkColorSpace *deviceCS, SkArenaAlloc *alloc, bool skipColorXform)
static void fill_triangle_3(const VertState &state, SkBlitter *blitter, const SkRasterClip &rc, const SkPoint3 dev3[])
static bool texture_to_matrix(const VertState &state, const SkPoint verts[], const SkPoint texs[], SkMatrix *matrix)
static void fill_triangle_2(const VertState &state, SkBlitter *blitter, const SkRasterClip &rc, const SkPoint dev2[])
static void fill_triangle(const VertState &state, SkBlitter *blitter, const SkRasterClip &rc, const SkPoint dev2[], const SkPoint3 dev3[])
static constexpr int kMaxClippedTrianglePointCount
static bool compute_is_opaque(const SkColor colors[], int count)
static bool SkIsFinite(T x, Pack... values)
static constexpr float sk_ieee_float_divide(float numer, float denom)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
sk_sp< T > sk_ref_sp(T *obj)
SkShaderBase * as_SB(SkShader *shader)
static SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps *props)
T * makeArray(size_t count)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
static sk_sp< SkColorSpace > MakeSRGB()
const SkSurfaceProps * fProps
void drawVertices(const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool skipColorXform) const
void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
bool invert(SkMatrix *inverse) const
static const SkMatrix & I()
bool hasPerspective() const
SkColorSpace * colorSpace() const
sk_sp< SkShader > clipShader() const
static void FillTriangle(const SkPoint pts[], const SkRasterClip &, SkBlitter *)
bool update(const SkMatrix &ctmInv, const SkPoint pts[], const SkPMColor4f colors[], int index0, int index1, int index2)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
PODArray< SkColor > colors
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
SK_API sk_sp< SkShader > Color(SkColor)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
bool(* Proc)(VertState *)