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

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

Issue 1135113002: Fix blur on large glyphs in runs < SkGlyphCache::max (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: a bit more Created 5 years, 7 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 "GrBatch.h" 9 #include "GrBatch.h"
10 #include "GrBatchFontCache.h" 10 #include "GrBatchFontCache.h"
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 765 }
766 766
767 void GrAtlasTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip, 767 void GrAtlasTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
768 const GrPaint& paint, const SkPaint& skPaint , 768 const GrPaint& paint, const SkPaint& skPaint ,
769 const SkMatrix& viewMatrix, 769 const SkMatrix& viewMatrix,
770 const char text[], size_t byteLength, 770 const char text[], size_t byteLength,
771 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) { 771 SkScalar x, SkScalar y, const SkIRect& regio nClipBounds) {
772 SkAutoTUnref<BitmapTextBlob> blob( 772 SkAutoTUnref<BitmapTextBlob> blob(
773 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix, 773 this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix,
774 text, byteLength, x, y, regionClipBounds)); 774 text, byteLength, x, y, regionClipBounds));
775 this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip); 775 this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip, regio nClipBounds);
776 } 776 }
777 777
778 void GrAtlasTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip, 778 void GrAtlasTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
779 const GrPaint& paint, const SkPaint& skPa int, 779 const GrPaint& paint, const SkPaint& skPa int,
780 const SkMatrix& viewMatrix, 780 const SkMatrix& viewMatrix,
781 const char text[], size_t byteLength, 781 const char text[], size_t byteLength,
782 const SkScalar pos[], int scalarsPerPosit ion, 782 const SkScalar pos[], int scalarsPerPosit ion,
783 const SkPoint& offset, const SkIRect& reg ionClipBounds) { 783 const SkPoint& offset, const SkIRect& reg ionClipBounds) {
784 SkAutoTUnref<BitmapTextBlob> blob( 784 SkAutoTUnref<BitmapTextBlob> blob(
785 this->createDrawPosTextBlob(rt, clip, paint, skPaint, viewMatrix, 785 this->createDrawPosTextBlob(rt, clip, paint, skPaint, viewMatrix,
786 text, byteLength, 786 text, byteLength,
787 pos, scalarsPerPosition, 787 pos, scalarsPerPosition,
788 offset, regionClipBounds)); 788 offset, regionClipBounds));
789 789
790 this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip); 790 this->flush(fContext->getTextTarget(), blob, rt, skPaint, paint, clip, regio nClipBounds);
791 } 791 }
792 792
793 void GrAtlasTextContext::internalDrawBMPText(BitmapTextBlob* blob, int runIndex, 793 void GrAtlasTextContext::internalDrawBMPText(BitmapTextBlob* blob, int runIndex,
794 SkGlyphCache* cache, const SkPaint& skPaint, 794 SkGlyphCache* cache, const SkPaint& skPaint,
795 GrColor color, 795 GrColor color,
796 const SkMatrix& viewMatrix, 796 const SkMatrix& viewMatrix,
797 const char text[], size_t byteLengt h, 797 const char text[], size_t byteLengt h,
798 SkScalar x, SkScalar y, const SkIRe ct& clipRect) { 798 SkScalar x, SkScalar y, const SkIRe ct& clipRect) {
799 SkASSERT(byteLength == 0 || text != NULL); 799 SkASSERT(byteLength == 0 || text != NULL);
800 800
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 } 2132 }
2133 2133
2134 SkAutoTUnref<BitmapTextBatch> batch(this->createBatch(cacheBlob, info, g lyphCount, run, 2134 SkAutoTUnref<BitmapTextBatch> batch(this->createBatch(cacheBlob, info, g lyphCount, run,
2135 subRun, color, tra nsX, transY, 2135 subRun, color, tra nsX, transY,
2136 skPaint)); 2136 skPaint));
2137 target->drawBatch(pipelineBuilder, batch); 2137 target->drawBatch(pipelineBuilder, batch);
2138 } 2138 }
2139 } 2139 }
2140 2140
2141 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend erTarget* rt, 2141 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend erTarget* rt,
2142 const GrPaint& grPaint, const GrC lip& clip, 2142 const SkPaint& skPaint,
2143 SkScalar transX, SkScalar transY) { 2143 SkScalar transX, SkScalar transY,
2144 const SkIRect& clipBounds) {
2144 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { 2145 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) {
2145 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; 2146 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i];
2146 bigGlyph.fVx += SkScalarTruncToInt(transX); 2147 bigGlyph.fVx += SkScalarTruncToInt(transX);
2147 bigGlyph.fVy += SkScalarTruncToInt(transY); 2148 bigGlyph.fVy += SkScalarTruncToInt(transY);
2148 SkMatrix translate; 2149 SkMatrix translate;
2149 translate.setTranslate(SkIntToScalar(bigGlyph.fVx), 2150 translate.setTranslate(SkIntToScalar(bigGlyph.fVx),
2150 SkIntToScalar(bigGlyph.fVy)); 2151 SkIntToScalar(bigGlyph.fVy));
2151 SkPath tmpPath(bigGlyph.fPath);
2152 tmpPath.transform(translate);
2153 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); 2152 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
2154 fContext->drawPath(rt, clip, grPaint, SkMatrix::I(), tmpPath, strokeInfo ); 2153 fGpuDevice->internalDrawPath(bigGlyph.fPath, skPaint, SkMatrix::I(), &tr anslate, clipBounds,
2154 false);
2155 } 2155 }
2156 } 2156 }
2157 2157
2158 void GrAtlasTextContext::flush(GrDrawTarget* target, 2158 void GrAtlasTextContext::flush(GrDrawTarget* target,
2159 const SkTextBlob* blob, 2159 const SkTextBlob* blob,
2160 BitmapTextBlob* cacheBlob, 2160 BitmapTextBlob* cacheBlob,
2161 GrRenderTarget* rt, 2161 GrRenderTarget* rt,
2162 const SkPaint& skPaint, 2162 const SkPaint& skPaint,
2163 const GrPaint& grPaint, 2163 const GrPaint& grPaint,
2164 SkDrawFilter* drawFilter, 2164 SkDrawFilter* drawFilter,
(...skipping 13 matching lines...) Expand all
2178 for (int run = 0; !it.done(); it.next(), run++) { 2178 for (int run = 0; !it.done(); it.next(), run++) {
2179 if (cacheBlob->fRuns[run].fDrawAsPaths) { 2179 if (cacheBlob->fRuns[run].fDrawAsPaths) {
2180 this->flushRunAsPaths(it, skPaint, drawFilter, viewMatrix, clipBound s, x, y); 2180 this->flushRunAsPaths(it, skPaint, drawFilter, viewMatrix, clipBound s, x, y);
2181 continue; 2181 continue;
2182 } 2182 }
2183 cacheBlob->fRuns[run].fVertexBounds.offset(transX, transY); 2183 cacheBlob->fRuns[run].fVertexBounds.offset(transX, transY);
2184 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, transX, transY, skPaint); 2184 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, transX, transY, skPaint);
2185 } 2185 }
2186 2186
2187 // Now flush big glyphs 2187 // Now flush big glyphs
2188 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, transX, transY); 2188 this->flushBigGlyphs(cacheBlob, rt, skPaint, transX, transY, clipBounds);
2189 } 2189 }
2190 2190
2191 void GrAtlasTextContext::flush(GrDrawTarget* target, 2191 void GrAtlasTextContext::flush(GrDrawTarget* target,
2192 BitmapTextBlob* cacheBlob, 2192 BitmapTextBlob* cacheBlob,
2193 GrRenderTarget* rt, 2193 GrRenderTarget* rt,
2194 const SkPaint& skPaint, 2194 const SkPaint& skPaint,
2195 const GrPaint& grPaint, 2195 const GrPaint& grPaint,
2196 const GrClip& clip) { 2196 const GrClip& clip,
2197 const SkIRect& clipBounds) {
2197 GrPipelineBuilder pipelineBuilder; 2198 GrPipelineBuilder pipelineBuilder;
2198 pipelineBuilder.setFromPaint(grPaint, rt, clip); 2199 pipelineBuilder.setFromPaint(grPaint, rt, clip);
2199 2200
2200 GrColor color = grPaint.getColor(); 2201 GrColor color = grPaint.getColor();
2201 for (int run = 0; run < cacheBlob->fRunCount; run++) { 2202 for (int run = 0; run < cacheBlob->fRunCount; run++) {
2202 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint); 2203 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint);
2203 } 2204 }
2204 2205
2205 // Now flush big glyphs 2206 // Now flush big glyphs
2206 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); 2207 this->flushBigGlyphs(cacheBlob, rt, skPaint, 0, 0, clipBounds);
2207 } 2208 }
2208 2209
2209 //////////////////////////////////////////////////////////////////////////////// /////////////////// 2210 //////////////////////////////////////////////////////////////////////////////// ///////////////////
2210 2211
2211 #ifdef GR_TEST_UTILS 2212 #ifdef GR_TEST_UTILS
2212 2213
2213 BATCH_TEST_DEFINE(TextBlob) { 2214 BATCH_TEST_DEFINE(TextBlob) {
2214 static uint32_t gContextID = SK_InvalidGenID; 2215 static uint32_t gContextID = SK_InvalidGenID;
2215 static GrAtlasTextContext* gTextContext = NULL; 2216 static GrAtlasTextContext* gTextContext = NULL;
2216 static SkDeviceProperties gDeviceProperties(SkDeviceProperties::kLegacyLCD_I nitType); 2217 static SkDeviceProperties gDeviceProperties(SkDeviceProperties::kLegacyLCD_I nitType);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2265 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2265 static_cast<size_t>(textLen), 0, 0, noClip)); 2266 static_cast<size_t>(textLen), 0, 0, noClip));
2266 2267
2267 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2268 SkScalar transX = static_cast<SkScalar>(random->nextU());
2268 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2269 SkScalar transY = static_cast<SkScalar>(random->nextU());
2269 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0]; 2270 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun s[0].fSubRunInfo[0];
2270 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2271 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2271 } 2272 }
2272 2273
2273 #endif 2274 #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