Suppress allocation warnings for tests that induce them intentionally

Change-Id: I918b4b28753f71a15963d2c762f93c1ae1de7836
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259173
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Chris Dalton 2019-12-11 13:24:11 -05:00 committed by Skia Commit-Bot
parent d111f043ba
commit a378b45616
5 changed files with 34 additions and 2 deletions

View File

@ -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<GrAuditTrail> fAuditTrail;
#ifdef GR_TEST_UTILS
bool fSuppressAllocationWarnings = false;
#endif
typedef GrImageContext INHERITED;
};

View File

@ -171,6 +171,13 @@ sk_sp<GrContext> 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;
}

View File

@ -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

View File

@ -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;

View File

@ -243,8 +243,13 @@ std::unique_ptr<GrRenderTargetContext> 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;
}