diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/atlastext/SkInternalAtlasTextContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.cpp | 18 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.h | 8 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasGlyphCache.h | 13 |
4 files changed, 27 insertions, 22 deletions
diff --git a/src/atlastext/SkInternalAtlasTextContext.cpp b/src/atlastext/SkInternalAtlasTextContext.cpp index a2855314e6..fcb4130665 100644 --- a/src/atlastext/SkInternalAtlasTextContext.cpp +++ b/src/atlastext/SkInternalAtlasTextContext.cpp @@ -39,7 +39,9 @@ SkInternalAtlasTextContext::~SkInternalAtlasTextContext() { if (fDistanceFieldAtlas.fProxy) { #ifdef SK_DEBUG auto atlasGlyphCache = fGrContext->contextPriv().getAtlasGlyphCache(); - SkASSERT(1 == atlasGlyphCache->getAtlasPageCount(kA8_GrMaskFormat)); + unsigned int numProxies; + atlasGlyphCache->getProxies(kA8_GrMaskFormat, &numProxies); + SkASSERT(1 == numProxies); #endif fRenderer->deleteTexture(fDistanceFieldAtlas.fTextureHandle); } @@ -86,8 +88,10 @@ void SkInternalAtlasTextContext::recordDraw(const void* srcVertexData, int glyph void SkInternalAtlasTextContext::flush() { auto* atlasGlyphCache = fGrContext->contextPriv().getAtlasGlyphCache(); if (!fDistanceFieldAtlas.fProxy) { - SkASSERT(1 == atlasGlyphCache->getAtlasPageCount(kA8_GrMaskFormat)); - fDistanceFieldAtlas.fProxy = atlasGlyphCache->getProxies(kA8_GrMaskFormat)->get(); + unsigned int numProxies; + fDistanceFieldAtlas.fProxy = atlasGlyphCache->getProxies(kA8_GrMaskFormat, + &numProxies)->get(); + SkASSERT(1 == numProxies); fDistanceFieldAtlas.fTextureHandle = fRenderer->createTexture(SkAtlasTextRenderer::AtlasFormat::kA8, fDistanceFieldAtlas.fProxy->width(), diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index b5f4d45152..8a4c50c0d6 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -218,8 +218,8 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { GrMaskFormat maskFormat = this->maskFormat(); - uint32_t atlasPageCount = fFontCache->getAtlasPageCount(maskFormat); - const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(maskFormat); + unsigned int atlasPageCount; + const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(maskFormat, &atlasPageCount); if (!atlasPageCount || !proxies[0]) { SkDebugf("Could not allocate backing texture for atlas\n"); return; @@ -305,20 +305,23 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { GrGeometryProcessor* gp = flushInfo->fGeometryProcessor.get(); GrMaskFormat maskFormat = this->maskFormat(); - if (gp->numTextureSamplers() != (int)fFontCache->getAtlasPageCount(maskFormat)) { + + unsigned int numProxies; + const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(maskFormat, &numProxies); + if (gp->numTextureSamplers() != (int) numProxies) { // 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( - fFontCache->getProxies(maskFormat), GrSamplerState::ClampBilerp()); + proxies, GrSamplerState::ClampBilerp()); } else { reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewProxies( - fFontCache->getProxies(maskFormat), GrSamplerState::ClampBilerp()); + proxies, GrSamplerState::ClampBilerp()); } } else { reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewProxies( - fFontCache->getProxies(maskFormat), GrSamplerState::ClampNearest()); + proxies, GrSamplerState::ClampNearest()); } } @@ -409,7 +412,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() const { - const sk_sp<GrTextureProxy>* p = fFontCache->getProxies(this->maskFormat()); + unsigned int numProxies; + const sk_sp<GrTextureProxy>* p = fFontCache->getProxies(this->maskFormat(), &numProxies); bool isLCD = this->isLCD(); SkMatrix localMatrix = SkMatrix::I(); diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 841e2a696c..de6f176d15 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -95,8 +95,10 @@ public: void visitProxies(const VisitProxyFunc& func) const override { fProcessors.visitProxies(func); - const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(this->maskFormat()); - for (int i = 0; i < kMaxTextures; ++i) { + unsigned int numProxies; + const sk_sp<GrTextureProxy>* proxies = fFontCache->getProxies(this->maskFormat(), + &numProxies); + for (unsigned int i = 0; i < numProxies; ++i) { if (proxies[i]) { func(proxies[i].get()); } @@ -183,8 +185,6 @@ private: bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override; - static constexpr auto kMaxTextures = 4; - sk_sp<GrGeometryProcessor> setupDfProcessor() const; SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData; diff --git a/src/gpu/text/GrAtlasGlyphCache.h b/src/gpu/text/GrAtlasGlyphCache.h index 6c5ce767db..aa337c43f5 100644 --- a/src/gpu/text/GrAtlasGlyphCache.h +++ b/src/gpu/text/GrAtlasGlyphCache.h @@ -130,20 +130,17 @@ public: // if getProxies returns nullptr, the client must not try to use other functions on the // GrAtlasGlyphCache which use the atlas. This function *must* be called first, before other // functions which use the atlas. - const sk_sp<GrTextureProxy>* getProxies(GrMaskFormat format) { + const sk_sp<GrTextureProxy>* getProxies(GrMaskFormat format, unsigned int* numProxies) { + SkASSERT(numProxies); + if (this->initAtlas(format)) { + *numProxies = this->getAtlas(format)->pageCount(); return this->getAtlas(format)->getProxies(); } + *numProxies = 0; return nullptr; } - uint32_t getAtlasPageCount(GrMaskFormat format) { - if (this->initAtlas(format)) { - return this->getAtlas(format)->pageCount(); - } - return 0; - } - SkScalar getGlyphSizeLimit() const { return fGlyphSizeLimit; } bool hasGlyph(GrGlyph* glyph) { |