Chromium Code Reviews| Index: src/gpu/GrBitmapTextContext.h |
| diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h |
| index e389f814806ac113e0e746e44d313bcfea055cb9..ad00939a13e17b0773f82933d7922fb7407bd3a1 100644 |
| --- a/src/gpu/GrBitmapTextContext.h |
| +++ b/src/gpu/GrBitmapTextContext.h |
| @@ -11,6 +11,108 @@ |
| #include "GrTextContext.h" |
| #include "GrGeometryProcessor.h" |
| +#include "SkTHash.h" |
| + |
| +class GrBatchTextStrike; |
| +class GrPipelineBuilder; |
| + |
| +/* |
| + * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs. |
| + * TODO replace GrBitmapTextContext |
| + */ |
| +class GrBitmapTextContextB : public GrTextContext { |
| +public: |
| + static GrBitmapTextContextB* Create(GrContext*, SkGpuDevice*, const SkDeviceProperties&); |
| + |
| + virtual ~GrBitmapTextContextB(); |
| + |
| +private: |
| + GrBitmapTextContextB(GrContext*, SkGpuDevice*, const SkDeviceProperties&); |
| + |
| + bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE; |
| + |
| + void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| + const SkMatrix& viewMatrix, const char text[], size_t byteLength, |
| + SkScalar x, SkScalar y, const SkIRect& regionClipBounds) SK_OVERRIDE; |
| + void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| + const SkMatrix& viewMatrix, |
| + const char text[], size_t byteLength, |
| + const SkScalar pos[], int scalarsPerPosition, |
| + const SkPoint& offset, const SkIRect& regionClipBounds) SK_OVERRIDE; |
| + void onDrawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
| + const SkMatrix& viewMatrix, const SkTextBlob*, |
| + SkScalar x, SkScalar y, SkDrawFilter*, |
| + const SkIRect& clipBounds) SK_OVERRIDE; |
| + |
| + void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, |
| + const SkIRect& regionClipBounds); |
| + |
| + struct BitmapTextBlob : public SkRefCnt { |
|
bsalomon
2015/03/26 17:06:56
Comment on what this encapsulates? I get why it is
joshualitt
2015/03/26 18:21:43
Acknowledged.
|
| + struct Run { |
| + Run() : fColor(GrColor_ILLEGAL) { fVertexBounds.setLargestInverted(); } |
| + struct TextInfo { |
|
bsalomon
2015/03/26 17:06:56
"PerFormatInfo"?
Comment somewhere that we consid
joshualitt
2015/03/26 18:21:43
Acknowledged.
|
| + TextInfo() : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) {} |
| + SkTDArray<unsigned char> fVertices; |
| + SkTDArray<GrGlyph::PackedID> fGlyphIDs; |
| + uint32_t fAtlasGeneration; |
| + }; |
| + SkAutoTUnref<const SkData> fDescriptor; |
| + SkAutoTUnref<SkTypeface> fTypeface; |
| + TextInfo fInfos[kMaskFormatCount]; |
| + SkRect fVertexBounds; |
| + GrColor fColor; |
| + }; |
| + SkSTArray<1, Run, true> fRuns; |
| + struct BigGlyph { |
| + BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {} |
| + SkPath fPath; |
| + int fVx; |
| + int fVy; |
| + }; |
| + SkTArray<BigGlyph> fBigGlyphs; |
| + SkTextBlob* fBlob; |
| + SkMatrix fViewMatrix; |
| + SkScalar fX; |
| + SkScalar fY; |
| + SkPaint::Style fStyle; |
| + |
| + static uint32_t Hash(const uint32_t& key) { |
| + return SkChecksum::Mix(key); |
| + } |
| + }; |
| + |
| + void appendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, int left, int top, |
| + GrFontScaler*, const SkIRect& clipRect); |
| + void flush(GrDrawTarget*, BitmapTextBlob*, int i, GrPipelineBuilder*, GrMaskFormat, |
| + GrColor color, int paintAlpha); |
| + void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const GrPaint&, const GrClip&, |
| + const SkMatrix& viewMatrix, int paintAlpha); |
| + |
| + void internalDrawText(BitmapTextBlob*, int runIndex, const SkPaint&, |
| + const SkMatrix& viewMatrix, const char text[], size_t byteLength, |
| + SkScalar x, SkScalar y, const SkIRect& clipRect); |
| + void internalDrawPosText(BitmapTextBlob*, int runIndex, const SkPaint&, |
| + const SkMatrix& viewMatrix, |
| + const char text[], size_t byteLength, |
| + const SkScalar pos[], int scalarsPerPosition, |
| + const SkPoint& offset, const SkIRect& clipRect); |
| + |
| + static inline bool MustRegenerateBlob(const BitmapTextBlob&, const SkPaint&, |
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y); |
| + void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, const SkMatrix& viewMatrix, |
| + const SkTextBlob* blob, SkScalar x, SkScalar y, |
| + SkDrawFilter* drawFilter, const SkIRect& clipRect); |
| + |
| + GrBatchTextStrike* fStrike; |
|
bsalomon
2015/03/26 17:06:56
Is this a current strike that is often updated? fC
joshualitt
2015/03/26 18:21:43
I only use this to avoid getting the strike multip
|
| + |
| + // TODO use real cache |
| + static void ClearCacheEntry(uint32_t key, BitmapTextBlob**); |
| + SkTHashMap<uint32_t, BitmapTextBlob*, BitmapTextBlob::Hash> fCache; |
| + |
| + friend class BitmapTextBatch; |
| + |
| + typedef GrTextContext INHERITED; |
| +}; |
| class GrTextStrike; |