78 void freeGpuData()
override {}
82 const size_t rowBytes =
info.minRowBytes();
95 return gpuDevice->target();
106 std::unique_ptr<Recorder> recorder = context->makeRecorder();
108 ResourceCache* resourceCache = resourceProvider->resourceCache();
109 const SharedContext* sharedContext = resourceProvider->sharedContext();
134 resourceCache->forceProcessReturnedResources();
149 resourcePtr2->
unref();
150 resourceCache->forceProcessReturnedResources();
166 resourceCache->forceProcessReturnedResources();
177 resourcePtr2->
unref();
199 imageProxy = view.proxy();
214 std::unique_ptr<Recording> recording = recorder->snap();
221 context->insertRecording(insertInfo);
222 testContext->syncedSubmit(context);
225 resourceCache->forceProcessReturnedResources();
229 if (!context->priv().caps()->bufferMapsAreAsync()) {
248 if (!surfaceProxy->
instantiate(resourceProvider)) {
256 if (!context->priv().caps()->bufferMapsAreAsync()) {
264 recording = recorder->snap();
266 context->insertRecording(insertInfo);
267 testContext->syncedSubmit(context);
271 resourceCache->forceProcessReturnedResources();
277 const SharedContext* sharedContext,
278 ResourceCache* resourceCache,
279 size_t gpuMemorySize,
290 resourceCache->insertResource(
resource.get());
295 const SharedContext* sharedContext,
296 ResourceCache* resourceCache,
297 size_t gpuMemorySize) {
298 auto resource = add_new_resource(
reporter, sharedContext, resourceCache, gpuMemorySize);
305 resourceCache->forceProcessReturnedResources();
312 std::unique_ptr<Recorder> recorder = context->makeRecorder();
314 ResourceCache* resourceCache = resourceProvider->resourceCache();
315 const SharedContext* sharedContext = resourceProvider->sharedContext();
317 resourceCache->setMaxBudget(10);
319 auto resourceSize10 = add_new_resource(
reporter,
328 auto resourceSize1 = add_new_resource(
reporter,
341 resourceSize1.reset();
343 auto resourceSize2 = add_new_resource(
reporter,
355 resourceSize10.reset();
356 resourceSize2.reset();
357 resourceCache->forceProcessReturnedResources();
358 resourceCache->setMaxBudget(0);
365 resourceCache->setMaxBudget(10);
366 auto resourceSize1Ptr = add_new_purgeable_resource(
reporter,
370 add_new_purgeable_resource(
reporter,
374 auto resourceSize3Ptr = add_new_purgeable_resource(
reporter,
378 auto resourceSize4Ptr = add_new_purgeable_resource(
reporter,
389 add_new_purgeable_resource(
reporter,
400 resourceSize10 = add_new_resource(
reporter,
412 resourceSize4Ptr = add_new_purgeable_resource(
reporter,
423 resourceCache->setMaxBudget(0);
428 resourceSize10.reset();
429 resourceCache->forceProcessReturnedResources();
430 resourceCache->forcePurgeAsNeeded();
439 std::unique_ptr<Recorder> recorder = context->makeRecorder();
441 ResourceCache* resourceCache = resourceProvider->resourceCache();
442 const SharedContext* sharedContext = resourceProvider->sharedContext();
458 resourceCache->setMaxBudget(0);
464 resourceCache->setMaxBudget(100);
467 resourcePtr = add_new_purgeable_resource(
reporter,
480 resourceCache->setMaxBudget(0);
486 resourceCache->setMaxBudget(100);
503 resourcePtr = add_new_purgeable_resource(
reporter,
518 resourceCache->setMaxBudget(0);
526 std::unique_ptr<Recorder> recorder = context->makeRecorder();
528 ResourceCache* resourceCache = resourceProvider->resourceCache();
529 const SharedContext* sharedContext = resourceProvider->sharedContext();
532 auto beforeTime = skgpu::StdSteadyClock::now();
534 auto resourcePtr = add_new_purgeable_resource(
reporter,
544 auto afterTime = skgpu::StdSteadyClock::now();
562 auto betweenTime = skgpu::StdSteadyClock::now();
569 afterTime = skgpu::StdSteadyClock::now();
595 afterTime = skgpu::StdSteadyClock::now();
617 std::unique_ptr<Recorder> recorder = context->makeRecorder();
619 ResourceCache* resourceCache = resourceProvider->resourceCache();
620 const SharedContext* sharedContext = resourceProvider->sharedContext();
623 resourceCache->setMaxBudget(10);
626 auto resourcePtr = add_new_purgeable_resource(
reporter,
638 auto resource1 = add_new_resource(
reporter,
644 auto resource2 = add_new_resource(
reporter,
650 auto resource3 = add_new_resource(
reporter,
656 auto resource1Ptr = resource1.get();
657 auto resource2Ptr = resource2.get();
658 auto resource3Ptr = resource3.get();
663 auto timeBeforeReturningToCache = skgpu::StdSteadyClock::now();
671 resourceCache->forceProcessReturnedResources();
695 std::unique_ptr<Recorder> recorder = context->makeRecorder();
697 ResourceCache* resourceCache = resourceProvider->resourceCache();
698 const SharedContext* sharedContext = resourceProvider->sharedContext();
701 resourceCache->setMaxBudget(10);
704 auto resourcePtr = add_new_purgeable_resource(
reporter,
728 if (!resourcePtr1 || !resourcePtr2) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorRED
static SkString resource(SkPDFResourceType type, int index)
#define REPORTER_ASSERT(r, cond,...)
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
static SkDevice * TopDevice(const SkCanvas *canvas)
void clear(SkColor color)
static sk_sp< SkData > MakeUninitialized(size_t length)
void reset(T *ptr=nullptr)
static ResourceType GenerateResourceType()
size_t currentBudgetedBytes() const
void purgeResourcesNotUsedSince(StdSteadyClock::time_point purgeTime)
int getResourceCount() const
void insertResource(Resource *)
Resource * findAndRefResource(const GraphiteResourceKey &key, skgpu::Budgeted)
skgpu::Budgeted budgeted() const
const GraphiteResourceKey & key() const
size_t gpuMemorySize() const
const SharedContext * sharedContext() const
static void CreateKey(GraphiteResourceKey *key, Shareable shareable)
const char * getResourceType() const override
static sk_sp< TestResource > Make(const SharedContext *sharedContext, Ownership owned, skgpu::Budgeted budgeted, Shareable shareable, size_t gpuMemorySize=1)
bool instantiate(ResourceProvider *)
const Texture * texture() const
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
sk_sp< const SkImage > image
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)
DlVertices::Builder Builder
static sk_sp< SkData > create_image_data(const SkImageInfo &info)
static skgpu::graphite::TextureProxy * top_device_graphite_target_proxy(SkCanvas *canvas)
DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(GraphiteBudgetedResourcesTest, reporter, context, testContext, true, CtsEnforcement::kNextRelease)
DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(DeviceTestVertexTransparency, reporter, context, CtsEnforcement::kNextRelease)
TextureProxyView AsView(const SkImage *image)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data