aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/text')
-rw-r--r--src/gpu/text/GrAtlasGlyphCache.cpp27
-rw-r--r--src/gpu/text/GrAtlasGlyphCache.h24
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h7
-rw-r--r--src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp10
4 files changed, 30 insertions, 38 deletions
diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp
index f7b1e1269a..fb52250781 100644
--- a/src/gpu/text/GrAtlasGlyphCache.cpp
+++ b/src/gpu/text/GrAtlasGlyphCache.cpp
@@ -9,7 +9,6 @@
#include "GrContext.h"
#include "GrDistanceFieldGenFromVector.h"
#include "GrGpu.h"
-#include "GrProxyProvider.h"
#include "GrRectanizer.h"
#include "SkAutoMalloc.h"
@@ -20,14 +19,14 @@
bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) {
int index = MaskFormatToAtlasIndex(format);
if (!fAtlases[index]) {
- GrPixelConfig config = MaskFormatToPixelConfig(format, *fProxyProvider->caps());
+ GrPixelConfig config = MaskFormatToPixelConfig(format, *fContext->caps());
int width = fAtlasConfigs[index].fWidth;
int height = fAtlasConfigs[index].fHeight;
int numPlotsX = fAtlasConfigs[index].numPlotsX();
int numPlotsY = fAtlasConfigs[index].numPlotsY();
- fAtlases[index] = GrDrawOpAtlas::Make(fProxyProvider, config, width, height,
- numPlotsX, numPlotsY, fAllowMultitexturing,
+ fAtlases[index] = GrDrawOpAtlas::Make(fContext, config, width, height, numPlotsX, numPlotsY,
+ fAllowMultitexturing,
&GrAtlasGlyphCache::HandleEviction, (void*)this);
if (!fAtlases[index]) {
return false;
@@ -36,13 +35,11 @@ bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) {
return true;
}
-GrAtlasGlyphCache::GrAtlasGlyphCache(GrProxyProvider* proxyProvider, float maxTextureBytes,
+GrAtlasGlyphCache::GrAtlasGlyphCache(GrContext* context, float maxTextureBytes,
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing)
- : fProxyProvider(proxyProvider)
- , fAllowMultitexturing(allowMultitexturing)
- , fPreserveStrike(nullptr) {
+ : fContext(context), fAllowMultitexturing(allowMultitexturing), fPreserveStrike(nullptr) {
// Calculate RGBA size. Must be between 512 x 256 and MaxTextureSize x MaxTextureSize / 2
- int log2MaxTextureSize = SkPrevLog2(fProxyProvider->caps()->maxTextureSize());
+ int log2MaxTextureSize = SkPrevLog2(context->caps()->maxTextureSize());
int log2MaxDim = 9;
for (; log2MaxDim <= log2MaxTextureSize; ++log2MaxDim) {
int maxDim = 1 << log2MaxDim;
@@ -177,12 +174,12 @@ static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, const char*
return true;
}
-void GrAtlasGlyphCache::dump(GrContext* context) const {
+void GrAtlasGlyphCache::dump() const {
static int gDumpCount = 0;
for (int i = 0; i < kMaskFormatCount; ++i) {
if (fAtlases[i]) {
const sk_sp<GrTextureProxy>* proxies = fAtlases[i]->getProxies();
- for (uint32_t pageIdx = 0; pageIdx < fAtlases[i]->numActivePages(); ++pageIdx) {
+ for (uint32_t pageIdx = 0; pageIdx < fAtlases[i]->pageCount(); ++pageIdx) {
SkASSERT(proxies[pageIdx]);
SkString filename;
#ifdef SK_BUILD_FOR_ANDROID
@@ -191,7 +188,7 @@ void GrAtlasGlyphCache::dump(GrContext* context) const {
filename.printf("fontcache_%d%d%d.png", gDumpCount, i, pageIdx);
#endif
- save_pixels(context, proxies[pageIdx].get(), filename.c_str());
+ save_pixels(fContext, proxies[pageIdx].get(), filename.c_str());
}
}
}
@@ -448,8 +445,7 @@ void GrAtlasTextStrike::removeID(GrDrawOpAtlas::AtlasID id) {
}
}
-bool GrAtlasTextStrike::addGlyphToAtlas(GrResourceProvider* resourceProvider,
- GrDeferredUploadTarget* target,
+bool GrAtlasTextStrike::addGlyphToAtlas(GrDeferredUploadTarget* target,
GrAtlasGlyphCache* atlasGlyphCache,
GrGlyph* glyph,
SkGlyphCache* cache,
@@ -477,8 +473,7 @@ bool GrAtlasTextStrike::addGlyphToAtlas(GrResourceProvider* resourceProvider,
}
}
- bool success = atlasGlyphCache->addToAtlas(resourceProvider, this, &glyph->fID, target,
- expectedMaskFormat,
+ bool success = atlasGlyphCache->addToAtlas(this, &glyph->fID, target, expectedMaskFormat,
glyph->width(), glyph->height(),
storage.get(), &glyph->fAtlasLocation);
if (success) {
diff --git a/src/gpu/text/GrAtlasGlyphCache.h b/src/gpu/text/GrAtlasGlyphCache.h
index 84b7d1b249..6175342c26 100644
--- a/src/gpu/text/GrAtlasGlyphCache.h
+++ b/src/gpu/text/GrAtlasGlyphCache.h
@@ -64,8 +64,8 @@ public:
// happen.
// TODO we can handle some of these cases if we really want to, but the long term solution is to
// get the actual glyph image itself when we get the glyph metrics.
- bool addGlyphToAtlas(GrResourceProvider*, GrDeferredUploadTarget*, GrAtlasGlyphCache*, GrGlyph*,
- SkGlyphCache*, GrMaskFormat expectedMaskFormat);
+ bool addGlyphToAtlas(GrDeferredUploadTarget*, GrAtlasGlyphCache*, GrGlyph*, SkGlyphCache*,
+ GrMaskFormat expectedMaskFormat);
// testing
int countGlyphs() const { return fCache.count(); }
@@ -109,8 +109,7 @@ private:
*/
class GrAtlasGlyphCache : public GrOnFlushCallbackObject {
public:
- GrAtlasGlyphCache(GrProxyProvider*, float maxTextureBytes,
- GrDrawOpAtlas::AllowMultitexturing);
+ GrAtlasGlyphCache(GrContext*, float maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing);
~GrAtlasGlyphCache() override;
// The user of the cache may hold a long-lived ref to the returned strike. However, actions by
// another client of the cache may cause the strike to be purged while it is still reffed.
@@ -133,7 +132,7 @@ public:
SkASSERT(numProxies);
if (this->initAtlas(format)) {
- *numProxies = this->getAtlas(format)->numActivePages();
+ *numProxies = this->getAtlas(format)->pageCount();
return this->getAtlas(format)->getProxies();
}
*numProxies = 0;
@@ -166,13 +165,11 @@ public:
}
// add to texture atlas that matches this format
- bool addToAtlas(GrResourceProvider* resourceProvider, GrAtlasTextStrike* strike,
- GrDrawOpAtlas::AtlasID* id,
+ bool addToAtlas(GrAtlasTextStrike* strike, GrDrawOpAtlas::AtlasID* id,
GrDeferredUploadTarget* target, GrMaskFormat format, int width, int height,
const void* image, SkIPoint16* loc) {
fPreserveStrike = strike;
- return this->getAtlas(format)->addToAtlas(resourceProvider, id, target,
- width, height, image, loc);
+ return this->getAtlas(format)->addToAtlas(id, target, width, height, image, loc);
}
// Some clients may wish to verify the integrity of the texture backing store of the
@@ -193,7 +190,8 @@ public:
}
}
- void postFlush(GrDeferredUploadToken startTokenForNextFlush, const uint32_t*, int) override {
+ void postFlush(GrDeferredUploadToken startTokenForNextFlush,
+ const uint32_t* opListIDs, int numOpListIDs) override {
for (int i = 0; i < kMaskFormatCount; ++i) {
if (fAtlases[i]) {
fAtlases[i]->compact(startTokenForNextFlush);
@@ -208,11 +206,13 @@ public:
///////////////////////////////////////////////////////////////////////////
// Functions intended debug only
#ifdef SK_DEBUG
- void dump(GrContext*) const;
+ void dump() const;
#endif
void setAtlasSizes_ForTesting(const GrDrawOpAtlasConfig configs[3]);
+ GrContext* context() const { return fContext; }
+
private:
static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format, const GrCaps& caps) {
switch (format) {
@@ -258,7 +258,7 @@ private:
static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
using StrikeHash = SkTDynamicHash<GrAtlasTextStrike, SkDescriptor>;
- GrProxyProvider* fProxyProvider;
+ GrContext* fContext;
StrikeHash fCache;
GrDrawOpAtlas::AllowMultitexturing fAllowMultitexturing;
std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount];
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 0fae3cd8c7..6e1d0b1bde 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -560,9 +560,9 @@ public:
* SkAutoGlyphCache is reused then it can save the cost of multiple detach/attach operations of
* SkGlyphCache.
*/
- VertexRegenerator(GrResourceProvider*, GrAtlasTextBlob*, int runIdx, int subRunIdx,
- const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
- GrDeferredUploadTarget*, GrAtlasGlyphCache*, SkAutoGlyphCache*);
+ VertexRegenerator(GrAtlasTextBlob* blob, int runIdx, int subRunIdx, const SkMatrix& viewMatrix,
+ SkScalar x, SkScalar y, GrColor color, GrDeferredUploadTarget*,
+ GrAtlasGlyphCache*, SkAutoGlyphCache*);
struct Result {
/**
@@ -589,7 +589,6 @@ private:
template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
Result doRegen();
- GrResourceProvider* fResourceProvider;
const SkMatrix& fViewMatrix;
GrAtlasTextBlob* fBlob;
GrDeferredUploadTarget* fUploadTarget;
diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
index 500ae31703..1a9c3d73e4 100644
--- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
+++ b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
@@ -190,13 +190,11 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri
}
}
-Regenerator::VertexRegenerator(GrResourceProvider* resourceProvider, GrAtlasTextBlob* blob,
- int runIdx, int subRunIdx,
+Regenerator::VertexRegenerator(GrAtlasTextBlob* blob, int runIdx, int subRunIdx,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
GrDeferredUploadTarget* uploadTarget, GrAtlasGlyphCache* glyphCache,
SkAutoGlyphCache* lazyCache)
- : fResourceProvider(resourceProvider)
- , fViewMatrix(viewMatrix)
+ : fViewMatrix(viewMatrix)
, fBlob(blob)
, fUploadTarget(uploadTarget)
, fGlyphCache(glyphCache)
@@ -276,8 +274,8 @@ Regenerator::Result Regenerator::doRegen() {
SkASSERT(glyph && glyph->fMaskFormat == fSubRun->maskFormat());
if (!fGlyphCache->hasGlyph(glyph) &&
- !strike->addGlyphToAtlas(fResourceProvider, fUploadTarget, fGlyphCache, glyph,
- fLazyCache->get(), fSubRun->maskFormat())) {
+ !strike->addGlyphToAtlas(fUploadTarget, fGlyphCache, glyph, fLazyCache->get(),
+ fSubRun->maskFormat())) {
fBrokenRun = glyphIdx > 0;
result.fFinished = false;
return result;