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

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

Issue 1061713003: Revert of Adding bulk plot reffer to cached textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atlastext
Patch Set: 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();
825 desc = run.fDescriptor.getDesc(); 824 desc = run.fDescriptor.getDesc();
826 cache = SkGlyphCache::DetachCache(run.fTypeface, desc); 825 cache = SkGlyphCache::DetachCache(run.fTypeface, desc);
827 scaler = GrTextContext::GetGrFontScaler(cache); 826 scaler = GrTextContext::GetGrFontScaler(cache);
828 strike = fFontCache->getStrike(scaler); 827 strike = fFontCache->getStrike(scaler);
829 } 828 }
830 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) { 829 for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) {
831 GrGlyph::PackedID glyphID = blob->fGlyphIDs[glyphIdx + info. fGlyphStartIndex]; 830 GrGlyph::PackedID glyphID = blob->fGlyphIDs[glyphIdx + info. fGlyphStartIndex];
832 831
833 if (regenerateTextureCoords) { 832 if (regenerateTextureCoords) {
834 // Upload the glyph only if needed 833 // Upload the glyph only if needed
835 GrGlyph* glyph = strike->getGlyph(glyphID, scaler); 834 GrGlyph* glyph = strike->getGlyph(glyphID, scaler);
836 SkASSERT(glyph); 835 SkASSERT(glyph);
837 836
838 if (!fFontCache->hasGlyph(glyph) && 837 if (!fFontCache->hasGlyph(glyph) &&
839 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) { 838 !strike->addGlyphToAtlas(batchTarget, glyph, scaler) ) {
840 this->flush(batchTarget, &drawInfo, instancesToFlush , 839 this->flush(batchTarget, &drawInfo, instancesToFlush ,
841 maxInstancesPerDraw); 840 maxInstancesPerDraw);
842 this->initDraw(batchTarget, gp, pipeline); 841 this->initDraw(batchTarget, gp, pipeline);
843 instancesToFlush = 0; 842 instancesToFlush = 0;
844 brokenRun = glyphIdx > 0; 843 brokenRun = glyphIdx > 0;
845 844
846 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget, glyph, 845 SkDEBUGCODE(bool success =) strike->addGlyphToAtlas( batchTarget, glyph,
847 scaler); 846 scaler);
848 SkASSERT(success); 847 SkASSERT(success);
849 } 848 }
850 fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseT oken, glyph, 849
851 batchTarget->cu rrentToken()); 850 fFontCache->setGlyphRefToken(glyph, batchTarget->current Token());
852 851
853 // Texture coords are the last vertex attribute so we ge t a pointer to the 852 // Texture coords are the last vertex attribute so we ge t a pointer to the
854 // first one and then map with stride in regenerateTextu reCoords 853 // first one and then map with stride in regenerateTextu reCoords
855 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices); 854 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices);
856 vertex += info.fVertexStartIndex; 855 vertex += info.fVertexStartIndex;
857 vertex += vertexStride * glyphIdx * kVerticesPerGlyph; 856 vertex += vertexStride * glyphIdx * kVerticesPerGlyph;
858 vertex += vertexStride - sizeof(SkIPoint16); 857 vertex += vertexStride - sizeof(SkIPoint16);
859 858
860 this->regenerateTextureCoords(glyph, vertex, vertexStrid e); 859 this->regenerateTextureCoords(glyph, vertex, vertexStrid e);
861 } 860 }
862 861
863 if (regenerateColors) { 862 if (regenerateColors) {
864 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices); 863 intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVert ices);
865 vertex += info.fVertexStartIndex; 864 vertex += info.fVertexStartIndex;
866 vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint); 865 vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint);
867 this->regenerateColors(vertex, vertexStride, args.fColor ); 866 this->regenerateColors(vertex, vertexStride, args.fColor );
868 } 867 }
869 868
870 instancesToFlush++; 869 instancesToFlush++;
871 } 870 }
872 871
873 if (regenerateTextureCoords) { 872 if (regenerateTextureCoords) {
874 SkGlyphCache::AttachCache(cache); 873 SkGlyphCache::AttachCache(cache);
875 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration : 874 info.fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAt lasGeneration :
876 fFontCache->atlasGenerat ion(fMaskFormat); 875 fFontCache->atlasGenerat ion(fMaskFormat);
877 } 876 }
878 } else { 877 } else {
879 instancesToFlush += glyphCount; 878 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);
886 } 879 }
887 880
888 // now copy all vertices 881 // now copy all vertices
889 size_t byteCount = info.fVertexEndIndex - info.fVertexStartIndex; 882 size_t byteCount = info.fVertexEndIndex - info.fVertexStartIndex;
890 memcpy(currVertex, blob->fVertices + info.fVertexStartIndex, byteCou nt); 883 memcpy(currVertex, blob->fVertices + info.fVertexStartIndex, byteCou nt);
891 884
892 currVertex += byteCount; 885 currVertex += byteCount;
893 } 886 }
894 887
895 this->flush(batchTarget, &drawInfo, instancesToFlush, maxInstancesPerDra w); 888 this->flush(batchTarget, &drawInfo, instancesToFlush, maxInstancesPerDra w);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 1131
1139 GrColor color = grPaint.getColor(); 1132 GrColor color = grPaint.getColor();
1140 uint8_t paintAlpha = skPaint.getAlpha(); 1133 uint8_t paintAlpha = skPaint.getAlpha();
1141 for (int run = 0; run < cacheBlob->fRunCount; run++) { 1134 for (int run = 0; run < cacheBlob->fRunCount; run++) {
1142 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, paintAlp ha); 1135 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, paintAlp ha);
1143 } 1136 }
1144 1137
1145 // Now flush big glyphs 1138 // Now flush big glyphs
1146 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip); 1139 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip);
1147 } 1140 }
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