diff options
author | Jim Van Verth <jvanverth@google.com> | 2018-05-16 14:54:41 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-16 19:28:32 +0000 |
commit | cbeae03caee3b6c26c22f5f24c817521c78f8e43 (patch) | |
tree | bc24b50ca9e52de8fc783e087656027af1db53ce /src/gpu/ops | |
parent | af0f79c286ac955a94b2a0834099f3abd61584b5 (diff) |
Fix check for valid proxies returned by AtlasManager.
Also renames a lot of variables to make it clearer that getProxies()
returns the number of instantiated proxies, not the number of all
proxies.
Bug: skia:
Change-Id: Ifbc910cbd6635dccdb4e7f0df2e69a0f341130af
Reviewed-on: https://skia-review.googlesource.com/128660
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/ops')
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.cpp | 36 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.h | 3 |
2 files changed, 20 insertions, 19 deletions
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index 96c592d5b4..99af581120 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -228,25 +228,26 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { GrMaskFormat maskFormat = this->maskFormat(); - unsigned int atlasPageCount; - const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &atlasPageCount); - if (!proxies[0]) { + unsigned int numActiveProxies; + const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &numActiveProxies); + if (!proxies) { SkDebugf("Could not allocate backing texture for atlas\n"); return; } + SkASSERT(proxies[0]); FlushInfo flushInfo; flushInfo.fPipeline = target->makePipeline(fSRGBFlags, std::move(fProcessors), target->detachAppliedClip()); SkDEBUGCODE(bool dfPerspective = false); if (this->usesDistanceFields()) { - flushInfo.fGeometryProcessor = this->setupDfProcessor(atlasManager); + flushInfo.fGeometryProcessor = this->setupDfProcessor(proxies, numActiveProxies); SkDEBUGCODE(dfPerspective = fGeoData[0].fViewMatrix.hasPerspective()); } else { GrSamplerState samplerState = fHasScaledGlyphs ? GrSamplerState::ClampBilerp() : GrSamplerState::ClampNearest(); flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make( - this->color(), proxies, atlasPageCount, samplerState, maskFormat, + this->color(), proxies, numActiveProxies, samplerState, maskFormat, localMatrix, this->usesLocalCoords()); } @@ -330,23 +331,24 @@ void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) co GrGeometryProcessor* gp = flushInfo->fGeometryProcessor.get(); GrMaskFormat maskFormat = this->maskFormat(); - unsigned int numProxies; - const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &numProxies); - if (gp->numTextureSamplers() != (int) numProxies) { + unsigned int numActiveProxies; + const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &numActiveProxies); + SkASSERT(proxies); + if (gp->numTextureSamplers() != (int) numActiveProxies) { // During preparation the number of atlas pages has increased. // Update the proxies used in the GP to match. if (this->usesDistanceFields()) { if (this->isLCD()) { reinterpret_cast<GrDistanceFieldLCDTextGeoProc*>(gp)->addNewProxies( - proxies, numProxies, GrSamplerState::ClampBilerp()); + proxies, numActiveProxies, GrSamplerState::ClampBilerp()); } else { reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewProxies( - proxies, numProxies, GrSamplerState::ClampBilerp()); + proxies, numActiveProxies, GrSamplerState::ClampBilerp()); } } else { GrSamplerState samplerState = fHasScaledGlyphs ? GrSamplerState::ClampBilerp() : GrSamplerState::ClampNearest(); - reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewProxies(proxies, numProxies, + reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewProxies(proxies, numActiveProxies, samplerState); } } @@ -441,10 +443,8 @@ bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { // TODO trying to figure out why lcd is so whack // (see comments in GrAtlasTextContext::ComputeCanonicalColor) -sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(GrAtlasManager* atlasManager) const { - unsigned int numProxies; - const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(this->maskFormat(), - &numProxies); +sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const sk_sp<GrTextureProxy>* proxies, + unsigned int numActiveProxies) const { bool isLCD = this->isLCD(); SkMatrix localMatrix = SkMatrix::I(); @@ -468,7 +468,7 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(GrAtlasManager* atlas GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make( redCorrection, greenCorrection, blueCorrection); - return GrDistanceFieldLCDTextGeoProc::Make(proxies, numProxies, + return GrDistanceFieldLCDTextGeoProc::Make(proxies, numActiveProxies, GrSamplerState::ClampBilerp(), widthAdjust, fDFGPFlags, localMatrix); } else { @@ -480,11 +480,11 @@ sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(GrAtlasManager* atlas correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable); } - return GrDistanceFieldA8TextGeoProc::Make(proxies, numProxies, + return GrDistanceFieldA8TextGeoProc::Make(proxies, numActiveProxies, GrSamplerState::ClampBilerp(), correction, fDFGPFlags, localMatrix); #else - return GrDistanceFieldA8TextGeoProc::Make(proxies, numProxies, + return GrDistanceFieldA8TextGeoProc::Make(proxies, numActiveProxies, GrSamplerState::ClampBilerp(), fDFGPFlags, localMatrix); #endif diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 2f0fcaec70..67474be827 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -175,7 +175,8 @@ private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override; - sk_sp<GrGeometryProcessor> setupDfProcessor(GrAtlasManager*) const; + sk_sp<GrGeometryProcessor> setupDfProcessor(const sk_sp<GrTextureProxy>* proxies, + unsigned int numActiveProxies) const; SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData; int fGeoDataAllocSize; |