diff --git a/include/private/GrRecordingContext.h b/include/private/GrRecordingContext.h index 284002c7f6..056d169246 100644 --- a/include/private/GrRecordingContext.h +++ b/include/private/GrRecordingContext.h @@ -37,6 +37,12 @@ public: GrRecordingContextPriv priv(); const GrRecordingContextPriv priv() const; +#if GR_TEST_UTILS + // Used by tests that induce intentional allocation failures, in order to keep the output clean. + void testingOnly_setSuppressAllocationWarnings() { fSuppressAllocationWarnings = true; } + bool testingOnly_getSuppressAllocationWarnings() const { return fSuppressAllocationWarnings; } +#endif + protected: friend class GrRecordingContextPriv; // for hidden functions @@ -150,6 +156,10 @@ private: std::unique_ptr fAuditTrail; +#ifdef GR_TEST_UTILS + bool fSuppressAllocationWarnings = false; +#endif + typedef GrImageContext INHERITED; }; diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp index d380eae89b..b760e027fd 100644 --- a/src/gpu/GrLegacyDirectContext.cpp +++ b/src/gpu/GrLegacyDirectContext.cpp @@ -171,6 +171,13 @@ sk_sp GrContext::MakeMock(const GrMockOptions* mockOptions, if (!context->init(context->fGpu->refCaps(), nullptr)) { return nullptr; } + +#if GR_TEST_UTILS + if (mockOptions && mockOptions->fFailTextureAllocations) { + context->testingOnly_setSuppressAllocationWarnings(); + } +#endif + return context; } diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp index 8cb748f236..fed9d6ad35 100644 --- a/src/gpu/GrOnFlushResourceProvider.cpp +++ b/src/gpu/GrOnFlushResourceProvider.cpp @@ -133,3 +133,9 @@ uint32_t GrOnFlushResourceProvider::contextID() const { const GrCaps* GrOnFlushResourceProvider::caps() const { return fDrawingMgr->getContext()->priv().caps(); } + +#if GR_TEST_UTILS +bool GrOnFlushResourceProvider::testingOnly_getSuppressAllocationWarnings() const { + return fDrawingMgr->getContext()->testingOnly_getSuppressAllocationWarnings(); +} +#endif diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h index 78a31f3038..ab701499c8 100644 --- a/src/gpu/GrOnFlushResourceProvider.h +++ b/src/gpu/GrOnFlushResourceProvider.h @@ -92,6 +92,10 @@ public: uint32_t contextID() const; const GrCaps* caps() const; +#if GR_TEST_UTILS + bool testingOnly_getSuppressAllocationWarnings() const; +#endif + private: GrOnFlushResourceProvider(const GrOnFlushResourceProvider&) = delete; GrOnFlushResourceProvider& operator=(const GrOnFlushResourceProvider&) = delete; diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp index d92f6a6b4c..ea7e6b921a 100644 --- a/src/gpu/ccpr/GrCCAtlas.cpp +++ b/src/gpu/ccpr/GrCCAtlas.cpp @@ -243,8 +243,13 @@ std::unique_ptr GrCCAtlas::makeRenderTargetContext( ? GrColorType::kAlpha_F16 : GrColorType::kAlpha_8; auto rtc = onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr); if (!rtc) { - SkDebugf("WARNING: failed to allocate a %ix%i atlas. Some paths will not be drawn.\n", - fWidth, fHeight); +#if GR_TEST_UTILS + if (!onFlushRP->testingOnly_getSuppressAllocationWarnings()) +#endif + { + SkDebugf("WARNING: failed to allocate a %ix%i atlas. Some paths will not be drawn.\n", + fWidth, fHeight); + } return nullptr; }