1 /* 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 8 #ifndef SkShadowTessellator_DEFINED 9 #define SkShadowTessellator_DEFINED 10 11 #include "SkColor.h" 12 #include "SkPoint.h" 13 #include "SkRefCnt.h" 14 15 class SkMatrix; 16 class SkPath; 17 class SkVertices; 18 19 namespace SkShadowTessellator { 20 21 typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc; 22 23 /** 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 */ 28 sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm, 29 HeightFunc heightFunc, SkScalar ambientAlpha, bool transparent); 30 31 /** 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 */ 36 sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, HeightFunc heightFunc, 37 const SkPoint3& lightPos, SkScalar lightRadius, 38 SkScalar spotAlpha, bool transparent); 39 } 40 41 #endif 42