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

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

Issue 1050113004: Adding bulk plot reffer to cached textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atlastext
Patch Set: rebase Created 5 years, 8 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/GrAtlasTextContext.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 "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 // then we can't really trust the atlas has all of the correct data. Atlas evictions 814 // then we can't really trust the atlas has all of the correct data. Atlas evictions
815 // should be pretty rare, so we just always regenerate in those case s 815 // should be pretty rare, so we just always regenerate in those case s
816 if (regenerateTextureCoords || regenerateColors) { 816 if (regenerateTextureCoords || regenerateColors) {
817 // first regenerate texture coordinates / colors if need be 817 // first regenerate texture coordinates / colors if need be
818 const SkDescriptor* desc = NULL; 818 const SkDescriptor* desc = NULL;
819 SkGlyphCache* cache = NULL; 819 SkGlyphCache* cache = NULL;
820 GrFontScaler* scaler = NULL; 820 GrFontScaler* scaler = NULL;
821 GrBatchTextStrike* strike = NULL; 821 GrBatchTextStrike* strike = NULL;
822 bool brokenRun = false; 822 bool brokenRun = false;
823 if (regenerateTextureCoords) { 823 if (regenerateTextureCoords) {
824 info.fBulkUseToken.reset();
824 desc = run.fDescriptor.getDesc(); 825 desc = run.fDescriptor.getDesc();
825 cache = SkGlyphCache::DetachCache(run.fTypeface, desc); 826 cache = SkGlyphCache::DetachCache(run.fTypeface, desc);
826 scaler = GrTextContext::GetGrFontScaler(cache); 827 scaler = GrTextContext::GetGrFontScaler(cache);
827 strike = fFontCache->getStrike(scaler); 828 strike = fFontCache->getStrike(scaler);
828 } 829 }
829 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) { 830 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) {
830 GrGlyph::PackedID glyphID = blob->fGlyphIDs[glyphIdx + info. fGlyphStartIndex]; 831 GrGlyph::PackedID glyphID = blob->fGlyphIDs[glyphIdx + info. fGlyphStartIndex];
831 832
832 if (regenerateTextureCoords) { 833 if (regenerateTextureCoords) {
833 // Upload the glyph only if needed 834 // Upload the glyph only if needed
834 GrGlyph* glyph = strike->getGlyph(glyphID, scaler); 835 GrGlyph* glyph = strike->getGlyph(glyphID, scaler);
835 SkASSERT(glyph); 836 SkASSERT(glyph);
836 837
837 if (!fFontCache->hasGlyph(glyph) && 838 if (!fFontCache->hasGlyph(glyph) &&
838 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) { 839 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) {
839 this->flush(batchTarget, &drawInfo, instancesToFlush , 840 this->flush(batchTarget, &drawInfo, instancesToFlush ,
840 maxInstancesPerDraw); 841 maxInstancesPerDraw);
841 this->initDraw(batchTarget, gp, pipeline); 842 this->initDraw(batchTarget, gp, pipeline);
842 instancesToFlush = 0; 843 instancesToFlush = 0;
843 brokenRun = glyphIdx > 0; 844 brokenRun = glyphIdx > 0;
844 845
845 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget, glyph, 846 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget, glyph,
846 scaler); 847 scaler);
847 SkASSERT(success); 848 SkASSERT(success);
848 } 849 }
849 850 fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseT oken, glyph,
850 fFontCache->setGlyphRefToken(glyph, batchTarget->current Token()); 851 batchTarget->cu rrentToken());
851 852
852 // Texture coords are the last vertex attribute so we ge t a pointer to the 853 // Texture coords are the last vertex attribute so we ge t a pointer to the
853 // first one and then map with stride in regenerateTextu reCoords 854 // first one and then map with stride in regenerateTextu reCoords
854 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices); 855 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices);
855 vertex += info.fVertexStartIndex; 856 vertex += info.fVertexStartIndex;
856 vertex += vertexStride * glyphIdx * kVerticesPerGlyph; 857 vertex += vertexStride * glyphIdx * kVerticesPerGlyph;
857 vertex += vertexStride - sizeof(SkIPoint16); 858 vertex += vertexStride - sizeof(SkIPoint16);
858 859
859 this->regenerateTextureCoords(glyph, vertex, vertexStrid e); 860 this->regenerateTextureCoords(glyph, vertex, vertexStrid e);
860 } 861 }
861 862
862 if (regenerateColors) { 863 if (regenerateColors) {
863 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices); 864 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices);
864 vertex += info.fVertexStartIndex; 865 vertex += info.fVertexStartIndex;
865 vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint); 866 vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint);
866 this->regenerateColors(vertex, vertexStride, args.fColor ); 867 this->regenerateColors(vertex, vertexStride, args.fColor );
867 } 868 }
868 869
869 instancesToFlush++; 870 instancesToFlush++;
870 } 871 }
871 872
872 if (regenerateTextureCoords) { 873 if (regenerateTextureCoords) {
873 SkGlyphCache::AttachCache(cache); 874 SkGlyphCache::AttachCache(cache);
874 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration : 875 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration :
875 fFontCache->atlasGenerat ion(fMaskFormat); 876 fFontCache->atlasGenerat ion(fMaskFormat);
876 } 877 }
877 } else { 878 } else {
878 instancesToFlush += glyphCount; 879 instancesToFlush += glyphCount;
880
881 // set use tokens for all of the glyphs in our subrun. This is only valid if we
882 // have a valid atlas generation
883 fFontCache->setUseTokenBulk(info.fBulkUseToken,
884 batchTarget->currentToken(),
885 fMaskFormat);
879 } 886 }
880 887
881 // now copy all vertices 888 // now copy all vertices
882 size_t byteCount = info.fVertexEndIndex - info.fVertexStartIndex; 889 size_t byteCount = info.fVertexEndIndex - info.fVertexStartIndex;
883 memcpy(currVertex, blob->fVertices + info.fVertexStartIndex, byteCou nt); 890 memcpy(currVertex, blob->fVertices + info.fVertexStartIndex, byteCou nt);
884 891
885 currVertex += byteCount; 892 currVertex += byteCount;
886 } 893 }
887 894
888 this->flush(batchTarget, &drawInfo, instancesToFlush, maxInstancesPerDra w); 895 this->flush(batchTarget, &drawInfo, instancesToFlush, maxInstancesPerDra w);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1138
1132 GrColor color = grPaint.getColor(); 1139 GrColor color = grPaint.getColor();
1133 uint8_t paintAlpha = skPaint.getAlpha(); 1140 uint8_t paintAlpha = skPaint.getAlpha();
1134 for (int run = 0; run < cacheBlob->fRunCount; run++) { 1141 for (int run = 0; run < cacheBlob->fRunCount; run++) {
1135 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, paintAlp ha); 1142 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, paintAlp ha);
1136 } 1143 }
1137 1144
1138 // Now flush big glyphs 1145 // Now flush big glyphs
1139 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip); 1146 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip);
1140 } 1147 }
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | src/gpu/GrBatchAtlas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698