Flutter Engine
The Flutter Engine
Classes | Functions | Variables
GrThreadSafeCacheTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSurface.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/chromium/GrDeferredDisplayList.h"
#include "include/private/chromium/GrDeferredDisplayListRecorder.h"
#include "include/private/chromium/GrSurfaceCharacterization.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkRandom.h"
#include "src/core/SkMessageBus.h"
#include "src/gpu/GpuTypesPriv.h"
#include "src/gpu/ResourceKey.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrBuffer.h"
#include "src/gpu/ganesh/GrCanvas.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrColorSpaceXform.h"
#include "src/gpu/ganesh/GrDefaultGeoProcFactory.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrGpuBuffer.h"
#include "src/gpu/ganesh/GrOpFlushState.h"
#include "src/gpu/ganesh/GrPaint.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrResourceCache.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSamplerState.h"
#include "src/gpu/ganesh/GrStyle.h"
#include "src/gpu/ganesh/GrSurface.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/GrThreadSafeCache.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include "src/gpu/ganesh/ops/GrOp.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/ProxyUtils.h"
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <thread>
#include <utility>

Go to the source code of this file.

Classes

class  TestHelper
 
struct  TestHelper::Stats
 
class  GrThreadSafeVertexTestOp
 

Functions

static SkImageInfo default_ii (int wh)
 
static std::unique_ptr< skgpu::ganesh::SurfaceDrawContextnew_SDC (GrRecordingContext *rContext, int wh)
 
static void create_view_key (skgpu::UniqueKey *key, int wh, int id)
 
static void create_vert_key (skgpu::UniqueKey *key, int wh, int id)
 
static bool default_is_newer_better (SkData *incumbent, SkData *challenger)
 
static SkBitmap create_bitmap (int wh)
 
static void test_1 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache1View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache1Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_2 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache2View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache2Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_3 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache3View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache3Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_4 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_4_5 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4_5View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4_5Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_4_75 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4_75View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache4_75Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_5 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache5View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache5Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_6 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache6View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache6Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_7 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache7View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache7Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_8 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache8View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache8Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_9 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache9View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache9Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_10 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache10View, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_11 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache11View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache11Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_12 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache12View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache12Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_13 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache13View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache13Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache14, reporter, ctxInfo, CtsEnforcement::kNever)
 
static void test_15 (GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check, void(*create_key)(skgpu::UniqueKey *, int wh, int id))
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache15View, reporter, ctxInfo, CtsEnforcement::kNever)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache15Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 
static bool newer_is_always_better (SkData *, SkData *)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrThreadSafeCache16Verts, reporter, ctxInfo, CtsEnforcement::kNever)
 

Variables

static constexpr int kImageWH = 32
 
static constexpr auto kImageOrigin = kBottomLeft_GrSurfaceOrigin
 
static constexpr int kNoID = -1
 

Function Documentation

◆ create_bitmap()

static SkBitmap create_bitmap ( int  wh)
static

Definition at line 145 of file GrThreadSafeCacheTest.cpp.

145 {
147
148 bitmap.allocPixels(default_ii(wh));
149
150 SkCanvas tmp(bitmap);
151 tmp.clear(SK_ColorWHITE);
152
153 SkPaint blue;
155 blue.setAntiAlias(false);
156
157 tmp.drawRect({10, 10, wh-10.0f, wh-10.0f}, blue);
158
159 bitmap.setImmutable();
160 return bitmap;
161}
static SkImageInfo default_ii(int wh)
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
Definition: bitmap.py:1

◆ create_vert_key()

static void create_vert_key ( skgpu::UniqueKey key,
int  wh,
int  id 
)
static

Definition at line 127 of file GrThreadSafeCacheTest.cpp.

127 {
129 skgpu::UniqueKey::Builder builder(key, kVertDomain, 1);
130 builder[0] = wh;
131 builder.finish();
132
133 if (id != kNoID) {
134 key->setCustomData(SkData::MakeWithCopy(&id, sizeof(id)));
135 }
136}
static constexpr int kNoID
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
static Domain GenerateDomain()
Definition: ResourceKey.cpp:27

◆ create_view_key()

static void create_view_key ( skgpu::UniqueKey key,
int  wh,
int  id 
)
static

Definition at line 116 of file GrThreadSafeCacheTest.cpp.

116 {
118 skgpu::UniqueKey::Builder builder(key, kViewDomain, 1);
119 builder[0] = wh;
120 builder.finish();
121
122 if (id != kNoID) {
123 key->setCustomData(SkData::MakeWithCopy(&id, sizeof(id)));
124 }
125}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [1/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache10View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1356 of file GrThreadSafeCacheTest.cpp.

1359 {
1361}
reporter
Definition: FontMgrTest.cpp:39
static void test_10(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
void addViewAccess(SkCanvas *canvas, int wh, int id=kNoID, bool failLookup=false, bool failFillingIn=false)
bool checkView(SkCanvas *canvas, int wh, int expectedHits, int expectedMisses, int expectedNumRefs, int expectedID)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [2/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache11Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1414 of file GrThreadSafeCacheTest.cpp.

1417 {
1419}
static void test_11(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)
bool checkVert(SkCanvas *canvas, int wh, int expectedHits, int expectedMisses, int expectedNumRefs, int expectedID)
void addVertAccess(SkCanvas *canvas, int wh, int id, bool failLookup, bool failFillingIn, GrThreadSafeVertexTestOp **createdOp)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [3/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache11View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1407 of file GrThreadSafeCacheTest.cpp.

1410 {
1412}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [4/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache12Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1470 of file GrThreadSafeCacheTest.cpp.

1473 {
1475}
static void test_12(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [5/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache12View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1463 of file GrThreadSafeCacheTest.cpp.

1466 {
1468}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [6/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache13Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1521 of file GrThreadSafeCacheTest.cpp.

1524 {
1526}
static void test_13(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [7/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache13View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1514 of file GrThreadSafeCacheTest.cpp.

1517 {
1519}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [8/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache14  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1530 of file GrThreadSafeCacheTest.cpp.

1533 {
1534 constexpr int kBestPrimeNumber = 73; // palindromic in binary
1535 SkRandom rand(kBestPrimeNumber);
1536
1537 TestHelper helper(ctxInfo.directContext());
1538
1539 for (int i = 0; i < 2; ++i) {
1540 SkCanvas* ddlCanvas = (!i) ? helper.ddlCanvas1() : helper.ddlCanvas2();
1541
1542 for (int j = 0; j < 10; ++j) {
1543 int numResources = 10*i + j + 1;
1544 int wh = numResources;
1545
1546 if (rand.nextBool()) {
1547 helper.addViewAccess(ddlCanvas, wh, kNoID, false, false);
1548 REPORTER_ASSERT(reporter, helper.checkView(ddlCanvas, wh,
1549 /*hits*/ 0, /*misses*/ numResources,
1550 /*refs*/ 1, kNoID));
1551 } else {
1552 helper.addVertAccess(ddlCanvas, wh, kNoID, false, false);
1553 REPORTER_ASSERT(reporter, helper.checkVert(ddlCanvas, wh,
1554 /*hits*/ 0, /*misses*/ numResources,
1555 /*refs*/ 1, kNoID));
1556 }
1557 }
1558
1559 if (!i) {
1560 // Drop all the accumulated resources from the thread-safe cache
1561 helper.snap1();
1562 ctxInfo.directContext()->purgeUnlockedResources(GrPurgeResourceOptions::kAllResources);
1563 }
1564 }
1565}
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [9/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache15Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1614 of file GrThreadSafeCacheTest.cpp.

1617 {
1620}
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_vert_key(skgpu::UniqueKey *key, int wh, int id)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [10/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache15View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1606 of file GrThreadSafeCacheTest.cpp.

1609 {
1612}
static void create_view_key(skgpu::UniqueKey *key, int wh, int id)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [11/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache16Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1632 of file GrThreadSafeCacheTest.cpp.

1635 {
1638
1639 TestHelper helper(ctxInfo.directContext(), newer_is_always_better);
1640
1641 GrThreadSafeVertexTestOp* op1 = nullptr, *op2 = nullptr;
1642
1643 helper.addVertAccess(helper.ddlCanvas1(), kImageWH, kNoID, false, false, &op1);
1644 REPORTER_ASSERT(reporter, helper.checkVert(helper.ddlCanvas1(), kImageWH,
1645 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1646 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1647
1648 {
1649 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1650 auto [vertexData, xtraData] = helper.threadSafeCache()->findVertsWithData(key);
1651 REPORTER_ASSERT(reporter, vertexData.get() == op1->vertexData());
1652 }
1653
1654 helper.addVertAccess(helper.ddlCanvas2(), kImageWH, kNoID, /* failLookup */ true, false, &op2);
1655 REPORTER_ASSERT(reporter, helper.checkVert(helper.ddlCanvas2(), kImageWH,
1656 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1657 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1658
1659 REPORTER_ASSERT(reporter, op1->vertexData() != op2->vertexData());
1660
1661 {
1662 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1663 auto [vertexData, xtraData] = helper.threadSafeCache()->findVertsWithData(key);
1664 REPORTER_ASSERT(reporter, vertexData.get() == op2->vertexData());
1665 }
1666
1667 helper.checkImage(reporter, std::move(ddl1));
1668 helper.checkImage(reporter, std::move(ddl2));
1669}
static bool newer_is_always_better(SkData *, SkData *)
static constexpr int kImageWH
const GrThreadSafeCache::VertexData * vertexData() const

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [12/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache1Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 824 of file GrThreadSafeCacheTest.cpp.

827 {
829}
static void test_1(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [13/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache1View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 817 of file GrThreadSafeCacheTest.cpp.

820 {
822}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [14/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache2Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 868 of file GrThreadSafeCacheTest.cpp.

871 {
873}
static void test_2(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [15/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache2View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 861 of file GrThreadSafeCacheTest.cpp.

864 {
866}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [16/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache3Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 906 of file GrThreadSafeCacheTest.cpp.

909 {
911}
static void test_3(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [17/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache3View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 899 of file GrThreadSafeCacheTest.cpp.

902 {
904}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [18/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4_5Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 992 of file GrThreadSafeCacheTest.cpp.

995 {
996 test_4_5(ctxInfo.directContext(), reporter,
998}
static void test_4_5(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [19/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4_5View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 984 of file GrThreadSafeCacheTest.cpp.

987 {
988 test_4_5(ctxInfo.directContext(), reporter,
990}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [20/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4_75Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1038 of file GrThreadSafeCacheTest.cpp.

1041 {
1042 test_4_75(ctxInfo.directContext(), reporter,
1044}
static void test_4_75(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [21/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4_75View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1030 of file GrThreadSafeCacheTest.cpp.

1033 {
1034 test_4_75(ctxInfo.directContext(), reporter,
1036}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [22/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 946 of file GrThreadSafeCacheTest.cpp.

949 {
951}
static void test_4(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [23/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache4View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 939 of file GrThreadSafeCacheTest.cpp.

942 {
944}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [24/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache5Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1082 of file GrThreadSafeCacheTest.cpp.

1085 {
1086 test_5(ctxInfo.directContext(), reporter, &TestHelper::addVertAccess, &TestHelper::checkVert);
1087}
static void test_5(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [25/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache5View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1075 of file GrThreadSafeCacheTest.cpp.

1078 {
1079 test_5(ctxInfo.directContext(), reporter, &TestHelper::addViewAccess, &TestHelper::checkView);
1080}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [26/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache6Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1131 of file GrThreadSafeCacheTest.cpp.

1134 {
1135 test_6(ctxInfo.directContext(), reporter, &TestHelper::addVertAccess, &TestHelper::checkVert);
1136}
static void test_6(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [27/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache6View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1124 of file GrThreadSafeCacheTest.cpp.

1127 {
1128 test_6(ctxInfo.directContext(), reporter, &TestHelper::addViewAccess, &TestHelper::checkView);
1129}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [28/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache7Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1181 of file GrThreadSafeCacheTest.cpp.

1184 {
1185 test_7(ctxInfo.directContext(), reporter, &TestHelper::addVertAccess, &TestHelper::checkVert);
1186}
static void test_7(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [29/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache7View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1174 of file GrThreadSafeCacheTest.cpp.

1177 {
1178 test_7(ctxInfo.directContext(), reporter, &TestHelper::addViewAccess, &TestHelper::checkView);
1179}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [30/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache8Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1232 of file GrThreadSafeCacheTest.cpp.

1235 {
1236 test_8(ctxInfo.directContext(), reporter, &TestHelper::addVertAccess, &TestHelper::checkVert);
1237}
static void test_8(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [31/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache8View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1225 of file GrThreadSafeCacheTest.cpp.

1228 {
1229 test_8(ctxInfo.directContext(), reporter, &TestHelper::addViewAccess, &TestHelper::checkView);
1230}

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [32/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache9Verts  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1283 of file GrThreadSafeCacheTest.cpp.

1286 {
1287 test_9(ctxInfo.directContext(), reporter, &TestHelper::addVertAccess, &TestHelper::checkVert);
1288}
static void test_9(GrDirectContext *dContext, skiatest::Reporter *reporter, TestHelper::addAccessFP addAccess, TestHelper::checkFP check)

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS() [33/33]

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrThreadSafeCache9View  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 1276 of file GrThreadSafeCacheTest.cpp.

1279 {
1280 test_9(ctxInfo.directContext(), reporter, &TestHelper::addViewAccess, &TestHelper::checkView);
1281}

◆ default_ii()

static SkImageInfo default_ii ( int  wh)
static

Definition at line 96 of file GrThreadSafeCacheTest.cpp.

96 {
98}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ default_is_newer_better()

static bool default_is_newer_better ( SkData incumbent,
SkData challenger 
)
static

Definition at line 138 of file GrThreadSafeCacheTest.cpp.

138 {
139 return false;
140}

◆ new_SDC()

static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > new_SDC ( GrRecordingContext rContext,
int  wh 
)
static

Definition at line 100 of file GrThreadSafeCacheTest.cpp.

101 {
104 nullptr,
106 {wh, wh},
108 /* label= */ {},
109 /* sampleCnt= */ 1,
114}
static constexpr auto kImageOrigin
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)

◆ newer_is_always_better()

static bool newer_is_always_better ( SkData ,
SkData  
)
static

Definition at line 1628 of file GrThreadSafeCacheTest.cpp.

1628 {
1629 return true;
1630}

◆ test_1()

static void test_1 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 794 of file GrThreadSafeCacheTest.cpp.

796 {
797
798 TestHelper helper(dContext);
799
800 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, 1, false, false);
801 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
802 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, /*id*/ 1));
803
804 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, 2, false, false);
805 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
806 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, /*id*/ 1));
807
808 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
809 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 0);
810 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 0);
811 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 1);
812
813 helper.checkImage(reporter, helper.snap1());
814 helper.checkImage(reporter, helper.snap2());
815}
#define check(reporter, ref, unref, make, kill)
Definition: RefCntTest.cpp:85

◆ test_10()

static void test_10 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1293 of file GrThreadSafeCacheTest.cpp.

1295 {
1296
1297 if (GrBackendApi::kOpenGL != dContext->backend()) {
1298 // The lower-level backends have too much going on for the following simple purging
1299 // test to work
1300 return;
1301 }
1302
1303 TestHelper helper(dContext);
1304
1305 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, false);
1306 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1307 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1308
1309 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1310 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1311 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1312 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, kNoID));
1313
1314 (helper.*addAccess)(helper.liveCanvas(), 2*kImageWH, kNoID, false, false);
1315 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1316 /*hits*/ 1, /*misses*/ 2, /*refs*/ 1, kNoID));
1317
1318 (helper.*addAccess)(helper.ddlCanvas2(), 2*kImageWH, kNoID, false, false);
1319 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1320 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), 2*kImageWH,
1321 /*hits*/ 2, /*misses*/ 2, /*refs*/ 2, kNoID));
1322
1323 dContext->flush();
1324 dContext->submit(GrSyncCpu::kYes);
1325
1326 // This should clear out everything but the textures locked in the thread-safe cache
1328
1329 ddl1 = nullptr;
1330 ddl2 = nullptr;
1331
1332 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1333 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1334 /*hits*/ 2, /*misses*/ 2, /*refs*/ 0, kNoID));
1335 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1336 /*hits*/ 2, /*misses*/ 2, /*refs*/ 0, kNoID));
1337
1338 // Regardless of which image is MRU, this should force the other out
1339 size_t desiredBytes = helper.gpuSize(2*kImageWH) + helper.gpuSize(kImageWH)/2;
1340
1341 auto cache = dContext->priv().getResourceCache();
1342 size_t currentBytes = cache->getResourceBytes();
1343
1344 SkASSERT(currentBytes >= desiredBytes);
1345 size_t amountToPurge = currentBytes - desiredBytes;
1346
1347 // The 2*kImageWH texture should be MRU.
1348 dContext->purgeUnlockedResources(amountToPurge, true);
1349
1350 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1351
1352 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1353 /*hits*/ 2, /*misses*/ 2, /*refs*/ 0, kNoID));
1354}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SK_API GrBackendApi backend() const
GrResourceCache * getResourceCache()
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
GrDirectContextPriv priv()
void purgeUnlockedResources(size_t bytesToPurge, bool preferScratchResources)
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
Definition: switches.h:191

◆ test_11()

static void test_11 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1374 of file GrThreadSafeCacheTest.cpp.

1376 {
1377
1378 TestHelper helper(dContext);
1379
1380 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, false);
1381 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1382 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1383
1384 (helper.*addAccess)(helper.liveCanvas(), 2*kImageWH, kNoID, false, false);
1385 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1386 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1387
1388 dContext->flush();
1389 dContext->submit(GrSyncCpu::kYes);
1390
1391 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1392 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1393 /*hits*/ 0, /*misses*/ 2, /*refs*/ 0, kNoID));
1394 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1395 /*hits*/ 0, /*misses*/ 2, /*refs*/ 0, kNoID));
1396
1397 // This shouldn't remove anything from the cache
1399
1400 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1401
1403
1404 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1405}

◆ test_12()

static void test_12 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1424 of file GrThreadSafeCacheTest.cpp.

1426 {
1427
1428 TestHelper helper(dContext);
1429
1430 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, false);
1431 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1432 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1433 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1434 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1435 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1436 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, kNoID));
1437
1438 (helper.*addAccess)(helper.liveCanvas(), 2*kImageWH, kNoID, false, false);
1439 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1440 /*hits*/ 1, /*misses*/ 2, /*refs*/ 1, kNoID));
1441
1442 dContext->flush();
1443 dContext->submit(GrSyncCpu::kYes);
1444
1445 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1446 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1447 /*hits*/ 1, /*misses*/ 2, /*refs*/ 1, kNoID));
1448 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1449 /*hits*/ 1, /*misses*/ 2, /*refs*/ 0, kNoID));
1450
1451 dContext->setResourceCacheLimit(0);
1452
1453 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1454
1455 ddl1 = nullptr;
1456
1457 // Explicitly kick off the purge - it won't happen automatically on unref
1458 dContext->performDeferredCleanup(std::chrono::milliseconds(0));
1459
1460 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1461}
void performDeferredCleanup(std::chrono::milliseconds msNotUsed, GrPurgeResourceOptions opts=GrPurgeResourceOptions::kAllResources)
void setResourceCacheLimit(size_t maxResourceBytes)

◆ test_13()

static void test_13 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1478 of file GrThreadSafeCacheTest.cpp.

1480 {
1481
1482 TestHelper helper(dContext);
1483
1484 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1485 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1486 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1487 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1488
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));
1492
1493 (helper.*addAccess)(helper.ddlCanvas2(), 2*kImageWH, kNoID, false, false);
1494
1495 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), 2*kImageWH,
1496 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1497 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1498
1499 ddl1 = nullptr;
1500 ddl2 = nullptr;
1501
1502 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1503
1504 auto secondTime = skgpu::StdSteadyClock::now();
1505
1506 auto msecs = std::chrono::duration_cast<std::chrono::milliseconds>(secondTime - firstTime);
1507 dContext->performDeferredCleanup(msecs);
1508
1509 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1510 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), 2*kImageWH,
1511 /*hits*/ 0, /*misses*/ 2, /*refs*/ 0, kNoID));
1512}

◆ test_15()

static void test_15 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check,
void(*)(skgpu::UniqueKey *, int wh, int id create_key 
)
static

Definition at line 1568 of file GrThreadSafeCacheTest.cpp.

1571 {
1572
1573 TestHelper helper(dContext);
1574
1575 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1576 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1577 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1578 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1579
1580 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1581
1583 (*create_key)(&key, kImageWH, kNoID);
1584
1586 /* inThreadSafeCache */ true);
1587
1589
1590 // This purge call is needed to process the invalidation messages
1592
1593 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1594
1595 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, kNoID, false, false);
1596 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
1597 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1598 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1599
1600 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1601
1602 helper.checkImage(reporter, std::move(ddl1));
1603 helper.checkImage(reporter, std::move(ddl2));
1604}
uint32_t contextID() const
static void Post(Message m)
Definition: SkMessageBus.h:130

◆ test_2()

static void test_2 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 833 of file GrThreadSafeCacheTest.cpp.

835 {
836
837 TestHelper helper(dContext);
838
839 (helper.*addAccess)(helper.liveCanvas(), kImageWH, 1, false, false);
840 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
841 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, /*id*/ 1));
842
843 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, 2, false, false);
844 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
845 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, /*id*/ 1));
846
847 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, 3, false, false);
848 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
849 /*hits*/ 2, /*misses*/ 1, /*refs*/ 3, /*id*/ 1));
850
851 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
852 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
853 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 1);
854 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
855
856 helper.checkImage(reporter);
857 helper.checkImage(reporter, helper.snap1());
858 helper.checkImage(reporter, helper.snap2());
859}

◆ test_3()

static void test_3 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 876 of file GrThreadSafeCacheTest.cpp.

878 {
879
880 TestHelper helper(dContext);
881
882 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, 1, false, false);
883 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
884 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, /*id*/ 1));
885
886 (helper.*addAccess)(helper.liveCanvas(), kImageWH, 2, false, false);
887 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
888 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, /*id*/ 1));
889
890 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
891 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
892 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 0);
893 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 1);
894
895 helper.checkImage(reporter);
896 helper.checkImage(reporter, helper.snap1());
897}

◆ test_4()

static void test_4 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 915 of file GrThreadSafeCacheTest.cpp.

917 {
918
919 TestHelper helper(dContext);
920
921 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, 1, false, false);
922 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
923 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, /*id*/ 1));
924
925 static const bool kFailLookup = true;
926 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, 2, kFailLookup, false);
927 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
928 /*hits*/ 0, /*misses*/ 2, /*refs*/ 2, /*id*/ 1));
929
930 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
931 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 0);
932 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 0);
933 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 2);
934
935 helper.checkImage(reporter, helper.snap1());
936 helper.checkImage(reporter, helper.snap2());
937}

◆ test_4_5()

static void test_4_5 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 955 of file GrThreadSafeCacheTest.cpp.

957 {
958
959 TestHelper helper(dContext);
960
961 (helper.*addAccess)(helper.liveCanvas(), kImageWH, 1, false, false);
962 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
963 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, /*id*/ 1));
964
965 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
966 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
967 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 1);
968 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
969
970 static const bool kFailLookup = true;
971 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, 2, kFailLookup, false);
972 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
973 /*hits*/ 0, /*misses*/ 2, /*refs*/ 2, /*id*/ 1));
974
975 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
976 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
977 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 1);
978 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 1);
979
980 helper.checkImage(reporter);
981 helper.checkImage(reporter, helper.snap1());
982}

◆ test_4_75()

static void test_4_75 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1002 of file GrThreadSafeCacheTest.cpp.

1004 {
1005
1006 TestHelper helper(dContext);
1007
1008 static const bool kFailFillingIn = true;
1009 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, kFailFillingIn);
1010 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1011 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1012
1013 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1014 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
1015 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 0);
1016 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
1017
1018 dContext->flush();
1019 dContext->submit(GrSyncCpu::kYes);
1020
1021 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1022 /*hits*/ 0, /*misses*/ 1, /*refs*/ 0, kNoID));
1023
1024 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1025 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
1026 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 0);
1027 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
1028}

◆ test_5()

static void test_5 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1047 of file GrThreadSafeCacheTest.cpp.

1049 {
1050
1051 TestHelper helper(dContext);
1052
1053 auto threadSafeCache = helper.threadSafeCache();
1054
1055 int size = 16;
1056 (helper.*addAccess)(helper.ddlCanvas1(), size, /*id*/ size, false, false);
1057
1058 size_t initialSize = threadSafeCache->approxBytesUsedForHash();
1059
1060 while (initialSize == threadSafeCache->approxBytesUsedForHash()) {
1061 size *= 2;
1062 (helper.*addAccess)(helper.ddlCanvas1(), size, /*id*/ size, false, false);
1063 }
1064
1065 for (int i = 16; i <= size; i *= 2) {
1066 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(),
1067 /*wh*/ i,
1068 /*hits*/ 0,
1069 /*misses*/ threadSafeCache->numEntries(),
1070 /*refs*/ 1,
1071 /*id*/ i));
1072 }
1073}
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
Definition: switches.h:259

◆ test_6()

static void test_6 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1091 of file GrThreadSafeCacheTest.cpp.

1093 {
1094
1095 TestHelper helper(dContext);
1096
1097 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1098 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1099 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1100 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1101
1102 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, kNoID, false, false);
1103 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1104 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1105 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, kNoID));
1106
1107 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1108
1109 ddl1 = nullptr;
1110 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1111 /*hits*/ 1, /*misses*/ 1, /*refs*/ 1, kNoID));
1112
1113 ddl2 = nullptr;
1114 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1115 /*hits*/ 1, /*misses*/ 1, /*refs*/ 0, kNoID));
1116
1117 // The cache still has its ref
1118 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1119
1120 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1121 /*hits*/ 1, /*misses*/ 1, /*refs*/ 0, kNoID));
1122}

◆ test_7()

static void test_7 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1140 of file GrThreadSafeCacheTest.cpp.

1142 {
1143
1144 TestHelper helper(dContext);
1145
1146 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1147 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1148 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, kImageWH,
1149 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1150
1151 (helper.*addAccess)(helper.ddlCanvas2(), 2*kImageWH, kNoID, false, false);
1152 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1153 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, 2*kImageWH,
1154 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1155
1156 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1157
1158 helper.threadSafeCache()->dropUniqueRefs(nullptr);
1159 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 2);
1160
1161 ddl1 = nullptr;
1162
1163 helper.threadSafeCache()->dropUniqueRefs(nullptr);
1164 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1165 REPORTER_ASSERT(reporter, (helper.*check)(nullptr, 2*kImageWH,
1166 /*hits*/ 0, /*misses*/ 2, /*refs*/ 1, kNoID));
1167
1168 helper.threadSafeCache()->dropAllRefs();
1169 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1170
1171 ddl2 = nullptr;
1172}

◆ test_8()

static void test_8 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1191 of file GrThreadSafeCacheTest.cpp.

1193 {
1194
1195 TestHelper helper(dContext);
1196
1197 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, false);
1198 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1199 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1200
1201 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1202 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1203 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1204 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, kNoID));
1205
1206 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, kNoID, false, false);
1207 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
1208 /*hits*/ 2, /*misses*/ 1, /*refs*/ 3, kNoID));
1209
1210 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1211 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
1212 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 1);
1213 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
1214
1215 dContext->abandonContext(); // This should exercise dropAllRefs
1216
1217 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1218
1219 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1220
1221 ddl1 = nullptr;
1222 ddl2 = nullptr;
1223}
void abandonContext() override

◆ test_9()

static void test_9 ( GrDirectContext dContext,
skiatest::Reporter reporter,
TestHelper::addAccessFP  addAccess,
TestHelper::checkFP  check 
)
static

Definition at line 1242 of file GrThreadSafeCacheTest.cpp.

1244 {
1245
1246 TestHelper helper(dContext);
1247
1248 (helper.*addAccess)(helper.liveCanvas(), kImageWH, kNoID, false, false);
1249 REPORTER_ASSERT(reporter, (helper.*check)(helper.liveCanvas(), kImageWH,
1250 /*hits*/ 0, /*misses*/ 1, /*refs*/ 1, kNoID));
1251
1252 (helper.*addAccess)(helper.ddlCanvas1(), kImageWH, kNoID, false, false);
1253 sk_sp<GrDeferredDisplayList> ddl1 = helper.snap1();
1254 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas1(), kImageWH,
1255 /*hits*/ 1, /*misses*/ 1, /*refs*/ 2, kNoID));
1256
1257 (helper.*addAccess)(helper.ddlCanvas2(), kImageWH, kNoID, false, false);
1258 REPORTER_ASSERT(reporter, (helper.*check)(helper.ddlCanvas2(), kImageWH,
1259 /*hits*/ 2, /*misses*/ 1, /*refs*/ 3, kNoID));
1260
1261 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 1);
1262 REPORTER_ASSERT(reporter, helper.stats()->fNumLazyCreations == 1);
1263 REPORTER_ASSERT(reporter, helper.stats()->fNumHWCreations == 1);
1264 REPORTER_ASSERT(reporter, helper.stats()->fNumSWCreations == 0);
1265
1266 dContext->releaseResourcesAndAbandonContext(); // This should hit dropAllRefs
1267
1268 sk_sp<GrDeferredDisplayList> ddl2 = helper.snap2();
1269
1270 REPORTER_ASSERT(reporter, helper.numCacheEntries() == 0);
1271
1272 ddl1 = nullptr;
1273 ddl2 = nullptr;
1274}
void releaseResourcesAndAbandonContext()

Variable Documentation

◆ kImageOrigin

constexpr auto kImageOrigin = kBottomLeft_GrSurfaceOrigin
staticconstexpr

Definition at line 93 of file GrThreadSafeCacheTest.cpp.

◆ kImageWH

constexpr int kImageWH = 32
staticconstexpr

Definition at line 92 of file GrThreadSafeCacheTest.cpp.

◆ kNoID

constexpr int kNoID = -1
staticconstexpr

Definition at line 94 of file GrThreadSafeCacheTest.cpp.