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

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

Issue 1315933002: Fix for distance field draw large glyph as paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix 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/GrAtlasTextContext.h ('k') | no next file » | 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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 SkScalarTruncToInt(dstRect.top()), 1334 SkScalarTruncToInt(dstRect.top()),
1335 SkScalarTruncToInt(dstRect.right()), 1335 SkScalarTruncToInt(dstRect.right()),
1336 SkScalarTruncToInt(dstRect.bottom()))) { 1336 SkScalarTruncToInt(dstRect.bottom()))) {
1337 return true; 1337 return true;
1338 } 1338 }
1339 #endif 1339 #endif
1340 1340
1341 // TODO combine with the above 1341 // TODO combine with the above
1342 // If the glyph is too large we fall back to paths 1342 // If the glyph is too large we fall back to paths
1343 if (glyph->fTooLargeForAtlas) { 1343 if (glyph->fTooLargeForAtlas) {
1344 this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy); 1344 this->appendGlyphPath(blob, glyph, scaler, skGlyph, sx - dx, sy - dy, sc ale, true);
1345 return true; 1345 return true;
1346 } 1346 }
1347 1347
1348 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); 1348 PerSubRunInfo* subRun = &run.fSubRunInfo.back();
1349 if (!run.fInitialized) { 1349 if (!run.fInitialized) {
1350 subRun->fStrike.reset(SkRef(fCurrStrike)); 1350 subRun->fStrike.reset(SkRef(fCurrStrike));
1351 } 1351 }
1352 run.fInitialized = true; 1352 run.fInitialized = true;
1353 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat); 1353 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat);
1354 subRun->fMaskFormat = kA8_GrMaskFormat; 1354 subRun->fMaskFormat = kA8_GrMaskFormat;
1355 1355
1356 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD Text); 1356 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD Text);
1357 1357
1358 bool useColorVerts = !subRun->fUseLCDText; 1358 bool useColorVerts = !subRun->fUseLCDText;
1359 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts, 1359 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts,
1360 glyph); 1360 glyph);
1361 return true; 1361 return true;
1362 } 1362 }
1363 1363
1364 inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph, 1364 inline void GrAtlasTextContext::appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph,
1365 GrFontScaler* scaler, const SkGl yph& skGlyph, 1365 GrFontScaler* scaler, const SkGl yph& skGlyph,
1366 SkScalar x, SkScalar y) { 1366 SkScalar x, SkScalar y, SkScalar scale,
1367 bool applyVM) {
1367 if (NULL == glyph->fPath) { 1368 if (NULL == glyph->fPath) {
1368 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph); 1369 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph);
1369 if (!glyphPath) { 1370 if (!glyphPath) {
1370 return; 1371 return;
1371 } 1372 }
1372 1373
1373 glyph->fPath = SkNEW_ARGS(SkPath, (*glyphPath)); 1374 glyph->fPath = SkNEW_ARGS(SkPath, (*glyphPath));
1374 } 1375 }
1375 blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y)); 1376 blob->fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, sc ale, applyVM));
1376 } 1377 }
1377 1378
1378 inline void GrAtlasTextContext::appendGlyphCommon(GrAtlasTextBlob* blob, Run* ru n, 1379 inline void GrAtlasTextContext::appendGlyphCommon(GrAtlasTextBlob* blob, Run* ru n,
1379 Run::SubRunInfo* subRun, 1380 Run::SubRunInfo* subRun,
1380 const SkRect& positions, GrCol or color, 1381 const SkRect& positions, GrCol or color,
1381 size_t vertexStride, bool useV ertexColor, 1382 size_t vertexStride, bool useV ertexColor,
1382 GrGlyph* glyph) { 1383 GrGlyph* glyph) {
1383 blob->fGlyphs[subRun->fGlyphEndIndex] = glyph; 1384 blob->fGlyphs[subRun->fGlyphEndIndex] = glyph;
1384 run->fVertexBounds.joinNonEmptyArg(positions); 1385 run->fVertexBounds.joinNonEmptyArg(positions);
1385 run->fColor = color; 1386 run->fColor = color;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 if (fFilteredColor != that->fFilteredColor) { 1925 if (fFilteredColor != that->fFilteredColor) {
1925 return false; 1926 return false;
1926 } 1927 }
1927 1928
1928 if (fUseBGR != that->fUseBGR) { 1929 if (fUseBGR != that->fUseBGR) {
1929 return false; 1930 return false;
1930 } 1931 }
1931 1932
1932 // TODO see note above 1933 // TODO see note above
1933 if (kLCDDistanceField_MaskType == fMaskType && this->color() != that ->color()) { 1934 if (kLCDDistanceField_MaskType == fMaskType && this->color() != that ->color()) {
1935 return false;
1934 } 1936 }
1935 } 1937 }
1936 1938
1937 fBatch.fNumGlyphs += that->numGlyphs(); 1939 fBatch.fNumGlyphs += that->numGlyphs();
1938 1940
1939 // Reallocate space for geo data if necessary and then import that's geo data. 1941 // Reallocate space for geo data if necessary and then import that's geo data.
1940 int newGeoCount = that->fGeoCount + fGeoCount; 1942 int newGeoCount = that->fGeoCount + fGeoCount;
1941 // We assume (and here enforce) that the allocation size is the smallest power of two that 1943 // We assume (and here enforce) that the allocation size is the smallest power of two that
1942 // is greater than or equal to the number of geometries (and at least 1944 // is greater than or equal to the number of geometries (and at least
1943 // kMinGeometryAllocated). 1945 // kMinGeometryAllocated).
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 } 2153 }
2152 2154
2153 inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob, GrRen derTarget* rt, 2155 inline void GrAtlasTextContext::flushBigGlyphs(GrAtlasTextBlob* cacheBlob, GrRen derTarget* rt,
2154 const GrClip& clip, const SkPaint & skPaint, 2156 const GrClip& clip, const SkPaint & skPaint,
2155 SkScalar transX, SkScalar transY, 2157 SkScalar transX, SkScalar transY,
2156 const SkIRect& clipBounds) { 2158 const SkIRect& clipBounds) {
2157 if (!cacheBlob->fBigGlyphs.count()) { 2159 if (!cacheBlob->fBigGlyphs.count()) {
2158 return; 2160 return;
2159 } 2161 }
2160 2162
2161 SkMatrix pathMatrix;
2162 if (!cacheBlob->fViewMatrix.invert(&pathMatrix)) {
2163 SkDebugf("could not invert viewmatrix\n");
2164 return;
2165 }
2166
2167 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { 2163 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) {
2168 GrAtlasTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; 2164 GrAtlasTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i];
2169 bigGlyph.fVx += transX; 2165 bigGlyph.fVx += transX;
2170 bigGlyph.fVy += transY; 2166 bigGlyph.fVy += transY;
2171 SkMatrix translate = cacheBlob->fViewMatrix; 2167 SkMatrix ctm;
2172 translate.postTranslate(bigGlyph.fVx, bigGlyph.fVy); 2168 ctm.setScale(bigGlyph.fScale, bigGlyph.fScale);
2169 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy);
2170 if (bigGlyph.fApplyVM) {
2171 ctm.postConcat(cacheBlob->fViewMatrix);
2172 }
2173 2173
2174 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, bi gGlyph.fPath, 2174 GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, bi gGlyph.fPath,
2175 skPaint, translate, &pathMatrix, cli pBounds, false); 2175 skPaint, ctm, nullptr, clipBounds, f alse);
2176 } 2176 }
2177 } 2177 }
2178 2178
2179 void GrAtlasTextContext::flush(const SkTextBlob* blob, 2179 void GrAtlasTextContext::flush(const SkTextBlob* blob,
2180 GrAtlasTextBlob* cacheBlob, 2180 GrAtlasTextBlob* cacheBlob,
2181 GrRenderTarget* rt, 2181 GrRenderTarget* rt,
2182 const SkPaint& skPaint, 2182 const SkPaint& skPaint,
2183 const GrPaint& grPaint, 2183 const GrPaint& grPaint,
2184 SkDrawFilter* drawFilter, 2184 SkDrawFilter* drawFilter,
2185 const GrClip& clip, 2185 const GrClip& clip,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2286 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2287 static_cast<size_t>(textLen), 0, 0, noClip)); 2287 static_cast<size_t>(textLen), 0, 0, noClip));
2288 2288
2289 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2289 SkScalar transX = static_cast<SkScalar>(random->nextU());
2290 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2290 SkScalar transY = static_cast<SkScalar>(random->nextU());
2291 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2291 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2292 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2292 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2293 } 2293 }
2294 2294
2295 #endif 2295 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698