blob: 351beee29d1e5e9a17e8b2e5f19c5bb27575067f [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
Jim Van Verthefe3ded2017-01-30 13:11:45 -050011#include "SkColor.h"
Brian Salomonaff27a22017-02-06 15:47:44 -050012#include "SkPoint.h"
13#include "SkRefCnt.h"
Jim Van Verthbce74962017-01-25 09:39:46 -050014
15class SkMatrix;
16class SkPath;
Brian Salomonaff27a22017-02-06 15:47:44 -050017class SkVertices;
Jim Van Verthbce74962017-01-25 09:39:46 -050018
Brian Salomonaff27a22017-02-06 15:47:44 -050019namespace SkShadowTessellator {
Jim Van Verthb4366552017-03-27 14:25:29 -040020
21typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc;
22
Brian Salomonaff27a22017-02-06 15:47:44 -050023/**
24 * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
25 * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
26 * If transparent is true, then the center of the ambient shadow will be filled in.
27 */
Jim Van Verthb4366552017-03-27 14:25:29 -040028sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
Jim Van Verthe308a122017-05-08 14:19:30 -040029 const SkPoint3& zPlane, bool transparent);
Jim Van Verthbce74962017-01-25 09:39:46 -050030
Brian Salomonaff27a22017-02-06 15:47:44 -050031/**
32 * This function generates a spot shadow mesh for a path by walking the transformed path,
33 * further transforming by the scale and translation, and outsetting and insetting by a radius.
34 * The center will be clipped against the original path unless transparent is true.
35 */
Jim Van Verthe308a122017-05-08 14:19:30 -040036sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane,
Jim Van Verth060d9822017-05-04 09:58:17 -040037 const SkPoint3& lightPos, SkScalar lightRadius, bool transparent);
Brian Salomonaff27a22017-02-06 15:47:44 -050038}
Jim Van Verth91af7272017-01-27 14:15:54 -050039
Jim Van Verthbce74962017-01-25 09:39:46 -050040#endif