Index: src/gpu/GrBitmapTextContext.h |
diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h |
index 3bf3a941c646cb42d28464d1afbd6efbd4ffe897..93bbe3beb5dee3c65cc5d74bcb76c24db8b15b31 100644 |
--- a/src/gpu/GrBitmapTextContext.h |
+++ b/src/gpu/GrBitmapTextContext.h |
@@ -11,6 +11,8 @@ |
#include "GrTextContext.h" |
#include "GrGeometryProcessor.h" |
+#include "GrMemoryPool.h" |
+#include "SkDescriptor.h" |
#include "SkTHash.h" |
class GrBatchTextStrike; |
@@ -68,59 +70,90 @@ private: |
// We maintain separate arrays for each format type, and flush them separately. In practice |
// most of the time a run will have the same format type |
struct Run { |
- Run() : fColor(GrColor_ILLEGAL) { fVertexBounds.setLargestInverted(); } |
- struct PerFormatInfo { |
- PerFormatInfo() : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) {} |
- SkTDArray<unsigned char> fVertices; |
- SkTDArray<GrGlyph::PackedID> fGlyphIDs; |
+ Run() : fColor(GrColor_ILLEGAL), fInitialized(false) { |
+ fVertexBounds.setLargestInverted(); |
+ fSubRunInfo.push_back(); |
+ } |
+ struct PerSubRunInfo { |
bsalomon
2015/03/31 21:19:11
SubRunInfo?
joshualitt
2015/04/01 13:21:18
Acknowledged.
|
+ PerSubRunInfo() |
+ : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) |
+ , fGlyphStartIndex(0) |
+ , fGlyphEndIndex(0) |
+ , fVertexStartIndex(0) |
+ , fVertexEndIndex(0) {} |
+ GrMaskFormat fMaskFormat; |
uint64_t fAtlasGeneration; |
+ uint32_t fGlyphStartIndex; |
+ uint32_t fGlyphEndIndex; |
+ uint32_t fVertexStartIndex; |
+ uint32_t fVertexEndIndex; |
}; |
- SkAutoTUnref<const SkData> fDescriptor; |
+ SkSTArray<1, PerSubRunInfo, true> fSubRunInfo; |
bsalomon
2015/03/31 21:19:11
Does this max out at 3? Maybe just always have an
joshualitt
2015/04/01 13:21:18
No, we can have as many subruns as there are glyph
|
+ SkAutoDescriptor fDescriptor; |
SkAutoTUnref<SkTypeface> fTypeface; |
- PerFormatInfo fInfos[kMaskFormatCount]; |
SkRect fVertexBounds; |
GrColor fColor; |
+ bool fInitialized; |
bsalomon
2015/03/31 21:19:11
can you use another param for this rather than add
joshualitt
2015/04/01 13:21:18
Unfortunately I can't just use the descriptor beca
bsalomon
2015/04/01 15:41:45
I'm not sure I totally follow... but maybe this ma
|
}; |
- 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; |
+ uint32_t fRunCount; |
+ |
+ // all glyph / vertex offsets are into these pools. |
+ unsigned char* fVertices; |
+ GrGlyph::PackedID* fGlyphIDs; |
+ Run* fRuns; |
static uint32_t Hash(const uint32_t& key) { |
return SkChecksum::Mix(key); |
} |
+ |
+ void operator delete(void* p) { sk_free(p); } |
+ void* operator new(size_t) { |
+ SkFAIL("All blobs are created by placement new."); |
+ return sk_malloc_throw(0); |
+ } |
+ void* operator new(size_t, void* p) { return p; } |
bsalomon
2015/03/31 21:19:11
some compilers will yell at you for not overriding
joshualitt
2015/04/01 13:21:18
Acknowledged. I'm not sure if I did the delete ri
bsalomon
2015/04/01 15:41:45
Now that I look more closely, why did you need to
joshualitt
2015/04/01 16:54:23
Just to put the throw in new. I guess its not rea
|
}; |
+ typedef BitmapTextBlob::Run Run; |
+ typedef Run::PerSubRunInfo PerSubRunInfo; |
+ |
+ inline BitmapTextBlob* CreateBlob(int glyphCount, int runCount); |
+ |
void appendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, int left, int top, |
GrFontScaler*, const SkIRect& clipRect); |
- void flushSubRun(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&, |
+ void internalDrawText(BitmapTextBlob*, int runIndex, SkGlyphCache*, 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&, |
+ void internalDrawPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const SkPaint&, |
const SkMatrix& viewMatrix, |
const char text[], size_t byteLength, |
const SkScalar pos[], int scalarsPerPosition, |
const SkPoint& offset, const SkIRect& clipRect); |
+ // sets up the descriptor on the blob and returns a detached cache. Client must attach |
+ inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix& viewMatrix); |
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); |
+ static inline void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob*); |
GrBatchTextStrike* fCurrStrike; |