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

Side by Side Diff: src/core/SkDistanceFieldGen.h

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 | « no previous file | src/gpu/GrDistanceFieldTextContext.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 #ifndef SkDistanceFieldGen_DEFINED 7 #ifndef SkDistanceFieldGen_DEFINED
8 #define SkDistanceFieldGen_DEFINED 8 #define SkDistanceFieldGen_DEFINED
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
11 11
12 // the max magnitude for the distance field 12 // the max magnitude for the distance field
13 // distance values are limited to the range [-SK_DistanceFieldMagnitude, SK_Dist anceFieldMagnitude) 13 // distance values are limited to the range [-SK_DistanceFieldMagnitude, SK_Dist anceFieldMagnitude)
14 #define SK_DistanceFieldMagnitude 4 14 #define SK_DistanceFieldMagnitude 4
15 // we need to pad around the original glyph to allow our maximum distance of 15 // we need to pad around the original glyph to allow our maximum distance of
16 // SK_DistanceFieldMagnitude texels away from any edge 16 // SK_DistanceFieldMagnitude texels away from any edge
17 // we add one to this pad to allow for bilerp 17 #define SK_DistanceFieldPad 4
18 #define SK_DistanceFieldPad (SK_DistanceFieldMagnitude+1) 18 // the rect we render with is inset from the distance field glyph size to allow for bilerp
19 #define SK_DistanceFieldInset 2
19 20
20 // for the fragment shader 21 // for the fragment shader
21 // The distance field is constructed as unsigned char values, so that the zero v alue is at 128, 22 // The distance field is constructed as unsigned char values, so that the zero v alue is at 128,
22 // and the range is [-4, 4 - 1/255). Hence our multiplier is 8 - 1/32 and zero t hreshold is 128/255. 23 // and the range is [-4, 4 - 1/255). Hence our multiplier is 8 - 1/32 and zero t hreshold is 128/255.
23 #define SK_DistanceFieldMultiplier "7.96875" 24 #define SK_DistanceFieldMultiplier "7.96875"
24 #define SK_DistanceFieldThreshold "0.50196078431" 25 #define SK_DistanceFieldThreshold "0.50196078431"
25 26
26 /** Given 8-bit mask data, generate the associated distance field 27 /** Given 8-bit mask data, generate the associated distance field
27 28
28 * @param distanceField The distance field to be generated. Should already be allocated 29 * @param distanceField The distance field to be generated. Should already be allocated
(...skipping 22 matching lines...) Expand all
51 52
52 /** Given width and height of original image, return size (in bytes) of distance field 53 /** Given width and height of original image, return size (in bytes) of distance field
53 * @param w Width of the original image. 54 * @param w Width of the original image.
54 * @param h Height of the original image. 55 * @param h Height of the original image.
55 */ 56 */
56 inline size_t SkComputeDistanceFieldSize(int w, int h) { 57 inline size_t SkComputeDistanceFieldSize(int w, int h) {
57 return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(un signed char); 58 return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(un signed char);
58 } 59 }
59 60
60 #endif 61 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698