/* 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.
 *
 *****************************************************************************/

#ifndef _U_WGL_IMGCF_H_
#define _U_WGL_IMGCF_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_wgl.h"
#include "u_wgl_tools.h"
#include "u_handle.h"
#include "u_lnk_list.h"

#ifdef __cplusplus
extern "C" {
#endif


/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/

/*Specific Command*/
#define WGL_CMD_IMGCF_SET_KEY_MAP        WGL_MAKE_WIDGET_CMD(HT_WGL_WIDGET_IMGCF, 1)    /**< This command changes the keys for operating a imgcf.

                                                                                                                                                        related parameters in c_wgl_do_cmd(),

                                                                                                                                                        pv_param1:   Pointer to a WGL_IMGCF_KEY_MAP_T that contains the new key map. If it is NULL, it means to use the imgcf's default setting. 

                                                                                                                                                        pv_param2:   Reserved. It must be NULL.
                                                                                                                                                        */
#define WGL_CMD_IMGCF_GET_KEY_MAP        WGL_MAKE_WIDGET_CMD(HT_WGL_WIDGET_IMGCF, 2)    /**<This command returns the key map of a imgcf.

                                                                                                                                                        related parameters in c_wgl_do_cmd(),

                                                                                                                                                        pv_param1:   Pointer to a WGL_IMGCF_KEY_MAP_T variable to receive the key map. It cannot be NULL.

                                                                                                                                                        pv_param2:   Reserved. It must be NULL.
                                                                                                                                                        */
#define WGL_CMD_IMGCF_SET_CNT_INSET      WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 3)    /**< This command is used to set the display margin of imgcf Static's foreground. The i4_left is for the left margin, the i4_right is for the right margin, the i4_top is for the top margin, and the i4_bottom is for the bottom margin. All of them cannot be less than 0.

                                                                                                                                                        related parameters in c_wgl_do_cmd(),

                                                                                                                                                        pv_param1:   Pointer to a WGL_INSET_T value to specify the display margin. It cannot be NULL.

                                                                                                                                                        pv_param2:   Reserved. It must be NULL.
                                                                                                                                                        */
#define WGL_CMD_IMGCF_GET_CNT_INSET      WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 4)    /**<This command returns the display margin of imgcf Static's foreground. The i4_left is the left margin, the i4_right is the right margin, the i4_top is the top margin, and the i4_bottom is the bottom margin. 

                                                                                                                                                        related parameters in c_wgl_do_cmd(),

                                                                                                                                                        pv_param1:   Pointer to a WGL_INSET_T value to receive the display margin. It cannot be NULL.

                                                                                                                                                        pv_param2:   Reserved. It must be NULL.
                                                                                                                                                        */
#define WGL_CMD_IMGCF_GET_CNT_WIDTH     WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 5) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   A UIN16  point to the width of wgl

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_ADD_ITEM          WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 6) /**<  This command add a image item to the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   Pointer to a WGL_IMGCF_ITEM_T value to receive a image item. It cannot be NULL.

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_BEGIN_PLAY        WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 7) /**<  This command begine to play the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   Point to the delay time after which the timer pops

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_PAUSE_REUME_TIMER     WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 8) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   NULL

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_SPEED_UP_PLAYE     WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 9) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   NULL

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_REGULAR_PLAYE     WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 10) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   NULL

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_PLAY_TO_LEFT      WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 11) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   NULL

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */
#define WGL_CMD_IMGCF_PLAY_TO_RIGHT     WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_IMGCF, 12) /**<  This command get  the width of the imgcf.       

                                                                                                                                                            related parameters in c_wgl_do_cmd(),

                                                                                                                                                            pv_param1:   NULL

                                                                                                                                                            pv_param2:   NULL
                                                                                                                                                            */

                                                                                                                                                           
#define IMGCF_CNT_PRIVATE_START          13    

/*Widget Style*/
#define WGL_IMGCF_FIVE_SHOWN            ((UINT32) WGL_STL_WGT_SPF_START)          /**< Indicates five images shown at the same time */
#define WGL_IMGCF_SEVEN_SHOWN           ((UINT32) WGL_STL_WGT_SPF_START << 1)    /**<Indicates seven images shown at the same time */
#define WGL_IMGCF_NIGHT_SHOWN           ((UINT32) WGL_STL_WGT_SPF_START << 2)    /**<Indicates night images shown at the same time */
#define IMGCF_BK_CLR_NOT_INIT           ((UINT32) WGL_STL_WGT_SPF_START << 3)    
#define IMGCF_BK_IMG_NOT_INIT           ((UINT32) WGL_STL_WGT_SPF_START << 4)    
#define IMGCF_NO_BK                     ((UINT32) WGL_STL_WGT_SPF_START << 5)    
#define IMGCF_NOT_CLEAN_BK              ((UINT32) WGL_STL_WGT_SPF_START << 6)    
#define IMGCF_EDGE_CLR_NOT_INIT         ((UINT32) WGL_STL_WGT_SPF_START << 7)    
#define IMGCF_IMGCF_BG_CLR_NOT_INIT     ((UINT32) WGL_STL_WGT_SPF_START << 8)    

/************************************************************************/
/* Error code                                                           */
/************************************************************************/
#define IMGCFR_ALREADY_STOP           ((INT32)     1)    /**< Imgcf stop       */
#define IMGCFR_OK                     ((INT32)     0)    /**< Imgcf ok       */
#define IMGCFR_OPEND_ENOUGH           ((INT32)    -1)    /**< the count of opened image items are enough */
#define IMGCFR_TEMPLATE_ERR           ((INT32)    -2)    /**< out of memory       */
#define IMGCFR_MEMORY_ERR             ((INT32)    -3)    /**< memory opration error       */
#define IMGCFR_SURFACE_ERR            ((INT32)    -4)    /**< surface opration error       */
#define IMGCFR_FILE_ERR               ((INT32)    -5)    /**< file opration error       */
#define IMGCFR_OUT_OF_MEMORY          ((INT32)    -6)    /**< out of memory       */
#define IMGCFR_EXCEED_MAX_SUPPORT     ((INT32)    -7)    /**< exceed imgcf MAX Support       */


/*-----------------------------------------------------------------------------
                    structures
 ----------------------------------------------------------------------------*/

typedef enum{
	WGL_IMGCF_DIRECTION_TO_LEFT,
	WGL_IMGCF_DIRECTION_TO_RIGHT
	
}WGL_IMGCF_DIRECTION_TYPE;

/*Control Key Map*/
typedef struct _WGL_IMGCF_KEY_MAP_T
{
    UINT32          ui4_to_right;
    UINT32          ui4_to_left;
    UINT32          ui4_speed_up;
    UINT32          ui4_speed_down;
	
} WGL_IMGCF_KEY_MAP_T;


/*-----------------------------------------------------------------------------
                    typedefs, enums
 ----------------------------------------------------------------------------*/

typedef enum{
	WGL_IMGCF_ITEM_TYPE_IMAGE_TEMPLATE,
	WGL_IMGCF_ITEM_TYPE_MEMORY,
	WGL_IMGCF_ITEM_TYPE_FILE,
	WGL_IMGCF_ITEM_TYPE_SURFACE,
	WGL_IMGCF_ITEM_TYPE_MAX
	
}WGL_IMGCF_ITEM_TYPE;


typedef struct _WGL_IMGCF_ITEM_TEMPLATE_T{
	WGL_HIMG_TPL_T		   h_img_tpl;
	
}WGL_IMGCF_ITEM_TEMPLATE_T;


typedef struct _WGL_MEMORY_META_DATA_T{
	VOID*				      buffer;
	UINT32				  zSize;
	UINT32 	              ui4_surf_width;
	UINT32 	              ui4_surf_height;
	
}WGL_IMGCF_ITEM_MEMORY_T;


typedef struct _WGL_IMGCF_ITEM_META_DATA_T{
	CHAR*				    Filename;
	UINT32               ui4_surf_width;
	UINT32               ui4_surf_height;
	
}WGL_IMGCF_ITEM_FILE_T;


typedef struct _WGL_IMGCF_ITEM_SURFACE_T{
	GL_HSURFACE_T			   h_surf;
	
}WGL_IMGCF_ITEM_SURFACE_T;


typedef struct _WGL_IMGCF_ITEM_T
{
	WGL_IMGCF_ITEM_TYPE 		e_type;
	union{
		WGL_IMGCF_ITEM_TEMPLATE_T	             image_item;
		WGL_IMGCF_ITEM_MEMORY_T                 memory_item;
		WGL_IMGCF_ITEM_FILE_T	                  file_item;
		WGL_IMGCF_ITEM_SURFACE_T                surf_item;		
   }u;
	
}WGL_IMGCF_ITEM_T;


typedef struct _WGL_IMGCF_ITEM_INTERNAL_T
{
	DLIST_ENTRY_T(_WGL_IMGCF_ITEM_INTERNAL_T) t_item_lnk;
	WGL_IMGCF_ITEM_T  item;	
	UINT8				     ui1_disp_index;/* if it is larger than 0, this item is being played */
	
}WGL_IMGCF_ITEM_INTERNAL_T;


typedef struct _WGL_IMGCF_ITEM_INFO_T
{
	DLIST_T(_WGL_IMGCF_ITEM_INTERNAL_T) t_item_list;
	
}WGL_IMGCF_ITEM_INFO_T;


#ifdef __cplusplus
}
#endif

#endif
/*----------------------------------------------------------------------------*/
/*! @} */   /* end of groupMW_WGL_IMGCF*/
/*----------------------------------------------------------------------------*/
