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();
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,
281 mbet->texture().getBackendFormat(),
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());
343 PromiseTextureChecker::Fulfill,
344 PromiseTextureChecker::Release,
350 static constexpr int kMaxBytes = 1;
351 dContext->setResourceCacheLimit(kMaxBytes);
353 for (
int i = 0;
i < 5; ++
i) {
356 textures.
emplace_back(dContext->priv().resourceProvider()->createTexture(
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;
446 paint.setShader(std::move(shader));
448 paint.setShader(
nullptr);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kTopLeft_GrSurfaceOrigin
skgpu::Protected Protected
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)
DEF_GANESH_TEST(PromiseImageTextureShutdown, reporter, ctxInfo, CtsEnforcement::kNever)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo, CtsEnforcement::kNever)
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
#define REPORTER_ASSERT(r, cond,...)
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()
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
GrDirectContext * get(ContextType type, ContextOverrides overrides=ContextOverrides::kNone)
void reset(T *ptr=nullptr)
T & emplace_back(Args &&... args)
uint32_t uint32_t * format
Dart_NativeFunction function
constexpr SkColor4f kTransparent
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, std::string_view label={})
void * PromiseImageTextureContext
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
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)
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 counts
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
static const int kContextTypeCount
SkSamplingOptions(SkFilterMode::kLinear))
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)