| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 struct Run { | 91 struct Run { |
| 92 Run() | 92 Run() |
| 93 : fColor(GrColor_ILLEGAL) | 93 : fColor(GrColor_ILLEGAL) |
| 94 , fInitialized(false) | 94 , fInitialized(false) |
| 95 , fDrawAsPaths(false) { | 95 , fDrawAsPaths(false) { |
| 96 fVertexBounds.setLargestInverted(); | 96 fVertexBounds.setLargestInverted(); |
| 97 } | 97 } |
| 98 struct SubRunInfo { | 98 struct SubRunInfo { |
| 99 SubRunInfo() | 99 SubRunInfo() |
| 100 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) | 100 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) |
| 101 , fVertexStartIndex(0) |
| 102 , fVertexEndIndex(0) |
| 101 , fGlyphStartIndex(0) | 103 , fGlyphStartIndex(0) |
| 102 , fGlyphEndIndex(0) | 104 , fGlyphEndIndex(0) |
| 103 , fVertexStartIndex(0) | |
| 104 , fVertexEndIndex(0) | |
| 105 , fDrawAsDistanceFields(false) {} | 105 , fDrawAsDistanceFields(false) {} |
| 106 GrMaskFormat fMaskFormat; | |
| 107 uint64_t fAtlasGeneration; | |
| 108 uint32_t fGlyphStartIndex; | |
| 109 uint32_t fGlyphEndIndex; | |
| 110 size_t fVertexStartIndex; | |
| 111 size_t fVertexEndIndex; | |
| 112 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | |
| 113 | |
| 114 // distance field properties | |
| 115 bool fDrawAsDistanceFields; | |
| 116 bool fUseLCDText; | |
| 117 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, | 106 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, |
| 118 // though the distance field text and the coloremoji may share t
he same run, they | 107 // though the distance field text and the coloremoji may share t
he same run, they |
| 119 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it | 108 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it |
| 120 // will be used in place of the run's descriptor to regen textur
e coords | 109 // will be used in place of the run's descriptor to regen textur
e coords |
| 121 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs | 110 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs |
| 122 // significantly, and then the subrun could just have a refed po
inter to the | 111 // significantly, and then the subrun could just have a refed po
inter to the |
| 123 // correct descriptor. | 112 // correct descriptor. |
| 124 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; | 113 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df prope
rties |
| 114 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; |
| 115 uint64_t fAtlasGeneration; |
| 116 size_t fVertexStartIndex; |
| 117 size_t fVertexEndIndex; |
| 118 uint32_t fGlyphStartIndex; |
| 119 uint32_t fGlyphEndIndex; |
| 120 SkScalar fTextRatio; // df property |
| 121 GrMaskFormat fMaskFormat; |
| 122 bool fDrawAsDistanceFields; // df property |
| 123 bool fUseLCDText; // df property |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 class SubRunInfoArray { | 126 class SubRunInfoArray { |
| 128 public: | 127 public: |
| 129 SubRunInfoArray() | 128 SubRunInfoArray() |
| 130 : fSubRunCount(0) | 129 : fSubRunCount(0) |
| 131 , fSubRunAllocation(kMinSubRuns) { | 130 , fSubRunAllocation(kMinSubRuns) { |
| 132 SK_COMPILE_ASSERT(kMinSubRuns > 0, insufficient_subrun_alloc
ation); | 131 SK_COMPILE_ASSERT(kMinSubRuns > 0, insufficient_subrun_alloc
ation); |
| 133 // We always seed with one here, so we can assume a valid su
brun during | 132 // We always seed with one here, so we can assume a valid su
brun during |
| 134 // push_back | 133 // push_back |
| (...skipping 29 matching lines...) Expand all Loading... |
| 164 SubRunInfo& operator[](int index) { | 163 SubRunInfo& operator[](int index) { |
| 165 return fPtr[index]; | 164 return fPtr[index]; |
| 166 } | 165 } |
| 167 const SubRunInfo& operator[](int index) const { | 166 const SubRunInfo& operator[](int index) const { |
| 168 return fPtr[index]; | 167 return fPtr[index]; |
| 169 } | 168 } |
| 170 | 169 |
| 171 private: | 170 private: |
| 172 static const int kMinSubRuns = 1; | 171 static const int kMinSubRuns = 1; |
| 173 static const int kMinSubRunStorage = kMinSubRuns * sizeof(SubRun
Info); | 172 static const int kMinSubRunStorage = kMinSubRuns * sizeof(SubRun
Info); |
| 173 SubRunInfo* fPtr; |
| 174 SkAutoSTMalloc<kMinSubRunStorage, unsigned char> fSubRunStorage; | 174 SkAutoSTMalloc<kMinSubRunStorage, unsigned char> fSubRunStorage; |
| 175 int fSubRunCount; | 175 int fSubRunCount; |
| 176 int fSubRunAllocation; | 176 int fSubRunAllocation; |
| 177 SubRunInfo* fPtr; | |
| 178 }; | 177 }; |
| 178 SkAutoTUnref<SkTypeface> fTypeface; |
| 179 SkRect fVertexBounds; |
| 179 SubRunInfoArray fSubRunInfo; | 180 SubRunInfoArray fSubRunInfo; |
| 180 SkAutoDescriptor fDescriptor; | 181 SkAutoDescriptor fDescriptor; |
| 181 SkAutoTUnref<SkTypeface> fTypeface; | |
| 182 SkRect fVertexBounds; | |
| 183 GrColor fColor; | 182 GrColor fColor; |
| 184 bool fInitialized; | 183 bool fInitialized; |
| 185 bool fDrawAsPaths; | 184 bool fDrawAsPaths; |
| 186 }; | 185 }; |
| 187 | 186 |
| 188 struct BigGlyph { | 187 struct BigGlyph { |
| 189 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} | 188 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} |
| 190 SkPath fPath; | 189 SkPath fPath; |
| 191 int fVx; | 190 int fVx; |
| 192 int fVy; | 191 int fVy; |
| 193 }; | 192 }; |
| 194 #ifdef SK_DEBUG | |
| 195 mutable SkScalar fTotalXError; | |
| 196 mutable SkScalar fTotalYError; | |
| 197 #endif | |
| 198 SkColor fPaintColor; | |
| 199 SkTArray<BigGlyph> fBigGlyphs; | |
| 200 SkMatrix fViewMatrix; | |
| 201 SkScalar fX; | |
| 202 SkScalar fY; | |
| 203 int fRunCount; | |
| 204 SkMaskFilter::BlurRec fBlurRec; | |
| 205 struct StrokeInfo { | |
| 206 SkScalar fFrameWidth; | |
| 207 SkScalar fMiterLimit; | |
| 208 SkPaint::Join fJoin; | |
| 209 }; | |
| 210 StrokeInfo fStrokeInfo; | |
| 211 GrMemoryPool* fPool; | |
| 212 | |
| 213 enum TextType { | |
| 214 kHasDistanceField_TextType = 0x1, | |
| 215 kHasBitmap_TextType = 0x2, | |
| 216 }; | |
| 217 uint8_t fTextType; | |
| 218 | |
| 219 BitmapTextBlob() : fTextType(0) {} | |
| 220 | |
| 221 // all glyph / vertex offsets are into these pools. | |
| 222 unsigned char* fVertices; | |
| 223 GrGlyph::PackedID* fGlyphIDs; | |
| 224 Run* fRuns; | |
| 225 | 193 |
| 226 struct Key { | 194 struct Key { |
| 227 Key() { | 195 Key() { |
| 228 sk_bzero(this, sizeof(Key)); | 196 sk_bzero(this, sizeof(Key)); |
| 229 } | 197 } |
| 230 uint32_t fUniqueID; | 198 uint32_t fUniqueID; |
| 231 SkPaint::Style fStyle; | 199 SkPaint::Style fStyle; |
| 232 // Color may affect the gamma of the mask we generate, but in a fair
ly limited way. | 200 // Color may affect the gamma of the mask we generate, but in a fair
ly limited way. |
| 233 // Each color is assigned to on of a fixed number of buckets based o
n its | 201 // Each color is assigned to on of a fixed number of buckets based o
n its |
| 234 // luminance. For each luminance bucket there is a "canonical color"
that | 202 // luminance. For each luminance bucket there is a "canonical color"
that |
| 235 // represents the bucket. This functionality is currently only supp
orted for A8 | 203 // represents the bucket. This functionality is currently only supp
orted for A8 |
| 236 SkColor fCanonicalColor; | 204 SkColor fCanonicalColor; |
| 237 bool fHasBlur; | 205 bool fHasBlur; |
| 238 | 206 |
| 239 bool operator==(const Key& other) const { | 207 bool operator==(const Key& other) const { |
| 240 return 0 == memcmp(this, &other, sizeof(Key)); | 208 return 0 == memcmp(this, &other, sizeof(Key)); |
| 241 } | 209 } |
| 242 }; | 210 }; |
| 211 |
| 212 struct StrokeInfo { |
| 213 SkScalar fFrameWidth; |
| 214 SkScalar fMiterLimit; |
| 215 SkPaint::Join fJoin; |
| 216 }; |
| 217 |
| 218 enum TextType { |
| 219 kHasDistanceField_TextType = 0x1, |
| 220 kHasBitmap_TextType = 0x2, |
| 221 }; |
| 222 |
| 223 // all glyph / vertex offsets are into these pools. |
| 224 unsigned char* fVertices; |
| 225 GrGlyph::PackedID* fGlyphIDs; |
| 226 Run* fRuns; |
| 227 GrMemoryPool* fPool; |
| 228 SkMaskFilter::BlurRec fBlurRec; |
| 229 StrokeInfo fStrokeInfo; |
| 230 SkTArray<BigGlyph> fBigGlyphs; |
| 243 Key fKey; | 231 Key fKey; |
| 232 SkMatrix fViewMatrix; |
| 233 #ifdef SK_DEBUG |
| 234 mutable SkScalar fTotalXError; |
| 235 mutable SkScalar fTotalYError; |
| 236 #endif |
| 237 SkScalar fX; |
| 238 SkScalar fY; |
| 239 SkColor fPaintColor; |
| 240 int fRunCount; |
| 241 uint8_t fTextType; |
| 242 |
| 243 BitmapTextBlob() : fTextType(0) {} |
| 244 | 244 |
| 245 static const Key& GetKey(const BitmapTextBlob& blob) { | 245 static const Key& GetKey(const BitmapTextBlob& blob) { |
| 246 return blob.fKey; | 246 return blob.fKey; |
| 247 } | 247 } |
| 248 | 248 |
| 249 static uint32_t Hash(const Key& key) { | 249 static uint32_t Hash(const Key& key) { |
| 250 return SkChecksum::Murmur3(&key, sizeof(Key)); | 250 return SkChecksum::Murmur3(&key, sizeof(Key)); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void operator delete(void* p) { | 253 void operator delete(void* p) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 bool fEnableDFRendering; | 383 bool fEnableDFRendering; |
| 384 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 384 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
| 385 | 385 |
| 386 friend class GrTextBlobCache; | 386 friend class GrTextBlobCache; |
| 387 friend class BitmapTextBatch; | 387 friend class BitmapTextBatch; |
| 388 | 388 |
| 389 typedef GrTextContext INHERITED; | 389 typedef GrTextContext INHERITED; |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 #endif | 392 #endif |
| OLD | NEW |