51#include <initializer_list>
59namespace skgpu {
class KeyBuilder; }
69 , fHasOpTexture(false)
70 , fHasClipTexture(false) {
79#if defined(GR_TEST_UTILS)
80 if (onFlushRP->failFlushTimeCallbacks()) {
103 return GrOp::Make<Op>(context, context, proxyProvider,
test, nullTexture);
107 func(fProxy.
get(), skgpu::Mipmapped::kNo);
129 fTest->fHasOpTexture =
true;
133 static constexpr SkISize kDimensions = {1234, 567};
147 format, GrRenderable::kNo, 1, GrProtected::kNo, *proxyProvider->
caps(),
154 const char*
name()
const override {
return "LazyProxyTest::Op"; }
179 , fProxyProvider(proxyProvider)
191 fTest->fHasClipTexture =
true;
195 format, GrRenderable::kYes, 1, GrProtected::kNo, *proxyProvider->
caps(),
203 const char*
name()
const override {
return "LazyProxyTest::ClipFP"; }
204 std::unique_ptr<GrFragmentProcessor>
clone()
const override {
205 return std::make_unique<ClipFP>(fContext, fProxyProvider, fTest, fAtlas);
236 SkRect* bounds)
const override {
238 out->addCoverageFP(std::make_unique<ClipFP>(rContext, proxyProvider, fTest, fAtlas));
249 bool fHasClipTexture;
259 for (
bool nullTexture : {
false,
true}) {
261 ctx->priv().addOnFlushCallbackObject(&
test);
279 sdc->addDrawOp(&
clip,
280 LazyProxyTest::Op::Make(ctx.
get(), proxyProvider, &
test, nullTexture));
281 ctx->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&
test);
290 auto proxyProvider = ctx->priv().proxyProvider();
291 const GrCaps* caps = ctx->priv().caps();
296 auto tex = ctx->priv().resourceProvider()->createTexture({
kSize,
kSize},
301 skgpu::Mipmapped::kNo,
306 for (
bool doInstantiate : {
true,
false}) {
307 for (
bool releaseCallback : {
false,
true}) {
314 , fReleaseCallback(releaseCallback)
315 , fTexture(std::move(tex)) {}
316 TestCallback(
const TestCallback& that) {
SkASSERT(0); }
317 TestCallback(TestCallback&& that)
318 : fValue(that.fValue)
319 , fReleaseCallback(that.fReleaseCallback)
320 , fTexture(std::move(that.fTexture)) {
321 that.fValue =
nullptr;
324 ~TestCallback() { fValue ? (void)(*fValue = -1) : void(); }
326 TestCallback& operator=(TestCallback&& that) {
327 fValue = std::exchange(that.fValue,
nullptr);
330 TestCallback& operator=(
const TestCallback& that) =
delete;
335 return {fTexture, fReleaseCallback};
339 int* fValue =
nullptr;
340 bool fReleaseCallback;
347 skgpu::Mipmapped::kNo,
360 proxy->priv().doLazyInstantiation(ctx->priv().resourceProvider());
361 if (releaseCallback) {
384 int* testExecuteValue,
385 bool shouldFailInstantiation) {
386 return GrOp::Make<LazyFailedInstantiationTestOp>(rContext,
390 shouldFailInstantiation);
394 func(fLazyProxy.
get(), skgpu::Mipmapped::kNo);
401 int* testExecuteValue,
bool shouldFailInstantiation)
403 , fTestExecuteValue(testExecuteValue) {
409 [testExecuteValue, shouldFailInstantiation](
412 if (shouldFailInstantiation) {
413 *testExecuteValue = 1;
429 skgpu::Mipmapped::kNo,
443 const char*
name()
const override {
return "LazyFailedInstantiationTestOp"; }
456 *fTestExecuteValue = 2;
459 int* fTestExecuteValue;
474 for (
bool failInstantiation : {
false,
true}) {
486 int executeTestValue = 0;
488 &executeTestValue, failInstantiation));
489 ctx->flushAndSubmit();
491 if (failInstantiation) {
const TextureProxy * fProxy
#define DEFINE_OP_CLASS_ID
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
@ kBottomLeft_GrSurfaceOrigin
static const size_t testCount
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define INHERITED(method,...)
sk_sp< T > sk_ref_sp(T *obj)
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
#define REPORTER_ASSERT(r, cond,...)
static constexpr auto kColorType
Type::kYUV Type::kRGBA() int(0.7 *637)
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
void registerChild(std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
@ kNone_OptimizationFlags
std::unique_ptr< GrOp > Owner
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
static constexpr Analysis EmptySetAnalysis()
sk_sp< GrTextureProxy > createLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, skgpu::Mipmapped, GrMipmapStatus, GrInternalSurfaceFlags, SkBackingFit, skgpu::Budgeted, GrProtected, UseAllocator, std::string_view label)
static sk_sp< GrTextureProxy > MakeFullyLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, GrRenderable, int renderTargetSampleCnt, GrProtected, const GrCaps &, UseAllocator)
const GrCaps * caps() const
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped mipmapped, skgpu::Budgeted budgeted, skgpu::Protected isProtected, std::string_view label)
GrTexture * peekTexture() const
SkISize dimensions() const
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
bool instantiate(GrResourceProvider *) override
void onPrepare(GrOpFlushState *) override
FixedFunctionFlags fixedFunctionFlags() const override
void visitProxies(const GrVisitProxyFunc &func) const override
GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *, GrClampType) override
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *rContext, GrProxyProvider *proxyProvider, int *testExecuteValue, bool shouldFailInstantiation)
const char * name() const override
void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp) override
void onExecute(GrOpFlushState *state, const SkRect &chainBounds) override
std::unique_ptr< ProgramImpl > onMakeProgramImpl() const override
const char * name() const override
std::unique_ptr< GrFragmentProcessor > clone() const override
ClipFP(GrRecordingContext *ctx, GrProxyProvider *proxyProvider, LazyProxyTest *test, GrTextureProxy *atlas)
bool onIsEqual(const GrFragmentProcessor &) const override
void onAddToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const override
SkIRect getConservativeBounds() const final
Clip(LazyProxyTest *test, GrTextureProxy *atlas)
Effect apply(GrRecordingContext *rContext, skgpu::ganesh::SurfaceDrawContext *, GrDrawOp *, GrAAType, GrAppliedClip *out, SkRect *bounds) const override
void onPrepare(GrOpFlushState *) override
GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *clip, GrClampType) override
void onExecute(GrOpFlushState *, const SkRect &chainBounds) override
const char * name() const override
void visitProxies(const GrVisitProxyFunc &func) const override
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrProxyProvider *proxyProvider, LazyProxyTest *test, bool nullTexture)
FixedFunctionFlags fixedFunctionFlags() const override
void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp) override
bool preFlush(GrOnFlushResourceProvider *onFlushRP) override
void postFlush(skgpu::AtlasToken) override
LazyProxyTest(skiatest::Reporter *reporter)
~LazyProxyTest() override
static SkRect MakeLargest()
void reset(T *ptr=nullptr)
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
uint32_t uint32_t * format
ConfigOptions fConfigOptions[kGrColorTypeCnt]
static constexpr SkIRect MakeSize(const SkISize &size)
static SkRGBA4f FromBytes_RGBA(uint32_t color)
static SkRect Make(const SkISize &size)