| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrAtlasTextContext_DEFINED | 8 #ifndef GrAtlasTextContext_DEFINED |
| 9 #define GrAtlasTextContext_DEFINED | 9 #define GrAtlasTextContext_DEFINED |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 /* | 51 /* |
| 52 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing | 52 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing |
| 53 * on the GPU. These are initially created with valid positions and colors,
but invalid | 53 * on the GPU. These are initially created with valid positions and colors,
but invalid |
| 54 * texture coordinates. The BitmapTextBlob itself has a few Blob-wide prope
rties, and also | 54 * texture coordinates. The BitmapTextBlob itself has a few Blob-wide prope
rties, and also |
| 55 * consists of a number of runs. Runs inside a blob are flushed individuall
y so they can be | 55 * consists of a number of runs. Runs inside a blob are flushed individuall
y so they can be |
| 56 * reordered. | 56 * reordered. |
| 57 * | 57 * |
| 58 * The only thing(aside from a memcopy) required to flush a BitmapTextBlob i
s to ensure that | 58 * The only thing(aside from a memcopy) required to flush a BitmapTextBlob i
s to ensure that |
| 59 * the GrAtlas will not evict anything the Blob needs. | 59 * the GrAtlas will not evict anything the Blob needs. |
| 60 * TODO this is currently a bug | |
| 61 */ | 60 */ |
| 61 // TODO Pack these bytes |
| 62 struct BitmapTextBlob : public SkRefCnt { | 62 struct BitmapTextBlob : public SkRefCnt { |
| 63 SK_DECLARE_INTERNAL_LLIST_INTERFACE(BitmapTextBlob); | 63 SK_DECLARE_INTERNAL_LLIST_INTERFACE(BitmapTextBlob); |
| 64 | 64 |
| 65 /* | 65 /* |
| 66 * Each Run inside of the blob can have its texture coordinates regenera
ted if required. | 66 * Each Run inside of the blob can have its texture coordinates regenera
ted if required. |
| 67 * To determine if regeneration is necessary, fAtlasGeneration is used.
If there have been | 67 * To determine if regeneration is necessary, fAtlasGeneration is used.
If there have been |
| 68 * any evictions inside of the atlas, then we will simply regenerate Run
s. We could track | 68 * any evictions inside of the atlas, then we will simply regenerate Run
s. We could track |
| 69 * this at a more fine grained level, but its not clear if this is worth
it, as evictions | 69 * this at a more fine grained level, but its not clear if this is worth
it, as evictions |
| 70 * should be fairly rare. | 70 * should be fairly rare. |
| 71 * | 71 * |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 struct BigGlyph { | 120 struct BigGlyph { |
| 121 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} | 121 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} |
| 122 SkPath fPath; | 122 SkPath fPath; |
| 123 int fVx; | 123 int fVx; |
| 124 int fVy; | 124 int fVy; |
| 125 }; | 125 }; |
| 126 #ifdef SK_DEBUG | 126 #ifdef SK_DEBUG |
| 127 mutable SkScalar fTotalXError; | 127 mutable SkScalar fTotalXError; |
| 128 mutable SkScalar fTotalYError; | 128 mutable SkScalar fTotalYError; |
| 129 #endif | 129 #endif |
| 130 SkColor fPaintColor; |
| 130 SkTArray<BigGlyph> fBigGlyphs; | 131 SkTArray<BigGlyph> fBigGlyphs; |
| 131 GrColor fColor; // the original color on the paint | |
| 132 SkMatrix fViewMatrix; | 132 SkMatrix fViewMatrix; |
| 133 SkScalar fX; | 133 SkScalar fX; |
| 134 SkScalar fY; | 134 SkScalar fY; |
| 135 int fRunCount; | 135 int fRunCount; |
| 136 SkMaskFilter::BlurRec fBlurRec; | 136 SkMaskFilter::BlurRec fBlurRec; |
| 137 struct StrokeInfo { | 137 struct StrokeInfo { |
| 138 SkScalar fFrameWidth; | 138 SkScalar fFrameWidth; |
| 139 SkScalar fMiterLimit; | 139 SkScalar fMiterLimit; |
| 140 SkPaint::Join fJoin; | 140 SkPaint::Join fJoin; |
| 141 }; | 141 }; |
| 142 StrokeInfo fStrokeInfo; | 142 StrokeInfo fStrokeInfo; |
| 143 GrMemoryPool* fPool; | 143 GrMemoryPool* fPool; |
| 144 | 144 |
| 145 // all glyph / vertex offsets are into these pools. | 145 // all glyph / vertex offsets are into these pools. |
| 146 unsigned char* fVertices; | 146 unsigned char* fVertices; |
| 147 GrGlyph::PackedID* fGlyphIDs; | 147 GrGlyph::PackedID* fGlyphIDs; |
| 148 Run* fRuns; | 148 Run* fRuns; |
| 149 | 149 |
| 150 struct Key { | 150 struct Key { |
| 151 Key() { | 151 Key() { |
| 152 memset(this, 0, sizeof(Key)); | 152 sk_bzero(this, sizeof(Key)); |
| 153 } | 153 } |
| 154 uint32_t fUniqueID; | 154 uint32_t fUniqueID; |
| 155 SkPaint::Style fStyle; | 155 SkPaint::Style fStyle; |
| 156 // Color may affect the gamma of the mask we generate, but in a fair
ly limited way. |
| 157 // Each color is assigned to on of a fixed number of buckets based o
n its |
| 158 // luminance. For each luminance bucket there is a "canonical color"
that |
| 159 // represents the bucket. This functionality is currently only supp
orted for A8 |
| 160 SkColor fCanonicalColor; |
| 156 bool fHasBlur; | 161 bool fHasBlur; |
| 157 | 162 |
| 158 bool operator==(const Key& other) const { | 163 bool operator==(const Key& other) const { |
| 159 return 0 == memcmp(this, &other, sizeof(Key)); | 164 return 0 == memcmp(this, &other, sizeof(Key)); |
| 160 } | 165 } |
| 161 }; | 166 }; |
| 162 Key fKey; | 167 Key fKey; |
| 163 | 168 |
| 164 static const Key& GetKey(const BitmapTextBlob& blob) { | 169 static const Key& GetKey(const BitmapTextBlob& blob) { |
| 165 return blob.fKey; | 170 return blob.fKey; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 SkScalar transX, SkScalar transY); | 205 SkScalar transX, SkScalar transY); |
| 201 | 206 |
| 202 // We have to flush SkTextBlobs differently from drawText / drawPosText | 207 // We have to flush SkTextBlobs differently from drawText / drawPosText |
| 203 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, | 208 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, |
| 204 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, | 209 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, |
| 205 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); | 210 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); |
| 206 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 211 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, |
| 207 const GrPaint&, const GrClip&, const SkMatrix& viewMatrix); | 212 const GrPaint&, const GrClip&, const SkMatrix& viewMatrix); |
| 208 | 213 |
| 209 void internalDrawText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const Sk
Paint&, | 214 void internalDrawText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const Sk
Paint&, |
| 210 const SkMatrix& viewMatrix, const char text[], size_t
byteLength, | 215 GrColor color, const SkMatrix& viewMatrix, |
| 216 const char text[], size_t byteLength, |
| 211 SkScalar x, SkScalar y, const SkIRect& clipRect); | 217 SkScalar x, SkScalar y, const SkIRect& clipRect); |
| 212 void internalDrawPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, | 218 void internalDrawPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, |
| 213 const SkMatrix& viewMatrix, | 219 GrColor color, const SkMatrix& viewMatrix, |
| 214 const char text[], size_t byteLength, | 220 const char text[], size_t byteLength, |
| 215 const SkScalar pos[], int scalarsPerPosition, | 221 const SkScalar pos[], int scalarsPerPosition, |
| 216 const SkPoint& offset, const SkIRect& clipRect); | 222 const SkPoint& offset, const SkIRect& clipRect); |
| 217 | 223 |
| 218 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 224 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
| 225 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
| 219 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix& viewMa
trix); | 226 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix& viewMa
trix); |
| 220 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, | 227 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, |
| 221 const BitmapTextBlob&, const SkPaint&, | 228 const BitmapTextBlob&, const SkPaint&, |
| 222 const SkMaskFilter::BlurRec&, | 229 const SkMaskFilter::BlurRec&, |
| 223 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); | 230 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); |
| 224 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, const S
kMatrix& viewMatrix, | 231 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor
, |
| 232 const SkMatrix& viewMatrix, |
| 225 const SkTextBlob* blob, SkScalar x, SkScalar y, | 233 const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 226 SkDrawFilter* drawFilter, const SkIRect& clipRect); | 234 SkDrawFilter* drawFilter, const SkIRect& clipRect); |
| 235 inline static bool HasLCD(const SkTextBlob*); |
| 227 | 236 |
| 228 GrBatchTextStrike* fCurrStrike; | 237 GrBatchTextStrike* fCurrStrike; |
| 229 GrTextBlobCache* fCache; | 238 GrTextBlobCache* fCache; |
| 230 | 239 |
| 231 friend class GrTextBlobCache; | 240 friend class GrTextBlobCache; |
| 232 friend class BitmapTextBatch; | 241 friend class BitmapTextBatch; |
| 233 | 242 |
| 234 typedef GrTextContext INHERITED; | 243 typedef GrTextContext INHERITED; |
| 235 }; | 244 }; |
| 236 | 245 |
| 237 #endif | 246 #endif |
| OLD | NEW |