69 return checker->fTexture;
84 int expectedFulfillCnt,
87 if (!expectedFulfillCnt) {
93 switch (releaseBalanceExpecation) {
102 releaseDiff >= 0 && releaseDiff <= promiseChecker.
fFulfillCount);
121 int expectedFulfillCnt = 1) {
129 int expectedFulfillCnt = 1) {
133 releaseBalanceExpectation = expectedFulfillCnt == 1
138 releaseBalanceExpectation);
143 int expectedFulfillCnt = 1) {
152 using namespace skgpu;
156 auto ctx = ctxInfo.directContext();
164 skgpu::Mipmapped::kNo,
177 skgpu::Mipmapped::kNo,
182 PromiseTextureChecker::Fulfill,
183 PromiseTextureChecker::Release,
225 ctx->deleteBackendTexture(backendTex);
238 dContext->abandonContext();
242 dContext->releaseResourcesAndAbandonContext();
255 DeathFn contextKillers[] = {
destroy, abandon, releaseResourcesAndAbandon};
256 for (
const DeathFn& contextDeath : contextKillers) {
258 auto ctx = factory.
get(contextType);
263 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(ctx,
267 skgpu::Mipmapped::kNo,
281 mbet->texture().getBackendFormat(),
283 skgpu::Mipmapped::kNo,
288 PromiseTextureChecker::Fulfill,
289 PromiseTextureChecker::Release,
299 ctx->flushAndSubmit();
300 contextDeath(&factory, ctx);
311 using namespace skgpu;
316 auto dContext = ctxInfo.directContext();
318 Protected isProtected =
Protected(dContext->priv().caps()->supportsProtectedContent());
324 skgpu::Mipmapped::kNo,
338 skgpu::Mipmapped::kNo,
343 PromiseTextureChecker::Fulfill,
344 PromiseTextureChecker::Release,
350 static constexpr int kMaxBytes = 1;
351 dContext->setResourceCacheLimit(kMaxBytes);
353 for (
int i = 0; i < 5; ++i) {
362 skgpu::Mipmapped::kNo,
365 "PromiseImageTextureFullCacheTest"));
371 dContext->getResourceCacheUsage(
nullptr, &bytesUsed);
392 dContext->deleteBackendTexture(backendTex);
403 auto dContext = ctxInfo.directContext();
407 if (!backendFormat.
isValid()) {
413 int fFulfillCount = 0;
414 int fReleaseCount = 0;
417 ++
static_cast<Counts*
>(ctx)->fFulfillCount;
421 ++
static_cast<Counts*
>(ctx)->fReleaseCount;
427 skgpu::Mipmapped::kNo,
446 paint.setShader(std::move(shader));
448 paint.setShader(
nullptr);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kTopLeft_GrSurfaceOrigin
ReleaseBalanceExpectation
static void check_fulfill_and_release_cnts(skiatest::Reporter *reporter, const PromiseTextureChecker &promiseChecker, int expectedFulfillCnt, ReleaseBalanceExpectation releaseBalanceExpecation)
static void check_unfulfilled(const PromiseTextureChecker &promiseChecker, skiatest::Reporter *reporter)
static void check_only_fulfilled(skiatest::Reporter *reporter, const PromiseTextureChecker &promiseChecker, int expectedFulfillCnt=1)
static void check_all_done(skiatest::Reporter *reporter, const PromiseTextureChecker &promiseChecker, int expectedFulfillCnt=1)
static void check_all_flushed_but_not_synced(skiatest::Reporter *reporter, const PromiseTextureChecker &promiseChecker, GrBackendApi api, int expectedFulfillCnt=1)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
GrBackendFormat getBackendFormat() const
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkColorFilter > LinearToSRGBGamma()
GrDirectContext * get(ContextType type, ContextOverrides overrides=ContextOverrides::kNone)
void reset(T *ptr=nullptr)
T & emplace_back(Args &&... args)
std::vector< std::shared_ptr< FakeTexture > > textures
uint32_t uint32_t * format
constexpr SkColor4f kTransparent
void * PromiseImageTextureContext
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext)
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)
skgpu::Protected Protected
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
static const int kContextTypeCount
static sk_sp< GrPromiseImageTexture > Fulfill(void *self)
static void Release(void *self)
sk_sp< GrPromiseImageTexture > fTexture
PromiseTextureChecker(const GrBackendTexture &tex, skiatest::Reporter *reporter, bool shared)
skiatest::Reporter * fReporter
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeWH(float w, float h)