1 #ifndef LAYER_INFO_RSH 2 #define LAYER_INFO_RSH 3 4 // An object that contains the front and back depths values of a layer 5 typedef struct LayerInfo { 6 // Front and back depth values of this layer. 7 // front_depth >= back_depth. 8 int front_depth; 9 int back_depth; 10 } LayerInfo_t; 11 12 // An object that contains parameters used for computing matte for the current 13 // layer. 14 typedef struct BlendInfo { 15 // The max kernel radius of a layer. 16 int dilation_radius; 17 18 // A scale factor =1.0f/(1+dilation_radius), which is used to normalize a 19 // distance transform result to be a matte value within [0,1]. 20 // This data member is only used for PixelFormatF32. 21 float matte_normalizer; 22 } BlendInfo_t; 23 24 static inline int ValidDepth(int depth) { return (depth != 0); } 25 26 static inline int NotInFrontOfTheLayer(int depth, 27 const LayerInfo_t *layer_info) { 28 return (depth <= layer_info->front_depth); 29 } 30 31 static inline int OnTheLayer(int depth, const LayerInfo_t *layer_info) { 32 return (layer_info->back_depth <= depth && depth <= layer_info->front_depth); 33 } 34 35 static inline int ValidDepthNotInFrontOfTheLayer( 36 int depth, const LayerInfo_t *layer_info) { 37 return (depth != 0) & (depth <= layer_info->front_depth); 38 } 39 40 static inline int ValidDepthNotOnTheLayer(int depth, 41 const LayerInfo_t *layer_info) { 42 return (depth != 0) & 43 ((depth < layer_info->back_depth) | (depth > layer_info->front_depth)); 44 } 45 46 #endif 47