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 #if !defined(SK_ENABLE_OPTIMIZE_SIZE) 12 13 #include "include/core/SkRefCnt.h" 14 #include "include/core/SkScalar.h" 15 16 #include <functional> 17 18 class SkMatrix; 19 class SkPath; 20 class SkVertices; 21 struct SkPoint3; 22 23 namespace SkShadowTessellator { 24 25 typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc; 26 27 /** 28 * This function generates an ambient shadow mesh for a path by walking the path, outsetting by 29 * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively. 30 * If transparent is true, then the center of the ambient shadow will be filled in. 31 */ 32 sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm, 33 const SkPoint3& zPlane, bool transparent); 34 35 /** 36 * This function generates a spot shadow mesh for a path by walking the transformed path, 37 * further transforming by the scale and translation, and outsetting and insetting by a radius. 38 * The center will be clipped against the original path unless transparent is true. 39 */ 40 sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane, 41 const SkPoint3& lightPos, SkScalar lightRadius, bool transparent, 42 bool directional); 43 44 45 } // namespace SkShadowTessellator 46 47 #endif // SK_ENABLE_OPTIMIZE_SIZE 48 49 #endif 50