Home | History | Annotate | Download | only in utils
      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 struct SkPoint3;
     18 class SkVertices;
     19 
     20 namespace SkShadowTessellator {
     21 
     22 typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc;
     23 
     24 /**
     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  */
     29 sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
     30                               const SkPoint3& zPlane, bool transparent);
     31 
     32 /**
     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  */
     37 sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane,
     38                            const SkPoint3& lightPos, SkScalar lightRadius, bool transparent);
     39 
     40 
     41 }
     42 
     43 #endif
     44