| Index: src/gpu/GrBitmapTextContext.h
|
| diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h
|
| index e389f814806ac113e0e746e44d313bcfea055cb9..ebf51a815183a2f1f4f94025ec9658295cc0c1af 100644
|
| --- a/src/gpu/GrBitmapTextContext.h
|
| +++ b/src/gpu/GrBitmapTextContext.h
|
| @@ -11,6 +11,109 @@
|
| #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 {
|
| + struct Run : public SkRefCnt {
|
| + Run() : fColor(GrColor_ILLEGAL) { fVertexBounds.setLargestInverted(); }
|
| + struct TextInfo {
|
| + 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;
|
| + };
|
| + SkTArray<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*);
|
| + void flush(BitmapTextBlob*, int i, GrPipelineBuilder*, GrMaskFormat);
|
| + void flush(BitmapTextBlob*); // automatically called by destructor
|
| + void finish(BitmapTextBlob*);
|
| +
|
| + void internalDrawText(BitmapTextBlob*, int runIndex, GrRenderTarget*, const GrClip&,
|
| + const GrPaint&, const SkPaint&,
|
| + const SkMatrix& viewMatrix, const char text[], size_t byteLength,
|
| + SkScalar x, SkScalar y, const SkIRect& regionClipBounds);
|
| + void internalDrawPosText(BitmapTextBlob*, int runIndex, 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);
|
| +
|
| + static inline bool MustRegenerateBlob(const BitmapTextBlob&, const SkPaint&,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
|
| + void regenerateTextBlob(BitmapTextBlob* bmp, GrRenderTarget* rt, const GrClip& clip,
|
| + const SkPaint& skPaint, const SkMatrix& viewMatrix,
|
| + const SkTextBlob* blob, SkScalar x, SkScalar y,
|
| + SkDrawFilter* drawFilter, const SkIRect& clipBounds);
|
| +
|
| + GrBatchTextStrike* fStrike;
|
| +
|
| + // 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;
|
|
|
|
|