blob: cadc33a162c792eab79655315102f181f822a565 [file] [log] [blame]
joel.liang8cbb4242017-01-09 18:39:43 -08001/*
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#include "SkPath.h"
12
13class SkMatrix;
14
15#ifndef SK_USE_LEGACY_DISTANCE_FIELDS
16 #define SK_USE_LEGACY_DISTANCE_FIELDS
17#endif
18
19/** Given a vector path, generate the associated distance field.
20
21 * @param distanceField The distance field to be generated. Should already be allocated
22 * by the client with the padding defined in "SkDistanceFieldGen.h".
23 * @param path The path we're using to generate the distance field.
24 * @param matrix Transformation matrix for path.
25 * @param width Width of the distance field.
26 * @param height Height of the distance field.
27 * @param rowBytes Size of each row in the distance field, in bytes.
28 */
29bool GrGenerateDistanceFieldFromPath(unsigned char* distanceField,
30 const SkPath& path, const SkMatrix& viewMatrix,
31 int width, int height, size_t rowBytes);
32
33inline bool IsDistanceFieldSupportedFillType(SkPath::FillType fFillType)
34{
Robert Phillipse4fda6c2018-02-21 12:10:41 -050035 return (SkPath::kEvenOdd_FillType == fFillType ||
joel.liang8cbb4242017-01-09 18:39:43 -080036 SkPath::kInverseEvenOdd_FillType == fFillType);
37}
38
39#endif