38namespace skgpu {
class KeyBuilder; }
47 float expectedCrossProduct);
83 const char*
name()
const override {
return "VisualizeCrossProductSignFP"; }
85 std::unique_ptr<GrFragmentProcessor> clone()
const override {
86 return std::unique_ptr<GrFragmentProcessor>(
new VisualizeCrossProductSignFP(fA, fB));
93 std::unique_ptr<ProgramImpl> onMakeProgramImpl()
const override {
96 void emitCode(EmitArgs&
args)
override {
97 auto&
fp =
args.fFp.cast<VisualizeCrossProductSignFP>();
103 args.fFragBuilder->codeAppendf(R
"(
104 float crossProduct = cross_length_2d(%s, %s);
105 float2 visualization = clamp(float2(-sign(crossProduct), sign(crossProduct)),
106 float2(0), float2(1));
107 return half2(visualization).xy01;)", a, b);
113 const auto&
fp = processor.
cast<VisualizeCrossProductSignFP>();
114 pdman.
set2f(fAUniform,
fp.fA.x(),
fp.fA.y());
115 pdman.
set2f(fBUniform,
fp.fB.x(),
fp.fB.y());
121 return std::make_unique<Impl>();
133 float expectedCrossProduct) {
150 sdc->
readPixels(directContext, resultPM, {0, 0});
153 if (expectedCrossProduct > 0) {
155 }
else if (expectedCrossProduct < 0) {
static GrColor GrColorPackRGBA(unsigned r, unsigned g, unsigned b, unsigned a)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kSrcOver
r = s + (1-sa)*d
constexpr SkPMColor4f SK_PMColor4fWHITE
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static void run_test(skiatest::Reporter *, GrDirectContext *, skgpu::ganesh::SurfaceDrawContext *, SkVector a, SkVector b, float expectedCrossProduct)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(SkSLCross, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
#define REPORTER_ASSERT(r, cond,...)
virtual void set2f(UniformHandle, float, float) const =0
void setColorFragmentProcessor(std::unique_ptr< GrFragmentProcessor > fp)
void setColor4f(const SkPMColor4f &color)
void setPorterDuffXPFactory(SkBlendMode mode)
static const SkMatrix & I()
bool readPixels(GrDirectContext *dContext, GrPixmap dst, SkIPoint srcPt)
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
void drawRect(const GrClip *, GrPaint &&paint, GrAA, const SkMatrix &viewMatrix, const SkRect &, const GrStyle *style=nullptr)
void clear(const SkIRect &rect, const SkRGBA4f< AlphaType > &color)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library name
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRGBA4f FromBytes_RGBA(uint32_t color)
static constexpr SkRect MakeWH(float w, float h)