36#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
38#ifndef GR_AA_TESSELLATOR_MAX_VERB_COUNT
39#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 10
62 TessInfo
info { numVertices, isLinear, tol };
69 const TessInfo*
info =
static_cast<const TessInfo*
>(
data->data());
71 return info->fIsLinear ||
info->fTolerance < 3.0f * tol;
75bool is_newer_better(
SkData* incumbent,
SkData* challenger) {
76 const TessInfo*
i =
static_cast<const TessInfo*
>(incumbent->
data());
77 const TessInfo* c =
static_cast<const TessInfo*
>(challenger->
data());
79 if (
i->fIsLinear ||
i->fTolerance <= c->fTolerance) {
90 : fMsg(
key, contextUniqueID,
true) {}
103 : fResourceProvider(resourceProvider)
104 , fCanMapVB(canMapVB) {
108 ~StaticVertexAllocator()
override {
113 void*
lock(
size_t stride,
int eagerCount)
override {
117 size_t size = eagerCount * stride;
132 fLockStride = stride;
136 void unlock(
int actualCount)
override {
144 actualCount*fLockStride,
150 actualCount, fLockStride);
159 return std::move(fVertexData);
167 void* fVertices =
nullptr;
168 size_t fLockStride = 0;
185 return Helper::FactoryHelper<TriangulatingPathOp>(context, std::move(
paint), shape,
186 viewMatrix, devClipBounds, aaType,
190 const char*
name()
const override {
return "TriangulatingPathOp"; }
208 , fHelper(processorSet, aaType, stencilSettings)
212 , fDevClipBounds(devClipBounds)
245 const SkIRect& devClipBounds) {
250 static constexpr int kClipBoundsCnt =
sizeof(devClipBounds) /
sizeof(uint32_t);
257 memcpy(&
builder[shapeKeyDataCnt], &devClipBounds,
sizeof(devClipBounds));
259 memset(&
builder[shapeKeyDataCnt], 0,
sizeof(devClipBounds));
276 if (!viewMatrix.
invert(&vmi)) {
291 auto threadSafeCache =
target->threadSafeCache();
300 auto [cachedVerts,
data] = threadSafeCache->findVertsWithData(
key);
301 if (cachedVerts && cache_match(
data.get(), tol)) {
302 fVertexData = std::move(cachedVerts);
307 if (!fVertexData->gpuBuffer()) {
318 fVertexData->setGpuBuffer(std::move(
buffer));
321 fMesh = CreateMesh(
target, fVertexData->refGpuBuffer(), 0, fVertexData->numVertices());
326 StaticVertexAllocator allocator(rp, canMapVB);
329 int vertexCount = Triangulate(&allocator,
fViewMatrix,
fShape, fDevClipBounds, tol,
331 if (vertexCount == 0) {
335 fVertexData = allocator.detachVertexData();
339 auto [tmpV, tmpD] = threadSafeCache->addVertsWithData(
key, fVertexData, is_newer_better);
340 if (tmpV != fVertexData) {
349 sk_make_sp<UniqueKeyInvalidator>(
key,
target->contextUniqueID()));
352 fMesh = CreateMesh(
target, fVertexData->refGpuBuffer(), 0, fVertexData->numVertices());
359 if (
path.isEmpty()) {
369 if (vertexCount == 0) {
372 fMesh = CreateMesh(
target, std::move(vertexBuffer), firstVertex, vertexCount);
380 bool usesMSAASurface,
391 ? LocalCoords::kUsePosition_Type
392 : LocalCoords::kUnused_Type;
396 coverageType = Coverage::kAttributeTweakAlpha_Type;
398 coverageType = Coverage::kAttribute_Type;
401 coverageType = Coverage::kSolid_Type;
416 auto vertexStride =
sizeof(
SkPoint);
418 vertexStride +=
sizeof(
float);
428 std::move(appliedClip), dstProxyView,
430 renderPassXferBarriers, colorLoadOp);
442 renderPassXferBarriers, colorLoadOp);
458 auto [cachedVerts,
data] = threadSafeViewCache->findVertsWithData(
key);
459 if (cachedVerts && cache_match(
data.get(), tol)) {
460 fVertexData = std::move(cachedVerts);
467 int vertexCount = Triangulate(&allocator,
fViewMatrix,
fShape, fDevClipBounds, tol,
469 if (vertexCount == 0) {
481 auto [tmpV, tmpD] = threadSafeViewCache->addVertsWithData(
key, fVertexData,
483 if (tmpV != fVertexData) {
486 SkASSERT(cache_match(tmpD.get(), tol));
487 fVertexData = std::move(tmpV);
499 this->createAAMesh(
target);
501 this->createNonAAMesh(
target);
510 mesh->set(std::move(vb),
count, firstVertex);
519 if (!fProgramInfo || !fMesh) {
528#if defined(GR_TEST_UTILS)
529 SkString onDumpInfo()
const override {
531 fColor.toBytes_RGBA(), fAntiAlias, fHelper.dumpInfo().c_str());
554#if defined(GR_TEST_UTILS)
556GR_DRAW_OP_TEST_DEFINE(TriangulatingPathOp) {
557 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
558 const SkPath&
path = GrTest::TestPath(random);
560 random->nextU(), random->nextU(), random->nextU(), random->nextU());
561 devClipBounds.
sort();
565 aaType = kAATypes[random->nextULessThan(
std::size(kAATypes))];
569 GrTest::TestStyle(random, &style);
573 aaType, GrGetRandomStencil(random, context));
587 const CanDrawPathArgs&
args)
const {
597 if (!
args.fShape->style().isSimpleFill() ||
args.fShape->knownToBeConvex()) {
600 switch (
args.fAAType) {
606 if (!
args.fShape->hasUnstyledKey()) {
615 if (
path.countVerbs() > fMaxVerbCount) {
623bool TriangulatingPathRenderer::onDrawPath(
const DrawPathArgs&
args) {
625 "GrTriangulatingPathRenderer::onDrawPath");
629 *
args.fClipConservativeBounds,
args.fAAType,
args.fUserStencilSettings);
630 args.fSurfaceDrawContext->addDrawOp(
args.fClip, std::move(op));
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename)
#define DEFINE_OP_CLASS_ID
GrProcessorAnalysisCoverage
#define TRIANGULATOR_WIREFRAME
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
@ kStatic_GrAccessPattern
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define INHERITED(method,...)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
sk_sp< const GrBuffer > fVertexBuffer
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT
static int PathToAATriangles(const SkPath &path, SkScalar tolerance, const SkRect &clipBounds, GrEagerVertexAllocator *vertexAllocator)
uint32_t contextID() const
sk_sp< GrThreadSafeCache::VertexData > detachVertexData()
friend class GrSimpleMeshDrawOpHelperWithStencil
virtual FixedFunctionFlags fixedFunctionFlags() const
virtual GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *, GrClampType)=0
virtual void unlock(int actualCount)=0
virtual void * lock(size_t stride, int eagerCount)=0
size_t vertexStride() const
virtual GrProgramInfo * programInfo()=0
void createProgramInfo(const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
GrMeshDrawOp(uint32_t classID)
virtual void onPrePrepareDraws(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
virtual void onCreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
virtual void onPrepareDraws(GrMeshDrawTarget *)=0
void drawMesh(const GrSimpleMesh &mesh)
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
static Owner Make(GrRecordingContext *context, Args &&... args)
std::unique_ptr< GrOp > Owner
virtual const char * name() const =0
virtual void visitProxies(const GrVisitProxyFunc &) const
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
void visitFPProxies(const GrVisitProxyFunc &func) const
GrThreadSafeCache * threadSafeCache()
GrRecordingContextPriv priv()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
GrProcessorSet::Analysis finalizeProcessors(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)
void visitProxies(const GrVisitProxyFunc &func) const
GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const
bool usesLocalCoords() const
bool compatibleWithCoverageAsAlpha() const
GrProgramInfo * createProgramInfoWithStencil(const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
bool isSimpleFill() const
void asPath(SkPath *out) const
void writeUnstyledKey(uint32_t *key) const
int unstyledKeySize() const
bool inverseFilled() const
const GrStyle & style() const
void addGenIDChangeListener(sk_sp< SkIDChangeListener >) const
static sk_sp< VertexData > MakeVertexData(const void *vertices, int vertexCount, size_t vertexSize)
static int PathToTriangles(const SkPath &path, SkScalar tolerance, const SkRect &clipBounds, GrEagerVertexAllocator *vertexAllocator, bool *isLinear)
const void * data() const
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
bool invert(SkMatrix *inverse) const
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static void Post(Message m)
static Domain GenerateDomain()
TriangulatingPathRenderer()
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static sk_sp< SkData > create_data(const SkIRect &drawRect, const SkIRect &origDevBounds)
GrGeometryProcessor * Make(SkArenaAlloc *, const Color &, const Coverage &, const LocalCoords &, const SkMatrix &viewMatrix)
GrGeometryProcessor * MakeForDeviceSpace(SkArenaAlloc *, const Color &, const Coverage &, const LocalCoords &, const SkMatrix &viewMatrix)
static const SkScalar kDefaultTolerance
SkScalar scaleToleranceToSrc(SkScalar devTol, const SkMatrix &viewM, const SkRect &pathBounds)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
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 buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static SkRect Make(const SkISize &size)
void join(const SkRect &r)
std::shared_ptr< const fml::Mapping > data
#define TRACE_EVENT0(category_group, name)