Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: src/gpu/GrAtlasTextContext.h

Issue 1275393003: Fix for 510931, merge to m44 (Closed) Base URL: https://skia.googlesource.com/skia.git@m44
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/fonts/SkRandomScalerContext.cpp ('k') | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 fSubRunInfo.push_back(); 102 fSubRunInfo.push_back();
103 } 103 }
104 struct SubRunInfo { 104 struct SubRunInfo {
105 SubRunInfo() 105 SubRunInfo()
106 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) 106 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration)
107 , fVertexStartIndex(0) 107 , fVertexStartIndex(0)
108 , fVertexEndIndex(0) 108 , fVertexEndIndex(0)
109 , fGlyphStartIndex(0) 109 , fGlyphStartIndex(0)
110 , fGlyphEndIndex(0) 110 , fGlyphEndIndex(0)
111 , fDrawAsDistanceFields(false) {} 111 , fDrawAsDistanceFields(false) {}
112 SubRunInfo(const SubRunInfo& that)
113 : fBulkUseToken(that.fBulkUseToken)
114 , fStrike(SkSafeRef(that.fStrike.get()))
115 , fAtlasGeneration(that.fAtlasGeneration)
116 , fVertexStartIndex(that.fVertexStartIndex)
117 , fVertexEndIndex(that.fVertexEndIndex)
118 , fGlyphStartIndex(that.fGlyphStartIndex)
119 , fGlyphEndIndex(that.fGlyphEndIndex)
120 , fTextRatio(that.fTextRatio)
121 , fMaskFormat(that.fMaskFormat)
122 , fDrawAsDistanceFields(that.fDrawAsDistanceFields)
123 , fUseLCDText(that.fUseLCDText) {
124 }
112 // Distance field text cannot draw coloremoji, and so has to fal l back. However, 125 // Distance field text cannot draw coloremoji, and so has to fal l back. However,
113 // though the distance field text and the coloremoji may share t he same run, they 126 // though the distance field text and the coloremoji may share t he same run, they
114 // will have different descriptors. If fOverrideDescriptor is n on-NULL, then it 127 // will have different descriptors. If fOverrideDescriptor is n on-NULL, then it
115 // will be used in place of the run's descriptor to regen textur e coords 128 // will be used in place of the run's descriptor to regen textur e coords
116 // TODO we could have a descriptor cache, it would reduce the si ze of these blobs 129 // TODO we could have a descriptor cache, it would reduce the si ze of these blobs
117 // significantly, and then the subrun could just have a refed po inter to the 130 // significantly, and then the subrun could just have a refed po inter to the
118 // correct descriptor. 131 // correct descriptor.
119 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; 132 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
133 SkAutoTUnref<GrBatchTextStrike> fStrike;
120 uint64_t fAtlasGeneration; 134 uint64_t fAtlasGeneration;
121 size_t fVertexStartIndex; 135 size_t fVertexStartIndex;
122 size_t fVertexEndIndex; 136 size_t fVertexEndIndex;
123 uint32_t fGlyphStartIndex; 137 uint32_t fGlyphStartIndex;
124 uint32_t fGlyphEndIndex; 138 uint32_t fGlyphEndIndex;
125 SkScalar fTextRatio; // df property 139 SkScalar fTextRatio; // df property
126 GrMaskFormat fMaskFormat; 140 GrMaskFormat fMaskFormat;
127 bool fDrawAsDistanceFields; // df property 141 bool fDrawAsDistanceFields; // df property
128 bool fUseLCDText; // df property 142 bool fUseLCDText; // df property
129 }; 143 };
130 144
131 SubRunInfo& push_back() { 145 SubRunInfo& push_back() {
132 // Forward glyph / vertex information to seed the new sub run 146 // Forward glyph / vertex information to seed the new sub run
133 SubRunInfo& prevSubRun = fSubRunInfo.back();
134 SubRunInfo& newSubRun = fSubRunInfo.push_back(); 147 SubRunInfo& newSubRun = fSubRunInfo.push_back();
148 SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1);
149
135 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; 150 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex;
136 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; 151 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex;
137 152
138 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; 153 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex;
139 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; 154 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex;
140 return newSubRun; 155 return newSubRun;
141 } 156 }
142 static const int kMinSubRuns = 1; 157 static const int kMinSubRuns = 1;
143 SkAutoTUnref<GrBatchTextStrike> fStrike;
144 SkAutoTUnref<SkTypeface> fTypeface; 158 SkAutoTUnref<SkTypeface> fTypeface;
145 SkRect fVertexBounds; 159 SkRect fVertexBounds;
146 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; 160 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo;
147 SkAutoDescriptor fDescriptor; 161 SkAutoDescriptor fDescriptor;
148 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df propertie s 162 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df propertie s
149 GrColor fColor; 163 GrColor fColor;
150 bool fInitialized; 164 bool fInitialized;
151 bool fDrawAsPaths; 165 bool fDrawAsPaths;
152 }; 166 };
153 167
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void setHasBitmap() { fTextType |= kHasBitmap_TextType; } 266 void setHasBitmap() { fTextType |= kHasBitmap_TextType; }
253 }; 267 };
254 268
255 typedef BitmapTextBlob::Run Run; 269 typedef BitmapTextBlob::Run Run;
256 typedef Run::SubRunInfo PerSubRunInfo; 270 typedef Run::SubRunInfo PerSubRunInfo;
257 271
258 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr ix); 272 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr ix);
259 BitmapTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, 273 BitmapTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint,
260 const SkMatrix& viewMatrix, SkGlyphCache** cache , 274 const SkMatrix& viewMatrix, SkGlyphCache** cache ,
261 SkPaint* dfPaint, SkScalar* textRatio); 275 SkPaint* dfPaint, SkScalar* textRatio);
262 void bmpAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, int le ft, int top, 276 void bmpAppendGlyph(BitmapTextBlob*, int runIndex, const SkGlyph&, int left, int top,
263 GrColor color, GrFontScaler*, const SkIRect& clipRect); 277 GrColor color, GrFontScaler*, const SkIRect& clipRect);
264 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala r sx, SkScalar sy, 278 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, const SkGlyph&, SkScalar s x, SkScalar sy,
265 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk Scalar textRatio, 279 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk Scalar textRatio,
266 const SkMatrix& viewMatrix); 280 const SkMatrix& viewMatrix);
267 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, 281 inline void appendGlyphPath(BitmapTextBlob*, GrGlyph*, GrFontScaler*, const SkGlyph&,
268 GrFontScaler* scaler, SkScalar x, SkScalar y); 282 SkScalar x, SkScalar y);
269 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, 283 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*,
270 const SkRect& positions, GrColor color, 284 const SkRect& positions, GrColor color,
271 size_t vertexStride, bool useVertexColor, 285 size_t vertexStride, bool useVertexColor,
272 GrGlyph*); 286 GrGlyph*);
273 287
274 inline void flushRunAsPaths(const SkTextBlob::RunIterator&, const SkPaint&, SkDrawFilter*, 288 inline void flushRunAsPaths(const SkTextBlob::RunIterator&, const SkPaint&, SkDrawFilter*,
275 const SkMatrix& viewMatrix, const SkIRect& clipB ounds, SkScalar x, 289 const SkMatrix& viewMatrix, const SkIRect& clipB ounds, SkScalar x,
276 SkScalar y); 290 SkScalar y);
277 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, 291 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&,
278 int glyphCount, int run, int subRun, 292 int glyphCount, int run, int subRun,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 friend class BitmapTextBatch; 402 friend class BitmapTextBatch;
389 403
390 #ifdef GR_TEST_UTILS 404 #ifdef GR_TEST_UTILS
391 BATCH_TEST_FRIEND(TextBlobBatch); 405 BATCH_TEST_FRIEND(TextBlobBatch);
392 #endif 406 #endif
393 407
394 typedef GrTextContext INHERITED; 408 typedef GrTextContext INHERITED;
395 }; 409 };
396 410
397 #endif 411 #endif
OLDNEW
« no previous file with comments | « src/fonts/SkRandomScalerContext.cpp ('k') | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698