77 if (pts[0] != pts[1]) {
82 edges[3 * n + 1] = -v.
fX;
85 edges[3 * n + 1] = v.
fX;
87 edges[3 * n + 2] = -(edges[3 * n] * pts[1].fX + edges[3 * n + 1] * pts[1].fY);
98 if (
path.isInverseFillType()) {
108 uint32_t
key = (fEdgeCount << 3) | static_cast<int>(fEdgeType);
112std::unique_ptr<GrFragmentProcessor::ProgramImpl> GrConvexPolyEffect::onMakeProgramImpl()
const {
115 void emitCode(EmitArgs&
args)
override {
118 const char *edgeArrayName;
119 fEdgeUniform =
args.fUniformHandler->addUniformArray(&cpe,
126 fragBuilder->
codeAppend(
"float alpha = 1.0;\n"
128 for (
int i = 0;
i < cpe.fEdgeCount; ++
i) {
129 fragBuilder->
codeAppendf(
"edge = dot(float3(%s[%d]), sk_FragCoord.xy1);\n",
132 fragBuilder->
codeAppend(
"alpha *= saturate(edge);\n");
134 fragBuilder->
codeAppend(
"alpha *= step(0.5, edge);\n");
139 fragBuilder->
codeAppend(
"alpha = 1.0 - alpha;\n");
144 fragBuilder->
codeAppendf(
"return %s * half(alpha);\n", inputSample.
c_str());
151 size_t n = 3*cpe.fEdgeCount;
152 if (!
std::equal(fPrevEdges.begin(), fPrevEdges.begin() + n, cpe.fEdges.begin())) {
153 pdman.
set3fv(fEdgeUniform, cpe.fEdgeCount, cpe.fEdges.data());
154 std::copy_n(cpe.fEdges.begin(), n, fPrevEdges.begin());
158 GrGLSLProgramDataManager::UniformHandle fEdgeUniform;
159 std::array<float, 3 * GrConvexPolyEffect::kMaxEdges> fPrevEdges = {
SK_FloatNaN};
162 return std::make_unique<Impl>();
165GrConvexPolyEffect::GrConvexPolyEffect(std::unique_ptr<GrFragmentProcessor> inputFP,
170 ProcessorOptimizationFlags(inputFP.
get()) &
171 kCompatibleWithCoverageAsAlpha_OptimizationFlag)
172 , fEdgeType(edgeType)
176 std::copy_n(edges, 3*n, fEdges.begin());
179 for (
int i = 0;
i < n; ++
i) {
188 , fEdgeType(that.fEdgeType)
189 , fEdgeCount(that.fEdgeCount) {
190 std::copy_n(that.fEdges.begin(), 3*that.fEdgeCount, fEdges.begin());
199 int n = 3*cpe.fEdgeCount;
200 return cpe.fEdgeType == fEdgeType &&
201 cpe.fEdgeCount == fEdgeCount &&
202 std::equal(cpe.fEdges.begin(), cpe.fEdges.begin() + n, fEdges.begin());
209#if defined(GR_TEST_UTILS)
210std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::TestCreate(GrProcessorTestData*
d) {
213 for (
int i = 0;
i < 3 *
count; ++
i) {
214 edges[
i] =
d->fRandom->nextSScalar1();
218 std::unique_ptr<GrFragmentProcessor>
fp =
d->inputFP();
static GrFPResult GrFPSuccess(std::unique_ptr< GrFragmentProcessor > fp)
std::tuple< bool, std::unique_ptr< GrFragmentProcessor > > GrFPResult
static GrFPResult GrFPFailure(std::unique_ptr< GrFragmentProcessor > fp)
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(...)
static const int kGrClipEdgeTypeCnt
static constexpr bool GrClipEdgeTypeIsInverseFill(const GrClipEdgeType edgeType)
static GrClipEdgeType GrInvertClipEdgeType(const GrClipEdgeType edgeType)
static constexpr bool GrClipEdgeTypeIsAA(const GrClipEdgeType edgeType)
static bool equal(const SkBitmap &a, const SkBitmap &b)
constexpr SkPMColor4f SK_PMColor4fWHITE
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
constexpr float SK_FloatNaN
#define INHERITED(method,...)
~GrConvexPolyEffect() override
static constexpr int kMaxEdges
std::unique_ptr< GrFragmentProcessor > clone() const override
static GrFPResult Make(std::unique_ptr< GrFragmentProcessor > inputFP, GrClipEdgeType edgeType, int n, const float edges[])
static std::unique_ptr< GrFragmentProcessor > ModulateRGBA(std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color)
void registerChild(std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const =0
void codeAppend(const char *str)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
static SkPathFirstDirection ComputeFirstDirection(const SkPath &)
Verb next(SkPoint pts[4])
const char * c_str() const
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
const myers::Point & get(const myers::Segment &)