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

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

Issue 239333002: Fix artifacts in distance field rendering due to bilerp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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/core/SkDistanceFieldGen.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 2013 Google Inc. 2 * Copyright 2013 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 7
8 #include "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrFontScaler.h" 12 #include "GrFontScaler.h"
13 #include "SkGlyphCache.h" 13 #include "SkGlyphCache.h"
14 #include "GrIndexBuffer.h" 14 #include "GrIndexBuffer.h"
15 #include "GrTextStrike.h" 15 #include "GrTextStrike.h"
16 #include "GrTextStrike_impl.h" 16 #include "GrTextStrike_impl.h"
17 #include "SkDistanceFieldGen.h"
17 #include "SkDraw.h" 18 #include "SkDraw.h"
18 #include "SkGpuDevice.h" 19 #include "SkGpuDevice.h"
19 #include "SkPath.h" 20 #include "SkPath.h"
20 #include "SkRTConf.h" 21 #include "SkRTConf.h"
21 #include "SkStrokeRec.h" 22 #include "SkStrokeRec.h"
22 #include "effects/GrDistanceFieldTextureEffect.h" 23 #include "effects/GrDistanceFieldTextureEffect.h"
23 24
24 static const int kGlyphCoordsAttributeIndex = 1; 25 static const int kGlyphCoordsAttributeIndex = 1;
25 26
26 static const int kSmallDFFontSize = 32; 27 static const int kSmallDFFontSize = 32;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 fMaxVertices = maxQuadVertices; 289 fMaxVertices = maxQuadVertices;
289 } 290 }
290 bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices, 291 bool success = fDrawTarget->reserveVertexAndIndexSpace(fMaxVertices,
291 0, 292 0,
292 GrTCast<void**>(& fVertices), 293 GrTCast<void**>(& fVertices),
293 NULL); 294 NULL);
294 GrAlwaysAssert(success); 295 GrAlwaysAssert(success);
295 SkASSERT(2*sizeof(SkPoint) == fDrawTarget->getDrawState().getVertexSize( )); 296 SkASSERT(2*sizeof(SkPoint) == fDrawTarget->getDrawState().getVertexSize( ));
296 } 297 }
297 298
298 SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft); 299 SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset);
299 SkScalar dy = SkIntToScalar(glyph->fBounds.fTop); 300 SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset);
300 SkScalar width = SkIntToScalar(glyph->fBounds.width()); 301 SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldIn set);
301 SkScalar height = SkIntToScalar(glyph->fBounds.height()); 302 SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceField Inset);
302 303
303 SkScalar scale = fTextRatio; 304 SkScalar scale = fTextRatio;
304 dx *= scale; 305 dx *= scale;
305 dy *= scale; 306 dy *= scale;
306 sx += dx; 307 sx += dx;
307 sy += dy; 308 sy += dy;
308 width *= scale; 309 width *= scale;
309 height *= scale; 310 height *= scale;
310 311
311 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); 312 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX + SK_DistanceFieldInset);
312 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); 313 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY + SK_DistanceFieldInset);
313 SkFixed tw = SkIntToFixed(glyph->fBounds.width()); 314 SkFixed tw = SkIntToFixed(glyph->fBounds.width() - 2*SK_DistanceFieldInset);
314 SkFixed th = SkIntToFixed(glyph->fBounds.height()); 315 SkFixed th = SkIntToFixed(glyph->fBounds.height() - 2*SK_DistanceFieldInset) ;
315 316
316 static const size_t kVertexSize = 2 * sizeof(SkPoint); 317 static const size_t kVertexSize = 2 * sizeof(SkPoint);
317 fVertices[2*fCurrVertex].setRectFan(sx, 318 fVertices[2*fCurrVertex].setRectFan(sx,
318 sy, 319 sy,
319 sx + width, 320 sx + width,
320 sy + height, 321 sy + height,
321 kVertexSize); 322 kVertexSize);
322 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)), 323 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)),
323 SkFixedToFloat(texture->normalizeFixed Y(ty)), 324 SkFixedToFloat(texture->normalizeFixed Y(ty)),
324 SkFixedToFloat(texture->normalizeFixed X(tx + tw)), 325 SkFixedToFloat(texture->normalizeFixed X(tx + tw)),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift) 495 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift)
495 + SK_FixedHalf, //d1g.fHalfSampleY, 496 + SK_FixedHalf, //d1g.fHalfSampleY,
496 fontScaler); 497 fontScaler);
497 } 498 }
498 pos += scalarsPerPosition; 499 pos += scalarsPerPosition;
499 } 500 }
500 } 501 }
501 502
502 this->finish(); 503 this->finish();
503 } 504 }
OLDNEW
« no previous file with comments | « src/core/SkDistanceFieldGen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698