diff options
Diffstat (limited to 'src/gpu/text/GrAtlasTextBlob.h')
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.h | 85 |
1 files changed, 55 insertions, 30 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h index a75d9f2a38..12a80c49d3 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrAtlasTextBlob.h @@ -142,6 +142,10 @@ public: subRun.setHasWCoord(hasWCoord); } + void setRunTooBigForAtlas(int runIndex) { + fRuns[runIndex].fTooBigForAtlas = true; + } + void setMinAndMaxScale(SkScalar scaledMax, SkScalar scaledMin) { // we init fMaxMinScale and fMinMaxScale in the constructor fMaxMinScale = SkMaxScalar(scaledMax, fMaxMinScale); @@ -171,11 +175,7 @@ public: GrAtlasTextStrike* strike, GrGlyph* glyph, SkGlyphCache*, const SkGlyph& skGlyph, - 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); + SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP); static size_t GetVertexStride(GrMaskFormat maskFormat, bool isDistanceFieldWithWCoord) { switch (maskFormat) { @@ -193,11 +193,19 @@ public: bool mustRegenerate(const GrTextUtils::Paint&, const SkMaskFilterBase::BlurRec& blurRec, const SkMatrix& viewMatrix, 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); + // 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 computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex, const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { @@ -277,6 +285,24 @@ 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 @@ -321,7 +347,9 @@ private: * would greatly increase the memory of these cached items. */ struct Run { - Run() : fInitialized(false) { + Run() + : fInitialized(false) + , fTooBigForAtlas(false) { // To ensure we always have one subrun, we push back a fresh run here fSubRunInfo.push_back(); } @@ -467,26 +495,8 @@ 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 - - // 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; - bool fInitialized; + bool fTooBigForAtlas; }; // Run inline std::unique_ptr<GrAtlasTextOp> makeOp( @@ -496,6 +506,20 @@ 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; @@ -514,6 +538,7 @@ private: GrMemoryPool* fPool; SkMaskFilterBase::BlurRec fBlurRec; StrokeInfo fStrokeInfo; + SkTArray<BigGlyph> fBigGlyphs; Key fKey; SkMatrix fInitialViewMatrix; SkMatrix fInitialViewMatrixInverse; |