157 tmp.
drawRect({10, 10, wh-10.0f, wh-10.0f}, blue);
177 , fIsNewerBetter(isNewerBetter) {
184 fRecorder1 = std::make_unique<GrDeferredDisplayListRecorder>(characterization);
187 fRecorder2 = std::make_unique<GrDeferredDisplayListRecorder>(characterization);
209 fRecorder1 =
nullptr;
219 fRecorder2 =
nullptr;
230 bool failLookUp,
bool failFillingIn);
232 int expectedHits,
int expectedMisses,
233 int expectedNumRefs,
int expectedID);
239 bool failLookup =
false,
240 bool failFillingIn =
false) {
244 wh, failLookup, failFillingIn,
id, &fStats);
249 sdc->drawTexture(
nullptr,
255 {1.0f, 1.0f, 1.0f, 1.0f},
267 int expectedHits,
int expectedMisses,
int expectedNumRefs,
int expectedID) {
269 SkDebugf(
"Hits E: %d A: %d --- Misses E: %d A: %d\n",
284 if (expectedID < 0) {
293 const int* cachedID =
static_cast<const int*
>(xtraData->data());
294 if (*cachedID != expectedID) {
299 if (!view.proxy()->refCntGreaterThan(expectedNumRefs+1) ||
300 view.proxy()->refCntGreaterThan(expectedNumRefs+2)) {
347 bool failLookup =
false,
348 bool failFillingIn =
false) {
349 this->
addVertAccess(canvas, wh,
id, failLookup, failFillingIn,
nullptr);
353 int expectedHits,
int expectedMisses,
int expectedNumRefs,
int expectedID) {
355 SkDebugf(
"Hits E: %d A: %d --- Misses E: %d A: %d\n",
370 if (expectedID < 0) {
379 const int* cachedID =
static_cast<const int*
>(xtraData->data());
380 if (*cachedID != expectedID) {
385 if (!vertData->refCntGreaterThan(expectedNumRefs+1) ||
386 vertData->refCntGreaterThan(expectedNumRefs+2)) {
408 if (!
s->readPixels(actual, 0, 0)) {
414 const float tols[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
416 auto error = std::function<ComparePixmapsErrorReporter>(
417 [
reporter](
int x,
int y,
const float diffs[4]) {
420 x,
y, diffs[0], diffs[1], diffs[2], diffs[3]);
441 return this->
checkImage(reporter, std::move(tmp));
459 bool failLookup,
bool failFillingIn,
int id,
471 std::unique_ptr<GrDeferredDisplayListRecorder> fRecorder1;
472 std::unique_ptr<GrDeferredDisplayListRecorder> fRecorder2;
480 int wh,
int id,
bool failLookup,
bool failFillingIn,
483 return GrOp::Make<GrThreadSafeVertexTestOp>(
484 rContext, rContext,
stats, wh,
id, failLookup, failFillingIn, isNewerBetter);
493 bool failLookup,
bool failFillingIn,
499 , fFailFillingIn(failFillingIn)
500 , fIsNewerBetter(isNewerBetter) {
506 this->findOrCreateVertices(rContext, failLookup, fFailFillingIn);
509 const char*
name()
const override {
return "GrThreadSafeVertexTestOp"; }
518 bool usesMSAASurface,
528 Coverage::kSolid_Type,
529 LocalCoords::kUnused_Type,
532 return sk_gpu_test::CreateProgramInfo(caps, arena, writeView, usesMSAASurface,
533 std::move(appliedClip), dstProxyView,
536 renderPassXferBarriers, colorLoadOp);
540 return this->createProgramInfo(&flushState->
caps(),
550 void findOrCreateVertices(
GrRecordingContext* rContext,
bool failLookup,
bool failFillingIn) {
565 auto [cachedVerts,
data] = threadSafeViewCache->findVertsWithData(
key);
566 if (cachedVerts && !failLookup) {
567 fVertexData = cachedVerts;
577 constexpr size_t kVertSize =
sizeof(
SkPoint);
580 verts[0].
set(10.0f, 10.0f);
581 verts[1].
set(fWH-10.0f, 10.0f);
582 verts[2].
set(10.0f, fWH-10.0f);
583 verts[3].
set(fWH-10.0f, fWH-10.0f);
587 auto [tmpV, tmpD] = threadSafeViewCache->addVertsWithData(
key, fVertexData,
589 if (tmpV != fVertexData) {
596 auto rp = dContext->priv().resourceProvider();
598 if (!failFillingIn) {
624 fProgramInfo = this->createProgramInfo(rContext->
priv().
caps(), arena, writeView,
625 usesMSAASurface, std::move(appliedClip),
626 dstProxyView, renderPassXferBarriers, colorLoadOp);
632 this->findOrCreateVertices(rContext,
false, fFailFillingIn);
640 this->findOrCreateVertices(dContext,
false, fFailFillingIn);
644 if (!fVertexData || !fVertexData->
gpuBuffer()) {
649 fProgramInfo = this->createProgramInfo(flushState);
654 flushState->
draw(4, 0);
671 bool failLookup,
bool failFillingIn,
678 failLookup, failFillingIn,
684 sdc->addDrawOp(std::move(op));
707 std::unique_ptr<skgpu::ganesh::SurfaceDrawContext> sdc =
new_SDC(
dContext, wh);
710 paint.setColor4f({0.0f, 0.0f, 1.0f, 1.0f});
717 auto view = sdc->readSurfaceView();
721 trampoline->fProxy = view.asTextureProxyRef();
729 bool failLookup,
bool failFillingIn,
int id,
742 if (view != lazyView) {
745 }
else if (
id !=
kNoID) {
748 SkDEBUGCODE(
const int* cachedID =
static_cast<const int*
>(
data->data());)
752 ++
stats->fCacheMisses;
760 if (!FillInViewOnGpu(
dContext, wh,
stats, lazyView, std::move(trampoline))) {
779 view = CreateViewOnCpu(rContext, wh,
stats);
783 if (view == newView &&
id !=
kNoID) {
786 SkDEBUGCODE(
const int* cachedID =
static_cast<const int*
>(
data->data());)
925 static const bool kFailLookup =
true;
970 static const bool kFailLookup =
true;
1008 static const bool kFailFillingIn =
true;
1065 for (
int i = 16;
i <=
size;
i *= 2) {
1342 size_t currentBytes =
cache->getResourceBytes();
1344 SkASSERT(currentBytes >= desiredBytes);
1345 size_t amountToPurge = currentBytes - desiredBytes;
1489 std::this_thread::sleep_for(std::chrono::milliseconds(5));
1490 auto firstTime = skgpu::StdSteadyClock::now();
1491 std::this_thread::sleep_for(std::chrono::milliseconds(5));
1504 auto secondTime = skgpu::StdSteadyClock::now();
1506 auto msecs = std::chrono::duration_cast<std::chrono::milliseconds>(secondTime - firstTime);
1534 constexpr int kBestPrimeNumber = 73;
1539 for (
int i = 0;
i < 2; ++
i) {
1542 for (
int j = 0; j < 10; ++j) {
1543 int numResources = 10*
i + j + 1;
1544 int wh = numResources;
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#define DEFINE_OP_CLASS_ID
static void test_2(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static constexpr auto kImageOrigin
static void test_11(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static SkImageInfo default_ii(int wh)
static void test_8(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static bool default_is_newer_better(SkData *incumbent, SkData *challenger)
static constexpr int kNoID
static void test_5(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void test_15(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check, void(*create_key)(skgpu::UniqueKey *, int wh, int id))
static void create_view_key(skgpu::UniqueKey *key, int wh, int id)
static void test_4_5(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void test_13(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static bool newer_is_always_better(SkData *, SkData *)
static void test_6(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(GrThreadSafeCache1View, reporter, ctxInfo, CtsEnforcement::kNever)
static void test_12(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void test_7(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > new_SDC(GrRecordingContext *rContext, int wh)
static void test_4_75(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static constexpr int kImageWH
static void test_10(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static SkBitmap create_bitmap(int wh)
static void test_1(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void test_9(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void create_vert_key(skgpu::UniqueKey *key, int wh, int id)
static void test_3(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
static void test_4(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
@ kStatic_GrAccessPattern
@ kBottomLeft_GrSurfaceOrigin
#define check(reporter, ref, unref, make, kill)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kSrcOver
r = s + (1-sa)*d
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void * sk_malloc_throw(size_t size)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define INHERITED(method,...)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
bool ComparePixels(const GrCPixmap &a, const GrCPixmap &b, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
uint32_t contextID() const
const GrCaps * caps() const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
virtual GrDirectContext * asDirectContext()
SK_API GrBackendApi backend() const
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
GrResourceProvider * resourceProvider()
GrResourceCache * getResourceCache()
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
void releaseResourcesAndAbandonContext()
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
GrDirectContextPriv priv()
void purgeUnlockedResources(size_t bytesToPurge, bool preferScratchResources)
void performDeferredCleanup(std::chrono::milliseconds msNotUsed, GrPurgeResourceOptions opts=GrPurgeResourceOptions::kAllResources)
void abandonContext() override
void setResourceCacheLimit(size_t maxResourceBytes)
GrDrawOp(uint32_t classID)
GrDirectContext * getContext()
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
const GrSurfaceProxyView & writeView() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
void bindPipeline(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void draw(int vertexCount, int baseVertex)
bool usesMSAASurface() const final
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
std::unique_ptr< GrOp > Owner
virtual void onPrepare(GrOpFlushState *)=0
virtual const char * name() const =0
virtual void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
static constexpr Analysis EmptySetAnalysis()
sk_sp< GrTextureProxy > findProxyByUniqueKey(const skgpu::UniqueKey &)
sk_sp< GrTextureProxy > createProxyFromBitmap(const SkBitmap &, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted)
GrProxyProvider * proxyProvider()
GrThreadSafeCache * threadSafeCache()
void recordProgramInfo(const GrProgramInfo *programInfo)
SkArenaAlloc * recordTimeAllocator()
GrRecordingContextPriv priv()
static const GrStyle & SimpleFill()
skgpu::Swizzle swizzle() const
GrSurfaceOrigin origin() const
GrRenderTargetProxy * asRenderTargetProxy() const
const GrBackendFormat & backendFormat() const
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
void setGpuBuffer(sk_sp< GrGpuBuffer > gpuBuffer)
GrGpuBuffer * gpuBuffer()
sk_sp< GrGpuBuffer > refGpuBuffer()
const void * vertices() const
bool(* IsNewerBetter)(SkData *incumbent, SkData *challenger)
static std::tuple< GrSurfaceProxyView, sk_sp< Trampoline > > CreateLazyView(GrDirectContext *, GrColorType, SkISize dimensions, GrSurfaceOrigin, SkBackingFit)
SkDEBUGCODE(bool has(const skgpu::UniqueKey &) SK_EXCLUDES(fSpinLock);) GrSurfaceProxyView find(const skgpu std::tuple< GrSurfaceProxyView, sk_sp< SkData > > findWithData(const skgpu::UniqueKey &) SK_EXCLUDES(fSpinLock)
std::tuple< sk_sp< VertexData >, sk_sp< SkData > > findVertsWithData(const skgpu::UniqueKey &) SK_EXCLUDES(fSpinLock)
void remove(const skgpu::UniqueKey &) SK_EXCLUDES(fSpinLock)
std::tuple< GrSurfaceProxyView, sk_sp< SkData > > findOrAddWithData(const skgpu::UniqueKey &, const GrSurfaceProxyView &) SK_EXCLUDES(fSpinLock)
std::tuple< GrSurfaceProxyView, sk_sp< SkData > > addWithData(const skgpu::UniqueKey &, const GrSurfaceProxyView &) SK_EXCLUDES(fSpinLock)
void dropUniqueRefs(GrResourceCache *resourceCache) SK_EXCLUDES(fSpinLock)
static sk_sp< VertexData > MakeVertexData(const void *vertices, int vertexCount, size_t vertexSize)
void dropAllRefs() SK_EXCLUDES(fSpinLock)
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *rContext, TestHelper::Stats *stats, int wh, int id, bool failLookup, bool failFillingIn, GrThreadSafeCache::IsNewerBetter isNewerBetter)
const GrThreadSafeCache::VertexData * vertexData() const
void allocPixels(const SkImageInfo &info, size_t rowBytes)
const SkPixmap & pixmap() const
void drawRect(const SkRect &rect, const SkPaint &paint)
virtual GrRecordingContext * recordingContext() const
@ kFast_SrcRectConstraint
sample outside bounds; faster
void clear(SkColor color)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
static const SkMatrix & I()
static void Post(Message m)
void setColor(SkColor color)
void setAntiAlias(bool aa)
bool characterize(GrSurfaceCharacterization *characterization) const
bool checkVert(SkCanvas *canvas, int wh, int expectedHits, int expectedMisses, int expectedNumRefs, int expectedID)
GrDirectContext * dContext()
void addVertAccess(SkCanvas *canvas, int wh, int id=kNoID, bool failLookup=false, bool failFillingIn=false)
int numCacheEntries() const
bool checkImage(skiatest::Reporter *reporter, sk_sp< GrDeferredDisplayList > ddl)
GrThreadSafeCache * threadSafeCache()
void(TestHelper::* addAccessFP)(SkCanvas *, int wh, int id, bool failLookUp, bool failFillingIn)
TestHelper(GrDirectContext *dContext, GrThreadSafeCache::IsNewerBetter isNewerBetter=default_is_newer_better)
void addVertAccess(SkCanvas *canvas, int wh, int id, bool failLookup, bool failFillingIn, GrThreadSafeVertexTestOp **createdOp)
sk_sp< GrDeferredDisplayList > snap2()
void addViewAccess(SkCanvas *canvas, int wh, int id=kNoID, bool failLookup=false, bool failFillingIn=false)
bool checkImage(skiatest::Reporter *reporter)
bool checkView(SkCanvas *canvas, int wh, int expectedHits, int expectedMisses, int expectedNumRefs, int expectedID)
const GrThreadSafeCache * threadSafeCache() const
bool(TestHelper::* checkFP)(SkCanvas *, int wh, int expectedHits, int expectedMisses, int expectedNumRefs, int expectedID)
sk_sp< GrDeferredDisplayList > snap1()
bool checkImage(skiatest::Reporter *reporter, const sk_sp< SkSurface > &s)
size_t gpuSize(int wh) const
static Domain GenerateDomain()
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
GrGeometryProcessor * MakeForDeviceSpace(SkArenaAlloc *, const Color &, const Coverage &, const LocalCoords &, const SkMatrix &viewMatrix)
constexpr SkColor4f kWhite
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
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 Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
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
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
SK_API bool DrawDDL(SkSurface *, sk_sp< const GrDeferredDisplayList > ddl)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
void set(float x, float y)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeWH(float w, float h)
std::shared_ptr< const fml::Mapping > data