/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file u_img_tfx.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This file contains all the common data for transition effect APIs  
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_IMG
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_IMG_TFX_H_
#define _U_IMG_TFX_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_handle.h"
#include "u_gl.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
#define TFX_NFY_JUST_CANCEL         ( 6)    /**<in photo frame, change from slideshow to single view, just cancel effect */
#define TFX_NFY_START               ( 5)    /**<start transition effect        */
#define TFX_NFY_FRAME_END           ( 4)    /**<transition effect one frame end         */
#define TFX_NFY_PAUSE               ( 3)    /**<transition effect pause        */
#define TFX_NFY_STOP                ( 2)    /**<transition effect stop        */
#define TFX_NFY_END                 ( 1)    /**<transition effect end        */
#define TFX_NFY_SURF_ERROR          (-1)    /**<surface error        */
#define TFX_NFY_SEND_NEXT_FRAME_ERR (-2)    /**<transition effect next frame error        */
#define TFX_NFY_RENDER_ERROR        (-3)    /**<render error        */
#define TFX_NFY_RECTANGLE_ERR       (-4)

#define TFX_COMMON_FIELD                    \
    VOID                *pv_src,            \
    INT32               i4_src_x,           \
    INT32               i4_src_y,           \
    UINT32              ui4_src_pitch,      \
    GL_COLORMODE_T      e_src_cm,           \
    VOID                *pv_dst,            \
    INT32               i4_dst_x,           \
    INT32               i4_dst_y,           \
    UINT32              ui4_dst_pitch,      \
    GL_COLORMODE_T      e_dst_cm,           \
    UINT32              ui4_width,          \
    UINT32              ui4_height,         \
    UINT32              ui4_frame_index,    \
    UINT32              ui4_total_frame,    \
    BOOL                b_redraw_all,       \
    TFX_AUX_DATA_T      *pt_aux,            \
    HANDLE_T            h_src,              \
    HANDLE_T            h_dst    /**<transition effect field        */

/*------------------------------------------------------------------*/
/*! @enum IMG_TFX_EFFECT_T
 *  @brief  enum of transition effect
 *  @code
 *  typedef enum
 *  {
 *      TFX_WIPE_LEFT,
 *      TFX_WIPE_RIGHT,
 *      TFX_WIPE_UP,
 *      TFX_WIPE_DOWN,
 *      TFX_BOX_IN,
 *      TFX_BOX_OUT,
 *      TFX_BLENDING,
 *      TFX_DISSOLVE,
 *      TFX_INTERLACE_H,
 *      TFX_INTERLACE_V,
 *      TFX_SPLIT_IN_H,
 *      TFX_SPLIT_OUT_H,
 *      TFX_SPLIT_IN_V,
 *      TFX_SPLIT_OUT_V,
 *      TFX_OSD_BLENDING,
 *      TFX_TOTAL_NUMBER
 *  } IMG_TFX_EFFECT_T;
 *  @endcode
 *  @li@c  TFX_WIPE_LEFT                                     - wipe left
 *  @li@c  TFX_WIPE_RIGHT                                    - wipe right
 *  @li@c  TFX_WIPE_UP                                       - wipe up
 *  @li@c  TFX_WIPE_DOWN                                     - wipe down
 *  @li@c  TFX_BOX_IN                                        - box in
 *  @li@c  TFX_BOX_OUT                                       - box out
 *  @li@c  TFX_BLENDING                                      - blending
 *  @li@c  TFX_DISSOLVE                                      - dissolve
 *  @li@c  TFX_INTERLACE_H                                   - interlace horzontal
 *  @li@c  TFX_INTERLACE_V                                   - interlace vertical
 *  @li@c  TFX_SPLIT_IN_H                                    - split in horzontal
 *  @li@c  TFX_SPLIT_OUT_H                                   -split out horzontal
 *  @li@c  TFX_SPLIT_IN_V                                    - split in vertical
 *  @li@c  TFX_SPLIT_OUT_V                                   -split out vertical
 *  @li@c  TFX_OSD_BLENDING                                  - osd blending
 *  @li@c  TFX_TOTAL_NUMBER                                  - enum number
 */
/*------------------------------------------------------------------*/
typedef enum
{
    TFX_WIPE_LEFT,
    TFX_WIPE_RIGHT,
    TFX_WIPE_UP,
    TFX_WIPE_DOWN,
    TFX_BOX_IN,
    TFX_BOX_OUT,
    TFX_BLENDING,
    TFX_DISSOLVE,
    TFX_INTERLACE_H,
    TFX_INTERLACE_V,
    TFX_SPLIT_IN_H,
    TFX_SPLIT_OUT_H,
    TFX_SPLIT_IN_V,
    TFX_SPLIT_OUT_V,
    TFX_OSD_BLENDING,

    TFX_TOTAL_NUMBER
} IMG_TFX_EFFECT_T;

/*------------------------------------------------------------------*/
/*! @enum IMG_TFX_SCHEME_T
 *  @brief type of playing scheme
 *  @code
 *  typedef enum
 *  {
 *      TFX_DROP_FRAME,
 *      TFX_NO_DROP_FRAME
 *  } IMG_TFX_SCHEME_T;
 *  @endcode
 *  @li@c  TFX_DROP_FRAME                                    - drop frame
 *  @li@c  TFX_NO_DROP_FRAME                                 - no drop frame
 */
/*------------------------------------------------------------------*/
typedef enum
{
    TFX_DROP_FRAME,
    TFX_NO_DROP_FRAME
} IMG_TFX_SCHEME_T;

/*------------------------------------------------------------------*/
/*! @struct IMG_TFX_OSD_BLEND_T
 *  @brief osd alpha blend range
 *  @code
 *  typedef struct
 *  {
 *      UINT8           ui1_alpha_begin;
 *      UINT8           ui1_alpha_middle;
 *      UINT8           ui1_alpha_end;
 *      GL_HPLANE_T     h_plane;
 *  } IMG_TFX_OSD_BLEND_T;
 *  @endcode
 *  @li@c  ui1_alpha_begin                                   - begin of alpha blend
 *  @li@c  ui1_alpha_middle                                  - middle of alpha blend
 *  @li@c  ui1_alpha_end                                     - end of alpha blend
 *  @li@c  h_plane                                           - plane handle 
 */
/*------------------------------------------------------------------*/
typedef struct
{
    UINT8           ui1_alpha_begin;
    UINT8           ui1_alpha_middle;
    UINT8           ui1_alpha_end;
    
    GL_HPLANE_T     h_plane;
} IMG_TFX_OSD_BLEND_T;

/*------------------------------------------------------------------*/
/*! @struct TFX_AUX_DATA_T
 *  @brief auxiliary data
 *  @code
 *  typedef struct
 *  {
 *      IMG_TFX_EFFECT_T        e_type;
 *      union
 *      {
 *          IMG_TFX_OSD_BLEND_T t_osd_blend_info;
 *      } u;
 *      GL_HSURFACE_T           h_aux_surf;
 *  } TFX_AUX_DATA_T;
 *  @endcode
 *  @li@c  e_type                                            - type of transition effect 
 *  @li@c  t_osd_blend_info                                  - osd blend information
 *  @li@c  h_aux_surf                                        - surface handle
 */
/*------------------------------------------------------------------*/
#pragma pack(4)
typedef struct
{
    IMG_TFX_EFFECT_T        e_type;

    GL_RECT_T               t_effect_rect;
    BOOL                    b_first_frame;
    union
    {
        IMG_TFX_OSD_BLEND_T t_osd_blend_info;
    } u;
    
    GL_HSURFACE_T           h_aux_surf;
    BOOL                    b_is_4k2k;
    BOOL                    b_is_pf_mode;
} TFX_AUX_DATA_T;
#pragma pack()

/*------------------------------------------------------------------*/
/*! @brief Notify function of transition effect .
 *  @param [in] i4_status  specify the status of transition effect.
 *  @param [in] h_tfx       specify the transition effect handle.
 *  @param [in] pv_tag     specify the callback data.
 */
/*------------------------------------------------------------------*/
typedef VOID (*IMG_TFX_NFY_FCT_T)(INT32 i4_status, HANDLE_T h_tfx, VOID *pv_tag);


/*------------------------------------------------------------------*/
/*! @brief render function of transition effect 
 *  @param [in] TFX_COMMON_FIELD specify the param for render.
 */
/*------------------------------------------------------------------*/
typedef INT32 (*IMG_TFX_RENDER_FCT_T)(TFX_COMMON_FIELD);

/*------------------------------------------------------------------*/
/*! @struct TFX_FRAME_INFO_T
 *  @brief information of gif
 *  @code
 *  typedef struct
 *  {
 *      UINT32                  ui4_frame_number;
 *      UINT32                  ui4_duration;
 *      IMG_TFX_RENDER_FCT_T    pf_render_func;
 *  } TFX_FRAME_INFO_T;
 *  @endcode
 *  @li@c  ui4_frame_number                                  - frame number in gif
 *  @li@c  ui4_duration                                      - delay time of frame display
 *  @li@c  pf_render_func                                    - point to the render function
 */
/*------------------------------------------------------------------*/
#pragma pack(4)
typedef struct
{
    UINT32                  ui4_frame_number;
    UINT32                  ui4_duration;
    IMG_TFX_RENDER_FCT_T    pf_render_func;
} TFX_FRAME_INFO_T;
#pragma pack()

#ifdef __cplusplus
}
#endif

#endif /* _U_IMG_TFX_H_ */
/*----------------------------------------------------------------------------*/
/*! @} */   /* end of  groupMW_IMG*/
/*----------------------------------------------------------------------------*/
