aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-02-20 15:18:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-20 21:16:53 +0000
commitf3690dd416a1ff63868dd886c0c08b7698c5dd1f (patch)
treef7b2dfbc731e769a4df698c4a9ddd5cbd7d8fba7 /src/gpu
parenta8c55fa4fec87bf6fd601b16c2684168abddbab8 (diff)
Change signature of GrAtlasGlyphCache::getProxies
Split out of https://skia-review.googlesource.com/c/skia/+/108001 (Fission GrAtlasGlyphCache in two) TBR=bsalomon@google.com Change-Id: I573730fdeddf178915eb5f5b8cf59a3ab29e0654 Reviewed-on: https://skia-review.googlesource.com/108441 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/ops/GrAtlasTextOp.cpp18
-rw-r--r--src/gpu/ops/GrAtlasTextOp.h8
-rw-r--r--src/gpu/text/GrAtlasGlyphCache.h13
3 files changed, 20 insertions, 19 deletions
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) {