aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkPaint.h3
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp16
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h6
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp57
-rw-r--r--src/gpu/text/GrAtlasTextContext.h5
-rw-r--r--src/gpu/text/GrTextUtils.cpp10
-rw-r--r--src/gpu/text/GrTextUtils.h5
7 files changed, 51 insertions, 51 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 51e8848a00..84f4c96054 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -1082,8 +1082,9 @@ private:
friend class SkCanvas;
friend class SkDraw;
friend class SkPDFDevice;
- friend class GrAtlasTextBlob;
+ friend class GrBitmapTextContext;
friend class GrAtlasTextContext;
+ friend class GrDistanceFieldTextContext;
friend class GrStencilAndCoverTextContext;
friend class GrPathRendering;
friend class GrTextUtils;
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index f79f82598f..dee6d133e3 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -13,25 +13,9 @@
#include "GrTextUtils.h"
#include "SkColorFilter.h"
#include "SkDrawFilter.h"
-#include "SkGlyphCache.h"
#include "SkTextBlobRunIterator.h"
#include "batches/GrAtlasTextBatch.h"
-SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
- const SkSurfaceProps& props,
- const SkPaint& skPaint,
- const SkMatrix* viewMatrix,
- bool noGamma) {
- GrAtlasTextBlob::Run* run = &fRuns[runIndex];
-
- // if we have an override descriptor for the run, then we should use that
- SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() :
- &run->fDescriptor;
- skPaint.getScalerContextDescriptor(desc, props, viewMatrix, noGamma);
- run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
- return SkGlyphCache::DetachCache(run->fTypeface, desc->getDesc());
-}
-
void GrAtlasTextBlob::appendGlyph(int runIndex,
const SkRect& positions,
GrColor color,
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index c24dabd010..d99ae707e0 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -290,12 +290,6 @@ public:
}
}
- SkGlyphCache* setupCache(int runIndex,
- const SkSurfaceProps& props,
- const SkPaint& skPaint,
- const SkMatrix* viewMatrix,
- bool noGamma);
-
// Appends a glyph to the blob. If the glyph is too large, the glyph will be appended
// as a path.
void appendGlyph(int runIndex,
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 37cd53d080..3769b0b439 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -105,6 +105,15 @@ bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) {
return false;
}
+inline SkGlyphCache* GrAtlasTextContext::setupCache(GrAtlasTextBlob::Run* run,
+ const SkPaint& skPaint,
+ const SkMatrix* viewMatrix,
+ bool noGamma) {
+ skPaint.getScalerContextDescriptor(&run->fDescriptor, fSurfaceProps, viewMatrix, noGamma);
+ run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
+ return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc());
+}
+
void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix, const SkTextBlob* blob,
@@ -282,17 +291,18 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
PerSubRunInfo& subRun = runIdx.fSubRunInfo.back();
subRun.setUseLCDText(runPaint.isLCDRenderText());
subRun.setDrawAsDistanceFields();
+ SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], dfPaint, nullptr, true);
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning: {
- this->internalDrawDFText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y(), textRatio, runPaint);
break;
}
case SkTextBlob::kHorizontal_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
- this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
1, dfOffset, textRatio,
runPaint);
@@ -300,36 +310,40 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
}
case SkTextBlob::kFull_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y);
- this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
2, dfOffset, textRatio, runPaint);
break;
}
}
+ SkGlyphCache::AttachCache(cache);
} else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) {
cacheBlob->fRuns[run].fDrawAsPaths = true;
} else {
cacheBlob->setHasBitmap();
+ SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], runPaint, &viewMatrix,
+ false);
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
case SkTextBlob::kHorizontal_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 1,
SkPoint::Make(x, y + offset.y()));
break;
case SkTextBlob::kFull_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y));
break;
}
+ SkGlyphCache::AttachCache(cache);
}
if (drawFilter) {
@@ -408,9 +422,14 @@ inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob,
// Push back a new subrun to fill and set the override descriptor
run.push_back();
run.fOverrideDescriptor.reset(new SkAutoDescriptor);
- GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), fSurfaceProps,
- skPaint, color, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(),
+ skPaint.getScalerContextDescriptor(run.fOverrideDescriptor,
+ fSurfaceProps, &viewMatrix, false);
+ SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
+ run.fOverrideDescriptor->getDesc());
+ GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), cache, skPaint,
+ color, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(),
fallbackPos.begin(), scalarsPerPosition, offset);
+ SkGlyphCache::AttachCache(cache);
}
inline GrAtlasTextBlob*
@@ -442,15 +461,19 @@ GrAtlasTextContext::createDrawTextBlob(const GrPaint& paint, const SkPaint& skPa
SkPaint dfPaint;
SkScalar textRatio;
blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &textRatio);
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr, true);
- this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
+ this->internalDrawDFText(blob, 0, cache, dfPaint, paint.getColor(), viewMatrix, text,
byteLength, x, y, textRatio, skPaint);
+ SkGlyphCache::AttachCache(cache);
} else {
blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
blob->fViewMatrix = viewMatrix;
- GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
+ GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), cache, skPaint,
paint.getColor(), viewMatrix, text, byteLength, x, y);
+ SkGlyphCache::AttachCache(cache);
}
return blob;
}
@@ -468,16 +491,20 @@ GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& s
SkPaint dfPaint;
SkScalar textRatio;
blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &textRatio);
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr, true);
- this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
+ this->internalDrawDFPosText(blob, 0, cache, dfPaint, paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, textRatio,
skPaint);
+ SkGlyphCache::AttachCache(cache);
} else {
blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
blob->fViewMatrix = viewMatrix;
- GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
+ GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), cache, skPaint,
paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
+ SkGlyphCache::AttachCache(cache);
}
return blob;
}
@@ -512,6 +539,7 @@ void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc,
}
void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex,
+ SkGlyphCache* cache,
const SkPaint& skPaint, GrColor color,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -577,11 +605,12 @@ void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex,
y -= alignY;
SkPoint offset = SkPoint::Make(x, y);
- this->internalDrawDFPosText(blob, runIndex, skPaint, color, viewMatrix, text, byteLength,
+ this->internalDrawDFPosText(blob, runIndex, cache, skPaint, color, viewMatrix, text, byteLength,
positions.begin(), 2, offset, textRatio, origPaint);
}
void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
+ SkGlyphCache* cache,
const SkPaint& skPaint,
GrColor color,
const SkMatrix& viewMatrix,
@@ -604,7 +633,6 @@ void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd
fCurrStrike = nullptr;
- SkGlyphCache* cache = blob->setupCache(runIndex, fSurfaceProps, skPaint, nullptr, true);
SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
GrFontScaler* fontScaler = GetGrFontScaler(cache);
@@ -669,7 +697,6 @@ void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runInd
}
}
- SkGlyphCache::AttachCache(cache);
if (fallbackTxt.count()) {
this->fallbackDrawPosText(blob, runIndex, origPaint.getColor(), origPaint, viewMatrix,
fallbackTxt, fallbackPos, scalarsPerPosition, offset);
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index 3971352e96..e38243d480 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -74,13 +74,13 @@ private:
const SkPoint& offset);
void internalDrawDFText(GrAtlasTextBlob*, int runIndex,
- const SkPaint&,
+ SkGlyphCache*, const SkPaint&,
GrColor color, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y,
SkScalar textRatio, const SkPaint& origPaint);
void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex,
- const SkPaint&,
+ SkGlyphCache*, const SkPaint&,
GrColor color, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
@@ -90,6 +90,7 @@ private:
// sets up the descriptor on the blob and returns a detached cache. Client must attach
inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
+ inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMatrix, bool noGamma);
void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColor,
const SkMatrix& viewMatrix,
const SkTextBlob* blob, SkScalar x, SkScalar y,
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 9d6bb2c857..293ea4d891 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -23,7 +23,7 @@
void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
GrBatchFontCache* fontCache,
- const SkSurfaceProps& props, const SkPaint& skPaint,
+ SkGlyphCache* cache, const SkPaint& skPaint,
GrColor color,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -38,7 +38,6 @@ void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
GrBatchTextStrike* currStrike = nullptr;
// Get GrFontScaler from cache
- SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix, false);
GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
SkFindAndPlaceGlyph::ProcessText(
@@ -53,13 +52,11 @@ void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
color, fontScaler);
}
);
-
- SkGlyphCache::AttachCache(cache);
}
void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
GrBatchFontCache* fontCache,
- const SkSurfaceProps& props, const SkPaint& skPaint,
+ SkGlyphCache* cache, const SkPaint& skPaint,
GrColor color,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -76,7 +73,6 @@ void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
GrBatchTextStrike* currStrike = nullptr;
// Get GrFontScaler from cache
- SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix, false);
GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
SkFindAndPlaceGlyph::ProcessPosText(
@@ -91,8 +87,6 @@ void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
color, fontScaler);
}
);
-
- SkGlyphCache::AttachCache(cache);
}
void GrTextUtils::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 0996f655a3..8f673afbed 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -35,14 +35,13 @@ class GrTextUtils {
public:
// Functions for appending BMP text to GrAtlasTextBlob
static void DrawBmpText(GrAtlasTextBlob*, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&,
- const SkPaint&,
+ GrBatchFontCache*, SkGlyphCache*, const SkPaint&,
GrColor, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y);
static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&, const SkPaint&,
+ GrBatchFontCache*, SkGlyphCache*, const SkPaint&,
GrColor, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,