aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text/GrAtlasTextBlob.h
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-02-08 16:14:48 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-08 22:42:40 +0000
commit54d9c889fb6aca043a7b005d61de4e0e65a3ae53 (patch)
treed19bd15855296d86798d8b103c297d7f872fc330 /src/gpu/text/GrAtlasTextBlob.h
parent6ba15ecb1cdd75f57abae8eeece7886aa8f28832 (diff)
Cleanup of large text rendering, take 2.
* Switch all path glyphs to be rendered as part of the fBigGlyphs (now fPathGlyphs) system * Use one flush command for both cached and throwaway blobs * Store and render path glyphs per run rather than one list for the entire blob (fixes a layering bug) * Fix bug with scaled fallback glyphs, where fallback glyphs were trying to use more than one descriptor * Set paint flags correctly for paths Bug: skia:7562 Change-Id: I9455eda2867860a713fbdbbda79c74109e95f9f2 Reviewed-on: https://skia-review.googlesource.com/105020 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/text/GrAtlasTextBlob.h')
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h93
1 files changed, 39 insertions, 54 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 12a80c49d3..9132684622 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -142,8 +142,8 @@ public:
subRun.setHasWCoord(hasWCoord);
}
- void setRunTooBigForAtlas(int runIndex) {
- fRuns[runIndex].fTooBigForAtlas = true;
+ void setRunPaintFlags(int runIndex, uint16_t paintFlags) {
+ fRuns[runIndex].fPaintFlags = paintFlags & Run::kPaintFlagsMask;
}
void setMinAndMaxScale(SkScalar scaledMax, SkScalar scaledMin) {
@@ -175,7 +175,11 @@ public:
GrAtlasTextStrike* strike,
GrGlyph* glyph,
SkGlyphCache*, const SkGlyph& skGlyph,
- SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP);
+ SkScalar x, SkScalar y, SkScalar scale, bool preTransformed);
+
+ // Appends a glyph to the blob as a path only.
+ void appendPathGlyph(int runIndex, const SkPath& path,
+ SkScalar x, SkScalar y, SkScalar scale, bool preTransformed);
static size_t GetVertexStride(GrMaskFormat maskFormat, bool isDistanceFieldWithWCoord) {
switch (maskFormat) {
@@ -193,19 +197,11 @@ public:
bool mustRegenerate(const GrTextUtils::Paint&, const SkMaskFilterBase::BlurRec& blurRec,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
- // flush a GrAtlasTextBlob associated with a SkTextBlob
- void flushCached(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkTextBlob* blob,
- const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- const GrTextUtils::Paint&, SkDrawFilter* drawFilter, const GrClip& clip,
- const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y);
-
- // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob
- void flushThrowaway(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- const GrTextUtils::Paint& paint, const GrClip& clip,
- const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
- SkScalar y);
+ void flush(GrAtlasGlyphCache*, GrTextUtils::Target*, const SkSurfaceProps& props,
+ const GrDistanceFieldAdjustTable* distanceAdjustTable,
+ const GrTextUtils::Paint& paint, const GrClip& clip,
+ const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
+ SkScalar y);
void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
@@ -285,24 +281,6 @@ private:
, fMinMaxScale(SK_ScalarMax)
, fTextType(0) {}
- void appendBigGlyph(GrGlyph* glyph, SkGlyphCache* cache, const SkGlyph& skGlyph,
- SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP);
-
- inline void flushRun(GrTextUtils::Target*, const GrClip&, int run, const SkMatrix& viewMatrix,
- SkScalar x, SkScalar y, const GrTextUtils::Paint& paint,
- const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrAtlasGlyphCache* cache);
-
- void flushBigGlyphs(GrTextUtils::Target*, const GrClip& clip,
- const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- const SkIRect& clipBounds);
-
- void flushBigRun(GrTextUtils::Target*, const SkSurfaceProps& props,
- const SkTextBlobRunIterator& it, const GrClip& clip,
- const GrTextUtils::Paint& paint, SkDrawFilter* drawFilter,
- const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x,
- SkScalar y);
// This function will only be called when we are generating a blob from scratch. We record the
// initial view matrix and initial offsets(x,y), because we record vertex bounds relative to
@@ -347,9 +325,8 @@ private:
* would greatly increase the memory of these cached items.
*/
struct Run {
- Run()
- : fInitialized(false)
- , fTooBigForAtlas(false) {
+ Run() : fPaintFlags(0)
+ , fInitialized(false) {
// To ensure we always have one subrun, we push back a fresh run here
fSubRunInfo.push_back();
}
@@ -495,8 +472,31 @@ private:
// will have different descriptors. If fOverrideDescriptor is non-nullptr, then it
// will be used in place of the run's descriptor to regen texture coords
std::unique_ptr<SkAutoDescriptor> fOverrideDescriptor; // df properties
- bool fInitialized;
- bool fTooBigForAtlas;
+
+ // Any glyphs that can't be rendered with the base or override descriptor
+ // are rendered as paths
+ struct PathGlyph {
+ PathGlyph(const SkPath& path, SkScalar x, SkScalar y, SkScalar scale, bool preXformed)
+ : fPath(path)
+ , fX(x)
+ , fY(y)
+ , fScale(scale)
+ , fPreTransformed(preXformed) {}
+ SkPath fPath;
+ SkScalar fX;
+ SkScalar fY;
+ SkScalar fScale;
+ bool fPreTransformed;
+ };
+
+ SkTArray<PathGlyph> fPathGlyphs;
+
+ struct {
+ unsigned fPaintFlags : 16; // needed mainly for rendering paths
+ bool fInitialized : 1;
+ };
+ // the only flags we need to set
+ static constexpr auto kPaintFlagsMask = SkPaint::kAntiAlias_Flag;
}; // Run
inline std::unique_ptr<GrAtlasTextOp> makeOp(
@@ -506,20 +506,6 @@ private:
const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache,
GrTextUtils::Target*);
- struct BigGlyph {
- BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP)
- : fPath(path)
- , fScale(scale)
- , fX(vx)
- , fY(vy)
- , fTreatAsBMP(treatAsBMP) {}
- SkPath fPath;
- SkScalar fScale;
- SkScalar fX;
- SkScalar fY;
- bool fTreatAsBMP;
- };
-
struct StrokeInfo {
SkScalar fFrameWidth;
SkScalar fMiterLimit;
@@ -538,7 +524,6 @@ private:
GrMemoryPool* fPool;
SkMaskFilterBase::BlurRec fBlurRec;
StrokeInfo fStrokeInfo;
- SkTArray<BigGlyph> fBigGlyphs;
Key fKey;
SkMatrix fInitialViewMatrix;
SkMatrix fInitialViewMatrixInverse;