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

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

Issue 1643143002: Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simplify path and add comments 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
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, so that the zero v alue is at 128,
23 // 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 - 1/128) ). Hence our multiplier is 8 - 1/32 and zero threshold is 128/255.
24 #define SK_DistanceFieldMultiplier "7.96875" 24 #define SK_DistanceFieldMultiplier "7.96875"
25 #define SK_DistanceFieldThreshold "0.50196078431" 25 #define SK_DistanceFieldThreshold "0.50196078431"
26 26
27 /** Given 8-bit mask data, generate the associated distance field 27 /** Given 8-bit mask data, generate the associated distance field
28 28
29 * @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
30 * by the client with the padding above. 30 * by the client with the padding above.
31 * @param image 8-bit mask we're using to generate the distance fie ld. 31 * @param image 8-bit mask we're using to generate the distance fie ld.
32 * @param w Width of the original image. 32 * @param w Width of the original image.
33 * @param h Height of the original image. 33 * @param h Height of the original image.
(...skipping 18 matching lines...) Expand all
52 52
53 /** 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
54 * @param w Width of the original image. 54 * @param w Width of the original image.
55 * @param h Height of the original image. 55 * @param h Height of the original image.
56 */ 56 */
57 inline size_t SkComputeDistanceFieldSize(int w, int h) { 57 inline size_t SkComputeDistanceFieldSize(int w, int h) {
58 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);
59 } 59 }
60 60
61 #endif 61 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698