55 resource->setKey(
key);
86 const size_t rowBytes =
info.minRowBytes();
99 return gpuDevice->target();
110 std::unique_ptr<Recorder> recorder = context->makeRecorder();
112 ResourceCache* resourceCache = resourceProvider->resourceCache();
113 const SharedContext* sharedContext = resourceProvider->sharedContext();
125 Resource* resourcePtr = resource.get();
138 resourceCache->forceProcessReturnedResources();
153 resourcePtr2->
unref();
154 resourceCache->forceProcessReturnedResources();
163 resourcePtr = resource.get();
170 resourceCache->forceProcessReturnedResources();
181 resourcePtr2->
unref();
203 imageProxy = view.proxy();
218 std::unique_ptr<Recording> recording = recorder->snap();
225 context->insertRecording(insertInfo);
226 testContext->syncedSubmit(context);
229 resourceCache->forceProcessReturnedResources();
233 if (!context->priv().caps()->bufferMapsAreAsync()) {
252 if (!surfaceProxy->
instantiate(resourceProvider)) {
260 if (!context->priv().caps()->bufferMapsAreAsync()) {
268 recording = recorder->snap();
270 context->insertRecording(insertInfo);
271 testContext->syncedSubmit(context);
275 resourceCache->forceProcessReturnedResources();
281 const SharedContext* sharedContext,
282 ResourceCache* resourceCache,
283 size_t gpuMemorySize,
294 resourceCache->insertResource(resource.get());
299 const SharedContext* sharedContext,
300 ResourceCache* resourceCache,
301 size_t gpuMemorySize) {
302 auto resource = add_new_resource(
reporter, sharedContext, resourceCache, gpuMemorySize);
307 Resource* ptr = resource.get();
309 resourceCache->forceProcessReturnedResources();
316 std::unique_ptr<Recorder> recorder = context->makeRecorder();
318 ResourceCache* resourceCache = resourceProvider->resourceCache();
319 const SharedContext* sharedContext = resourceProvider->sharedContext();
321 resourceCache->setMaxBudget(10);
323 auto resourceSize10 = add_new_resource(
reporter,
332 auto resourceSize1 = add_new_resource(
reporter,
345 resourceSize1.reset();
347 auto resourceSize2 = add_new_resource(
reporter,
359 resourceSize10.reset();
360 resourceSize2.reset();
361 resourceCache->forceProcessReturnedResources();
362 resourceCache->setMaxBudget(0);
369 resourceCache->setMaxBudget(10);
370 auto resourceSize1Ptr = add_new_purgeable_resource(
reporter,
374 add_new_purgeable_resource(
reporter,
378 auto resourceSize3Ptr = add_new_purgeable_resource(
reporter,
382 auto resourceSize4Ptr = add_new_purgeable_resource(
reporter,
393 add_new_purgeable_resource(
reporter,
404 resourceSize10 = add_new_resource(
reporter,
416 resourceSize4Ptr = add_new_purgeable_resource(
reporter,
427 resourceCache->setMaxBudget(0);
432 resourceSize10.reset();
433 resourceCache->forceProcessReturnedResources();
434 resourceCache->forcePurgeAsNeeded();
443 std::unique_ptr<Recorder> recorder = context->makeRecorder();
445 ResourceCache* resourceCache = resourceProvider->resourceCache();
446 const SharedContext* sharedContext = resourceProvider->sharedContext();
462 resourceCache->setMaxBudget(0);
468 resourceCache->setMaxBudget(100);
471 resourcePtr = add_new_purgeable_resource(
reporter,
484 resourceCache->setMaxBudget(0);
490 resourceCache->setMaxBudget(100);
507 resourcePtr = add_new_purgeable_resource(
reporter,
522 resourceCache->setMaxBudget(0);
530 std::unique_ptr<Recorder> recorder = context->makeRecorder();
532 ResourceCache* resourceCache = resourceProvider->resourceCache();
533 const SharedContext* sharedContext = resourceProvider->sharedContext();
536 auto beforeTime = skgpu::StdSteadyClock::now();
538 auto resourcePtr = add_new_purgeable_resource(
reporter,
548 auto afterTime = skgpu::StdSteadyClock::now();
566 auto betweenTime = skgpu::StdSteadyClock::now();
573 afterTime = skgpu::StdSteadyClock::now();
588 auto resource = add_new_resource(
reporter,
595 resourcePtr = resource.get();
599 afterTime = skgpu::StdSteadyClock::now();
621 std::unique_ptr<Recorder> recorder = context->makeRecorder();
623 ResourceCache* resourceCache = resourceProvider->resourceCache();
624 const SharedContext* sharedContext = resourceProvider->sharedContext();
627 resourceCache->setMaxBudget(10);
630 auto resourcePtr = add_new_purgeable_resource(
reporter,
642 auto resource1 = add_new_resource(
reporter,
648 auto resource2 = add_new_resource(
reporter,
654 auto resource3 = add_new_resource(
reporter,
660 auto resource1Ptr = resource1.get();
661 auto resource2Ptr = resource2.get();
662 auto resource3Ptr = resource3.get();
667 auto timeBeforeReturningToCache = skgpu::StdSteadyClock::now();
675 resourceCache->forceProcessReturnedResources();
699 std::unique_ptr<Recorder> recorder = context->makeRecorder();
701 ResourceCache* resourceCache = resourceProvider->resourceCache();
702 const SharedContext* sharedContext = resourceProvider->sharedContext();
705 resourceCache->setMaxBudget(10);
708 auto resourcePtr = add_new_purgeable_resource(
reporter,
732 if (!resourcePtr1 || !resourcePtr2) {
744 auto resource = add_new_resource(
reporter,
751 resourcePtr = resource.get();
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
#define DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, ctsEnforcement)
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, test_ctx, cond, ctsEnforcement)
#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
void freeGpuData() override
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_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)
static sk_sp< SkData > create_image_data(const SkImageInfo &info)
static skgpu::graphite::TextureProxy * top_device_graphite_target_proxy(SkCanvas *canvas)
TextureProxyView AsView(const SkImage *image)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)