Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: src/gpu/GrAtlasTextContext.cpp

Issue 1096753002: Small change to allow DistanceField and BMP text to coexist in a blob (Closed) Base URL: https://skia.googlesource.com/skia.git@atdfnow
Patch Set: warnings Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlasTextContext.cpp
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 34c691a9d718687bb0ae8c5991005ed256f33acb..aac3e3311f6324f6a0d5eddc99bb1d23f5455910 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -545,7 +545,8 @@ inline void GrAtlasTextContext::initDistanceFieldPaint(SkPaint* skPaint, SkScala
skPaint->setSubpixelText(true);
}
-inline void GrAtlasTextContext::fallbackDrawPosText(GrRenderTarget* rt, const GrClip& clip,
+inline void GrAtlasTextContext::fallbackDrawPosText(BitmapTextBlob* blob,
+ GrRenderTarget* rt, const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
@@ -554,20 +555,18 @@ inline void GrAtlasTextContext::fallbackDrawPosText(GrRenderTarget* rt, const Gr
int scalarsPerPosition,
const SkPoint& offset,
const SkIRect& clipRect) {
- int glyphCount = fallbackTxt.count();
- SkASSERT(glyphCount);
- // TODO currently we have to create a whole new blob for fallback text. This is because
- // they have a different descriptor and we currently only have one descriptor per run.
- // We should fix this and allow an override descriptor on each subrun
- SkAutoTUnref<BitmapTextBlob> blob(fCache->createBlob(glyphCount, 1, kGrayTextVASize));
- blob->fViewMatrix = viewMatrix;
-
- SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
+ SkASSERT(fallbackTxt.count());
+ Run& run = blob->fRuns[0];
+ PerSubRunInfo& subRun = run.fSubRunInfo.push_back();
+ subRun.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor));
+ skPaint.getScalerContextDescriptor(subRun.fOverrideDescriptor,
+ &fDeviceProperties, &viewMatrix, false);
+ SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
+ subRun.fOverrideDescriptor->getDesc());
this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix,
fallbackTxt.begin(), fallbackTxt.count(),
fallbackPos.begin(), scalarsPerPosition, offset, clipRect);
SkGlyphCache::AttachCache(cache);
- this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip);
}
inline GrAtlasTextContext::BitmapTextBlob*
@@ -610,11 +609,11 @@ void GrAtlasTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
byteLength, x, y, clipRect, textRatio, &fallbackTxt, &fallbackPos,
&offset, skPaint);
SkGlyphCache::AttachCache(cache);
- this->flush(fContext->getTextTarget(), blob, rt, dfPaint, paint, clip);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
+ this->fallbackDrawPosText(blob, rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
fallbackPos, 2, offset, clipRect);
}
+ this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip);
} else {
SkAutoTUnref<BitmapTextBlob> blob(fCache->createBlob(glyphCount, 1, kGrayTextVASize));
blob->fViewMatrix = viewMatrix;
@@ -651,11 +650,11 @@ void GrAtlasTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
byteLength, pos, scalarsPerPosition, offset, clipRect,
textRatio, &fallbackTxt, &fallbackPos);
SkGlyphCache::AttachCache(cache);
- this->flush(fContext->getTextTarget(), blob, rt, dfPaint, paint, clip);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
+ this->fallbackDrawPosText(blob, rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
fallbackPos, scalarsPerPosition, offset, clipRect);
}
+ this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip);
} else {
SkAutoTUnref<BitmapTextBlob> blob(fCache->createBlob(glyphCount, 1, kGrayTextVASize));
blob->fViewMatrix = viewMatrix;
@@ -1134,14 +1133,7 @@ void GrAtlasTextContext::bmpAppendGlyph(BitmapTextBlob* blob, int runIndex,
PerSubRunInfo* subRun = &run.fSubRunInfo.back();
if (run.fInitialized && subRun->fMaskFormat != format) {
- PerSubRunInfo* newSubRun = &run.fSubRunInfo.push_back();
- newSubRun->fGlyphStartIndex = subRun->fGlyphEndIndex;
- newSubRun->fGlyphEndIndex = subRun->fGlyphEndIndex;
-
- newSubRun->fVertexStartIndex = subRun->fVertexEndIndex;
- newSubRun->fVertexEndIndex = subRun->fVertexEndIndex;
-
- subRun = newSubRun;
+ subRun = &run.fSubRunInfo.push_back();
}
run.fInitialized = true;
@@ -1475,7 +1467,8 @@ public:
bool brokenRun = false;
if (regenerateTextureCoords) {
info.fBulkUseToken.reset();
- desc = run.fDescriptor.getDesc();
+ desc = info.fOverrideDescriptor ? info.fOverrideDescriptor->getDesc() :
+ run.fDescriptor.getDesc();
cache = SkGlyphCache::DetachCache(run.fTypeface, desc);
scaler = GrTextContext::GetGrFontScaler(cache);
strike = fFontCache->getStrike(scaler);
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698