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

Unified Diff: src/gpu/GrAtlasTextContext.cpp

Issue 1448453002: Convert drawText to using the find and place code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove adjusted test. Created 5 years, 1 month 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/core/SkFindAndPlaceGlyph.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 f8004656c10207c976daf982525506565607ff70..37fe092496d0f4521d4f8ce77a36544ac880072d 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -487,7 +487,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter, const SkIRect& clipRect,
GrRenderTarget* rt, const GrClip& clip) {
- // 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.
// We use this color vs the SkPaint color because it has the colorfilter applied.
cacheBlob->fPaintColor = color;
@@ -686,8 +686,8 @@ inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob,
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
- const SkMatrix& viewMatrix, SkPaint* dfPaint,
+GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
+ const SkMatrix& viewMatrix, SkPaint* dfPaint,
SkScalar* textRatio) {
GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
@@ -725,7 +725,7 @@ GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
byteLength, x, y, clipRect, textRatio, &fallbackTxt, &fallbackPos,
&offset, skPaint);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
+ this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
fallbackTxt, fallbackPos, 2, offset, clipRect);
}
} else {
@@ -764,8 +764,8 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
byteLength, pos, scalarsPerPosition, offset, clipRect,
textRatio, &fallbackTxt, &fallbackPos);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
- fallbackTxt, fallbackPos, scalarsPerPosition, offset,
+ this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
+ fallbackTxt, fallbackPos, scalarsPerPosition, offset,
clipRect);
}
} else {
@@ -780,7 +780,7 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
}
void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
- const GrClip& clip,
+ const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -826,73 +826,16 @@ void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex
// Get GrFontScaler from cache
GrFontScaler* fontScaler = GetGrFontScaler(cache);
- // transform our starting point
- {
- SkPoint loc;
- viewMatrix.mapXY(x, y, &loc);
- x = loc.fX;
- y = loc.fY;
- }
-
- // need to measure first
- if (skPaint.getTextAlign() != SkPaint::kLeft_Align) {
- SkVector stopVector;
- MeasureText(cache, glyphCacheProc, text, byteLength, &stopVector);
-
- SkScalar stopX = stopVector.fX;
- SkScalar stopY = stopVector.fY;
-
- if (skPaint.getTextAlign() == SkPaint::kCenter_Align) {
- stopX = SkScalarHalf(stopX);
- stopY = SkScalarHalf(stopY);
- }
- x -= stopX;
- y -= stopY;
- }
-
- const char* stop = text + byteLength;
-
- SkAutoKern autokern;
-
- SkFixed fxMask = ~0;
- SkFixed fyMask = ~0;
- SkScalar halfSampleX, halfSampleY;
- if (cache->isSubpixel()) {
- halfSampleX = halfSampleY = SkFixedToScalar(SkGlyph::kSubpixelRound);
- SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix);
- if (kX_SkAxisAlignment == baseline) {
- fyMask = 0;
- halfSampleY = SK_ScalarHalf;
- } else if (kY_SkAxisAlignment == baseline) {
- fxMask = 0;
- halfSampleX = SK_ScalarHalf;
- }
- } else {
- halfSampleX = halfSampleY = SK_ScalarHalf;
- }
-
- Sk48Dot16 fx = SkScalarTo48Dot16(x + halfSampleX);
- Sk48Dot16 fy = SkScalarTo48Dot16(y + halfSampleY);
-
- while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask);
-
- fx += autokern.adjust(glyph);
-
- if (glyph.fWidth) {
- this->bmpAppendGlyph(blob,
- runIndex,
- glyph,
- Sk48Dot16FloorToInt(fx),
- Sk48Dot16FloorToInt(fy),
- color,
- fontScaler,
- clipRect);
+ SkFindAndPlaceGlyph::ProcessText(
+ text, byteLength, {x, y}, viewMatrix, skPaint.getTextAlign(), glyphCacheProc, cache,
+ [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
+ position += rounding;
+ this->bmpAppendGlyph(
+ blob, runIndex, glyph,
+ SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY),
+ color, fontScaler, clipRect);
}
-
- fx += glyph.fAdvanceX;
- fy += glyph.fAdvanceY;
- }
+ );
}
void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIndex,
@@ -949,7 +892,7 @@ void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex,
SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc();
SkAutoDescriptor desc;
origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, nullptr, true);
- SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypeface(),
+ SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypeface(),
desc.getDesc());
SkTArray<SkScalar> positions;
@@ -1932,7 +1875,7 @@ private:
};
void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
- const SkTextBlobRunIterator& it,
+ const SkTextBlobRunIterator& it,
const GrClip& clip, const SkPaint& skPaint,
SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
const SkIRect& clipBounds, SkScalar x, SkScalar y) {
@@ -2029,7 +1972,7 @@ inline void GrAtlasTextContext::flushRun(GrDrawContext* dc, GrPipelineBuilder* p
}
}
-inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob,
+inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob,
GrDrawContext* dc, GrRenderTarget* rt,
const GrClip& clip, const SkPaint& skPaint,
SkScalar transX, SkScalar transY,
@@ -2056,7 +1999,7 @@ inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob,
void GrAtlasTextContext::flush(const SkTextBlob* blob,
GrAtlasTextBlob* cacheBlob,
- GrDrawContext* dc,
+ GrDrawContext* dc,
GrRenderTarget* rt,
const SkPaint& skPaint,
const GrPaint& grPaint,
« no previous file with comments | « src/core/SkFindAndPlaceGlyph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698