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 #include "GrAtlasTextContext.h" | 7 #include "GrAtlasTextContext.h" |
8 | 8 |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 const SkPaint& skPaint, | 653 const SkPaint& skPaint, |
654 const SkMatrix& viewMatrix, | 654 const SkMatrix& viewMatrix, |
655 const SkTDArray<char>& fallb
ackTxt, | 655 const SkTDArray<char>& fallb
ackTxt, |
656 const SkTDArray<SkScalar>& f
allbackPos, | 656 const SkTDArray<SkScalar>& f
allbackPos, |
657 int scalarsPerPosition, | 657 int scalarsPerPosition, |
658 const SkPoint& offset, | 658 const SkPoint& offset, |
659 const SkIRect& clipRect) { | 659 const SkIRect& clipRect) { |
660 SkASSERT(fallbackTxt.count()); | 660 SkASSERT(fallbackTxt.count()); |
661 blob->setHasBitmap(); | 661 blob->setHasBitmap(); |
662 Run& run = blob->fRuns[runIndex]; | 662 Run& run = blob->fRuns[runIndex]; |
663 PerSubRunInfo& subRun = run.fSubRunInfo.push_back(); | 663 // Push back a new subrun to fill and set the override descriptor |
664 subRun.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor)); | 664 run.push_back(); |
665 skPaint.getScalerContextDescriptor(subRun.fOverrideDescriptor, | 665 run.fOverrideDescriptor.reset(SkNEW(SkAutoDescriptor)); |
| 666 skPaint.getScalerContextDescriptor(run.fOverrideDescriptor, |
666 &fDeviceProperties, &viewMatrix, false); | 667 &fDeviceProperties, &viewMatrix, false); |
667 SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, | 668 SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface, |
668 subRun.fOverrideDescriptor->
getDesc()); | 669 run.fOverrideDescriptor->get
Desc()); |
669 this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(
), viewMatrix, | 670 this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(
), viewMatrix, |
670 fallbackTxt.begin(), fallbackTxt.count(), | 671 fallbackTxt.begin(), fallbackTxt.count(), |
671 fallbackPos.begin(), scalarsPerPosition, offset
, clipRect); | 672 fallbackPos.begin(), scalarsPerPosition, offset
, clipRect); |
672 SkGlyphCache::AttachCache(cache); | 673 SkGlyphCache::AttachCache(cache); |
673 } | 674 } |
674 | 675 |
675 inline GrAtlasTextContext::BitmapTextBlob* | 676 inline GrAtlasTextContext::BitmapTextBlob* |
676 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, | 677 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint, |
677 const SkMatrix& viewMatrix, SkGlyphCache** cache
, | 678 const SkMatrix& viewMatrix, SkGlyphCache** cache
, |
678 SkPaint* dfPaint, SkScalar* textRatio) { | 679 SkPaint* dfPaint, SkScalar* textRatio) { |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 // new strike, we instead keep our ref to the old strike and use
the packed ids from | 1596 // new strike, we instead keep our ref to the old strike and use
the packed ids from |
1596 // it. These ids will still be valid as long as we hold the ref
. When we are done | 1597 // it. These ids will still be valid as long as we hold the ref
. When we are done |
1597 // updating our cache of the GrGlyph*s, we drop our ref on the o
ld strike | 1598 // updating our cache of the GrGlyph*s, we drop our ref on the o
ld strike |
1598 bool regenerateGlyphs = false; | 1599 bool regenerateGlyphs = false; |
1599 GrBatchTextStrike* strike = NULL; | 1600 GrBatchTextStrike* strike = NULL; |
1600 if (regenerateTextureCoords) { | 1601 if (regenerateTextureCoords) { |
1601 info.fBulkUseToken.reset(); | 1602 info.fBulkUseToken.reset(); |
1602 | 1603 |
1603 // We can reuse if we have a valid strike and our descriptor
s / typeface are the | 1604 // We can reuse if we have a valid strike and our descriptor
s / typeface are the |
1604 // same | 1605 // same |
1605 const SkDescriptor* newDesc = info.fOverrideDescriptor ? | 1606 const SkDescriptor* newDesc = run.fOverrideDescriptor ? |
1606 info.fOverrideDescriptor->getD
esc() : | 1607 run.fOverrideDescriptor->getDe
sc() : |
1607 run.fDescriptor.getDesc(); | 1608 run.fDescriptor.getDesc(); |
1608 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) || | 1609 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) || |
1609 !(desc->equals(*newDesc))) { | 1610 !(desc->equals(*newDesc))) { |
1610 if (cache) { | 1611 if (cache) { |
1611 SkGlyphCache::AttachCache(cache); | 1612 SkGlyphCache::AttachCache(cache); |
1612 } | 1613 } |
1613 desc = newDesc; | 1614 desc = newDesc; |
1614 cache = SkGlyphCache::DetachCache(run.fTypeface, desc); | 1615 cache = SkGlyphCache::DetachCache(run.fTypeface, desc); |
1615 scaler = GrTextContext::GetGrFontScaler(cache); | 1616 scaler = GrTextContext::GetGrFontScaler(cache); |
1616 strike = run.fStrike; | 1617 strike = run.fStrike; |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 pipelineBuilder.setFromPaint(grPaint, rt, clip); | 2165 pipelineBuilder.setFromPaint(grPaint, rt, clip); |
2165 | 2166 |
2166 GrColor color = grPaint.getColor(); | 2167 GrColor color = grPaint.getColor(); |
2167 for (int run = 0; run < cacheBlob->fRunCount; run++) { | 2168 for (int run = 0; run < cacheBlob->fRunCount; run++) { |
2168 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk
Paint); | 2169 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk
Paint); |
2169 } | 2170 } |
2170 | 2171 |
2171 // Now flush big glyphs | 2172 // Now flush big glyphs |
2172 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); | 2173 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); |
2173 } | 2174 } |
OLD | NEW |