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);
129 fTest->fHasOpTexture =
true;
133 static constexpr SkISize kDimensions = {1234, 567};
154 const char*
name()
const override {
return "LazyProxyTest::Op"; }
179 , fProxyProvider(proxyProvider)
191 fTest->fHasClipTexture =
true;
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);
207 std::unique_ptr<ProgramImpl> onMakeProgramImpl()
const override {
228 SkIRect getConservativeBounds() const final {
238 out->addCoverageFP(std::make_unique<ClipFP>(rContext, proxyProvider, fTest, fAtlas));
249 bool fHasClipTexture;
255 GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
259 for (
bool nullTexture : {
false,
true}) {
279 sdc->addDrawOp(&
clip,
281 ctx->
priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&
test);
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;
361 if (releaseCallback) {
384 int* testExecuteValue,
385 bool shouldFailInstantiation) {
386 return GrOp::Make<LazyFailedInstantiationTestOp>(rContext,
390 shouldFailInstantiation);
401 int* testExecuteValue,
bool shouldFailInstantiation)
403 , fTestExecuteValue(testExecuteValue) {
409 [testExecuteValue, shouldFailInstantiation](
412 if (shouldFailInstantiation) {
413 *testExecuteValue = 1;
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));
491 if (failInstantiation) {
const TextureProxy * fProxy
#define DEFINE_OP_CLASS_ID
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
@ kBottomLeft_GrSurfaceOrigin
DEF_GANESH_TEST(LazyProxyTest, reporter,, CtsEnforcement::kApiLevel_T)
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 REPORTER_ASSERT(r, cond,...)
static constexpr auto kColorType
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
GrResourceProvider * resourceProvider()
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
GrDirectContextPriv priv()
GrDrawOp(uint32_t classID)
void registerChild(std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
@ kNone_OptimizationFlags
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
std::unique_ptr< GrOp > Owner
virtual void onPrepare(GrOpFlushState *)=0
virtual const char * name() const =0
virtual void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
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
void addOnFlushCallbackObject(GrOnFlushCallbackObject *)
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)
bool doLazyInstantiation(GrResourceProvider *)
GrSurfaceProxyPriv priv()
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 visitProxies(const GrVisitProxyFunc &func) const override
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *rContext, GrProxyProvider *proxyProvider, int *testExecuteValue, bool shouldFailInstantiation)
ClipFP(GrRecordingContext *ctx, GrProxyProvider *proxyProvider, LazyProxyTest *test, GrTextureProxy *atlas)
Clip(LazyProxyTest *test, GrTextureProxy *atlas)
void onExecute(GrOpFlushState *, const SkRect &chainBounds) override
void visitProxies(const GrVisitProxyFunc &func) const override
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrProxyProvider *proxyProvider, LazyProxyTest *test, bool nullTexture)
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
sk_sp< const SkImage > atlas
Optional< SkRect > bounds
ConfigOptions fConfigOptions[kGrColorTypeCnt]
static constexpr SkIRect MakeSize(const SkISize &size)
static SkRGBA4f FromBytes_RGBA(uint32_t color)
static SkRect Make(const SkISize &size)