cleanup textblob cache sanity check and prevent it from bitrotting
TBR=bsalomon@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1684513004 Review URL: https://codereview.chromium.org/1684513004
This commit is contained in:
parent
9972c424ea
commit
2f2ee83a9c
@ -422,104 +422,89 @@ GrDrawBatch* GrAtlasTextBlob::test_createBatch(
|
|||||||
props, distanceAdjustTable, cache);
|
props, distanceAdjustTable, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO get this code building again
|
|
||||||
#ifdef CACHE_SANITY_CHECK
|
|
||||||
void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) {
|
void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) {
|
||||||
SkASSERT(l.fSize == r.fSize);
|
SkASSERT_RELEASE(l.fSize == r.fSize);
|
||||||
SkASSERT(l.fPool == r.fPool);
|
SkASSERT_RELEASE(l.fPool == r.fPool);
|
||||||
|
|
||||||
SkASSERT(l.fBlurRec.fSigma == r.fBlurRec.fSigma);
|
SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma);
|
||||||
SkASSERT(l.fBlurRec.fStyle == r.fBlurRec.fStyle);
|
SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle);
|
||||||
SkASSERT(l.fBlurRec.fQuality == r.fBlurRec.fQuality);
|
SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality);
|
||||||
|
|
||||||
SkASSERT(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth);
|
SkASSERT_RELEASE(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth);
|
||||||
SkASSERT(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit);
|
SkASSERT_RELEASE(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit);
|
||||||
SkASSERT(l.fStrokeInfo.fJoin == r.fStrokeInfo.fJoin);
|
SkASSERT_RELEASE(l.fStrokeInfo.fJoin == r.fStrokeInfo.fJoin);
|
||||||
|
|
||||||
SkASSERT(l.fBigGlyphs.count() == r.fBigGlyphs.count());
|
SkASSERT_RELEASE(l.fBigGlyphs.count() == r.fBigGlyphs.count());
|
||||||
for (int i = 0; i < l.fBigGlyphs.count(); i++) {
|
for (int i = 0; i < l.fBigGlyphs.count(); i++) {
|
||||||
const BigGlyph& lBigGlyph = l.fBigGlyphs[i];
|
const BigGlyph& lBigGlyph = l.fBigGlyphs[i];
|
||||||
const BigGlyph& rBigGlyph = r.fBigGlyphs[i];
|
const BigGlyph& rBigGlyph = r.fBigGlyphs[i];
|
||||||
|
|
||||||
SkASSERT(lBigGlyph.fPath == rBigGlyph.fPath);
|
SkASSERT_RELEASE(lBigGlyph.fPath == rBigGlyph.fPath);
|
||||||
// We can't assert that these have the same translations
|
// We can't assert that these have the same translations
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(l.fKey == r.fKey);
|
SkASSERT_RELEASE(l.fKey == r.fKey);
|
||||||
SkASSERT(l.fViewMatrix.cheapEqualTo(r.fViewMatrix));
|
SkASSERT_RELEASE(l.fViewMatrix.cheapEqualTo(r.fViewMatrix));
|
||||||
SkASSERT(l.fPaintColor == r.fPaintColor);
|
//SkASSERT_RELEASE(l.fPaintColor == r.fPaintColor); // Colors might not actually be identical
|
||||||
SkASSERT(l.fMaxMinScale == r.fMaxMinScale);
|
SkASSERT_RELEASE(l.fMaxMinScale == r.fMaxMinScale);
|
||||||
SkASSERT(l.fMinMaxScale == r.fMinMaxScale);
|
SkASSERT_RELEASE(l.fMinMaxScale == r.fMinMaxScale);
|
||||||
SkASSERT(l.fTextType == r.fTextType);
|
SkASSERT_RELEASE(l.fTextType == r.fTextType);
|
||||||
|
|
||||||
SkASSERT(l.fRunCount == r.fRunCount);
|
SkASSERT_RELEASE(l.fRunCount == r.fRunCount);
|
||||||
for (int i = 0; i < l.fRunCount; i++) {
|
for (int i = 0; i < l.fRunCount; i++) {
|
||||||
const Run& lRun = l.fRuns[i];
|
const Run& lRun = l.fRuns[i];
|
||||||
const Run& rRun = r.fRuns[i];
|
const Run& rRun = r.fRuns[i];
|
||||||
|
|
||||||
if (lRun.fStrike.get()) {
|
|
||||||
SkASSERT(rRun.fStrike.get());
|
|
||||||
SkASSERT(GrBatchTextStrike::GetKey(*lRun.fStrike) ==
|
|
||||||
GrBatchTextStrike::GetKey(*rRun.fStrike));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
SkASSERT(!rRun.fStrike.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lRun.fTypeface.get()) {
|
if (lRun.fTypeface.get()) {
|
||||||
SkASSERT(rRun.fTypeface.get());
|
SkASSERT_RELEASE(rRun.fTypeface.get());
|
||||||
SkASSERT(SkTypeface::Equal(lRun.fTypeface, rRun.fTypeface));
|
SkASSERT_RELEASE(SkTypeface::Equal(lRun.fTypeface, rRun.fTypeface));
|
||||||
} else {
|
} else {
|
||||||
SkASSERT(!rRun.fTypeface.get());
|
SkASSERT_RELEASE(!rRun.fTypeface.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We offset bounds right before flush time so they will not be correct here
|
|
||||||
//SkASSERT(lRun.fVertexBounds == rRun.fVertexBounds);
|
|
||||||
|
|
||||||
SkASSERT(lRun.fDescriptor.getDesc());
|
SkASSERT_RELEASE(lRun.fDescriptor.getDesc());
|
||||||
SkASSERT(rRun.fDescriptor.getDesc());
|
SkASSERT_RELEASE(rRun.fDescriptor.getDesc());
|
||||||
SkASSERT(lRun.fDescriptor.getDesc()->equals(*rRun.fDescriptor.getDesc()));
|
SkASSERT_RELEASE(lRun.fDescriptor.getDesc()->equals(*rRun.fDescriptor.getDesc()));
|
||||||
|
|
||||||
if (lRun.fOverrideDescriptor.get()) {
|
if (lRun.fOverrideDescriptor.get()) {
|
||||||
SkASSERT(lRun.fOverrideDescriptor->getDesc());
|
SkASSERT_RELEASE(lRun.fOverrideDescriptor->getDesc());
|
||||||
SkASSERT(rRun.fOverrideDescriptor.get() && rRun.fOverrideDescriptor->getDesc());;
|
SkASSERT_RELEASE(rRun.fOverrideDescriptor.get() && rRun.fOverrideDescriptor->getDesc());
|
||||||
SkASSERT(lRun.fOverrideDescriptor->getDesc()->equals(
|
SkASSERT_RELEASE(lRun.fOverrideDescriptor->getDesc()->equals(
|
||||||
*rRun.fOverrideDescriptor->getDesc()));
|
*rRun.fOverrideDescriptor->getDesc()));
|
||||||
} else {
|
} else {
|
||||||
SkASSERT(!rRun.fOverrideDescriptor.get());
|
SkASSERT_RELEASE(!rRun.fOverrideDescriptor.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// color can be changed
|
// color can be changed
|
||||||
//SkASSERT(lRun.fColor == rRun.fColor);
|
//SkASSERT(lRun.fColor == rRun.fColor);
|
||||||
SkASSERT(lRun.fInitialized == rRun.fInitialized);
|
SkASSERT_RELEASE(lRun.fInitialized == rRun.fInitialized);
|
||||||
SkASSERT(lRun.fDrawAsPaths == rRun.fDrawAsPaths);
|
SkASSERT_RELEASE(lRun.fDrawAsPaths == rRun.fDrawAsPaths);
|
||||||
|
|
||||||
SkASSERT(lRun.fSubRunInfo.count() == rRun.fSubRunInfo.count());
|
SkASSERT_RELEASE(lRun.fSubRunInfo.count() == rRun.fSubRunInfo.count());
|
||||||
for(int j = 0; j < lRun.fSubRunInfo.count(); j++) {
|
for(int j = 0; j < lRun.fSubRunInfo.count(); j++) {
|
||||||
const Run::SubRunInfo& lSubRun = lRun.fSubRunInfo[j];
|
const Run::SubRunInfo& lSubRun = lRun.fSubRunInfo[j];
|
||||||
const Run::SubRunInfo& rSubRun = rRun.fSubRunInfo[j];
|
const Run::SubRunInfo& rSubRun = rRun.fSubRunInfo[j];
|
||||||
|
|
||||||
SkASSERT(lSubRun.fVertexStartIndex == rSubRun.fVertexStartIndex);
|
// TODO we can do this check, but we have to apply the VM to the old vertex bounds
|
||||||
SkASSERT(lSubRun.fVertexEndIndex == rSubRun.fVertexEndIndex);
|
//SkASSERT_RELEASE(lSubRun.vertexBounds() == rSubRun.vertexBounds());
|
||||||
SkASSERT(lSubRun.fGlyphStartIndex == rSubRun.fGlyphStartIndex);
|
|
||||||
SkASSERT(lSubRun.fGlyphEndIndex == rSubRun.fGlyphEndIndex);
|
|
||||||
SkASSERT(lSubRun.fTextRatio == rSubRun.fTextRatio);
|
|
||||||
SkASSERT(lSubRun.fMaskFormat == rSubRun.fMaskFormat);
|
|
||||||
SkASSERT(lSubRun.fDrawAsDistanceFields == rSubRun.fDrawAsDistanceFields);
|
|
||||||
SkASSERT(lSubRun.fUseLCDText == rSubRun.fUseLCDText);
|
|
||||||
|
|
||||||
//We can't compare the bulk use tokens with this method
|
if (lSubRun.strike()) {
|
||||||
/*
|
SkASSERT_RELEASE(rSubRun.strike());
|
||||||
SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate.count() ==
|
SkASSERT_RELEASE(GrBatchTextStrike::GetKey(*lSubRun.strike()) ==
|
||||||
rSubRun.fBulkUseToken.fPlotsToUpdate.count());
|
GrBatchTextStrike::GetKey(*rSubRun.strike()));
|
||||||
SkASSERT(lSubRun.fBulkUseToken.fPlotAlreadyUpdated ==
|
|
||||||
rSubRun.fBulkUseToken.fPlotAlreadyUpdated);
|
} else {
|
||||||
for (int k = 0; k < lSubRun.fBulkUseToken.fPlotsToUpdate.count(); k++) {
|
SkASSERT_RELEASE(!rSubRun.strike());
|
||||||
SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate[k] ==
|
}
|
||||||
rSubRun.fBulkUseToken.fPlotsToUpdate[k]);
|
|
||||||
}*/
|
SkASSERT_RELEASE(lSubRun.vertexStartIndex() == rSubRun.vertexStartIndex());
|
||||||
|
SkASSERT_RELEASE(lSubRun.vertexEndIndex() == rSubRun.vertexEndIndex());
|
||||||
|
SkASSERT_RELEASE(lSubRun.glyphStartIndex() == rSubRun.glyphStartIndex());
|
||||||
|
SkASSERT_RELEASE(lSubRun.glyphEndIndex() == rSubRun.glyphEndIndex());
|
||||||
|
SkASSERT_RELEASE(lSubRun.maskFormat() == rSubRun.maskFormat());
|
||||||
|
SkASSERT_RELEASE(lSubRun.drawAsDistanceFields() == rSubRun.drawAsDistanceFields());
|
||||||
|
SkASSERT_RELEASE(lSubRun.hasUseLCDText() == rSubRun.hasUseLCDText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -25,7 +25,7 @@ class SkTextBlobRunIterator;
|
|||||||
|
|
||||||
// With this flag enabled, the GrAtlasTextContext will, as a sanity check, regenerate every blob
|
// With this flag enabled, the GrAtlasTextContext will, as a sanity check, regenerate every blob
|
||||||
// that comes in to verify the integrity of its cache
|
// that comes in to verify the integrity of its cache
|
||||||
//#define CACHE_SANITY_CHECK // VERY SLOW
|
#define CACHE_SANITY_CHECK 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing
|
* A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing
|
||||||
@ -200,10 +200,7 @@ public:
|
|||||||
static const size_t kLCDTextVASize = kGrayTextVASize;
|
static const size_t kLCDTextVASize = kGrayTextVASize;
|
||||||
static const int kVerticesPerGlyph = 4;
|
static const int kVerticesPerGlyph = 4;
|
||||||
|
|
||||||
#ifdef CACHE_SANITY_CHECK
|
|
||||||
static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&);
|
static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&);
|
||||||
size_t fSize;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The color here is the GrPaint color, and it is used to determine whether we
|
// The color here is the GrPaint color, and it is used to determine whether we
|
||||||
// have to regenerate LCD text blobs.
|
// have to regenerate LCD text blobs.
|
||||||
@ -443,6 +440,7 @@ private:
|
|||||||
Key fKey;
|
Key fKey;
|
||||||
SkMatrix fViewMatrix;
|
SkMatrix fViewMatrix;
|
||||||
SkMatrix fInitialViewMatrixInverse;
|
SkMatrix fInitialViewMatrixInverse;
|
||||||
|
size_t fSize;
|
||||||
GrColor fPaintColor;
|
GrColor fPaintColor;
|
||||||
SkScalar fInitialX;
|
SkScalar fInitialX;
|
||||||
SkScalar fInitialY;
|
SkScalar fInitialY;
|
||||||
|
@ -156,20 +156,18 @@ void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
|
|||||||
blob, x, y, drawFilter);
|
blob, x, y, drawFilter);
|
||||||
} else {
|
} else {
|
||||||
fCache->makeMRU(cacheBlob);
|
fCache->makeMRU(cacheBlob);
|
||||||
#ifdef CACHE_SANITY_CHECK
|
|
||||||
{
|
if (CACHE_SANITY_CHECK) {
|
||||||
int glyphCount = 0;
|
int glyphCount = 0;
|
||||||
int runCount = 0;
|
int runCount = 0;
|
||||||
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
|
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
|
||||||
SkAutoTUnref<GrAtlasTextBlob> sanityBlob(fCache->createBlob(glyphCount, runCount,
|
SkAutoTUnref<GrAtlasTextBlob> sanityBlob(
|
||||||
kGrayTextVASize));
|
fCache->createBlob(glyphCount, runCount, GrAtlasTextBlob::kGrayTextVASize));
|
||||||
GrTextBlobCache::SetupCacheBlobKey(sanityBlob, key, blurRec, skPaint);
|
GrTextBlobCache::SetupCacheBlobKey(sanityBlob, key, blurRec, skPaint);
|
||||||
this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix,
|
this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix,
|
||||||
blob, x, y, drawFilter);
|
blob, x, y, drawFilter);
|
||||||
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
|
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (canCache) {
|
if (canCache) {
|
||||||
|
@ -23,14 +23,12 @@ GrAtlasTextBlob* GrTextBlobCache::createBlob(int glyphCount, int runCount, size_
|
|||||||
sizeof(GrAtlasTextBlob::Run) * runCount;
|
sizeof(GrAtlasTextBlob::Run) * runCount;
|
||||||
|
|
||||||
void* allocation = fPool.allocate(size);
|
void* allocation = fPool.allocate(size);
|
||||||
#ifdef CACHE_SANITY_CHECK
|
if (CACHE_SANITY_CHECK) {
|
||||||
sk_bzero(allocation, size);
|
sk_bzero(allocation, size);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob;
|
GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob;
|
||||||
#ifdef CACHE_SANITY_CHECK
|
|
||||||
cacheBlob->fSize = size;
|
cacheBlob->fSize = size;
|
||||||
#endif
|
|
||||||
|
|
||||||
// setup offsets for vertices / glyphs
|
// setup offsets for vertices / glyphs
|
||||||
cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned char*>(cacheBlob);
|
cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned char*>(cacheBlob);
|
||||||
|
Loading…
Reference in New Issue
Block a user