| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 * glyphs. However, its not clear if this is a win because we'd still h
ave to either go the | 87 * glyphs. However, its not clear if this is a win because we'd still h
ave to either go the |
| 88 * glyph cache to get the path at flush time, or hold onto the path in t
he cache, which | 88 * glyph cache to get the path at flush time, or hold onto the path in t
he cache, which |
| 89 * would greatly increase the memory of these cached items. | 89 * would greatly increase the memory of these cached items. |
| 90 */ | 90 */ |
| 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 // To ensure we always have one subrun, we push back a fresh run
here |
| 98 fSubRunInfo.push_back(); |
| 97 } | 99 } |
| 98 struct SubRunInfo { | 100 struct SubRunInfo { |
| 99 SubRunInfo() | 101 SubRunInfo() |
| 100 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) | 102 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) |
| 101 , fVertexStartIndex(0) | 103 , fVertexStartIndex(0) |
| 102 , fVertexEndIndex(0) | 104 , fVertexEndIndex(0) |
| 103 , fGlyphStartIndex(0) | 105 , fGlyphStartIndex(0) |
| 104 , fGlyphEndIndex(0) | 106 , fGlyphEndIndex(0) |
| 105 , fDrawAsDistanceFields(false) {} | 107 , fDrawAsDistanceFields(false) {} |
| 106 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, | 108 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, |
| 107 // though the distance field text and the coloremoji may share t
he same run, they | 109 // though the distance field text and the coloremoji may share t
he same run, they |
| 108 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it | 110 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it |
| 109 // will be used in place of the run's descriptor to regen textur
e coords | 111 // will be used in place of the run's descriptor to regen textur
e coords |
| 110 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs | 112 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs |
| 111 // significantly, and then the subrun could just have a refed po
inter to the | 113 // significantly, and then the subrun could just have a refed po
inter to the |
| 112 // correct descriptor. | 114 // correct descriptor. |
| 113 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df prope
rties | |
| 114 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | 115 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; |
| 115 uint64_t fAtlasGeneration; | 116 uint64_t fAtlasGeneration; |
| 116 size_t fVertexStartIndex; | 117 size_t fVertexStartIndex; |
| 117 size_t fVertexEndIndex; | 118 size_t fVertexEndIndex; |
| 118 uint32_t fGlyphStartIndex; | 119 uint32_t fGlyphStartIndex; |
| 119 uint32_t fGlyphEndIndex; | 120 uint32_t fGlyphEndIndex; |
| 120 SkScalar fTextRatio; // df property | 121 SkScalar fTextRatio; // df property |
| 121 GrMaskFormat fMaskFormat; | 122 GrMaskFormat fMaskFormat; |
| 122 bool fDrawAsDistanceFields; // df property | 123 bool fDrawAsDistanceFields; // df property |
| 123 bool fUseLCDText; // df property | 124 bool fUseLCDText; // df property |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 class SubRunInfoArray { | 127 SubRunInfo& push_back() { |
| 127 public: | 128 // Forward glyph / vertex information to seed the new sub run |
| 128 SubRunInfoArray() | 129 SubRunInfo& prevSubRun = fSubRunInfo.back(); |
| 129 : fSubRunCount(0) | 130 SubRunInfo& newSubRun = fSubRunInfo.push_back(); |
| 130 , fSubRunAllocation(kMinSubRuns) { | 131 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; |
| 131 SK_COMPILE_ASSERT(kMinSubRuns > 0, insufficient_subrun_alloc
ation); | 132 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; |
| 132 // We always seed with one here, so we can assume a valid su
brun during | |
| 133 // push_back | |
| 134 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get()); | |
| 135 SkNEW_PLACEMENT(&fPtr[fSubRunCount++], SubRunInfo); | |
| 136 } | |
| 137 ~SubRunInfoArray() { | |
| 138 for (int i = 0; i < fSubRunCount; i++) { | |
| 139 fPtr[i].~SubRunInfo(); | |
| 140 } | |
| 141 } | |
| 142 | 133 |
| 143 int count() const { return fSubRunCount; } | 134 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; |
| 144 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; } | 135 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; |
| 145 SubRunInfo& push_back() { | 136 return newSubRun; |
| 146 if (fSubRunCount >= fSubRunAllocation) { | 137 } |
| 147 fSubRunAllocation = fSubRunAllocation << 1; | 138 static const int kMinSubRuns = 1; |
| 148 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun
Info)); | |
| 149 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get(
)); | |
| 150 } | |
| 151 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo); | |
| 152 | |
| 153 // Forward glyph / vertex information to seed the new sub ru
n | |
| 154 SubRunInfo& newSubRun = fPtr[fSubRunCount]; | |
| 155 SubRunInfo& prevSubRun = fPtr[fSubRunCount - 1]; | |
| 156 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; | |
| 157 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; | |
| 158 | |
| 159 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; | |
| 160 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; | |
| 161 return fPtr[fSubRunCount++]; | |
| 162 } | |
| 163 SubRunInfo& operator[](int index) { | |
| 164 return fPtr[index]; | |
| 165 } | |
| 166 const SubRunInfo& operator[](int index) const { | |
| 167 return fPtr[index]; | |
| 168 } | |
| 169 | |
| 170 private: | |
| 171 static const int kMinSubRuns = 1; | |
| 172 static const int kMinSubRunStorage = kMinSubRuns * sizeof(SubRun
Info); | |
| 173 SubRunInfo* fPtr; | |
| 174 SkAutoSTMalloc<kMinSubRunStorage, unsigned char> fSubRunStorage; | |
| 175 int fSubRunCount; | |
| 176 int fSubRunAllocation; | |
| 177 }; | |
| 178 SkAutoTUnref<GrBatchTextStrike> fStrike; | 139 SkAutoTUnref<GrBatchTextStrike> fStrike; |
| 179 SkAutoTUnref<SkTypeface> fTypeface; | 140 SkAutoTUnref<SkTypeface> fTypeface; |
| 180 SkRect fVertexBounds; | 141 SkRect fVertexBounds; |
| 181 SubRunInfoArray fSubRunInfo; | 142 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; |
| 182 SkAutoDescriptor fDescriptor; | 143 SkAutoDescriptor fDescriptor; |
| 144 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df propertie
s |
| 183 GrColor fColor; | 145 GrColor fColor; |
| 184 bool fInitialized; | 146 bool fInitialized; |
| 185 bool fDrawAsPaths; | 147 bool fDrawAsPaths; |
| 186 }; | 148 }; |
| 187 | 149 |
| 188 struct BigGlyph { | 150 struct BigGlyph { |
| 189 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} | 151 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx),
fVy(vy) {} |
| 190 SkPath fPath; | 152 SkPath fPath; |
| 191 int fVx; | 153 int fVx; |
| 192 int fVy; | 154 int fVy; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 bool fEnableDFRendering; | 362 bool fEnableDFRendering; |
| 401 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 363 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
| 402 | 364 |
| 403 friend class GrTextBlobCache; | 365 friend class GrTextBlobCache; |
| 404 friend class BitmapTextBatch; | 366 friend class BitmapTextBatch; |
| 405 | 367 |
| 406 typedef GrTextContext INHERITED; | 368 typedef GrTextContext INHERITED; |
| 407 }; | 369 }; |
| 408 | 370 |
| 409 #endif | 371 #endif |
| OLD | NEW |