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

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

Issue 1726763002: Use ARM fixes for SDF encoding. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix another comment Created 4 years, 10 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/core/SkDistanceFieldGen.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 #define SK_DistanceFieldPad 4 17 #define SK_DistanceFieldPad 4
18 // the rect we render with is inset from the distance field glyph size to allow for bilerp 18 // the rect we render with is inset from the distance field glyph size to allow for bilerp
19 #define SK_DistanceFieldInset 2 19 #define SK_DistanceFieldInset 2
20 20
21 // for the fragment shader 21 // For the fragment shader:
22 // 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,
23 // and the range is [-4, 4 - 1/255). Hence our multiplier is 8 - 1/32 and zero t hreshold is 128/255. 23 // so that the zero value is at 128, and the supported range of distances is [ -4 * 127/128, 4].
24 // Hence our multiplier (width of the range) is 4 * 255/128 and zero threshold is 128/255.
24 #define SK_DistanceFieldMultiplier "7.96875" 25 #define SK_DistanceFieldMultiplier "7.96875"
25 #define SK_DistanceFieldThreshold "0.50196078431" 26 #define SK_DistanceFieldThreshold "0.50196078431"
26 27
27 /** Given 8-bit mask data, generate the associated distance field 28 /** Given 8-bit mask data, generate the associated distance field
28 29
29 * @param distanceField The distance field to be generated. Should already be allocated 30 * @param distanceField The distance field to be generated. Should already be allocated
30 * by the client with the padding above. 31 * by the client with the padding above.
31 * @param image 8-bit mask we're using to generate the distance fie ld. 32 * @param image 8-bit mask we're using to generate the distance fie ld.
32 * @param w Width of the original image. 33 * @param w Width of the original image.
33 * @param h Height of the original image. 34 * @param h Height of the original image.
(...skipping 18 matching lines...) Expand all
52 53
53 /** Given width and height of original image, return size (in bytes) of distance field 54 /** Given width and height of original image, return size (in bytes) of distance field
54 * @param w Width of the original image. 55 * @param w Width of the original image.
55 * @param h Height of the original image. 56 * @param h Height of the original image.
56 */ 57 */
57 inline size_t SkComputeDistanceFieldSize(int w, int h) { 58 inline size_t SkComputeDistanceFieldSize(int w, int h) {
58 return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(un signed char); 59 return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(un signed char);
59 } 60 }
60 61
61 #endif 62 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkDistanceFieldGen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698