xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrDistanceFieldGenFromVector.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2017 ARM Ltd.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GrDistanceFieldGenFromVector_DEFINED
9 #define GrDistanceFieldGenFromVector_DEFINED
10 
11 #if !defined(SK_ENABLE_OPTIMIZE_SIZE)
12 
13 #include "include/core/SkPathTypes.h"
14 
15 #include <cstddef>
16 
17 class SkMatrix;
18 class SkPath;
19 
20 /** Given a vector path, generate the associated distance field.
21 
22  *  @param distanceField     The distance field to be generated. Should already be allocated
23  *                           by the client with the padding defined in "SkDistanceFieldGen.h".
24  *  @param path              The path we're using to generate the distance field.
25  *  @param matrix            Transformation matrix for path.
26  *  @param width             Width of the distance field.
27  *  @param height            Height of the distance field.
28  *  @param rowBytes          Size of each row in the distance field, in bytes.
29  */
30 bool GrGenerateDistanceFieldFromPath(unsigned char* distanceField,
31                                      const SkPath& path, const SkMatrix& viewMatrix,
32                                      int width, int height, size_t rowBytes);
33 
IsDistanceFieldSupportedFillType(SkPathFillType fFillType)34 inline bool IsDistanceFieldSupportedFillType(SkPathFillType fFillType)
35 {
36     return (SkPathFillType::kEvenOdd == fFillType ||
37             SkPathFillType::kInverseEvenOdd == fFillType);
38 }
39 
40 #endif // SK_ENABLE_OPTIMIZE_SIZE
41 
42 #endif // GrDistanceFieldGenFromVector_DEFINED
43