blob: 92faccccf755ca55a5af64d7ed4132b53282a5a5 [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"
Mike Klein334a6422019-08-27 08:12:15 -050014#include <functional> // std::function
Jim Van Verthbce74962017-01-25 09:39:46 -050015
16class SkMatrix;
17class SkPath;
Mike Reed54518ac2017-07-22 08:29:48 -040018struct SkPoint3;
Brian Salomonaff27a22017-02-06 15:47:44 -050019class SkVertices;
Jim Van Verthbce74962017-01-25 09:39:46 -050020
Brian Salomonaff27a22017-02-06 15:47:44 -050021namespace SkShadowTessellator {
Jim Van Verthb4366552017-03-27 14:25:29 -040022
23typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc;
24
Brian Salomonaff27a22017-02-06 15:47:44 -050025/**
26 * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
27 * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
28 * If transparent is true, then the center of the ambient shadow will be filled in.
29 */
Jim Van Verthb4366552017-03-27 14:25:29 -040030sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
Jim Van Verthe308a122017-05-08 14:19:30 -040031 const SkPoint3& zPlane, bool transparent);
Jim Van Verthbce74962017-01-25 09:39:46 -050032
Brian Salomonaff27a22017-02-06 15:47:44 -050033/**
34 * This function generates a spot shadow mesh for a path by walking the transformed path,
35 * further transforming by the scale and translation, and outsetting and insetting by a radius.
36 * The center will be clipped against the original path unless transparent is true.
37 */
Jim Van Verthe308a122017-05-08 14:19:30 -040038sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane,
Jim Van Verth060d9822017-05-04 09:58:17 -040039 const SkPoint3& lightPos, SkScalar lightRadius, bool transparent);
Jim Van Verth1af03d42017-07-31 09:34:58 -040040
41
Brian Salomonaff27a22017-02-06 15:47:44 -050042}
Jim Van Verth91af7272017-01-27 14:15:54 -050043
Jim Van Verthbce74962017-01-25 09:39:46 -050044#endif