blob: 09fc597e3b921b9c1a0119340f67dc455fbe0354 [file] [log] [blame]
Jim Van Verthbce74962017-01-25 09:39:46 -05001/*
2 * Copyright 2017 Google Inc.
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
Jim Van Verthefe3ded2017-01-30 13:11:45 -05008#ifndef SkShadowTessellator_DEFINED
9#define SkShadowTessellator_DEFINED
Jim Van Verthbce74962017-01-25 09:39:46 -050010
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkColor.h"
12#include "include/core/SkPoint.h"
13#include "include/core/SkRefCnt.h"
Jim Van Verthbce74962017-01-25 09:39:46 -050014
15class SkMatrix;
16class SkPath;
Mike Reed54518ac2017-07-22 08:29:48 -040017struct SkPoint3;
Brian Salomonaff27a22017-02-06 15:47:44 -050018class SkVertices;
Jim Van Verthbce74962017-01-25 09:39:46 -050019
Brian Salomonaff27a22017-02-06 15:47:44 -050020namespace SkShadowTessellator {
Jim Van Verthb4366552017-03-27 14:25:29 -040021
22typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc;
23
Brian Salomonaff27a22017-02-06 15:47:44 -050024/**
25 * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
26 * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
27 * If transparent is true, then the center of the ambient shadow will be filled in.
28 */
Jim Van Verthb4366552017-03-27 14:25:29 -040029sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
Jim Van Verthe308a122017-05-08 14:19:30 -040030 const SkPoint3& zPlane, bool transparent);
Jim Van Verthbce74962017-01-25 09:39:46 -050031
Brian Salomonaff27a22017-02-06 15:47:44 -050032/**
33 * This function generates a spot shadow mesh for a path by walking the transformed path,
34 * further transforming by the scale and translation, and outsetting and insetting by a radius.
35 * The center will be clipped against the original path unless transparent is true.
36 */
Jim Van Verthe308a122017-05-08 14:19:30 -040037sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane,
Jim Van Verth060d9822017-05-04 09:58:17 -040038 const SkPoint3& lightPos, SkScalar lightRadius, bool transparent);
Jim Van Verth1af03d42017-07-31 09:34:58 -040039
40
Brian Salomonaff27a22017-02-06 15:47:44 -050041}
Jim Van Verth91af7272017-01-27 14:15:54 -050042
Jim Van Verthbce74962017-01-25 09:39:46 -050043#endif