| 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 #include "GrAtlasTextBlob.h" | 8 #include "GrAtlasTextBlob.h" |
| 9 | 9 |
| 10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Initialize runs | 42 // Initialize runs |
| 43 for (int i = 0; i < runCount; i++) { | 43 for (int i = 0; i < runCount; i++) { |
| 44 new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run; | 44 new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run; |
| 45 } | 45 } |
| 46 cacheBlob->fRunCount = runCount; | 46 cacheBlob->fRunCount = runCount; |
| 47 cacheBlob->fPool = pool; | 47 cacheBlob->fPool = pool; |
| 48 return cacheBlob; | 48 return cacheBlob; |
| 49 } | 49 } |
| 50 | 50 |
| 51 | |
| 52 SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex, | 51 SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex, |
| 53 const SkSurfaceProps& props, | 52 const SkSurfaceProps& props, |
| 54 uint32_t scalerContextFlags, | 53 uint32_t scalerContextFlags, |
| 55 const SkPaint& skPaint, | 54 const SkPaint& skPaint, |
| 56 const SkMatrix* viewMatrix) { | 55 const SkMatrix* viewMatrix) { |
| 57 GrAtlasTextBlob::Run* run = &fRuns[runIndex]; | 56 GrAtlasTextBlob::Run* run = &fRuns[runIndex]; |
| 58 | 57 |
| 59 // if we have an override descriptor for the run, then we should use that | 58 // if we have an override descriptor for the run, then we should use that |
| 60 SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDesc
riptor.get() : | 59 SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDesc
riptor.get() : |
| 61 &run->fDescriptor; | 60 &run->fDescriptor; |
| 62 skPaint.getScalerContextDescriptor(&run->fEffects, desc, props, scalerContex
tFlags, viewMatrix); | 61 skPaint.getScalerContextDescriptor(&run->fEffects, desc, props, scalerContex
tFlags, viewMatrix); |
| 63 run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); | 62 run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); |
| 64 return SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, desc->getDes
c()); | 63 return SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, desc->getDes
c()); |
| 65 } | 64 } |
| 66 | 65 |
| 67 void GrAtlasTextBlob::appendGlyph(int runIndex, | 66 void GrAtlasTextBlob::appendGlyph(int runIndex, |
| 68 const SkRect& positions, | 67 const SkRect& positions, |
| 69 GrColor color, | 68 GrColor color, |
| 70 GrBatchTextStrike* strike, | 69 GrBatchTextStrike* strike, |
| 71 GrGlyph* glyph, | 70 GrGlyph* glyph, |
| 72 GrFontScaler* scaler, const SkGlyph& skGlyph, | 71 SkGlyphCache* cache, const SkGlyph& skGlyph, |
| 73 SkScalar x, SkScalar y, SkScalar scale, bool a
pplyVM) { | 72 SkScalar x, SkScalar y, SkScalar scale, bool a
pplyVM) { |
| 74 | 73 |
| 75 // If the glyph is too large we fall back to paths | 74 // If the glyph is too large we fall back to paths |
| 76 if (glyph->fTooLargeForAtlas) { | 75 if (glyph->fTooLargeForAtlas) { |
| 77 this->appendLargeGlyph(glyph, scaler, skGlyph, x, y, scale, applyVM); | 76 this->appendLargeGlyph(glyph, cache, skGlyph, x, y, scale, applyVM); |
| 78 return; | 77 return; |
| 79 } | 78 } |
| 80 | 79 |
| 81 Run& run = fRuns[runIndex]; | 80 Run& run = fRuns[runIndex]; |
| 82 GrMaskFormat format = glyph->fMaskFormat; | 81 GrMaskFormat format = glyph->fMaskFormat; |
| 83 | 82 |
| 84 Run::SubRunInfo* subRun = &run.fSubRunInfo.back(); | 83 Run::SubRunInfo* subRun = &run.fSubRunInfo.back(); |
| 85 if (run.fInitialized && subRun->maskFormat() != format) { | 84 if (run.fInitialized && subRun->maskFormat() != format) { |
| 86 subRun = &run.push_back(); | 85 subRun = &run.push_back(); |
| 87 subRun->setStrike(strike); | 86 subRun->setStrike(strike); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 144 |
| 146 // V3 | 145 // V3 |
| 147 position = reinterpret_cast<SkPoint*>(vertex); | 146 position = reinterpret_cast<SkPoint*>(vertex); |
| 148 position->set(positions.fRight, positions.fTop); | 147 position->set(positions.fRight, positions.fTop); |
| 149 } | 148 } |
| 150 subRun->appendVertices(vertexStride); | 149 subRun->appendVertices(vertexStride); |
| 151 fGlyphs[subRun->glyphEndIndex()] = glyph; | 150 fGlyphs[subRun->glyphEndIndex()] = glyph; |
| 152 subRun->glyphAppended(); | 151 subRun->glyphAppended(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void GrAtlasTextBlob::appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, con
st SkGlyph& skGlyph, | 154 void GrAtlasTextBlob::appendLargeGlyph(GrGlyph* glyph, SkGlyphCache* cache, cons
t SkGlyph& skGlyph, |
| 156 SkScalar x, SkScalar y, SkScalar scale, b
ool applyVM) { | 155 SkScalar x, SkScalar y, SkScalar scale, b
ool applyVM) { |
| 157 if (nullptr == glyph->fPath) { | 156 if (nullptr == glyph->fPath) { |
| 158 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph); | 157 const SkPath* glyphPath = cache->findPath(skGlyph); |
| 159 if (!glyphPath) { | 158 if (!glyphPath) { |
| 160 return; | 159 return; |
| 161 } | 160 } |
| 162 | 161 |
| 163 glyph->fPath = new SkPath(*glyphPath); | 162 glyph->fPath = new SkPath(*glyphPath); |
| 164 } | 163 } |
| 165 fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, a
pplyVM)); | 164 fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, a
pplyVM)); |
| 166 } | 165 } |
| 167 | 166 |
| 168 bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint, | 167 bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint, |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 | 556 |
| 558 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, | 557 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, |
| 559 SkScalar x, SkScalar y
, SkScalar* transX, | 558 SkScalar x, SkScalar y
, SkScalar* transX, |
| 560 SkScalar* transY) { | 559 SkScalar* transY) { |
| 561 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, | 560 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, |
| 562 fCurrentViewMatrix, fX, fY, transX, transY); | 561 fCurrentViewMatrix, fX, fY, transX, transY); |
| 563 fCurrentViewMatrix = viewMatrix; | 562 fCurrentViewMatrix = viewMatrix; |
| 564 fX = x; | 563 fX = x; |
| 565 fY = y; | 564 fY = y; |
| 566 } | 565 } |
| OLD | NEW |