Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkTriColorShader.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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
9
14#include "src/base/SkVx.h"
18
20 rec.fPipeline->append(SkRasterPipelineOp::seed_shader);
21 if (fUsePersp) {
22 rec.fPipeline->append(SkRasterPipelineOp::matrix_perspective, &fM33);
23 }
24 rec.fPipeline->append(SkRasterPipelineOp::matrix_4x3, &fM43);
25 return true;
26}
27
29 const SkPoint pts[],
30 const SkPMColor4f colors[],
31 int index0,
32 int index1,
33 int index2) {
34 SkMatrix m, im;
35 m.reset();
36 m.set(0, pts[index1].fX - pts[index0].fX);
37 m.set(1, pts[index2].fX - pts[index0].fX);
38 m.set(2, pts[index0].fX);
39 m.set(3, pts[index1].fY - pts[index0].fY);
40 m.set(4, pts[index2].fY - pts[index0].fY);
41 m.set(5, pts[index0].fY);
42 if (!m.invert(&im)) {
43 return false;
44 }
45
46 fM33.setConcat(im, ctmInv);
47
48 auto c0 = skvx::float4::Load(colors[index0].vec()),
49 c1 = skvx::float4::Load(colors[index1].vec()),
50 c2 = skvx::float4::Load(colors[index2].vec());
51
52 (c1 - c0).store(&fM43.fMat[0]);
53 (c2 - c0).store(&fM43.fMat[4]);
54 c0.store(&fM43.fMat[8]);
55
56 if (!fUsePersp) {
57 fM43.setConcat(fM43, fM33);
58 }
59 return true;
60}
SI void store(P *ptr, const T &val)
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.cpp:603
void append(SkRasterPipelineOp, void *=nullptr)
bool appendStages(const SkStageRec &rec, const SkShaders::MatrixRec &) const override
bool update(const SkMatrix &ctmInv, const SkPoint pts[], const SkPMColor4f colors[], int index0, int index1, int index2)
SkRasterPipeline * fPipeline
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109