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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/gpu/GrAtlasTextBlob.h ('k') | src/gpu/GrBatchAtlas.h » ('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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrBatchFontCache.h" 9 #include "GrBatchFontCache.h"
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 }; 97 };
98 98
99 GrAtlasTextContext::GrAtlasTextContext(GrContext* context, 99 GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
100 GrDrawContext* drawContext, 100 GrDrawContext* drawContext,
101 const SkSurfaceProps& surfaceProps) 101 const SkSurfaceProps& surfaceProps)
102 : INHERITED(context, drawContext, surfaceProps), fDistanceAdjustTable(new Di stanceAdjustTable) { 102 : INHERITED(context, drawContext, surfaceProps), fDistanceAdjustTable(new Di stanceAdjustTable) {
103 // We overallocate vertices in our textblobs based on the assumption that A8 has the greatest 103 // We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
104 // vertexStride 104 // vertexStride
105 static_assert(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCD TextVASize, 105 static_assert(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCD TextVASize,
106 "vertex_attribute_changed"); 106 "vertex_attribute_changed");
107 fCurrStrike = NULL; 107 fCurrStrike = nullptr;
108 fCache = context->getTextBlobCache(); 108 fCache = context->getTextBlobCache();
109 } 109 }
110 110
111 void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() { 111 void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() {
112 112
113 // This is used for an approximation of the mask gamma hack, used by raster and bitmap 113 // This is used for an approximation of the mask gamma hack, used by raster and bitmap
114 // text. The mask gamma hack is based off of guessing what the blend color i s going to 114 // text. The mask gamma hack is based off of guessing what the blend color i s going to
115 // be, and adjusting the mask so that when run through the linear blend will 115 // be, and adjusting the mask so that when run through the linear blend will
116 // produce the value closest to the desired result. However, in practice thi s means 116 // produce the value closest to the desired result. However, in practice thi s means
117 // that the 'adjusted' mask is just increasing or decreasing the coverage of 117 // that the 'adjusted' mask is just increasing or decreasing the coverage of
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (this->canDrawAsDistanceFields(runPaint, viewMatrix)) { 530 if (this->canDrawAsDistanceFields(runPaint, viewMatrix)) {
531 cacheBlob->setHasDistanceField(); 531 cacheBlob->setHasDistanceField();
532 SkPaint dfPaint = runPaint; 532 SkPaint dfPaint = runPaint;
533 SkScalar textRatio; 533 SkScalar textRatio;
534 this->initDistanceFieldPaint(cacheBlob, &dfPaint, &textRatio, viewMa trix); 534 this->initDistanceFieldPaint(cacheBlob, &dfPaint, &textRatio, viewMa trix);
535 Run& runIdx = cacheBlob->fRuns[run]; 535 Run& runIdx = cacheBlob->fRuns[run];
536 PerSubRunInfo& subRun = runIdx.fSubRunInfo.back(); 536 PerSubRunInfo& subRun = runIdx.fSubRunInfo.back();
537 subRun.fUseLCDText = runPaint.isLCDRenderText(); 537 subRun.fUseLCDText = runPaint.isLCDRenderText();
538 subRun.fDrawAsDistanceFields = true; 538 subRun.fDrawAsDistanceFields = true;
539 539
540 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], dfPai nt, NULL, true); 540 SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], dfPai nt, nullptr, true);
541 541
542 SkTDArray<char> fallbackTxt; 542 SkTDArray<char> fallbackTxt;
543 SkTDArray<SkScalar> fallbackPos; 543 SkTDArray<SkScalar> fallbackPos;
544 SkPoint dfOffset; 544 SkPoint dfOffset;
545 int scalarsPerPosition = 2; 545 int scalarsPerPosition = 2;
546 switch (it.positioning()) { 546 switch (it.positioning()) {
547 case SkTextBlob::kDefault_Positioning: { 547 case SkTextBlob::kDefault_Positioning: {
548 this->internalDrawDFText(cacheBlob, run, cache, dfPaint, col or, viewMatrix, 548 this->internalDrawDFText(cacheBlob, run, cache, dfPaint, col or, viewMatrix,
549 (const char *)it.glyphs(), textLen, 549 (const char *)it.glyphs(), textLen,
550 x + offset.x(), y + offset.y(), cli pRect, textRatio, 550 x + offset.x(), y + offset.y(), cli pRect, textRatio,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize); 697 GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
698 698
699 *dfPaint = origPaint; 699 *dfPaint = origPaint;
700 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix); 700 this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix);
701 blob->fViewMatrix = viewMatrix; 701 blob->fViewMatrix = viewMatrix;
702 Run& run = blob->fRuns[0]; 702 Run& run = blob->fRuns[0];
703 PerSubRunInfo& subRun = run.fSubRunInfo.back(); 703 PerSubRunInfo& subRun = run.fSubRunInfo.back();
704 subRun.fUseLCDText = origPaint.isLCDRenderText(); 704 subRun.fUseLCDText = origPaint.isLCDRenderText();
705 subRun.fDrawAsDistanceFields = true; 705 subRun.fDrawAsDistanceFields = true;
706 706
707 *cache = this->setupCache(&blob->fRuns[0], *dfPaint, NULL, true); 707 *cache = this->setupCache(&blob->fRuns[0], *dfPaint, nullptr, true);
708 return blob; 708 return blob;
709 } 709 }
710 710
711 inline GrAtlasTextBlob* 711 inline GrAtlasTextBlob*
712 GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip, 712 GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
713 const GrPaint& paint, const SkPaint& skPa int, 713 const GrPaint& paint, const SkPaint& skPa int,
714 const SkMatrix& viewMatrix, 714 const SkMatrix& viewMatrix,
715 const char text[], size_t byteLength, 715 const char text[], size_t byteLength,
716 SkScalar x, SkScalar y, const SkIRect& re gionClipBounds) { 716 SkScalar x, SkScalar y, const SkIRect& re gionClipBounds) {
717 int glyphCount = skPaint.countText(text, byteLength); 717 int glyphCount = skPaint.countText(text, byteLength);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 816
817 this->flush(blob, rt, skPaint, paint, clip, regionClipBounds); 817 this->flush(blob, rt, skPaint, paint, clip, regionClipBounds);
818 } 818 }
819 819
820 void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex , 820 void GrAtlasTextContext::internalDrawBMPText(GrAtlasTextBlob* blob, int runIndex ,
821 SkGlyphCache* cache, const SkPaint& skPaint, 821 SkGlyphCache* cache, const SkPaint& skPaint,
822 GrColor color, 822 GrColor color,
823 const SkMatrix& viewMatrix, 823 const SkMatrix& viewMatrix,
824 const char text[], size_t byteLengt h, 824 const char text[], size_t byteLengt h,
825 SkScalar x, SkScalar y, const SkIRe ct& clipRect) { 825 SkScalar x, SkScalar y, const SkIRe ct& clipRect) {
826 SkASSERT(byteLength == 0 || text != NULL); 826 SkASSERT(byteLength == 0 || text != nullptr);
827 827
828 // nothing to draw 828 // nothing to draw
829 if (text == NULL || byteLength == 0) { 829 if (text == nullptr || byteLength == 0) {
830 return; 830 return;
831 } 831 }
832 832
833 fCurrStrike = NULL; 833 fCurrStrike = nullptr;
834 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); 834 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
835 835
836 // Get GrFontScaler from cache 836 // Get GrFontScaler from cache
837 GrFontScaler* fontScaler = GetGrFontScaler(cache); 837 GrFontScaler* fontScaler = GetGrFontScaler(cache);
838 838
839 // transform our starting point 839 // transform our starting point
840 { 840 {
841 SkPoint loc; 841 SkPoint loc;
842 viewMatrix.mapXY(x, y, &loc); 842 viewMatrix.mapXY(x, y, &loc);
843 x = loc.fX; 843 x = loc.fX;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 } 905 }
906 } 906 }
907 907
908 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn dex, 908 void GrAtlasTextContext::internalDrawBMPPosText(GrAtlasTextBlob* blob, int runIn dex,
909 SkGlyphCache* cache, const SkPai nt& skPaint, 909 SkGlyphCache* cache, const SkPai nt& skPaint,
910 GrColor color, 910 GrColor color,
911 const SkMatrix& viewMatrix, 911 const SkMatrix& viewMatrix,
912 const char text[], size_t byteLe ngth, 912 const char text[], size_t byteLe ngth,
913 const SkScalar pos[], int scalar sPerPosition, 913 const SkScalar pos[], int scalar sPerPosition,
914 const SkPoint& offset, const SkI Rect& clipRect) { 914 const SkPoint& offset, const SkI Rect& clipRect) {
915 SkASSERT(byteLength == 0 || text != NULL); 915 SkASSERT(byteLength == 0 || text != nullptr);
916 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 916 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
917 917
918 // nothing to draw 918 // nothing to draw
919 if (text == NULL || byteLength == 0) { 919 if (text == nullptr || byteLength == 0) {
920 return; 920 return;
921 } 921 }
922 922
923 fCurrStrike = NULL; 923 fCurrStrike = nullptr;
924 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); 924 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
925 925
926 // Get GrFontScaler from cache 926 // Get GrFontScaler from cache
927 GrFontScaler* fontScaler = GetGrFontScaler(cache); 927 GrFontScaler* fontScaler = GetGrFontScaler(cache);
928 928
929 const char* stop = text + byteLength; 929 const char* stop = text + byteLength;
930 SkTextAlignProc alignProc(skPaint.getTextAlign()); 930 SkTextAlignProc alignProc(skPaint.getTextAlign());
931 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); 931 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition);
932 932
933 if (cache->isSubpixel()) { 933 if (cache->isSubpixel()) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 SkGlyphCache* cache, const SkPaint& skPaint, 1062 SkGlyphCache* cache, const SkPaint& skPaint,
1063 GrColor color, 1063 GrColor color,
1064 const SkMatrix& viewMatrix, 1064 const SkMatrix& viewMatrix,
1065 const char text[], size_t byteLength , 1065 const char text[], size_t byteLength ,
1066 SkScalar x, SkScalar y, const SkIRec t& clipRect, 1066 SkScalar x, SkScalar y, const SkIRec t& clipRect,
1067 SkScalar textRatio, 1067 SkScalar textRatio,
1068 SkTDArray<char>* fallbackTxt, 1068 SkTDArray<char>* fallbackTxt,
1069 SkTDArray<SkScalar>* fallbackPos, 1069 SkTDArray<SkScalar>* fallbackPos,
1070 SkPoint* offset, 1070 SkPoint* offset,
1071 const SkPaint& origPaint) { 1071 const SkPaint& origPaint) {
1072 SkASSERT(byteLength == 0 || text != NULL); 1072 SkASSERT(byteLength == 0 || text != nullptr);
1073 1073
1074 // nothing to draw 1074 // nothing to draw
1075 if (text == NULL || byteLength == 0) { 1075 if (text == nullptr || byteLength == 0) {
1076 return; 1076 return;
1077 } 1077 }
1078 1078
1079 SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc(); 1079 SkDrawCacheProc glyphCacheProc = origPaint.getDrawCacheProc();
1080 SkAutoDescriptor desc; 1080 SkAutoDescriptor desc;
1081 origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, NULL, true); 1081 origPaint.getScalerContextDescriptor(&desc, fSurfaceProps, nullptr, true);
1082 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa ce(), 1082 SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(origPaint.getTypefa ce(),
1083 desc.getDesc()); 1083 desc.getDesc());
1084 1084
1085 SkTArray<SkScalar> positions; 1085 SkTArray<SkScalar> positions;
1086 1086
1087 const char* textPtr = text; 1087 const char* textPtr = text;
1088 SkFixed stopX = 0; 1088 SkFixed stopX = 0;
1089 SkFixed stopY = 0; 1089 SkFixed stopY = 0;
1090 SkFixed origin = 0; 1090 SkFixed origin = 0;
1091 switch (origPaint.getTextAlign()) { 1091 switch (origPaint.getTextAlign()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 SkGlyphCache* cache, const SkPain t& skPaint, 1136 SkGlyphCache* cache, const SkPain t& skPaint,
1137 GrColor color, 1137 GrColor color,
1138 const SkMatrix& viewMatrix, 1138 const SkMatrix& viewMatrix,
1139 const char text[], size_t byteLen gth, 1139 const char text[], size_t byteLen gth,
1140 const SkScalar pos[], int scalars PerPosition, 1140 const SkScalar pos[], int scalars PerPosition,
1141 const SkPoint& offset, const SkIR ect& clipRect, 1141 const SkPoint& offset, const SkIR ect& clipRect,
1142 SkScalar textRatio, 1142 SkScalar textRatio,
1143 SkTDArray<char>* fallbackTxt, 1143 SkTDArray<char>* fallbackTxt,
1144 SkTDArray<SkScalar>* fallbackPos) { 1144 SkTDArray<SkScalar>* fallbackPos) {
1145 1145
1146 SkASSERT(byteLength == 0 || text != NULL); 1146 SkASSERT(byteLength == 0 || text != nullptr);
1147 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 1147 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
1148 1148
1149 // nothing to draw 1149 // nothing to draw
1150 if (text == NULL || byteLength == 0) { 1150 if (text == nullptr || byteLength == 0) {
1151 return; 1151 return;
1152 } 1152 }
1153 1153
1154 fCurrStrike = NULL; 1154 fCurrStrike = nullptr;
1155 1155
1156 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc(); 1156 SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
1157 GrFontScaler* fontScaler = GetGrFontScaler(cache); 1157 GrFontScaler* fontScaler = GetGrFontScaler(cache);
1158 1158
1159 const char* stop = text + byteLength; 1159 const char* stop = text + byteLength;
1160 1160
1161 if (SkPaint::kLeft_Align == skPaint.getTextAlign()) { 1161 if (SkPaint::kLeft_Align == skPaint.getTextAlign()) {
1162 while (text < stop) { 1162 while (text < stop) {
1163 const char* lastText = text; 1163 const char* lastText = text;
1164 // the last 2 parameters are ignored 1164 // the last 2 parameters are ignored
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 bool useColorVerts = !subRun->fUseLCDText; 1357 bool useColorVerts = !subRun->fUseLCDText;
1358 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts, 1358 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts,
1359 glyph); 1359 glyph);
1360 return true; 1360 return true;
1361 } 1361 }
1362 1362
1363 inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph, 1363 inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph,
1364 GrFontScaler* scaler, const SkGl yph& skGlyph, 1364 GrFontScaler* scaler, const SkGl yph& skGlyph,
1365 SkScalar x, SkScalar y, SkScalar scale, 1365 SkScalar x, SkScalar y, SkScalar scale,
1366 bool applyVM) { 1366 bool applyVM) {
1367 if (NULL == glyph->fPath) { 1367 if (nullptr == glyph->fPath) {
1368 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph); 1368 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
1369 if (!glyphPath) { 1369 if (!glyphPath) {
1370 return; 1370 return;
1371 } 1371 }
1372 1372
1373 glyph->fPath = new SkPath(*glyphPath); 1373 glyph->fPath = new SkPath(*glyphPath);
1374 } 1374 }
1375 blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, sc ale, applyVM)); 1375 blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, sc ale, applyVM));
1376 } 1376 }
1377 1377
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuf fer()); 1617 flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuf fer());
1618 if (!vertices || !flushInfo.fVertexBuffer) { 1618 if (!vertices || !flushInfo.fVertexBuffer) {
1619 SkDebugf("Could not allocate vertices\n"); 1619 SkDebugf("Could not allocate vertices\n");
1620 return; 1620 return;
1621 } 1621 }
1622 1622
1623 unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices); 1623 unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices);
1624 1624
1625 // We cache some values to avoid going to the glyphcache for the same fo ntScaler twice 1625 // We cache some values to avoid going to the glyphcache for the same fo ntScaler twice
1626 // in a row 1626 // in a row
1627 const SkDescriptor* desc = NULL; 1627 const SkDescriptor* desc = nullptr;
1628 SkGlyphCache* cache = NULL; 1628 SkGlyphCache* cache = nullptr;
1629 GrFontScaler* scaler = NULL; 1629 GrFontScaler* scaler = nullptr;
1630 SkTypeface* typeface = NULL; 1630 SkTypeface* typeface = nullptr;
1631 1631
1632 for (int i = 0; i < fGeoCount; i++) { 1632 for (int i = 0; i < fGeoCount; i++) {
1633 Geometry& args = fGeoData[i]; 1633 Geometry& args = fGeoData[i];
1634 Blob* blob = args.fBlob; 1634 Blob* blob = args.fBlob;
1635 Run& run = blob->fRuns[args.fRun]; 1635 Run& run = blob->fRuns[args.fRun];
1636 TextInfo& info = run.fSubRunInfo[args.fSubRun]; 1636 TextInfo& info = run.fSubRunInfo[args.fSubRun];
1637 1637
1638 uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat); 1638 uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat);
1639 bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlas Gen || 1639 bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlas Gen ||
1640 info.fStrike->isAbandoned(); 1640 info.fStrike->isAbandoned();
(...skipping 20 matching lines...) Expand all
1661 1661
1662 // Because the GrBatchFontCache may evict the strike a blob depe nds on using for 1662 // Because the GrBatchFontCache may evict the strike a blob depe nds on using for
1663 // generating its texture coords, we have to track whether or no t the strike has 1663 // generating its texture coords, we have to track whether or no t the strike has
1664 // been abandoned. If it hasn't been abandoned, then we can use the GrGlyph*s as is 1664 // been abandoned. If it hasn't been abandoned, then we can use the GrGlyph*s as is
1665 // otherwise we have to get the new strike, and use that to get the correct glyphs. 1665 // otherwise we have to get the new strike, and use that to get the correct glyphs.
1666 // Because we do not have the packed ids, and thus can't look up our glyphs in the 1666 // Because we do not have the packed ids, and thus can't look up our glyphs in the
1667 // new strike, we instead keep our ref to the old strike and use the packed ids from 1667 // new strike, we instead keep our ref to the old strike and use the packed ids from
1668 // it. These ids will still be valid as long as we hold the ref . When we are done 1668 // it. These ids will still be valid as long as we hold the ref . When we are done
1669 // updating our cache of the GrGlyph*s, we drop our ref on the o ld strike 1669 // updating our cache of the GrGlyph*s, we drop our ref on the o ld strike
1670 bool regenerateGlyphs = false; 1670 bool regenerateGlyphs = false;
1671 GrBatchTextStrike* strike = NULL; 1671 GrBatchTextStrike* strike = nullptr;
1672 if (regenerateTextureCoords) { 1672 if (regenerateTextureCoords) {
1673 info.fBulkUseToken.reset(); 1673 info.fBulkUseToken.reset();
1674 1674
1675 // We can reuse if we have a valid strike and our descriptor s / typeface are the 1675 // We can reuse if we have a valid strike and our descriptor s / typeface are the
1676 // same 1676 // same
1677 const SkDescriptor* newDesc = run.fOverrideDescriptor ? 1677 const SkDescriptor* newDesc = run.fOverrideDescriptor ?
1678 run.fOverrideDescriptor->getDe sc() : 1678 run.fOverrideDescriptor->getDe sc() :
1679 run.fDescriptor.getDesc(); 1679 run.fDescriptor.getDesc();
1680 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) || 1680 if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) ||
1681 !(desc->equals(*newDesc))) { 1681 !(desc->equals(*newDesc))) {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 // Now flush big glyphs 2224 // Now flush big glyphs
2225 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds); 2225 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds);
2226 } 2226 }
2227 2227
2228 //////////////////////////////////////////////////////////////////////////////// /////////////////// 2228 //////////////////////////////////////////////////////////////////////////////// ///////////////////
2229 2229
2230 #ifdef GR_TEST_UTILS 2230 #ifdef GR_TEST_UTILS
2231 2231
2232 DRAW_BATCH_TEST_DEFINE(TextBlobBatch) { 2232 DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
2233 static uint32_t gContextID = SK_InvalidGenID; 2233 static uint32_t gContextID = SK_InvalidGenID;
2234 static GrAtlasTextContext* gTextContext = NULL; 2234 static GrAtlasTextContext* gTextContext = nullptr;
2235 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType ); 2235 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType );
2236 2236
2237 if (context->uniqueID() != gContextID) { 2237 if (context->uniqueID() != gContextID) {
2238 gContextID = context->uniqueID(); 2238 gContextID = context->uniqueID();
2239 delete gTextContext; 2239 delete gTextContext;
2240 2240
2241 // We don't yet test the fall back to paths in the GrTextContext base cl ass. This is mostly 2241 // We don't yet test the fall back to paths in the GrTextContext base cl ass. This is mostly
2242 // because we don't really want to have a gpu device here. 2242 // because we don't really want to have a gpu device here.
2243 // We enable distance fields by twiddling a knob on the paint 2243 // We enable distance fields by twiddling a knob on the paint
2244 GrDrawContext* drawContext = context->drawContext(&gSurfaceProps); 2244 GrDrawContext* drawContext = context->drawContext(&gSurfaceProps);
2245 2245
2246 gTextContext = GrAtlasTextContext::Create(context, drawContext, gSurface Props); 2246 gTextContext = GrAtlasTextContext::Create(context, drawContext, gSurface Props);
2247 } 2247 }
2248 2248
2249 // create dummy render target 2249 // create dummy render target
2250 GrSurfaceDesc desc; 2250 GrSurfaceDesc desc;
2251 desc.fFlags = kRenderTarget_GrSurfaceFlag; 2251 desc.fFlags = kRenderTarget_GrSurfaceFlag;
2252 desc.fWidth = 1024; 2252 desc.fWidth = 1024;
2253 desc.fHeight = 1024; 2253 desc.fHeight = 1024;
2254 desc.fConfig = kRGBA_8888_GrPixelConfig; 2254 desc.fConfig = kRGBA_8888_GrPixelConfig;
2255 desc.fSampleCnt = 0; 2255 desc.fSampleCnt = 0;
2256 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, NULL, 0)); 2256 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de sc, true, nullptr, 0));
2257 SkASSERT(texture); 2257 SkASSERT(texture);
2258 SkASSERT(NULL != texture->asRenderTarget()); 2258 SkASSERT(nullptr != texture->asRenderTarget());
2259 GrRenderTarget* rt = texture->asRenderTarget(); 2259 GrRenderTarget* rt = texture->asRenderTarget();
2260 2260
2261 // Setup dummy SkPaint / GrPaint 2261 // Setup dummy SkPaint / GrPaint
2262 GrColor color = GrRandomColor(random); 2262 GrColor color = GrRandomColor(random);
2263 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 2263 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
2264 SkPaint skPaint; 2264 SkPaint skPaint;
2265 skPaint.setColor(color); 2265 skPaint.setColor(color);
2266 skPaint.setLCDRenderText(random->nextBool()); 2266 skPaint.setLCDRenderText(random->nextBool());
2267 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); 2267 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool());
2268 skPaint.setSubpixelText(random->nextBool()); 2268 skPaint.setSubpixelText(random->nextBool());
(...skipping 16 matching lines...) Expand all
2285 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2285 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2286 static_cast<size_t>(textLen), 0, 0, noClip)); 2286 static_cast<size_t>(textLen), 0, 0, noClip));
2287 2287
2288 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2288 SkScalar transX = static_cast<SkScalar>(random->nextU());
2289 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2289 SkScalar transY = static_cast<SkScalar>(random->nextU());
2290 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2290 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2291 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2291 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2292 } 2292 }
2293 2293
2294 #endif 2294 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextBlob.h ('k') | src/gpu/GrBatchAtlas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698