update arm2d to v1.1.0-preview1

This commit is contained in:
Lyon 2022-09-07 01:14:27 +08:00
parent ad22498992
commit 7d2f0825db
73 changed files with 33504 additions and 12430 deletions

27
package/Arm2D/Arm2D.c Normal file
View File

@ -0,0 +1,27 @@
#include "Arm2D.h"
#include "Arm2D_Region.h"
#include "Arm2D_Location.h"
#include "Arm2D_common.h"
int Arm2D_is_point_inside_region(PikaObj* self,
PikaObj* region,
PikaObj* location) {
arm_2d_region_t* _region = obj_getStruct(region, "_self");
arm_2d_location_t* _location = obj_getStruct(location, "_self");
return arm_2d_is_point_inside_region(_region, _location);
}
int Arm2D_is_root_tile(PikaObj* self, PikaObj* tile) {
arm_2d_tile_t* _tile = obj_getStruct(tile, "_self");
return arm_2d_is_root_tile(_tile);
}
PikaObj* Arm2D_get_absolute_location(PikaObj *self, PikaObj* tile){
arm_2d_tile_t* _tile = obj_getStruct(tile, "_self");
arm_2d_location_t _location = {0};
arm_2d_get_absolute_location(_tile, &_location);
PikaObj* location = newNormalObj(New_Arm2D_Location);
obj_setStruct(location, "_self", _location);
return location;
}

View File

@ -1,73 +0,0 @@
#api
from PikaObj import *
class BackGround(TinyObj):
def init():
pass
def setColor(color: str):
pass
def getColor() -> str:
pass
def update():
pass
class ElementList(BaseObj):
def update():
pass
class Element(TinyObj):
def init():
pass
def move(x: int, y: int):
pass
def right(x: int):
pass
def lift(x: int):
pass
def up(y: int):
pass
def down(y: int):
pass
def update():
pass
def setAlpha(alpha: int):
pass
class Box(Element):
# override
def update():
pass
def init():
pass
def setColor(color: str):
pass
def setSize(x: int, y: int):
pass
class Window(BaseObj):
background = BackGround()
elems = ElementList()
def init():
pass
def update():
pass

View File

@ -1,6 +1,6 @@
#include "Arm2D_common.h"
void Arm2D_BackGround_init(PikaObj* self) {
void Arm2D_BackGround___init__(PikaObj* self) {
obj_setStr(self, "color", "white");
}

View File

@ -3,7 +3,7 @@
#include "asset_corner_box.h"
#include "dataArgs.h"
void Arm2D_Box_init(PikaObj* self) {
void Arm2D_Box___init__(PikaObj* self) {
/* init element info */
obj_setInt(self, "alpha", 255);
obj_setInt(self, "x", 0);

View File

@ -6,7 +6,7 @@ void Arm2D_Element_update(PikaObj* self) {
obj_setSysOut(self, "[error]: update method not be overrided !");
}
void Arm2D_Element_init(PikaObj* self) {
void Arm2D_Element___init__(PikaObj* self) {
/* init element info */
obj_setInt(self, "alpha", 255);
obj_setInt(self, "x", 0);

View File

@ -5,7 +5,7 @@ int32_t __foreach_ElementList_update(Arg* elem, Args* buffs) {
ArgType type = arg_getType(elem);
if (ARG_TYPE_OBJECT == type) {
PikaObj* elemObj = arg_getPtr(elem);
pikaVM_runAsm(elemObj, "0 RUN update\n");
obj_runNativeMethod(elemObj, "update", NULL);
}
return 0;
}

View File

@ -0,0 +1,9 @@
#include "Arm2D_common.h"
#include "Arm2D_Location.h"
void Arm2D_Location___init__(PikaObj *self){
arm_2d_location_t _self = {0};
if (NULL == obj_getStruct(self, "_self")){
obj_setStruct(self, "_self", _self);
}
}

View File

@ -0,0 +1,19 @@
#include "Arm2D_common.h"
#include "Arm2D_region.h"
void Arm2D_Region___init__(PikaObj *self){
arm_2d_region_t _self = {0};
if (NULL == obj_getStruct(self, "_self")){
obj_setStruct(self, "_self", _self);
}
}
PikaObj* Arm2D_Region_intersect(PikaObj *self, PikaObj* in2){
arm_2d_region_t* _self = obj_getStruct(self, "_self");
arm_2d_region_t* _in2 = obj_getStruct(in2, "_self");
arm_2d_region_t _intersect = {0};
arm_2d_region_intersect(_self, _in2, &_intersect);
PikaObj* intersect = newNormalObj(New_Arm2D_Region);
obj_setStruct(intersect, "_self", _intersect);
return intersect;
}

View File

@ -0,0 +1,62 @@
#include "Arm2D_tile.h"
#include "Arm2D_Region.h"
#include "Arm2D_common.h"
void Arm2D_Tile___init__(PikaObj* self) {
arm_2d_tile_t _self = {0};
if (NULL == obj_getStruct(self, "_self")) {
obj_setStruct(self, "_self", _self);
}
}
PikaObj* Arm2D_Tile_generate_child(PikaObj* self,
PikaObj* reg,
int clipRegion) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_region_t* _reg = obj_getStruct(reg, "_self");
arm_2d_tile_t _child = {0};
arm_2d_tile_generate_child(_self, _reg, &_child, clipRegion);
PikaObj* child = newNormalObj(New_Arm2D_Tile);
obj_setStruct(child, "_self", _child);
return child;
}
PikaObj* Arm2D_Tile_get_root(PikaObj* self,
PikaObj* validRegion,
PikaObj* offset) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_region_t* _validRegion = obj_getStruct(validRegion, "_self");
arm_2d_location_t* _offset = obj_getStruct(offset, "_self");
const arm_2d_tile_t* _root =
arm_2d_tile_get_root(_self, _validRegion, _offset);
PikaObj* root = newNormalObj(New_Arm2D_Tile);
obj_setStruct(root, "_self", _root);
return root;
}
int Arm2D_Tile_height_compare(PikaObj* self, PikaObj* reference) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_tile_t* _reference = obj_getStruct(reference, "_self");
return arm_2d_tile_height_compare(_self, _reference);
}
PikaObj* Arm2D_Tile_region_diff(PikaObj* self, PikaObj* tile) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_tile_t* _tile = obj_getStruct(tile, "_self");
arm_2d_region_t _region = {0};
arm_2d_tile_region_diff(_self, _tile, &_region);
PikaObj* region = newNormalObj(New_Arm2D_Region);
obj_setStruct(region, "_self", _region);
return region;
}
int Arm2D_Tile_shape_compare(PikaObj* self, PikaObj* reference) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_tile_t* _reference = obj_getStruct(reference, "_self");
return arm_2d_tile_shape_compare(_self, _reference);
}
int Arm2D_Tile_width_compare(PikaObj* self, PikaObj* reference) {
arm_2d_tile_t* _self = obj_getStruct(self, "_self");
arm_2d_tile_t* _reference = obj_getStruct(reference, "_self");
return arm_2d_tile_width_compare(_self, _reference);
}

View File

@ -66,9 +66,8 @@ void pika_arm2d_init(void) {
}
}
void Arm2D_Window_init(PikaObj* self) {
void Arm2D_Window___init__(PikaObj* self) {
__Arm2D_platform_Init();
obj_run(self, "background.init()");
pika_arm2d_init();
pika_arm2d_window.pika_windows_object = self;
pika_arm2d_window.pika_elems_object = obj_getObj(self, "elems");

View File

@ -5,10 +5,10 @@
#include "Arm2D_Box.h"
#include "BaseObj.h"
#include "arm_2d.h"
#include "arm_2d_helper.h"
#include "dataStrs.h"
#include "pikaScript.h"
#include "arm2d_config.h"
#include "arm_2d_cfg.h"
#include "arm_2d_helper.h"
#ifndef ARM2DQEMUBOOTER_APP_ARM2D_H_
#define APPLICATIONS_APP_ARM2D_H_
@ -71,4 +71,19 @@ typedef struct {
arm_2d_region_t tRegion;
} rotate_tile_t;
#define __implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
ARM_NOINIT static __TYPE \
__NAME##Buffer[(__WIDTH) * (__HEIGHT)]; \
const arm_2d_tile_t __NAME = { \
.tRegion = { \
.tSize = {(__WIDTH), (__HEIGHT)}, \
}, \
.tInfo.bIsRoot = true, \
.pchBuffer = (uint8_t *)__NAME##Buffer, \
__VA_ARGS__ \
};
#define implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
__implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ##__VA_ARGS__)
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
* Copyright (c) 2009-2022 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -18,31 +18,50 @@
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d.c
* Description: Tables for pixel pipeline OPs
* Title: #include "arm_2d_dis_adapters.h"
* Description: Public header file to include all display adapter header files
*
* $Date: 02 Oct 2021
* $Date: 12. Aug 2022
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
*
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_DISP_ADAPTERS_H__
#define __ARM_2D_DISP_ADAPTERS_H__
/*============================ INCLUDES ======================================*/
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER0__
# include "arm_2d_disp_adapter_0.h"
#endif
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER1__
# include "arm_2d_disp_adapter_1.h"
#endif
#define __ARM_2D_COMPILATION_UNIT
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER2__
# include "arm_2d_disp_adapter_2.h"
#endif
#include "__arm_2d_core.c"
#include "__arm_2d_tile.c"
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER3__
# include "arm_2d_disp_adapter_3.h"
#endif
#ifdef __cplusplus
extern "C" {
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER4__
# include "arm_2d_disp_adapter_4.h"
#endif
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER5__
# include "arm_2d_disp_adapter_5.h"
#endif
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER6__
# include "arm_2d_disp_adapter_6.h"
#endif
#ifdef __RTE_ACCELERATION_ARM_2D_HELPER_DISP_ADAPTER7__
# include "arm_2d_disp_adapter_7.h"
#endif
/*============================ MACROS ========================================*/
@ -50,10 +69,6 @@ extern "C" {
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2020 Arm Limited. All rights reserved.
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -16,12 +16,25 @@
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d_helper.h"
* Description: Public header file for the all helper services
*
* $Date: 03. Sept 2022
* $Revision: V.1.2.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_HELPER_H__
#define __ARM_2D_HELPER_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d.h"
#include "./arm_2d_helper_pfb.h"
#include "./arm_2d_helper_scene.h"
#include "./arm_2d_disp_adapters.h"
#ifdef __cplusplus
extern "C" {
@ -30,16 +43,26 @@ extern "C" {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
/*!
* \addtogroup gHelper 7 Helper Services
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define __declare_tile(__NAME) \
extern const arm_2d_tile_t __NAME;
#define declare_tile(__NAME) __declare_tile(__NAME)
#define __declare_tile(__name) \
extern const arm_2d_tile_t __name;
#define declare_tile(__name) __declare_tile(__name)
#define __implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
#define dcl_tile(__name) declare_tile(__name)
#define dcl_fb(__name) declare_tile(__name)
#define __impl_fb(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
ARM_NOINIT static __TYPE \
__NAME##Buffer[(__WIDTH) * (__HEIGHT)]; \
const arm_2d_tile_t __NAME = { \
@ -51,8 +74,8 @@ extern "C" {
__VA_ARGS__ \
};
#define implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
__implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ##__VA_ARGS__)
#define impl_fb(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
__impl_fb(__NAME, __WIDTH, __HEIGHT, __TYPE, ##__VA_ARGS__)
#define get_tile_buffer_pixel_count(__NAME) \
(uint32_t)( (__NAME.tRegion.tSize.iWidth) \
@ -62,17 +85,34 @@ extern "C" {
(get_2d_layer_buffer_pixel_count(__NAME) * sizeof(TYPE))
#define impl_child_tile(__PARENT, __X, __Y, __WIDTH, __HEIGHT, ...) { \
.tRegion = { \
.tLocation = { \
.iX = (__X), \
.iY = (__Y), \
}, \
.tSize = { \
.iWidth = (__WIDTH), \
.iHeight = (__HEIGHT), \
}, \
}, \
.tInfo.bIsRoot = false, \
.tInfo.bDerivedResource = true, \
.ptParent = (arm_2d_tile_t *)&(__PARENT), \
__VA_ARGS__ \
}
#define __arm_2d_align_centre2(__region, __size) \
for (arm_2d_region_t __centre_region = { \
.tSize = (__size), \
.tLocation = { \
.iX = ((__region).tRegion.tSize.iWidth - (__size).iWidth) >> 1,\
.iY = ((__region).tRegion.tSize.iHeight - (__size).iHeight)>> 1,\
.iX = ((__region).tSize.iWidth - (__size).iWidth) >> 1,\
.iY = ((__region).tSize.iHeight - (__size).iHeight)>> 1,\
}, \
}, \
*ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL; \
arm_2d_op_wait_async(NULL) \
)
#define __arm_2d_align_centre3(__region, __width, __height) \
@ -82,8 +122,8 @@ extern "C" {
.iHeight = (__height), \
}, \
.tLocation = { \
.iX = ((__region).tRegion.tSize.iWidth - (__width)) >> 1, \
.iY = ((__region).tRegion.tSize.iHeight - (__height))>> 1, \
.iX = ((__region).tSize.iWidth - (__width)) >> 1, \
.iY = ((__region).tSize.iHeight - (__height))>> 1, \
}, \
}, \
*ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
@ -95,11 +135,47 @@ extern "C" {
ARM_CONNECT2( __arm_2d_align_centre, \
__ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
/*!
* \brief set an alarm with given period and check the status
*
* \param[in] wMS a time period in millisecond
* \param[in] ... an optional timestamp holder
*
* \return bool whether it is timeout
*/
#define arm_2d_helper_is_time_out(__MS, ...) \
__arm_2d_helper_is_time_out((__MS), (NULL, ##__VA_ARGS__))
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
__STATIC_INLINE bool __arm_2d_helper_is_time_out(uint32_t wMS, int64_t *plTimestamp)
{
int64_t lTimestamp = arm_2d_helper_get_system_timestamp();
static int64_t s_lTimestamp = 0;
if (NULL == plTimestamp) {
plTimestamp = &s_lTimestamp;
}
if (0 == *plTimestamp) {
*plTimestamp = arm_2d_helper_convert_ms_to_ticks(wMS);
*plTimestamp += lTimestamp;
return false;
}
if (lTimestamp >= *plTimestamp) {
*plTimestamp = arm_2d_helper_convert_ms_to_ticks(wMS) + lTimestamp;
return true;
}
return false;
}
/*! @} */
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

View File

@ -0,0 +1,625 @@
/*
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d_helper_pfb.h"
* Description: Public header file for the PFB helper service
*
* $Date: 29. Aug 2022
* $Revision: V.1.2.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_HELPER_PFB_H__
#define __ARM_2D_HELPER_PFB_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wpadded"
#endif
/*!
* \addtogroup gHelper 7 Helper Services
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*!
* \brief a macro wrapper in uppercase to help initialising PFB service
* \param[in] __CB_ADDR the address of the arm_2d_helper_pfb_t object
* \param[in] __SCREEN_WIDTH the width of the screen
* \param[in] __SCREEN_HEIGHT the hight of the screen
* \param[in] __PIXEL_TYPE the integer type of the pixel, i.e. uint8_t, uint16_t,
* uint32_t
* \param[in] __WIDTH the width of the PFB block
* \param[in] __HEIGHT the height of the PFB block
* \note For the same number of pixels in a PFB block, please priority the width
* over height, for example, 240 * 1 is better than 30 * 8
* \param[in] __PFB_NUM the number of PFB blocks in the built-in PFB pool.
* \param[in] ... a code block to add additional initializer, see example below:
* \return arm_2d_err_t the result of the initialisation process
*
* \code {.c}
static ARM_NOINIT arm_2d_helper_pfb_t s_tExamplePFB;
...
// initialise FPB helper
if (ARM_2D_HELPER_PFB_INIT(
&s_tExamplePFB, // FPB Helper object
__GLCD_CFG_SCEEN_WIDTH__, // screen width
__GLCD_CFG_SCEEN_HEIGHT__, // screen height
uint16_t, // colour date type
240, // PFB block width
1, // PFB block height
1, // number of PFB in the PFB pool
{
.evtOnLowLevelRendering = {
// callback for low level rendering
.fnHandler = &__pfb_render_handler,
},
.evtOnDrawing = {
// callback for drawing GUI
.fnHandler = &__pfb_draw_background_handler,
},
},
//.FrameBuffer.bSwapRGB16 = true,
) < 0) {
//! error detected
assert(false);
}
* \endcode
*
*/
#define ARM_2D_HELPER_PFB_INIT( __CB_ADDR, /* PFB Helper object address */ \
__SCREEN_WIDTH, /* Screen width */ \
__SCREEN_HEIGHT,/* Screen height */ \
__PIXEL_TYPE, /* The type of the pixels */ \
__WIDTH, /* The width of the PFB block */\
__HEIGHT, /* The height of the PFB block*/\
__PFB_NUM, /* Block count in the PFB pool*/\
... /* Event Handler */ \
) \
({ \
__attribute__((section(".bss.noinit.arm_2d_pfb_pool"))) \
static struct { \
arm_2d_pfb_t tFPB; \
__ALIGNED(4) \
__PIXEL_TYPE tBuffer[(__WIDTH) * (__HEIGHT)]; \
} s_tPFBs[__PFB_NUM]; \
\
arm_2d_helper_pfb_cfg_t tCFG = { \
.tDisplayArea.tSize = { \
.iWidth = (__SCREEN_WIDTH), \
.iHeight = (__SCREEN_HEIGHT), \
}, \
\
.FrameBuffer.ptPFBs = (arm_2d_pfb_t *)s_tPFBs, \
.FrameBuffer.tFrameSize = { \
.iWidth = (__WIDTH), \
.iHeight = (__HEIGHT), \
}, \
.FrameBuffer.wBufferSize = sizeof(s_tPFBs[0].tBuffer), \
.FrameBuffer.hwPFBNum = dimof(s_tPFBs), \
.Dependency = \
__VA_ARGS__ \
}; \
\
arm_2d_helper_pfb_init((__CB_ADDR), &tCFG); \
})
/*!
* \brief a macro wrapper to update the evtOnDrawring event handler
* \param[in] __CB_ADDR the address of the arm_2d_helper_pfb_t object
* \param[in] __HANDLER the new handler
* \param[in] ... [Optional] an address (of user defined structure) passed to the
* event handler.
* \return arm_2d_err_t the process result
*/
#define ARM_2D_HELPER_PFB_UPDATE_ON_DRAW_HANDLER( \
__CB_ADDR, /* PFB Helper object address */ \
__HANDLER, /* new on-draw-handler function*/\
...) /* An optional target address */ \
arm_2d_helper_pfb_update_dependency((__CB_ADDR), \
ARM_2D_PFB_DEPEND_ON_DRAWING, \
(arm_2d_helper_pfb_dependency_t []) {{ \
.evtOnDrawing = { \
.fnHandler = (__HANDLER), \
.pTarget = (NULL,##__VA_ARGS__),\
}, \
}})
#define __IMPL_ARM_2D_REGION_LIST(__NAME, ...) \
enum { \
__NAME##_offset = __COUNTER__, \
}; \
__VA_ARGS__ \
arm_2d_region_list_item_t __NAME[] = {
#define IMPL_ARM_2D_REGION_LIST(__NAME, ...) \
__IMPL_ARM_2D_REGION_LIST(__NAME,##__VA_ARGS__)
#define END_IMPL_ARM_2D_REGION_LIST(...) \
};
#define __ADD_REGION_TO_LIST(__NAME, ...) \
{ \
.ptNext = (arm_2d_region_list_item_t *) \
&(__NAME[__COUNTER__ - __NAME##_offset]), \
.tRegion = { \
__VA_ARGS__ \
}, \
}
#define ADD_REGION_TO_LIST(__NAME, ...) \
__ADD_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define __ADD_LAST_REGION_TO_LIST(__NAME, ...) \
{ \
.ptNext = NULL, \
.tRegion = { \
__VA_ARGS__ \
}, \
}
#define ADD_LAST_REGION_TO_LIST(__NAME, ...) \
__ADD_LAST_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define IMPL_PFB_ON_DRAW(__NAME) \
arm_fsm_rt_t __NAME(void *pTarget, \
const arm_2d_tile_t *ptTile, \
bool bIsNewFrame)
#define IMPL_PFB_ON_LOW_LV_RENDERING(__NAME) \
void __NAME(void *pTarget, \
const arm_2d_pfb_t *ptPFB, \
bool bIsNewFrame)
#define IMPL_PFB_ON_FRAME_SYNC_UP(__NAME) \
bool __NAME(void *pTarget)
/*!
* \brief a macro wrapper in lowercase to help initialising PFB service
* \param[in] __CB_ADDR the address of the arm_2d_helper_pfb_t object
* \param[in] __SCREEN_WIDTH the width of the screen
* \param[in] __SCREEN_HEIGHT the hight of the screen
* \param[in] __PIXEL_TYPE the integer type of the pixel, i.e. uint8_t, uint16_t,
* uint32_t
* \param[in] __WIDTH the width of the PFB block
* \param[in] __HEIGHT the height of the PFB block
* \note For the same number of pixels in a PFB block, please priority the width
* over height, for example, 240 * 1 is better than 30 * 8
* \param[in] __PFB_NUM the number of PFB blocks in the built-in PFB pool.
* \param[in] ... a code block to add additional initializer, see example below:
* \return arm_2d_err_t the result of the initialisation process
*
* \code {.c}
static ARM_NOINIT arm_2d_helper_pfb_t s_tExamplePFB;
...
// initialise FPB helper
if (init_arm_2d_helper_pfb(
&s_tExamplePFB, // FPB Helper object
__GLCD_CFG_SCEEN_WIDTH__, // screen width
__GLCD_CFG_SCEEN_HEIGHT__, // screen height
uint16_t, // colour date type
240, // PFB block width
1, // PFB block height
1, // number of PFB in the PFB pool
{
.evtOnLowLevelRendering = {
// callback for low level rendering
.fnHandler = &__pfb_render_handler,
},
.evtOnDrawing = {
// callback for drawing GUI
.fnHandler = &__pfb_draw_background_handler,
},
},
//.FrameBuffer.bSwapRGB16 = true,
) < 0) {
//! error detected
assert(false);
}
* \endcode
*
*/
#define init_arm_2d_helper_pfb( __CB_ADDR, \
__SCREEN_WIDTH, \
__SCREEN_HEIGHT, \
__PIXEL_TYPE, \
__WIDTH, \
__HEIGHT, \
__PFB_NUM, \
... \
) \
ARM_2D_HELPER_PFB_INIT( \
__CB_ADDR, \
__SCREEN_WIDTH, \
__SCREEN_HEIGHT, \
__PIXEL_TYPE, \
__WIDTH, \
__HEIGHT, \
__PFB_NUM, \
##__VA_ARGS__ \
)
/*!
* \brief a macro wrapper to update the evtOnDrawring event handler
* \param[in] __CB_ADDR the address of the arm_2d_helper_pfb_t object
* \param[in] __HANDLER the new handler
* \param[in] ... [Optional] an address (of user defined structure) passed to the
* event handler.
* \return arm_2d_err_t the process result
*/
#define update_arm_2d_helper_pfb_on_draw_handler( \
__CB_ADDR, /* PFB Helper object address */ \
__HANDLER, /* new on-draw-handler function*/\
...) /* An optional target address */ \
ARM_2D_HELPER_PFB_UPDATE_ON_DRAW_HANDLER( \
(__CB_ADDR), \
(__HANDLER),##__VA_ARGRS__)
#define impl_arm_2d_region_list(__NAME, ...) \
IMPL_ARM_2D_REGION_LIST(__NAME,##__VA_ARGS__)
#define add_region_to_list(__NAME, ...) \
ADD_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define add_last_region_to_list(__NAME, ...) \
ADD_LAST_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define end_impl_arm_2d_region_list(...) \
END_IMPL_ARM_2D_REGION_LIST(__VA_ARGS__)
#define impl_pfb_on_draw(__NAME) IMPL_PFB_ON_DRAW(__NAME)
#define impl_pfb_on_low_lv_rendering(__NAME) \
IMPL_PFB_ON_LOW_LV_RENDERING(__NAME)
/*============================ TYPES =========================================*/
typedef struct arm_2d_helper_pfb_t arm_2d_helper_pfb_t;
/*!
* \brief the header of a PFB block
*/
typedef struct arm_2d_pfb_t {
struct arm_2d_pfb_t *ptNext; //!< next pfb block
arm_2d_helper_pfb_t *ptPFBHelper; //!< the pfb helper service current PFB block comes from
arm_2d_tile_t tTile; //!< descriptor
uint32_t u24Size : 24;
uint32_t : 7;
uint32_t bIsNewFrame : 1; //!< a flag to indicate the starting of a frame
}arm_2d_pfb_t;
/*!
* \brief the node of a region list
*
*/
typedef struct arm_2d_region_list_item_t {
struct arm_2d_region_list_item_t *ptNext; //!< the next node
arm_2d_region_t tRegion; //!< the region
}arm_2d_region_list_item_t;
/*!
* \brief the On-Drawing event handler for application layer
*
* \param[in] pTarget a user attached target address
* \param[in] ptTile a tile for the virtual screen
* \param[in] bIsNewFrame a flag indicate the starting of a new frame
* \return arm_fsm_rt_t the status of the FSM.
*/
typedef arm_fsm_rt_t arm_2d_helper_draw_handler_t(
void *pTarget,
const arm_2d_tile_t *ptTile,
bool bIsNewFrame);
/*!
* \brief the On Low Level Rendering event handler for the low level (LCD Driver)
*
* \param[in] pTarget a user attached target address
* \param[in] ptPFB the PFB block
* \param[in] bIsNewFrame a flag indicate the starting of a new frame
*/
typedef void arm_2d_helper_render_handler_t(
void *pTarget,
const arm_2d_pfb_t *ptPFB,
bool bIsNewFrame);
/*!
* \brief on low level render event
*/
typedef struct arm_2d_helper_render_evt_t {
arm_2d_helper_render_handler_t *fnHandler; //!< event handler function
void *pTarget; //!< user attached target
} arm_2d_helper_render_evt_t;
/*!
* \brief on drawing event
*/
typedef struct arm_2d_helper_draw_evt_t {
arm_2d_helper_draw_handler_t *fnHandler; //!< event handler function
void *pTarget; //!< user attached target
} arm_2d_helper_draw_evt_t;
/*!
* \brief the enumeration for events
*
*/
enum {
ARM_2D_PFB_DEPEND_ON_LOW_LEVEL_RENDERING = _BV(0), //!< On Low Level Rendering Event
ARM_2D_PFB_DEPEND_ON_DRAWING = _BV(1), //!< On Drawing Event
ARM_2D_PFB_DEPEND_ON_LOW_LEVEL_SYNC_UP = _BV(2), //!< On Low Level Sync-up Event
ARM_2D_PFB_DEPEND_ON_FRAME_SYNC_UP = _BV(3), //!< On Frame Sync-up Event
};
/*!
* \brief The PFB Helper Service Dependency
*
*/
typedef struct arm_2d_helper_pfb_dependency_t {
//! event handler for low level rendering
arm_2d_helper_render_evt_t evtOnLowLevelRendering;
//! event handler for drawing GUI
arm_2d_helper_draw_evt_t evtOnDrawing;
//! low level rendering handler wants to sync-up (return arm_fsm_rt_wait_for_obj)
arm_2d_evt_t evtOnLowLevelSyncUp;
} arm_2d_helper_pfb_dependency_t;
/*!
* \brief PFB Helper configuration
*
*/
typedef struct arm_2d_helper_pfb_cfg_t {
arm_2d_region_t tDisplayArea; //!< screen description
struct {
arm_2d_pfb_t *ptPFBs; //!< current PFB block
arm_2d_size_t tFrameSize; //!< the size of the frame
uint32_t wBufferSize; //!< the buffer size
uint16_t hwPFBNum; //!< the number of PFB
uint16_t bDoNOTUpdateDefaultFrameBuffer : 1; //!< A flag to disable automatically default-framebuffer-registration
uint16_t bDisableDynamicFPBSize : 1; //!< A flag to disable resize of the PFB block
uint16_t bSwapRGB16 : 1; //!< A flag to enable swapping high and low bytes of an RGB16 pixel
uint16_t : 9;
uint16_t u4PoolReserve : 4; //!< reserve specific number of PFB for other helper services
} FrameBuffer; //!< frame buffer context
arm_2d_helper_pfb_dependency_t Dependency; //!< user registered dependency
} arm_2d_helper_pfb_cfg_t;
/*!
* \brief the PFB helper control block
*
*/
struct arm_2d_helper_pfb_t{
ARM_PRIVATE(
arm_2d_helper_pfb_cfg_t tCFG; //!< user configuration
struct {
arm_2d_region_t tDrawRegion;
arm_2d_region_t tTargetRegion;
arm_2d_region_list_item_t *ptDirtyRegion;
arm_2d_tile_t tPFBTile;
arm_2d_size_t tFrameSize;
bool bFirstIteration;
bool bIsRegionChanged;
uint8_t chPT;
struct {
uint8_t bIsNewFrame : 1;
uint8_t bIsFlushRequested :1;
};
uint16_t hwFreePFBCount;
arm_2d_pfb_t *ptCurrent;
arm_2d_pfb_t *ptFreeList;
struct {
arm_2d_pfb_t *ptHead;
arm_2d_pfb_t *ptTail;
}FlushFIFO;
arm_2d_tile_t *ptFrameBuffer;
} Adapter;
)
struct {
int64_t lTimestamp; //!< PLEASE DO NOT USE
int32_t nTotalCycle; //!< cycles used by drawing
int32_t nRenderingCycle; //!< cycles used in LCD flushing
} Statistics; //!< performance statistics
};
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*!
* \brief initialize pfb helper service
* \param[in] ptThis the pfb helper control block
* \param[in] ptCFG the configuration
* \return arm_2d_err_t the process result
*/
extern
ARM_NONNULL(1,2)
arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
arm_2d_helper_pfb_cfg_t *ptCFG);
/*!
* \brief get the display (screen) region
* \param[in] ptThis the pfb helper control block
* \return arm_2d_region_t the screen region
*/
extern
ARM_NONNULL(1)
arm_2d_region_t arm_2d_helper_pfb_get_display_area(arm_2d_helper_pfb_t *ptThis);
/*!
* \brief the task function for pfb helper
* \param[in] ptThis an initialised PFB control block
* \param[in] ptDirtyRegions a region list pending for refresh, NULL means
* refreshing the whole screen
* \retval arm_fsm_rt_cpl complete refreshing one frame
* \retval arm_fsm_rt_on_going the refreshing work is on-going
* \retval arm_fsm_rt_wait_for_obj user's OnDrawing event handler wants to wait
* for some objects, e.g. semaphore etc.
* \retval <0 An error is detected
*/
extern
ARM_NONNULL(1)
arm_fsm_rt_t arm_2d_helper_pfb_task(arm_2d_helper_pfb_t *ptThis,
arm_2d_region_list_item_t *ptDirtyRegions);
/*!
* \brief flush the FPB FIFO
* \note This function is THREAD-SAFE
* \note For normal usage, please DO NOT use this function unless you know what
* you are doing.
* \param[in] ptThis an initialised PFB control block
*/
extern
ARM_NONNULL(1)
void arm_2d_helper_pfb_flush(arm_2d_helper_pfb_t *ptThis);
/*!
* \brief update PFB dependency (event handlers)
* \param[in] ptThis the PFB control block
* \param[in] chMask the bit mask for event handlers
* \param[in] ptDependency the new dependency description
* \return arm_2d_err_t the process result
*/
extern
ARM_NONNULL(1,3)
arm_2d_err_t arm_2d_helper_pfb_update_dependency(
arm_2d_helper_pfb_t *ptThis,
uint_fast8_t chMask,
const arm_2d_helper_pfb_dependency_t *ptDependency);
/*!
* \brief tell PFB helper that a low level LCD flushing work is complete
* \note This function is THREAD-SAFE, You can call this function asynchronously,
* e.g.
* - A ISR to indicate DMA-transfer complete event or
* - A different Thread
* \param[in] ptThis the PFB control block
* \param[in] ptPFB the used PFB block
*/
extern
ARM_NONNULL(1,2)
void arm_2d_helper_pfb_report_rendering_complete( arm_2d_helper_pfb_t *ptThis,
arm_2d_pfb_t *ptPFB);
/*!
* \brief swap the high and low bytes for each rgb16 pixel
*
* \params[in] phwBuffer the pixel buffer
* \note the phwBuffer MUST aligned to half-word addresses
*
* \params[in] wSize the number of pixels
*/
extern
void arm_2d_helper_swap_rgb16(uint16_t *phwBuffer, uint32_t wCount);
/*!
* \brief convert ticks of a reference timer to millisecond
*
* \param[in] lTick the tick count
* \return int64_t the millisecond
*/
extern
int64_t arm_2d_helper_convert_ticks_to_ms(int64_t lTick);
/*!
* \brief convert millisecond into ticks of the reference timer
*
* \param[in] wMS the target time in millisecond
* \return int64_t the ticks
*/
extern
int64_t arm_2d_helper_convert_ms_to_ticks(uint32_t wMS);
/*!
* \brief get the reference clock frequency
* \return uint32_t the frequency
*/
extern
uint32_t arm_2d_helper_get_reference_clock_frequency(void);
/*!
* \brief get the current system stamp from the reference clock
*
* \return int64_t the timestamp in ticks (no overflow issue)
* \note you have to call arm_2d_helper_convert_ticks_to_ms() to convert the
* the timestamp into milliseconds when required.
*/
extern
int64_t arm_2d_helper_get_system_timestamp(void);
/*!
* \brief try to get a PFB block from the pool
* \param[in] ptThis the PFB control block
* \retval NULL the pool is empty
* \retval !NULL a valid pfb block
*/
extern
ARM_NONNULL(1)
arm_2d_pfb_t *__arm_2d_helper_pfb_new(arm_2d_helper_pfb_t *ptThis);
/*!
* \brief free a PFB block to the pool
* \param[in] ptThis the PFB control block
* \param[in] ptPFB the target PFB block
*/
extern
ARM_NONNULL(1)
void __arm_2d_helper_pfb_free(arm_2d_helper_pfb_t *ptThis, arm_2d_pfb_t *ptPFB);
/*! @} */
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,292 @@
/*
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d_helper_scene.h"
* Description: Public header file for the scene service
*
* $Date: 29. Aug 2022
* $Revision: V.1.3.4
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_HELPER_SCENE_H__
#define __ARM_2D_HELPER_SCENE_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_helper_pfb.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
# pragma clang diagnostic ignored "-Wpadded"
#endif
/*!
* \addtogroup gHelper 7 Helper Services
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*!
* \brief scene switching mode
*/
typedef enum {
/* valid switching visual effects begin */
ARM_2D_SCENE_SWITCH_MODE_NONE = 0, //!< no switching visual effect
ARM_2D_SCENE_SWITCH_MODE_USER = 1, //!< user defined switching visual effect
ARM_2D_SCENE_SWITCH_MODE_FADE_WHITE = 2, //!< fade in fade out (white)
ARM_2D_SCENE_SWITCH_MODE_FADE_BLACK = 3, //!< fade in fade out (black)
ARM_2D_SCENE_SWITCH_MODE_SLIDE_LEFT = 4, //!< slide left
ARM_2D_SCENE_SWITCH_MODE_SLIDE_RIGHT, //!< slide right
ARM_2D_SCENE_SWITCH_MODE_SLIDE_UP, //!< slide up
ARM_2D_SCENE_SWITCH_MODE_SLIDE_DOWN, //!< slide down
ARM_2D_SCENE_SWITCH_MODE_ERASE_LEFT = 8, //!< erase to the right
ARM_2D_SCENE_SWITCH_MODE_ERASE_RIGHT, //!< erase to the left
ARM_2D_SCENE_SWITCH_MODE_ERASE_UP, //!< erase to the top
ARM_2D_SCENE_SWITCH_MODE_ERASE_DOWN, //!< erase to the bottom
/* valid switching visual effects end */
__ARM_2D_SCENE_SWITCH_MODE_VALID, //!< For internal user only
ARM_2D_SCENE_SWITCH_MODE_IGNORE_OLD_BG = _BV(8), //!< ignore the background of the old scene
ARM_2D_SCENE_SWITCH_MODE_IGNORE_OLD_SCEBE = _BV(9), //!< ignore the old scene
ARM_2D_SCENE_SWITCH_MODE_IGNORE_NEW_BG = _BV(10), //!< ignore the background of the new scene
ARM_2D_SCENE_SWITCH_MODE_IGNORE_NEW_SCEBE = _BV(11), //!< ignore the new scene
ARM_2D_SCENE_SWITCH_MODE_DEFAULT_BG_WHITE = 0 << 12, //!< use white as default background
ARM_2D_SCENE_SWITCH_MODE_DEFAULT_BG_BLACK = 1 << 12, //!< use black as default background
ARM_2D_SCENE_SWITCH_MODE_DEFAULT_BG_USER = 2 << 12, //!< use user defined default background
__ARM_2D_SCENE_SWTICH_MODE_IGNORE_msk = 0x0F << 8, //!< For internal user only
__ARM_2D_SCENE_SWTICH_MODE_IGNORE_pos = 8, //!< For internal user only
__ARM_2D_SCENE_SWTICH_MODE_DEFAULT_BG_msk = 3 << 12, //!< For internal user only
__ARM_2D_SCENE_SWTICH_MODE_DEFAULT_BG_pos = 12, //!< For internal user only
} arm_2d_scene_player_switch_mode_t;
typedef union __arm_2d_helper_scene_switch_t {
struct {
uint8_t chMode; //!< the switch visual effect
uint8_t bIgnoreOldSceneBG : 1; //!< when set, ignore the background of the old scene
uint8_t bIgnoreOldScene : 1; //!< when set, ignore the old scene
uint8_t bIgnoreNewSceneBG : 1; //!< when set, ignore the background of the new scene
uint8_t bIgnoreNewScene : 1; //!< when set, ignore the new scene
uint8_t u2DefaultBG : 2; //!< the default background
uint8_t : 2;
} Feature;
uint16_t hwSetting; //!< the setting value
}__arm_2d_helper_scene_switch_t;
typedef struct arm_2d_scene_player_t arm_2d_scene_player_t;
/*!
* \brief a class for describing scenes which are the combination of a
* background and a foreground with a dirty-region-list support
*
*/
typedef struct arm_2d_scene_t arm_2d_scene_t;
struct arm_2d_scene_t {
arm_2d_scene_t *ptNext; //!< next scene
arm_2d_scene_player_t *ptPlayer; //!< points to the host scene player
arm_2d_region_list_item_t *ptDirtyRegion; //!< dirty region list for the foreground
arm_2d_helper_draw_handler_t *fnBackground; //!< the function pointer for the background
arm_2d_helper_draw_handler_t *fnScene; //!< the function pointer for the foreground
void (*fnOnBGStart)(arm_2d_scene_t *ptThis); //!< on-start-drawing-background event handler
void (*fnOnBGComplete)(arm_2d_scene_t *ptThis); //!< on-complete-drawing-background event handler
void (*fnOnFrameStart)(arm_2d_scene_t *ptThis); //!< on-frame-start event handler
void (*fnOnFrameCPL)(arm_2d_scene_t *ptThis); //!< on-frame-complete event handler
/*!
* \note We use fnDepose to free the resources
*/
void (*fnDepose)(arm_2d_scene_t *ptThis); //!< on-scene-depose event handler
struct {
uint8_t bOnSwitchingIgnoreBG : 1; //!< ignore background during switching period
uint8_t bOnSwitchingIgnoreScene : 1; //!< ignore forground during switching period
};
};
/*!
* \brief a class to manage scenes
*
*/
struct arm_2d_scene_player_t {
inherit(arm_2d_helper_pfb_t); //!< inherit from arm_2d_helper_pfb_t
ARM_PRIVATE(
struct {
arm_2d_scene_t *ptHead; //!< points to the head of the FIFO
arm_2d_scene_t *ptTail; //!< points to the tail of the FIFO
} SceneFIFO; //!< Scene FIFO
struct {
uint8_t bNextSceneReq : 1; //!< a flag to request switching-to-the next-scene
uint8_t bSwitchCPL : 1; //!< indication of scene switching completion
uint8_t : 6;
uint8_t chState; //!< the state of the FSM used by runtime.
} Runtime; //!< scene player runtime
struct {
union {
uint8_t chState;
struct {
uint8_t chState;
uint8_t chOpacity;
bool bIsFadeBlack;
}Fade;
struct {
uint8_t chState;
arm_2d_tile_t tSceneWindow;
arm_2d_tile_t tTemp;
int16_t iOffset;
}Erase;
struct {
uint8_t chState;
arm_2d_tile_t tSceneWindow;
int16_t iOffset;
}Slide;
};
__arm_2d_helper_scene_switch_t tConfig; //!< the switching configuration
uint16_t hwPeriod; //!< the switching should finish in specified millisecond
int64_t lTimeStamp;
}Switch;
)
};
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*!
* \brief flush the scene FIFO
*
* \param[in] ptThis the target scene player
*/
extern
ARM_NONNULL(1)
void arm_2d_scene_player_flush_fifo(arm_2d_scene_player_t *ptThis);
/*!
* \brief append a set of scenes to a scene player
*
* \param[in] ptThis the target scene player
* \param[in] ptScenes a scene array
* \param[in] hwCount the number of scenes in the array
*/
extern
ARM_NONNULL(1)
void arm_2d_scene_player_append_scenes(arm_2d_scene_player_t *ptThis,
arm_2d_scene_t *ptScenes,
int_fast16_t hwCount);
/*!
* \brief request switching to the next scene safely
*
* \param[in] ptThis the target scene player
*
* \note Once received a request, the scene player will only switch to the
* next scene at the end of a frame.
*/
extern
ARM_NONNULL(1)
void arm_2d_scene_player_switch_to_next_scene(arm_2d_scene_player_t *ptThis);
/*!
* \brief configure the scene switching mode
*
* \param[in] ptThis the target scene player
* \param[in] hwSettings a combination of valid settings defined in
* arm_2d_scene_player_switch_mode_t
*/
extern
ARM_NONNULL(1)
void arm_2d_scene_player_set_switching_mode(arm_2d_scene_player_t *ptThis,
uint_fast16_t hwSettings);
/*!
* \brief read the current scene switching mode
*
* \param[in] ptThis the target scene player
* \return uint16_t the current setting value for the scene switching mode
*/
extern
ARM_NONNULL(1)
uint16_t arm_2d_scene_player_get_switching_mode(arm_2d_scene_player_t *ptThis);
/*!
* \brief configure the scene switching period
*
* \param[in] ptThis the target scene player
* \param[in] hwMS period in millisecond
*/
extern
ARM_NONNULL(1)
void arm_2d_scene_player_set_switching_period( arm_2d_scene_player_t *ptThis,
uint_fast16_t hwMS);
/*!
* \brief the scene player task function
*
* \param[in] ptThis the target scene player
*
* \note the event sequence of a scene:
* 1. when fnBackground is valid
* - invoke fnOnBGStart when it is valid
* - invoke fnBackground
* - invoke fnOnBGComplete when it is valid
* 2. invoke fnOnFrameStart when it is valid
* 3. invoke fnScene
* 4. invoke fnOnFrameCPL when it is valid
* 5. Check bNextSceneReq
* - false (0), go back to step 2
* - true, invoke fnDepose when it is valid and switch to the next scene
*
*/
extern
ARM_NONNULL(1)
arm_fsm_rt_t arm_2d_scene_player_task(arm_2d_scene_player_t *ptThis);
/*! @} */
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -16,6 +16,17 @@
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d_helper_pfb.c"
* Description: the pfb helper service source code
*
* $Date: 29. Aug 2022
* $Revision: V.1.2.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
/*============================ INCLUDES ======================================*/
#define __ARM_2D_IMPL__
@ -24,11 +35,17 @@
#include <assert.h>
#include "arm_2d_helper.h"
#if defined(__PERF_COUNTER__)
# include "perf_counter.h"
#else
# include <time.h>
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
# pragma clang diagnostic ignored "-Wcast-qual"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wpadded"
@ -130,6 +147,37 @@ Author: Adam Dunkels
/*============================ PROTOTYPES ====================================*/
/*============================ IMPLEMENTATION ================================*/
ARM_NONNULL(1)
arm_2d_pfb_t *__arm_2d_helper_pfb_new(arm_2d_helper_pfb_t *ptThis)
{
assert(NULL != ptThis);
arm_2d_pfb_t *ptPFB = NULL;
arm_irq_safe {
this.Adapter.hwFreePFBCount--;
ARM_LIST_STACK_POP(this.Adapter.ptFreeList, ptPFB);
}
ptPFB->ptPFBHelper = ptThis;
return ptPFB;
}
ARM_NONNULL(1)
void __arm_2d_helper_pfb_free(arm_2d_helper_pfb_t *ptThis, arm_2d_pfb_t *ptPFB)
{
assert(NULL != ptThis);
if (NULL == ptPFB) {
return ;
}
arm_irq_safe {
ARM_LIST_STACK_PUSH(this.Adapter.ptFreeList, ptPFB);
this.Adapter.hwFreePFBCount++;
}
}
ARM_NONNULL(1,2)
arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
arm_2d_helper_pfb_cfg_t *ptCFG)
@ -140,18 +188,17 @@ arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
memset(ptThis, 0, sizeof(this));
this.tCFG = *ptCFG;
if ( (NULL == this.tCFG.Dependency.evtOnDrawing.fnHandler)
|| (NULL == this.tCFG.Dependency.evtOnLowLevelRendering.fnHandler)) {
if (NULL == this.tCFG.Dependency.evtOnLowLevelRendering.fnHandler) {
return ARM_2D_ERR_MISSING_PARAM;
}
//! perform validation
// perform validation
do {
int_fast16_t n = this.tCFG.FrameBuffer.hwPFBNum;
arm_2d_pfb_t *ptItem = this.tCFG.FrameBuffer.ptPFBs;
uint32_t wBufferSize = this.tCFG.FrameBuffer.wBufferSize;
//! handle alignments
// handle alignments
wBufferSize += __alignof__(arm_2d_pfb_t) - 1;
wBufferSize &= ~(__alignof__(arm_2d_pfb_t) - 1);
@ -163,7 +210,8 @@ arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
return ARM_2D_ERR_INVALID_PARAM;
}
//! add PFBs to pool
this.Adapter.hwFreePFBCount = 0;
// add PFBs to pool
do {
ptItem->tTile = (arm_2d_tile_t) {
.tRegion = {
@ -172,9 +220,13 @@ arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
.tInfo.bIsRoot = true,
.pchBuffer = (uint8_t *)((uintptr_t)ptItem + sizeof(arm_2d_pfb_t)),
};
ARM_LIST_STACK_PUSH(this.Adapter.ptFreeList, ptItem);
//! update pointer
// update buffer size
ptItem->u24Size = wBufferSize;
//ARM_LIST_STACK_PUSH(this.Adapter.ptFreeList, ptItem);
__arm_2d_helper_pfb_free(ptThis, ptItem);
// update pointer
ptItem = (arm_2d_pfb_t *)( (uintptr_t)ptItem
+ wBufferSize
+ sizeof(arm_2d_pfb_t));
@ -188,39 +240,55 @@ arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
return ARM_2D_ERR_NONE;
}
static
void __arm_2d_helper_swap_rgb16(uint16_t *phwBuffer, uint32_t wSize)
ARM_NONNULL(1)
arm_2d_region_t arm_2d_helper_pfb_get_display_area(arm_2d_helper_pfb_t *ptThis)
{
if (0 == wSize) {
assert(NULL != ptThis);
return this.tCFG.tDisplayArea;
}
__WEAK
void arm_2d_helper_swap_rgb16(uint16_t *phwBuffer, uint32_t wCount)
{
if (0 == wCount) {
return ;
}
//! aligned (4)
assert((((uintptr_t) phwBuffer) & 0x03) == 0);
uint32_t wWords = wSize >> 1;
// aligned (2)
assert((((uintptr_t) phwBuffer) & 0x01) == 0);
// it is not aligned to 4
if ((((uintptr_t) phwBuffer) & 0x03) == 0x02) {
// handle the leading pixel
uint32_t wTemp = *phwBuffer;
*phwBuffer++ = (uint16_t)__REV16(wTemp);
wCount--;
}
uint32_t wWords = wCount >> 1;
uint32_t *pwBuffer = (uint32_t *)phwBuffer;
wSize &= 0x01;
wCount &= 0x01;
if (wWords > 0) {
do {
uint32_t wTemp = *pwBuffer;
*pwBuffer++ = __REV16(wTemp);
} while(--wWords);
}
if (wSize) {
if (wCount) {
uint32_t wTemp = *pwBuffer;
(*(uint16_t *)pwBuffer) = (uint16_t)__REV16(wTemp);
}
}
static
void __arm_2d_helper_flush_pfb(arm_2d_helper_pfb_t *ptThis)
ARM_NONNULL(1)
void arm_2d_helper_pfb_flush(arm_2d_helper_pfb_t *ptThis)
{
assert(NULL != ptThis);
arm_2d_pfb_t *ptPFB = NULL;
arm_irq_safe {
@ -231,7 +299,9 @@ void __arm_2d_helper_flush_pfb(arm_2d_helper_pfb_t *ptThis)
}
if (NULL != ptPFB) {
//! call handler
ptPFB->ptPFBHelper = ptThis;
// call handler
(*this.tCFG.Dependency.evtOnLowLevelRendering.fnHandler)(
this.tCFG.Dependency.evtOnLowLevelRendering.pTarget,
ptPFB,
@ -253,7 +323,7 @@ void __arm_2d_helper_enqueue_pfb(arm_2d_helper_pfb_t *ptThis)
}
if (bIsFlushRequested) {
__arm_2d_helper_flush_pfb(ptThis);
arm_2d_helper_pfb_flush(ptThis);
}
}
@ -266,7 +336,7 @@ void __arm_2d_helper_low_level_rendering(arm_2d_helper_pfb_t *ptThis)
assert(NULL != this.tCFG.Dependency.evtOnLowLevelRendering.fnHandler);
assert(NULL != this.Adapter.ptCurrent);
//! update location info
// update location info
this.Adapter.ptCurrent->tTile.tRegion.tLocation = (arm_2d_location_t) {
.iX = this.Adapter.tDrawRegion.tLocation.iX
+ this.Adapter.tTargetRegion.tLocation.iX,
@ -275,7 +345,7 @@ void __arm_2d_helper_low_level_rendering(arm_2d_helper_pfb_t *ptThis)
};
if (this.tCFG.FrameBuffer.bSwapRGB16) {
__arm_2d_helper_swap_rgb16( this.Adapter.ptCurrent->tTile.phwBuffer,
arm_2d_helper_swap_rgb16( this.Adapter.ptCurrent->tTile.phwBuffer,
get_tile_buffer_pixel_count(
this.Adapter.ptCurrent->tTile));
}
@ -290,7 +360,7 @@ void __arm_2d_helper_low_level_rendering(arm_2d_helper_pfb_t *ptThis)
static bool __arm_2d_helper_pfb_get_next_dirty_region(arm_2d_helper_pfb_t *ptThis)
{
if (NULL == this.Adapter.ptDirtyRegion) {
//! no dirty region list
// no dirty region list
this.Adapter.bFirstIteration = true;
return false;
@ -299,7 +369,7 @@ static bool __arm_2d_helper_pfb_get_next_dirty_region(arm_2d_helper_pfb_t *ptThi
this.Adapter.ptDirtyRegion = this.Adapter.ptDirtyRegion->ptNext;
if (NULL == this.Adapter.ptDirtyRegion) {
//! reach last item in a chain
// reach last item in a chain
this.Adapter.bFirstIteration = true;
return false;
@ -310,55 +380,63 @@ static bool __arm_2d_helper_pfb_get_next_dirty_region(arm_2d_helper_pfb_t *ptThi
return true;
}
/*! \brief begin a iteration of drawing and request a frame buffer from
*! low level display driver.
*! \param ptTargetRegion the address of the target region in the LCD
*! passing NULL means we want to draw the whole LCD.
*! \retval NULL the display driver is not ready
*! \retval (intptr_t)-1 the display driver want to ignore this drawing
*! (maybe because the target area is out of the LCD)
*! \retval non-null a tile which contains the (partial) frame buffer
* low level display driver.
* \param[in] ptThis the PFB helper control block
* \param[in] ptTargetRegion the address of the target region in the LCD
* passing NULL means we want to draw the whole LCD.
* \retval NULL the display driver is not ready
* \retval (intptr_t)-1 the display driver want to ignore this drawing
* (maybe because the target area is out of the LCD)
* \retval non-null a tile which contains the (partial) frame buffer
*/
static
arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
arm_2d_helper_pfb_t *ptThis,
arm_2d_region_list_item_t *ptDirtyRegions)
{
// arm_irq_safe {
// ARM_LIST_STACK_POP(this.Adapter.ptFreeList, this.Adapter.ptCurrent);
// }
this.Adapter.ptCurrent = NULL;
arm_irq_safe {
ARM_LIST_STACK_POP(this.Adapter.ptFreeList, this.Adapter.ptCurrent);
/* allocating pfb only when the number of free PFB blocks is larger than
* the reserved threashold
*/
if (this.Adapter.hwFreePFBCount > this.tCFG.FrameBuffer.u4PoolReserve) {
this.Adapter.ptCurrent = __arm_2d_helper_pfb_new(ptThis);
}
}
if (NULL == this.Adapter.ptCurrent) {
//! no resource left
// no resource left
return NULL;
}
arm_2d_tile_t *ptPartialFrameBuffer = &(this.Adapter.ptCurrent->tTile);
if (this.Adapter.bFirstIteration) {
this.Adapter.ptDirtyRegion = ptDirtyRegions;
//this.Adapter.bFirstIteration = false;
this.Adapter.bIsRegionChanged = true;
}
do {
if (this.Adapter.bIsRegionChanged) {
this.Adapter.bIsRegionChanged = false;
if (NULL != this.Adapter.ptDirtyRegion) {
//! calculate the valid region
// calculate the valid region
if (!arm_2d_region_intersect( &this.tCFG.tDisplayArea,
&(this.Adapter.ptDirtyRegion->tRegion),
&this.Adapter.tTargetRegion)) {
if (__arm_2d_helper_pfb_get_next_dirty_region(ptThis)) {
//! try next region
// try next region
continue;
}
//! out of lcd
// out of lcd
return (arm_2d_tile_t *)-1;
}
} else {
@ -366,11 +444,11 @@ arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
}
#if __ARM_ARCH == 6 || __TARGET_ARCH_THUMB == 3
//! reset adapter frame size
// reset adapter frame size
this.Adapter.tFrameSize = this.tCFG.FrameBuffer.tFrameSize;
#else
if (this.tCFG.FrameBuffer.bDisableDynamicFPBSize) {
//! reset adapter frame size
// reset adapter frame size
this.Adapter.tFrameSize = this.tCFG.FrameBuffer.tFrameSize;
} else { //!< update PFB size
@ -385,7 +463,7 @@ arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
if ( (wTargetPixelCount <= wPFBPixelCount)
|| ( this.Adapter.tTargetRegion.tSize.iWidth
< this.tCFG.FrameBuffer.tFrameSize.iWidth)) {
//! redefine the shape of PFB
// redefine the shape of PFB
this.Adapter.tFrameSize.iWidth
= this.Adapter.tTargetRegion.tSize.iWidth;
@ -395,7 +473,7 @@ arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
/ (uint32_t)this.Adapter.tTargetRegion.tSize.iWidth);
} else {
//! reset adapter frame size
// reset adapter frame size
this.Adapter.tFrameSize = this.tCFG.FrameBuffer.tFrameSize;
}
}
@ -432,11 +510,11 @@ arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
if (!this.tCFG.FrameBuffer.bDoNOTUpdateDefaultFrameBuffer) {
//! update default frame buffer
// update default frame buffer
arm_2d_set_default_frame_buffer(&this.Adapter.tPFBTile);
}
//! uncomment this when necessary for debug purpose
// uncomment this when necessary for debug purpose
//arm_2d_rgb16_fill_colour(&this.Adapter.tPFBTile, NULL, 0);
return (arm_2d_tile_t *)&(this.Adapter.tPFBTile);
@ -445,10 +523,10 @@ arm_2d_tile_t * __arm_2d_helper_pfb_drawing_iteration_begin(
/*! \brief end a drawing iteration and decide wether a new iteration is required
*! or not based on the return value
*! \param none
*! \retval true a new iteration is required
*! \retval false no more iteration is required
* or not based on the return value
* \param[in] ptThis the PFB control block
* \retval true a new iteration is required
* \retval false no more iteration is required
*/
static
bool __arm_2d_helper_pfb_drawing_iteration_end(arm_2d_helper_pfb_t *ptThis)
@ -458,7 +536,7 @@ bool __arm_2d_helper_pfb_drawing_iteration_end(arm_2d_helper_pfb_t *ptThis)
arm_2d_tile_t *ptPartialFrameBuffer = &(this.Adapter.ptCurrent->tTile);
if (!this.tCFG.FrameBuffer.bDoNOTUpdateDefaultFrameBuffer) {
//! update default frame buffer
// update default frame buffer
arm_2d_set_default_frame_buffer(NULL);
}
@ -472,7 +550,7 @@ bool __arm_2d_helper_pfb_drawing_iteration_end(arm_2d_helper_pfb_t *ptThis)
if ( this.Adapter.tDrawRegion.tLocation.iY
>= this.Adapter.tTargetRegion.tSize.iHeight) {
//! finished
// finished
this.Adapter.tDrawRegion.tLocation.iY = 0;
return __arm_2d_helper_pfb_get_next_dirty_region(ptThis);
@ -484,16 +562,50 @@ bool __arm_2d_helper_pfb_drawing_iteration_end(arm_2d_helper_pfb_t *ptThis)
}
__WEAK void arm_2d_helper_perf_counter_start(void)
__WEAK int64_t arm_2d_helper_get_system_timestamp(void)
{
#if defined(__PERF_COUNTER__)
return get_system_ticks();
#else
return (int64_t)clock();
#endif
}
__WEAK int32_t arm_2d_helper_perf_counter_stop(void)
__WEAK
uint32_t arm_2d_helper_get_reference_clock_frequency(void)
{
return 0;
extern uint32_t SystemCoreClock;
return SystemCoreClock;
}
int64_t arm_2d_helper_convert_ticks_to_ms(int64_t lTick)
{
return (lTick * 1000) / (int64_t)arm_2d_helper_get_reference_clock_frequency();
}
int64_t arm_2d_helper_convert_ms_to_ticks(uint32_t wMS)
{
int64_t lResult = arm_2d_helper_get_reference_clock_frequency()
* (int64_t)wMS / 1000ul;
return lResult ? lResult : 1;
}
__WEAK void __arm_2d_helper_perf_counter_start(int64_t *plTimestamp)
{
assert(NULL != plTimestamp);
*plTimestamp = arm_2d_helper_get_system_timestamp();
}
__WEAK int32_t __arm_2d_helper_perf_counter_stop(int64_t *plTimestamp)
{
assert(NULL != plTimestamp);
return (int32_t)( (int64_t)arm_2d_helper_get_system_timestamp()
- (int64_t)*plTimestamp);
}
ARM_NONNULL(1,2)
void arm_2d_helper_pfb_report_rendering_complete(arm_2d_helper_pfb_t *ptThis,
@ -504,11 +616,12 @@ void arm_2d_helper_pfb_report_rendering_complete(arm_2d_helper_pfb_t *ptThis,
ptPFB->tTile.tRegion.tLocation = (arm_2d_location_t) {0,0};
arm_irq_safe {
ARM_LIST_STACK_PUSH(this.Adapter.ptFreeList, ptPFB);
}
// arm_irq_safe {
// ARM_LIST_STACK_PUSH(this.Adapter.ptFreeList, ptPFB);
// }
__arm_2d_helper_pfb_free(ptThis, ptPFB);
__arm_2d_helper_flush_pfb(ptThis);
arm_2d_helper_pfb_flush(ptThis);
}
@ -554,48 +667,48 @@ ARM_PT_BEGIN(this.Adapter.chPT)
this.Statistics.nTotalCycle = 0;
this.Statistics.nRenderingCycle = 0;
this.Adapter.bIsNewFrame = true;
arm_2d_helper_perf_counter_start();
__arm_2d_helper_perf_counter_start(&this.Statistics.lTimestamp);
do {
this.Statistics.nRenderingCycle += arm_2d_helper_perf_counter_stop();
this.Statistics.nRenderingCycle += __arm_2d_helper_perf_counter_stop(&this.Statistics.lTimestamp);
/*! begin of the drawing iteration,
*! try to request the tile of frame buffer
/* begin of the drawing iteration,
* try to request the tile of frame buffer
*/
do {
/*! \note In deep embedded applications, a LCD usually is connected
*! via a serial interface to save pins, hence the bandwidth
*! is limited and the FPS is low due to the bandwidth.
*! To overcome this issue, some partial-flushing schemes are
*! used, such as:
*! - Dirty Region based partial-flushing
*! - Flush the known and fixed small area that is updated
*! frequently based on the application scenarios.
*!
*! It is worth emphasizing that as we are using partial
*! flushing scheme, which means for a given frame, we only
*! update those changed area(s) but not the complete frame,
*! using the term frame per sec (FPS) might confuse people,
*! hence, we decide to introduce a NEW term called update per
*! sec (UPS) to avoid this confusion. It reflects what people
*! feel when looking at the LCD but not necessarily means
*! the rate that a complete frame is flushed into LCD.
*!
*! In Arm-2D:
*! - FPS is a sub-set of UPS.
*! - UPS forcus on how people feel and FPS is sticks to the
*! concept of (full) frame per sec.
* via a serial interface to save pins, hence the bandwidth
* is limited and the FPS is low due to the bandwidth.
* To overcome this issue, some partial-flushing schemes are
* used, such as:
* - Dirty Region based partial-flushing
* - Flush the known and fixed small area that is updated
* frequently based on the application scenarios.
*
* It is worth emphasizing that as we are using partial
* flushing scheme, which means for a given frame, we only
* update those changed area(s) but not the complete frame,
* using the term frame per sec (FPS) might confuse people,
* hence, we decide to introduce a NEW term called update per
* sec (UPS) to avoid this confusion. It reflects what people
* feel when looking at the LCD but not necessarily means
* the rate that a complete frame is flushed into LCD.
*
* In Arm-2D:
* - FPS is a sub-set of UPS.
* - UPS forcus on how people feel and FPS is sticks to the
* concept of (full) frame per sec.
*/
//! request to draw the whole LCD
// request to draw the whole LCD
this.Adapter.ptFrameBuffer =
__arm_2d_helper_pfb_drawing_iteration_begin(
ptThis,
ptDirtyRegions);
if (NULL == this.Adapter.ptFrameBuffer) {
if (NULL != this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler){
//!wait until lcd is ready
// wait until lcd is ready
(*this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler)(
this.tCFG.Dependency.evtOnLowLevelSyncUp.pTarget
);
@ -609,22 +722,22 @@ ARM_PT_BEGIN(this.Adapter.chPT)
ARM_PT_ENTRY(this.Adapter.chPT)
arm_2d_helper_perf_counter_start();
//! draw all the gui elements on target frame buffer
__arm_2d_helper_perf_counter_start(&this.Statistics.lTimestamp);
// draw all the gui elements on target frame buffer
tResult = this.tCFG.Dependency.evtOnDrawing.fnHandler(
this.tCFG.Dependency.evtOnDrawing.pTarget,
this.Adapter.ptFrameBuffer,
this.Adapter.bIsNewFrame);
//! just in case some one forgot to do this...
// just in case some one forgot to do this...
arm_2d_op_wait_async(NULL);
this.Adapter.bIsNewFrame = false;
this.Statistics.nTotalCycle += arm_2d_helper_perf_counter_stop();
this.Statistics.nTotalCycle += __arm_2d_helper_perf_counter_stop(&this.Statistics.lTimestamp);
if (arm_fsm_rt_on_going == tResult) {
ARM_PT_GOTO_PREV_ENTRY()
} else if (tResult < 0) {
//! error was reported
// error was reported
ARM_PT_RETURN(this.Adapter.chPT, tResult)
} else if (arm_fsm_rt_wait_for_obj == tResult) {
ARM_PT_REPORT_STATUS(this.Adapter.chPT, tResult)
@ -632,17 +745,13 @@ ARM_PT_BEGIN(this.Adapter.chPT)
ARM_PT_YIELD(this.Adapter.chPT)
}
arm_2d_helper_perf_counter_start();
__arm_2d_helper_perf_counter_start(&this.Statistics.lTimestamp);
} while(__arm_2d_helper_pfb_drawing_iteration_end(ptThis));
this.Statistics.nRenderingCycle += arm_2d_helper_perf_counter_stop();
this.Statistics.nRenderingCycle += __arm_2d_helper_perf_counter_stop(&this.Statistics.lTimestamp);
ARM_PT_END(this.Adapter.chPT)
return arm_fsm_rt_cpl;
}
}
#if defined(__clang__)
# pragma clang diagnostic pop
#elif __IS_COMPILER_GCC__
# pragma GCC diagnostic pop
#endif

201
package/Arm2D/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2020 signalProcessing
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,64 @@
# Header Files Summary {#headers}
## 1 Overview
As an open-source project, arm-2d serves users with different purposes and background. In general, arm-2d is designed with two groups of users in mind:
- **Library Users** - who use arm-2d public APIs in their applications
- **Professional Users** - all other users who are
- Integrating arm-2d with GUI stacks
- Accelerating arm-2d with some 2D HW accelerators
- Hobbyists writing new GUIs and/or 2D game engines based on arm-2d.
For the Library Users, **Public Header Files** provide all the information required to use arm-2d services. For the Professional Users, additional information are provided in **Private Header Files** to help their design.
## 2 Public Header Files
In the `Library/Include` folder, all header files (*.h) **without** double-underscore-prefix, i.e. "__", are considered as **PUBLIC HEADER FILES**. They are listed in the **Table 2-1**.
**Table 2-1 Summary of Public Header Files**
| File Name | Description | Note |
| ----------------------------- | ------------------------------------------------------------ | ---------------------------------------------------- |
| ***arm_2d.h*** | **The main entry for all users.** To use any arm-2d services, you **must** include this header file first. It includes all other public header files list below. | |
| ***arm_2d_types.h*** | This header file provides the definitions for the common and/or important data types, enumerations etc. | |
| ***arm_2d_utils.h*** | This header file provides utilities used in arm-2d, such as macros for compiler-detection, OOPC, C language helpers etc. | |
| ***arm_2d_features.h*** | This header file provides feature detection services for compiler and target processors. It also help to define, detect and validate macro-based-options for switching arm-2d features on and off. | **Do Not Modify** |
| ***arm_2d_op.h*** | This header file list all the arm-2d OPCODE, i.e. ***ARM_2D_OP_xxxx*** | |
| ***arm_2d_tile.h*** | The header file for all basic tile operations, e.g. tile-copy/filling with/without mirroring, with/without colour-keying etc. | [Doc](../../documentation/how_to_use_tile_operations.md) |
| ***arm_2d_draw.h*** | The header file for all drawing related operations, e.g. filling rectangular area, drawing points, drawing bit-patterns etc. | |
| ***arm_2d_conversion.h*** | The header file for colour-format conversion operations, e.g. conversion between RGB565 and RGB888 etc. | |
| ***arm_2d_alpha_blending.h*** | The header file for alpha-blending centric operations, e.g. alpha-blending, copy with masks, colour-keying with opacity etc. | |
| ***arm_2d_transform.h*** | The header file for transform operations, i.e. rotation and/or scaling (zooming). | |
## 3 Private Header Files
In the `Library/Include` folder, all header files (*.h) **with** double-underscore-prefix, i.e. "__", are considered as **PRIVATE HEADER FILES**. Only professional users should read them.
**Table 3-1 Summary of Private Header Files**
| File Name | Description | Note |
| ------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ***__arm_2d_impl.h*** | **The main entry for all professional users.** For advanced development (not for normal applications), you must include this header file that includes most of the private header files list below. | |
| ***__arm_2d_direct.h*** | This file lists all the low level implementations for specific variants of 2D operations. It is useful when integrating arm-2d with a GUI stack. | This file is included by ***__arm_2d_impl.h***, please do NOT include it directly. |
| ***__arm_2d_math.h*** | This file provides some math related utilities. | |
| ***__arm_2d_math_helium.h*** | This file provides some math related utilities for helium only. It is **NOT** intended to be used outside of arm-2d. | **Do NOT Use.** |
| ***__arm_2d_paving.h*** | This file lists some internal macro templates. It is **NOT** intended to be used outside of arm-2d. | **Do NOT Use.** |
| ***__arm_2d_paving_helium.h*** | This file lists some internal macro templates for helium only. It is **NOT** intended to be used outside of arm-2d. | **Do NOT Use.** |
| ***__arm_2d_utils_helium.h*** | This file lists some internal utils for helium only. It is **NOT** intended to be used outside of arm-2d. | **Do NOT Use.** |
## 4 Templates
In the `Library/Include/template` folder, there are some header files used as templates for purposes including but not limited to configuration etc.
**Table 4-1 Summary of Templates**
| File Name | Description | Note |
| ------------------ | ------------------------------------------------------- | ---- |
| ***arm_2d_cfg.h*** | A configuration template used in the arm-2d cmsis-pack. | |

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -18,11 +18,11 @@
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d_acc.h
* Description: Basic Tile operations
* Title: __arm_2d_impl.h
* Description: header files for internal users or professional developers
*
* $Date: 13. Jan 2021
* $Revision: V.0.5.0
* $Date: 09. Aug 2022
* $Revision: V.1.2.2
*
* Target Processor: Cortex-M cores
*
@ -48,6 +48,8 @@ extern "C" {
# pragma clang diagnostic ignored "-Wpadded"
#elif __IS_COMPILER_ARM_COMPILER_5__
# pragma diag_suppress 174,177,188,68,513,144,64
#elif __IS_COMPILER_IAR__
# pragma diag_suppress=Pe301
#elif __IS_COMPILER_GCC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-value"
@ -87,28 +89,21 @@ extern "C" {
} else { \
tResult = (arm_fsm_rt_t)ARM_2D_ERR_NOT_SUPPORT; \
}
#define __ARM_2D_PIXEL_AVERAGE_GRAY8(__PIXEL_IN, __ALPHA) \
do { \
tPixel += (uint16_t)(__PIXEL_IN) * (uint16_t)(__ALPHA); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_GRAY8(__SRC_ADDR, __DES_ADDR, __OPACITY) \
#define __ARM_2D_PIXEL_BLENDING_GRAY8(__SRC_ADDR, __DES_ADDR, __TRANS) \
do { \
uint16_t chTransparency = 256 - (__OPACITY); \
uint16_t hwOPA = 256 - (__TRANS); \
const uint8_t *pchSrc = (uint8_t *)(__SRC_ADDR); \
uint8_t *pchDes = (uint8_t *)(__DES_ADDR); \
\
*pchDes = ((uint16_t)( ((uint16_t)(*pchSrc++) * chTransparency) \
+ ((uint16_t)(*pchDes) * (__OPACITY)) \
*pchDes = ((uint16_t)( ((uint16_t)(*pchSrc++) * hwOPA) \
+ ((uint16_t)(*pchDes) * (__TRANS)) \
) >> 8); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_RGB565(__SRC_ADDR, __DES_ADDR, __OPACITY) \
#define __ARM_2D_PIXEL_BLENDING_RGB565(__SRC_ADDR, __DES_ADDR, __TRANS) \
do { \
uint16_t chTransparency = 256 - (__OPACITY); \
uint16_t hwOPA = 256 - (__TRANS); \
__arm_2d_color_fast_rgb_t tSrcPix, tTargetPix; \
uint16_t *phwTargetPixel = (__DES_ADDR); \
__arm_2d_rgb565_unpack(*(__SRC_ADDR), &tSrcPix); \
@ -116,14 +111,78 @@ extern "C" {
\
for (int i = 0; i < 3; i++) { \
uint16_t hwTemp = \
(uint16_t) (tSrcPix.RGB[i] * chTransparency) + \
(tTargetPix.RGB[i] * (__OPACITY)); \
tTargetPix.RGB[i] = (uint16_t) (hwTemp >> 8); \
(uint16_t) (tSrcPix.BGRA[i] * hwOPA) + \
(tTargetPix.BGRA[i] * (__TRANS)); \
tTargetPix.BGRA[i] = (uint16_t) (hwTemp >> 8); \
} \
\
/* pack merged stream */ \
*phwTargetPixel = __arm_2d_rgb565_pack(&tTargetPix); \
} while(0);
} while(0)
#define __ARM_2D_PIXEL_BLENDING_CCCN888(__SRC_ADDR, __DES_ADDR, __TRANS) \
do { \
uint16_t hwOPA = 256 - (__TRANS); \
/* do not change alpha */ \
uint_fast8_t ARM_2D_SAFE_NAME(n) = sizeof(uint32_t) - 1; \
const uint8_t *pchSrc = (uint8_t *)(__SRC_ADDR); \
uint8_t *pchDes = (uint8_t *)(__DES_ADDR); \
\
do { \
*pchDes = ( ((uint_fast16_t)(*pchSrc++) * hwOPA) \
+ ((uint_fast16_t)(*pchDes) * (__TRANS)) \
) >> 8; \
pchDes++; \
} while(--ARM_2D_SAFE_NAME(n)); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_OPA_GRAY8(__SRC_ADDR, __DES_ADDR, __OPA) \
do { \
uint16_t hwTrans = 256 - (__OPA); \
const uint8_t *pchSrc = (uint8_t *)(__SRC_ADDR); \
uint8_t *pchDes = (uint8_t *)(__DES_ADDR); \
\
*pchDes = ((uint16_t)( ((uint16_t)(*pchSrc++) * (__OPA)) \
+ ((uint16_t)(*pchDes) * hwTrans) \
) >> 8); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_OPA_RGB565(__SRC_ADDR, __DES_ADDR, __OPA) \
do { \
uint16_t hwTrans = 256 - (__OPA); \
__arm_2d_color_fast_rgb_t tSrcPix, tTargetPix; \
uint16_t *phwTargetPixel = (__DES_ADDR); \
__arm_2d_rgb565_unpack(*(__SRC_ADDR), &tSrcPix); \
__arm_2d_rgb565_unpack(*phwTargetPixel, &tTargetPix); \
\
for (int i = 0; i < 3; i++) { \
uint16_t hwTemp = \
(uint16_t) (tSrcPix.BGRA[i] * (__OPA)) + \
(tTargetPix.BGRA[i] * hwTrans); \
tTargetPix.BGRA[i] = (uint16_t) (hwTemp >> 8); \
} \
\
/* pack merged stream */ \
*phwTargetPixel = __arm_2d_rgb565_pack(&tTargetPix); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_OPA_CCCN888(__SRC_ADDR, __DES_ADDR, __OPA) \
do { \
uint16_t hwTrans = 256 - (__OPA); \
/* do not change alpha */ \
uint_fast8_t ARM_2D_SAFE_NAME(n) = sizeof(uint32_t) - 1; \
const uint8_t *pchSrc = (uint8_t *)(__SRC_ADDR); \
uint8_t *pchDes = (uint8_t *)(__DES_ADDR); \
\
do { \
*pchDes = ( ((uint_fast16_t)(*pchSrc++) * (__OPA)) \
+ ((uint_fast16_t)(*pchDes) * hwTrans) \
) >> 8; \
pchDes++; \
} while(--ARM_2D_SAFE_NAME(n)); \
} while(0)
#define __ARM_2D_PIXEL_AVERAGE_RGB565(__PIXEL_IN, __ALPHA) \
do { \
@ -142,28 +201,18 @@ extern "C" {
tPixel.G += tTempColour.u8G * (__ALPHA); \
tPixel.B += tTempColour.u8B * (__ALPHA); \
} while(0)
#define __ARM_2D_PIXEL_BLENDING_CCCN888(__SRC_ADDR, __DES_ADDR, __OPACITY) \
do { \
uint16_t chTransparency = 256 - (__OPACITY); \
uint_fast8_t n = sizeof(uint32_t) - 1; /* do not change alpha */\
const uint8_t *pchSrc = (uint8_t *)(__SRC_ADDR); \
uint8_t *pchDes = (uint8_t *)(__DES_ADDR); \
\
do { \
*pchDes = ( ((uint_fast16_t)(*pchSrc++) * chTransparency) \
+ ((uint_fast16_t)(*pchDes) * (__OPACITY)) \
) >> 8; \
pchDes++; \
} while(--n); \
} while(0)
#define __ARM_2D_PIXEL_AVERAGE_GRAY8(__PIXEL_IN, __ALPHA) \
do { \
tPixel += (uint16_t)(__PIXEL_IN) * (uint16_t)(__ALPHA); \
} while(0)
/*============================ TYPES =========================================*/
typedef struct __arm_2d_point_adj_alpha_t{
struct {
arm_2d_location_t tOffset;
uint8_t chAlpha;
uint_fast8_t chAlpha;
}tMatrix[4];
} __arm_2d_point_adj_alpha_t;
@ -178,10 +227,20 @@ enum {
__ARM_2D_OP_IDX_SYNC = __ARM_2D_OP_IDX_BARRIER,
__ARM_2D_OP_IDX_COPY,
__ARM_2D_OP_IDX_COPY_ONLY,
__ARM_2D_OP_IDX_COPY_WITH_X_MIRROR,
__ARM_2D_OP_IDX_COPY_WITH_Y_MIRROR,
__ARM_2D_OP_IDX_COPY_WITH_XY_MIRROR,
__ARM_2D_OP_IDX_FILL_ONLY,
__ARM_2D_OP_IDX_FILL_WITH_X_MIRROR,
__ARM_2D_OP_IDX_FILL_WITH_Y_MIRROR,
__ARM_2D_OP_IDX_FILL_WITH_XY_MIRROR,
__ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING,
__ARM_2D_OP_IDX_COPY_WITH_MASK,
__ARM_2D_OP_IDX_COPY_WITH_SRC_MASK,
__ARM_2D_OP_IDX_COPY_WITH_DES_MASK,
__ARM_2D_OP_IDX_COPY_WITH_MASKS,
__ARM_2D_OP_IDX_COPY_WITH_SOURCE_MASK,
__ARM_2D_OP_IDX_COPY_WITH_TARGET_MASK,
__ARM_2D_OP_IDX_FILL_COLOUR,
__ARM_2D_OP_IDX_FILL_COLOUR_WITH_COLOUR_KEYING,
__ARM_2D_OP_IDX_FILL_COLOUR_WITH_MASK,
@ -197,8 +256,15 @@ enum {
__ARM_2D_OP_IDX_COLOUR_FORMAT_CONVERSION,
__ARM_2D_OP_IDX_ROTATE,
__ARM_2D_OP_IDX_ROTATE_WITH_ALPHA
__ARM_2D_OP_IDX_TRANSFORM,
//__ARM_2D_OP_IDX_TRANSFORM_WITH_MASKS, //!< todo in v1.xx
__ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK,
//__ARM_2D_OP_IDX_TRANSFORM_WITH_TARGET_MASK, //!< todo in v1.xx
__ARM_2D_OP_IDX_TRANSFORM_WITH_OPACITY,
//__ARM_2D_OP_IDX_TRANSFORM_WITH_MASKS_AND_OPACITY, //!< todo in v1.xx
__ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK_AND_OPACITY,
//__ARM_2D_OP_IDX_TRANSFORM_WITH_TARGET_MASK_AND_OPACITY, //!< todo in v1.xx
/*------------ cmsisi-2d operation idx end --------------*/
};
//! @}
@ -226,6 +292,7 @@ typedef struct __arm_2d_tile_param_t {
uint8_t : 6;
arm_2d_region_t tValidRegion;
arm_2d_tile_t *ptDerivedResource;
} __arm_2d_tile_param_t;
typedef struct __arm_2d_param_copy_t {
@ -248,6 +315,14 @@ typedef struct __arm_2d_param_copy_orig_t {
} __arm_2d_param_copy_orig_t;
typedef struct __arm_2d_param_copy_orig_msk_t {
implement(__arm_2d_param_copy_orig_t);
__arm_2d_tile_param_t tOrigMask;
__arm_2d_tile_param_t tDesMask;
} __arm_2d_param_copy_orig_msk_t;
typedef struct __arm_2d_param_fill_t {
__arm_2d_tile_param_t tSource;
__arm_2d_tile_param_t tTarget;
@ -273,19 +348,22 @@ ARM_PRIVATE(
arm_2d_op_core_t *ptOP;
uint8_t chLowLeveIOIndex; //!< the type of IO interface
uint8_t chLowLeveIOIndex; //!< the type of IO interface
uint8_t bIsCPL : 1;
uint8_t : 7;
uint16_t : 16;
union {
__arm_2d_tile_param_t tTileProcess;
__arm_2d_param_copy_t tCopy;
__arm_2d_param_fill_t tFill;
__arm_2d_param_copy_orig_t tCopyOrig;
__arm_2d_param_copy_msk_t tCopyMask;
__arm_2d_param_fill_orig_t tFillOrig;
__arm_2d_param_copy_orig_t tCopyOrig; //!< for transform
__arm_2d_param_copy_orig_msk_t tCopyOrigMask; //!< for transform with masks
__arm_2d_param_fill_t tFill;
__arm_2d_param_fill_msk_t tFillMask;
__arm_2d_param_fill_orig_t tFillOrig;
}Param;
)};
@ -323,8 +401,8 @@ ARM_PRIVATE(
arm_2d_op_cp_msk_t tCopyMasks;
arm_2d_op_drw_patn_t tDrawPattern;
arm_2d_op_rotate_t tRotate;
arm_2d_op_rotate_opacity_t tRotateOpacity;
arm_2d_op_trans_t tTransform;
arm_2d_op_trans_opa_t tRotateOpacity;
arm_2d_op_msk_t tBasicMask;
arm_2d_op_src_msk_t tSourceMask;
@ -370,6 +448,9 @@ arm_fsm_rt_t __arm_2d_op_frontend_op_decoder(arm_2d_op_core_t *ptThis);
extern
arm_fsm_rt_t __arm_2d_op_depose(arm_2d_op_core_t *ptThis,
arm_fsm_rt_t tResult);
extern
void __arm_2d_sub_task_depose(arm_2d_op_core_t *ptOP);
/*----------------------------------------------------------------------------*
* Utilities *
*----------------------------------------------------------------------------*/
@ -381,6 +462,20 @@ extern
__arm_2d_point_adj_alpha_t
__arm_2d_point_get_adjacent_alpha_q16(arm_2d_point_fx_t *ptPoint);
extern
arm_2d_err_t __arm_mask_validate( const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptSrcMask,
const arm_2d_tile_t *ptTarget,
const arm_2d_tile_t *ptDesMask,
uint32_t wMode);
extern
ARM_NONNULL(1,2)
const arm_2d_tile_t *__arm_2d_tile_get_root(const arm_2d_tile_t *ptTile,
arm_2d_region_t *ptValidRegion,
arm_2d_location_t *ptOffset,
arm_2d_tile_t **ppFirstDerivedChild);
/*----------------------------------------------------------------------------*
* Default Software Implementations *
*----------------------------------------------------------------------------*/
@ -415,6 +510,77 @@ arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_gray8_sw_tile_copy_with_masks(
@ -440,8 +606,6 @@ extern
arm_fsm_rt_t __arm_2d_cccn888_sw_tile_fill_with_masks(
__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_gray8_sw_tile_copy_with_src_mask(
__arm_2d_sub_task_t *ptTask);
@ -583,34 +747,71 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_colour_filling_with_opacity(
extern
arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_opacity(
__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_gray8(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(
__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(
__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_gray8_sw_rotate(__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t __arm_2d_gray8_sw_transform(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb565_sw_rotate(__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t __arm_2d_rgb565_sw_transform(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_cccn888_sw_rotate(__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t __arm_2d_cccn888_sw_transform(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_rgb565_sw_rotate_with_alpha(__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t
__arm_2d_gray8_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t __arm_2d_cccn888_sw_rotate_with_alpha(__arm_2d_sub_task_t *ptTask);
arm_fsm_rt_t
__arm_2d_rgb565_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_cccn888_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_gray8_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_rgb565_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_cccn888_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_gray8_sw_transform_with_src_mask_and_opacity(
__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_rgb565_sw_transform_with_src_mask_and_opacity(
__arm_2d_sub_task_t *ptTask);
extern
arm_fsm_rt_t
__arm_2d_cccn888_sw_transform_with_src_mask_and_opacity(
__arm_2d_sub_task_t *ptTask);
/*========================== POST INCLUDES ===================================*/
#include "__arm_2d_direct.h"
#if defined(__clang__)
# pragma clang diagnostic pop
#elif __IS_COMPILER_ARM_COMPILER_5__
# pragma diag_warning 174,177,188,68,513,144,64
#elif __IS_COMPILER_IAR__
# pragma diag_warning=pe111
#endif
#ifdef __cplusplus

View File

@ -36,6 +36,8 @@
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wsign-conversion"
@ -46,13 +48,11 @@
# pragma GCC diagnostic ignored "-Wpedantic"
#endif
/*! \note arm-2d relies on CMSIS 5.8.0 and above.
*/
#include <arm_math.h>
#if defined(__IS_COMPILER_ARM_COMPILER_5__) \
&& defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__
# warning 'Arm Compiler 5 doesn\'t support Armv8.1-M architecture, please use Arm Compiler 5 instead. If you insist using Arm Compiler 5, __ARM_2D_HAS_HELIUM__ is forced to 0.'
# warning 'Arm Compiler 5 doesn\'t support Armv8.1-M architecture, please use \
Arm Compiler 5 instead. If you insist using Arm Compiler 5,\
__ARM_2D_HAS_HELIUM__ is forced to 0.'
# undef __ARM_2D_HAS_HELIUM__
# define __ARM_2D_HAS_HELIUM__ 0
#endif
@ -75,6 +75,8 @@ typedef float float16_t;
#endif
#include "arm_math.h"
#ifdef __cplusplus
extern "C" {
@ -112,7 +114,7 @@ extern "C" {
#define ARM_PIX_SCLTYP(sz) ARM_CONNECT2(ARM_CONNECT2(uint, sz), _t)
#define ARM_2D_ANGLE(__ANGLE) ((float)((float)(__ANGLE) * 3.1416926f / 180.0f))
#define ARM_2D_ANGLE(__ANGLE) ((float)((float)(__ANGLE) * 3.1415926f / 180.0f))
#if __ARM_2D_HAS_DSP__
@ -121,11 +123,13 @@ extern "C" {
#define __QDADD(X, Y) __qadd(X, __qdbl(Y))
#define __QDSUB(X, Y) __qsub(X, __qdbl(Y))
#define __LARGEINVF32 100.0f
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
#elif defined(__ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__)
#elif defined(__ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__)
/*
* @brief C custom defined QDADD
*/

View File

@ -65,12 +65,12 @@ extern "C" {
#define ARM_VLD_ASM(sz) ARM_CONNECT2(vld, sz)
#define ARM_VST_ASM(sz) ARM_CONNECT2(vst, sz)
#define ARM_VLD1_ASM(sz) TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,sz))
#define ARM_VST1_ASM(sz) TO_STRING(ARM_VST_ASM(sz).ARM_CONNECT2(u,sz))
#define ARM_VLD1Z_ASM(sz) TO_STRING(ARM_VLD_ASM(sz)t.ARM_CONNECT2(u,sz))
#define ARM_VST1P_ASM(sz) TO_STRING(ARM_VST_ASM(sz)t.ARM_CONNECT2(u,sz))
#define ARM_VLDWID_ASM(sz, wid) TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,wid))
#define ARM_VSTNRW_ASM(sz, nrw) TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,nrw))
#define ARM_VLD1_ASM(sz) ARM_TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,sz))
#define ARM_VST1_ASM(sz) ARM_TO_STRING(ARM_VST_ASM(sz).ARM_CONNECT2(u,sz))
#define ARM_VLD1Z_ASM(sz) ARM_TO_STRING(ARM_VLD_ASM(sz)t.ARM_CONNECT2(u,sz))
#define ARM_VST1P_ASM(sz) ARM_TO_STRING(ARM_VST_ASM(sz)t.ARM_CONNECT2(u,sz))
#define ARM_VLDWID_ASM(sz, wid) ARM_TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,wid))
#define ARM_VSTNRW_ASM(sz, nrw) ARM_TO_STRING(ARM_VLD_ASM(sz).ARM_CONNECT2(u,nrw))
/* number of vector elements */
@ -94,7 +94,7 @@ extern "C" {
#define __LARGEINVF32 100.0f
#define __PI_2_F16 (__PIF16/2.0f16)
#define INV_NEWTON_INIT_F16 0x7773
#define INV_NEWTON_INIT_F16 0x7773
#define INFINITY_F16 ((float16_t)__builtin_inf())

View File

@ -359,7 +359,7 @@ extern "C" {
do { \
uint32_t rowCnt = 0; \
\
pSourceBaseCur = pSourceBase; \
pSourceBaseCur = (ARM_PIX_SCLTYP(sz) *)pSourceBase; \
\
/* single source row loop */ \
do { \
@ -443,7 +443,7 @@ extern "C" {
do { \
uint32_t rowCnt = 0; \
\
pSourceBaseCur = pSourceBase; \
pSourceBaseCur = (ARM_PIX_SCLTYP(sz) *)pSourceBase; \
\
/* single source row loop */ \
do { \
@ -526,7 +526,7 @@ extern "C" {
* ........ \
*/ \
\
pSourceBaseCur = pSourceBase; \
pSourceBaseCur = (ARM_PIX_SCLTYP(sz) *)pSourceBase; \
\
/* copy 2 x 2 source image block */ \
do { \
@ -577,7 +577,7 @@ extern "C" {
\
for (int_fast16_t y = 0; y < ptDstCopySize->iHeight; y++) { \
ARM_PIX_SCLTYP(sz) *__RESTRICT pDst = pTarget; \
ARM_PIX_SCLTYP(sz) *__RESTRICT pSrc = pSource; \
ARM_PIX_SCLTYP(sz) *__RESTRICT pSrc = (ARM_PIX_SCLTYP(sz) *)pSource; \
uint32_t srcWidth = ptSrcCopySize->iWidth; \
uint32_t dstWidth = ptDstCopySize->iWidth; \
\

View File

@ -0,0 +1,300 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d_utils_helium.h
* Description: Provides helium utility routines
*
* $Date: 20. May 2022
* $Revision: V 0.0.2
*
* Target Processor: Cortex-M cores with Helium
*
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_UTILS_HELIUM_H__
#define __ARM_2D_UTILS_HELIUM_H__
#if __ARM_2D_HAS_HELIUM_INTEGER__ == 1
/*============================ INCLUDES ======================================*/
#include "arm_2d.h"
#include <arm_math.h>
#if defined(__ARM_2D_HAS_CDE__) && __ARM_2D_HAS_CDE__
#include "__arm_2d_cde.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
#if defined(__MVE_DEBUG__) && __MVE_DEBUG__
# define ____MVE_WRAPPER(__FUNC) __FUNC##_mve
#else
# define ____MVE_WRAPPER(__FUNC) __FUNC
#endif
#define __MVE_WRAPPER(__FUNC) ____MVE_WRAPPER(__FUNC)
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
/* set vecAlpha value to 0 when equal to the compensated value */
/* (=1 or 2 when involving 2 alpha = 255 multiplications) */
/* 16-bit vector */
#define ALPHA_255_COMP_VEC16(vecAlpha, compVal) vecAlpha = \
vpselq(vdupq_n_u16(256), vecAlpha, vcmpeqq_n_u16(vecAlpha, compVal))
/* 32-bit vector */
#define ALPHA_255_COMP_VEC32(vecAlpha, compVal) vecAlpha = \
vpselq(vdupq_n_u32(256), vecAlpha, vcmpeqq_n_u32(vecAlpha, compVal))
#else
#define ALPHA_255_COMP_VEC16(vecAlpha, compVal)
#define ALPHA_255_COMP_VEC32(vecAlpha, compVal)
#endif
/*============================ MACROFIED FUNCTIONS ===========================*/
__STATIC_FORCEINLINE
void __arm_2d_rgb565_unpack_single_vec(uint16x8_t in,
uint16x8_t * R, uint16x8_t * G, uint16x8_t * B)
{
uint16x8_t vecMaskR = vdupq_n_u16(0x001f);
uint16x8_t vecMaskG = vdupq_n_u16(0x003f);
*R = (in & vecMaskR) * 8;
*B = ((in >> 11)) * 8;
*G = ((in >> 5) & vecMaskG) * 4;
}
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_pack_single_vec(uint16x8_t R, uint16x8_t G, uint16x8_t B)
{
uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8);
uint16x8_t vecMaskGpck = vdupq_n_u16(0x00fc);
uint16x8_t vOut = vorrq(vshrq(R, 3),
vmulq(vandq(G, vecMaskGpck), 8));
vOut = vorrq(vOut, vmulq(vandq(B, vecMaskBpck), 256));
return vOut;
}
#if !defined(__ARM_2D_HAS_CDE__) || __ARM_2D_HAS_CDE__ == 0
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_blending_scal_opacity_single_vec(
uint16x8_t Source1,
uint16x8_t Source2,
uint_fast16_t hwRatio)
{
/* scalar ratio allows extra optimization */
uint16_t ratio1x8 = (256 - hwRatio) * 8;
uint16_t ratio1x4 = (256 - hwRatio) * 4;
uint16_t ratio2x8 = (hwRatio) * 8;
uint16_t ratio2x4 = (hwRatio) * 4;
uint16x8_t vecMaskR = vdupq_n_u16(0x001f);
uint16x8_t vecMaskG = vdupq_n_u16(0x003f);
uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8);
uint16x8_t vecMaskGpck = vdupq_n_u16(0x00fc);
uint16x8_t vecR0, vecB0, vecG0;
uint16x8_t vecR1, vecB1, vecG1;
/* unpack 1st stream */
vecR0 = Source1 & vecMaskR;
vecB0 = Source1 >> 11;
vecG0 = Source1 >> 5;
vecG0 = vecG0 & vecMaskG;
/* unpack 2nd stream */
vecR1 = Source2 & vecMaskR;
vecB1 = Source2 >> 11;
vecG1 = Source2 >> 5;
vecG1 = vecG1 & vecMaskG;
/* merge */
vecR0 = vecR0 * ratio1x8 + vecR1 * ratio2x8;
vecR0 = vecR0 >> 8;
vecG0 = vecG0 * ratio1x4 + vecG1 * ratio2x4;
vecG0 = vecG0 >> 8;
vecB0 = vecB0 * ratio1x8 + vecB1 * ratio2x8;
vecB0 = vecB0 >> 8;
/* pack */
return vecR0 >> 3 | vmulq((vecG0 & vecMaskGpck), 8)
| vmulq((vecB0 & vecMaskBpck), 256);
}
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_blending_opacity_single_vec(
uint16x8_t Source1,
uint16x8_t Source2,
uint16x8_t vecHwOpacity)
{
uint16x8_t vecAlpha = vsubq(vdupq_n_u16(256), vecHwOpacity);
uint16x8_t vecR, vecG, vecB;
uint16x8_t vecSrcR, vecSrcG, vecSrcB;
/* unpack sources */
__arm_2d_rgb565_unpack_single_vec(Source1, &vecR, &vecG, &vecB);
__arm_2d_rgb565_unpack_single_vec(Source2, &vecSrcR, &vecSrcG, &vecSrcB);
/* merge */
vecR = vecR * vecHwOpacity + vecSrcR * vecAlpha;
vecR = vecR >> 8;
vecG = vecG * vecHwOpacity + vecSrcG * vecAlpha;
vecG = vecG >> 8;
vecB = vecB * vecHwOpacity + vecSrcB * vecAlpha;
vecB = vecB >> 8;
/* pack */
return __arm_2d_rgb565_pack_single_vec(vecR, vecG, vecB);
}
#endif
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_gray8_blending_opacity_single_vec(
uint16x8_t Source1,
uint16x8_t Source2,
uint16x8_t vecHwOpacity)
{
uint16x8_t vecAlpha = vsubq(vdupq_n_u16(256), vecHwOpacity);
return vaddq(
vmulq(Source1, vecHwOpacity),
vmulq(Source2, vecAlpha)) >> 8;
}
__STATIC_FORCEINLINE
uint32x4_t __arm_2d_cccn888_blending_opacity_single_vec_alt(
uint32x4_t Source1,
uint32x4_t Source2,
uint32x4_t vecHwOpacity)
{
uint32x4_t vecAlpha = vsubq(vdupq_n_u32(256), vecHwOpacity);
uint32x4_t acc;
acc = ((Source1 & 0xff) * vecHwOpacity + (Source2 & 0xff) * vecAlpha) >> 8;
acc |=
((((Source1 >> 8) & 0xff) * vecHwOpacity +
((Source2 >> 8) & 0xff) * vecAlpha) >> 8) << 8;
acc |=
((((Source1 >> 16) & 0xff) * vecHwOpacity +
((Source2 >> 16) & 0xff) * vecAlpha) >> 8) << 16;
/* preserve Source1 alpha */
acc |= Source1 & 0xff000000;
return acc;
}
__STATIC_FORCEINLINE
uint32x4_t __arm_2d_cccn888_blending_opacity_single_vec(
uint32x4_t Source1,
uint32x4_t Source2,
uint32x4_t vecHwOpacity)
{
uint32x4_t vecAlpha = vsubq(vdupq_n_u32(256), vecHwOpacity);
/* expand opacity / alpha from byte to packed 32-bit*/
/* {0x000000a0 0x000000a1 0x000000a2 0x000000a3}
=> {0x00a0a0a0 0x00a1a1a1 0x00a2a2a2 0x00a3a3a3}
*/
uint32x4_t vecAlphaExp = (vecAlpha & 0xff) * 0x00010101;
uint32x4_t vecHwOpacityExp = (vecHwOpacity & 0xff) * 0x00010101;
uint32x4_t blendB = vaddq_u16(vmullbq_int_u8((uint8x16_t) Source1,
(uint8x16_t) vecHwOpacityExp),
vmullbq_int_u8((uint8x16_t) Source2,
(uint8x16_t) vecAlphaExp));
uint32x4_t blendT = vaddq_u16(vmulltq_int_u8((uint8x16_t) Source1,
(uint8x16_t) vecHwOpacityExp),
vmulltq_int_u8((uint8x16_t) Source2,
(uint8x16_t) vecAlphaExp));
int8x16_t target = vshrnbq_n_s16(vuninitializedq_u8(), blendB, 8);
target = vshrntq_n_s16(target, blendT, 8);
target = vpselq_u32(Source1, target, vcmpeqq_n_u32(vecHwOpacity, 0x100));
target = vpselq_u32(Source2, target, vcmpeqq_n_u32(vecHwOpacity, 0));
/* preserve Source1 alpha */
target = (int8x16_t) ((Source1 & 0xff000000) | ((uint32x4_t) target & 0x00ffffff));
return target;
}
__STATIC_FORCEINLINE
uint16x8_t __rgb888_alpha_blending_direct_single_vec(
uint16x8_t wSource1, /* widened input bytes */
uint16x8_t wSource2, /* widened input bytes */
uint_fast16_t hwRatio)
{
uint16_t transp = 256 - (uint16_t) hwRatio;
uint16x8_t vecOut;
vecOut = vmulq_n_u16(wSource1, (uint16_t) hwRatio);
vecOut = vmlaq_n_u16(vecOut, wSource2, transp);
/* widened output */
return vecOut >> 8;
}
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
#ifdef __cplusplus
}
#endif
#endif // (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI)
#endif // __ARM_2D_UTILS_HELIUM_H__

View File

@ -0,0 +1,214 @@
/*
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d.h"
* Description: Public header file to contain the all avaialble Arm-2D
* interface header files
*
* $Date: 05. Sept 2022
* $Revision: V.1.0.7
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_H__
#define __ARM_2D_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#include "arm_2d_op.h"
#include "arm_2d_tile.h"
#include "arm_2d_draw.h"
#include "arm_2d_conversion.h"
#include "arm_2d_alpha_blending.h"
#include "arm_2d_transform.h"
#ifdef __cplusplus
extern "C" {
#endif
/* suppress some warnings for user applications when using arm-2d.
*/
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_suppress 1296,174
#endif
/*!
* \addtogroup gKernel 1 Kernel
* @{
*/
/*============================ MACROS ========================================*/
/* arm-2d version */
#define ARM_2D_VERSION_MAJOR 1 //!< Major version
#define ARM_2D_VERSION_MINOR 1 //!< Minor version
#define ARM_2D_VERSION_PATCH 0 //!< Patch number
#define ARM_2D_VERSION_STR "preview1" //!< tag
/*!
* \brief arm-2d version number in decimal
*
*/
#define ARM_2D_VERISON ( ARM_2D_VERSION_MAJOR * 10000ul \
+ ARM_2D_VERSION_MINOR * 100ul \
ARM_2D_VERSION_PATCH)
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*!
* \brief a type for arm-2d runtime configuration
*
*/
typedef struct {
/*! if the target region is out of the target tile, return arm_fsm_rt_cpl */
uint8_t TREAT_OUT_OF_RANGE_AS_COMPLETE : 1;
/*! indicate that there is a dedicated thread to run arm_2d_task() in RTOS env */
uint8_t HAS_DEDICATED_THREAD_FOR_2D_TASK : 1;
uint8_t : 6;
} arm_2d_runtime_feature_t;
/*!
* \brief a type for arm-2d version
*
*/
typedef struct {
uint8_t Major; //!< major version
uint8_t Minor; //!< minor version
uint8_t Patch; //!< patch number
uint8_t : 8;
} arm_2d_version_t;
/*============================ GLOBAL VARIABLES ==============================*/
/*!
* \brief arm-2d runtime feature configuration
*
*/
extern
arm_2d_runtime_feature_t ARM_2D_RUNTIME_FEATURE;
/*!
* \brief arm-2d version
*
*/
extern
const arm_2d_version_t ARM_2D_VERSION;
/*============================ PROTOTYPES ====================================*/
/*!
* \brief initialise arm-2d
*/
extern
void arm_2d_init(void);
/*!
* \brief set the default frame buffer
* \param ptFrameBuffer the new frame buffer,
* \note Passing NULL means using no default framebuffer
* \return arm_2d_tile_t* the address of the old frame buffer
*/
extern
arm_2d_tile_t *arm_2d_set_default_frame_buffer(
const arm_2d_tile_t *ptFrameBuffer);
/*!
* \brief get the default frame buffer
* \return arm_2d_tile_t* the address of the default frame buffer
*/
extern
arm_2d_tile_t *arm_2d_get_default_frame_buffer(void);
/*!
* \brief attach a user param (which could be a pointer) to specified OP
*
* \param ptOP the address of the target OP (NULL means using the default OP)
*
* \param pUserParam a user parameter (it can be used as a pointer)
*/
extern
void arm_2d_set_user_param(arm_2d_op_core_t *ptOP, uintptr_t pUserParam);
/*!
* \brief wait asynchronous operation complete
* \param[in] ptOP the address of the target OP (NULL means using the default OP)
* \retval true sync up with operation
* \retval false operation is busy
*/
extern
bool arm_2d_op_wait_async(arm_2d_op_core_t *ptOP);
/*!
\brief get the status of a specified OP,
\details usually, it is used after calling arm_2d_op_wait_async().
E.g.
\code
//! wait for previous operation complete
do {
arm_2d_op_wait_async();
arm_2d_op_status_t tStatus = arm_2d_get_op_status();
if (tStatus.bIOError) {
//! error detected
...
} else if (tStatus.bOpCpl) {
break;
}
} while(true);
\endcode
\param ptOP the address of the target OP (NULL means using the default OP)
\return arm_2d_op_status_t the operation status
*/
extern
arm_2d_op_status_t arm_2d_get_op_status(arm_2d_op_core_t *ptOP);
/*!
* \brief arm-2d pixel pipeline task entery
* \note This function is *TRHEAD-SAFE*
* \param ptTask the address of an arm-2d task control block
* \retval arm_fsm_rt_cpl The sub-task FIFO is empty, the caller can wait for a
* semaphore set by arm_2d_notif_sub_task_fifo_task_arrive()
* \retval arm_fsm_rt_on_going The arm_2d_task yields
* \retval arm_fsm_rt_async You shouldn't see this value
* \retval arm_fsm_rt_wait_for_obj hardware accelerator wants to sync-up with applications.
* \retval (<0) Serious error is detected.
*/
extern
arm_fsm_rt_t arm_2d_task(arm_2d_task_t *ptTask);
/*! @} */
/*! \note delibrately comment out */
//#if defined(__clang__)
//# pragma clang diagnostic pop
//#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -22,8 +22,8 @@
* Description: Public header file to contain the APIs for colour space
* conversions
*
* $Date: 01. December 2020
* $Revision: V.0.5.0
* $Date: 09. Aug 2022
* $Revision: V.1.0.3
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
@ -43,22 +43,31 @@ extern "C" {
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wnarrowing"
#elif defined(__IS_COMPILER_IAR__)
# pragma diag_suppress=Go029
#endif
/*!
* \addtogroup gConversion 6 Conversion Operations
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define arm_2d_convert_colour_to_rgb888(__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR /*!< target tile address */) \
#define arm_2d_convert_colour_to_rgb888(__SRC_ADDR, /* source tile address */ \
__DES_ADDR /* target tile address */) \
arm_2dp_convert_colour_to_rgb888( NULL, \
(__SRC_ADDR), \
(__DES_ADDR))
#define arm_2d_convert_colour_to_rgb565(__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR /*!< target tile address */) \
#define arm_2d_convert_colour_to_rgb565(__SRC_ADDR, /* source tile address */ \
__DES_ADDR /* target tile address */) \
arm_2dp_convert_colour_to_rgb565( NULL, \
(__SRC_ADDR), \
(__DES_ADDR))
@ -67,17 +76,16 @@ extern "C" {
typedef arm_2d_op_src_t arm_2d_op_cl_convt_t;
/*! \brief 3x16-bit packed RGB color
*! autovectorizer friendly format
* autovectorizer friendly format
*/
typedef union {
uint16_t RGB[3];
uint16_t BGRA[4];
struct {
uint16_t R;
uint16_t G;
uint16_t B;
uint16_t G;
uint16_t R;
uint16_t A;
};
} __arm_2d_color_fast_rgb_t;
@ -88,19 +96,37 @@ typedef union {
* RGB565 channels extraction/packing *
*----------------------------------------------------------------------------*/
/*!
* \brief unpack a rgb565 colour into a given __arm_2d_color_fast_rgb_t object
* \param[in] hwColour the target rgb565 colour
* \param[out] ptRGB a __arm_2d_color_fast_rgb_t object
*/
ARM_NONNULL(2)
__STATIC_INLINE void __arm_2d_rgb565_unpack(uint16_t hwColor,
__arm_2d_color_fast_rgb_t * ptRGB)
{
assert(NULL != ptRGB);
/* uses explicit extraction, leading to a more efficient autovectorized code */
uint16_t maskRunpk = 0x001f, maskGunpk = 0x003f;
ptRGB->R = (uint16_t) ((hwColor & maskRunpk) << 3);
ptRGB->B = (uint16_t) ((hwColor >> 11) << 3);
ptRGB->B = (uint16_t) ((hwColor & maskRunpk) << 3);
ptRGB->R = (uint16_t) ((hwColor >> 11) << 3);
ptRGB->G = (uint16_t) (((hwColor >> 5) & maskGunpk) << 2);
ptRGB->A = 0xFF;
}
/*!
* \brief generate a rgb565 colour from a __arm_2d_color_fast_rgb_t object
* \param[in] ptRGB the target __arm_2d_color_fast_rgb_t object
* \return uint16_t a rgb565 colour
*/
ARM_NONNULL(1)
__STATIC_INLINE uint16_t __arm_2d_rgb565_pack(__arm_2d_color_fast_rgb_t * ptRGB)
{
assert(NULL != ptRGB);
arm_2d_color_rgb565_t tOutput = {
.u5R = (uint16_t) ptRGB->R >> 3,
.u6G = (uint16_t) ptRGB->G >> 2,
@ -109,13 +135,22 @@ __STATIC_INLINE uint16_t __arm_2d_rgb565_pack(__arm_2d_color_fast_rgb_t * ptRGB)
return tOutput.tValue;
}
/*!
* \brief generate a cccn888 colour from a __arm_2d_color_fast_rgb_t object
* \param[in] ptRGB the target __arm_2d_color_fast_rgb_t object
* \return uint32_t a cccn888 colour
* \note the alpha channel will be kept in the output value
*/
ARM_NONNULL(1)
__STATIC_INLINE uint32_t __arm_2d_cccn888_pack(__arm_2d_color_fast_rgb_t * ptRGB)
{
arm_2d_color_rgba8888_t tOutput = {
assert(NULL != ptRGB);
arm_2d_color_bgra8888_t tOutput = {
.u8R = (uint16_t) ptRGB->R,
.u8G = (uint16_t) ptRGB->G,
.u8B = (uint16_t) ptRGB->B,
.u8A = 0xFF,
.u8A = (uint16_t) ptRGB->A,
};
return tOutput.tValue;
}
@ -125,20 +160,50 @@ __STATIC_INLINE uint32_t __arm_2d_cccn888_pack(__arm_2d_color_fast_rgb_t * ptRGB
* Colour Conversion *
*----------------------------------------------------------------------------*/
/*!
* \brief convert the colour format of a given tile to gray8
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_gray8( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget);
/*!
* \brief convert the colour format of a given tile to rgb888
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_rgb888( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget);
/*!
* \brief convert the colour format of a given tile to rgb565
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_rgb565( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget);
/*! @} */
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__IS_COMPILER_IAR__)
# pragma diag_warning=Go029
#endif
#ifdef __cplusplus

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -22,8 +22,8 @@
* Description: Public header file to contain the APIs for colour space
* conversions
*
* $Date: 22. February 2021
* $Revision: V.0.5.0
* $Date: 17. June 2022
* $Revision: V.1.0.2
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
@ -43,43 +43,49 @@ extern "C" {
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
# pragma clang diagnostic ignored "-Wsign-conversion"
#endif
/*!
* \addtogroup Drawing 3 Drawing Operations
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define arm_2d_c8bit_draw_point(__TARGET_ADDR, /*!< target tile address */ \
__LOCATION, /*!< point coordinate */ \
__COLOUR) /*!< target colour */ \
#define arm_2d_c8bit_draw_point(__TARGET_ADDR, /* target tile address */ \
__LOCATION, /* point coordinate */ \
__COLOUR) /* target colour */ \
arm_2dp_c8bit_draw_point(NULL, \
(__TARGET_ADDR), \
(__LOCATION), \
(__COLOUR))
#define arm_2d_rgb16_draw_point(__TARGET_ADDR, /*!< target tile address */ \
__LOCATION, /*!< point coordinate */ \
__COLOUR) /*!< target colour */ \
#define arm_2d_rgb16_draw_point(__TARGET_ADDR, /* target tile address */ \
__LOCATION, /* point coordinate */ \
__COLOUR) /* target colour */ \
arm_2dp_rgb16_draw_point(NULL, \
(__TARGET_ADDR), \
(__LOCATION), \
(__COLOUR))
#define arm_2d_rgb32_draw_point(__TARGET_ADDR, /*!< target tile address */ \
__LOCATION, /*!< point coordinate */ \
__COLOUR) /*!< target colour */ \
#define arm_2d_rgb32_draw_point(__TARGET_ADDR, /* target tile address */ \
__LOCATION, /* point coordinate */ \
__COLOUR) /* target colour */ \
arm_2dp_rgb32_draw_point(NULL, \
(__TARGET_ADDR), \
(__LOCATION), \
(__COLOUR))
#define arm_2d_c8bit_draw_pattern( __PATTERN_ADDR, /*!< pattern tile address */\
__TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__MODE, /*!< draw mode */ \
__FG_COLOUR, /*!< foreground colour */ \
__BG_COLOUR) /*!< background colour */ \
#define arm_2d_c8bit_draw_pattern( __PATTERN_ADDR, /* pattern tile address */ \
__TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__MODE, /* draw mode */ \
__FG_COLOUR, /* foreground colour */ \
__BG_COLOUR) /* background colour */ \
arm_2dp_c8bit_draw_pattern(NULL, \
(__PATTERN_ADDR), \
(__TARGET_ADDR), \
@ -88,12 +94,12 @@ extern "C" {
(__FG_COLOUR), \
(__BG_COLOUR))
#define arm_2d_rgb16_draw_pattern( __PATTERN_ADDR, /*!< pattern tile address */\
__TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__MODE, /*!< draw mode */ \
__FG_COLOUR, /*!< foreground colour */ \
__BG_COLOUR) /*!< background colour */ \
#define arm_2d_rgb16_draw_pattern( __PATTERN_ADDR, /* pattern tile address */ \
__TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__MODE, /* draw mode */ \
__FG_COLOUR, /* foreground colour */ \
__BG_COLOUR) /* background colour */ \
arm_2dp_rgb16_draw_pattern(NULL, \
(__PATTERN_ADDR), \
(__TARGET_ADDR), \
@ -102,12 +108,12 @@ extern "C" {
(__FG_COLOUR), \
(__BG_COLOUR))
#define arm_2d_rgb32_draw_pattern( __PATTERN_ADDR, /*!< pattern tile address */\
__TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__MODE, /*!< draw mode */ \
__FG_COLOUR, /*!< foreground colour */ \
__BG_COLOUR) /*!< background colour */ \
#define arm_2d_rgb32_draw_pattern( __PATTERN_ADDR, /* pattern tile address */ \
__TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__MODE, /* draw mode */ \
__FG_COLOUR, /* foreground colour */ \
__BG_COLOUR) /* background colour */ \
arm_2dp_rgb32_draw_pattern(NULL, \
(__PATTERN_ADDR), \
(__TARGET_ADDR), \
@ -116,25 +122,25 @@ extern "C" {
(__FG_COLOUR), \
(__BG_COLOUR))
#define arm_2d_c8bit_fill_colour( __TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__COLOUR) /*!< colour */ \
#define arm_2d_c8bit_fill_colour( __TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__COLOUR) /* colour */ \
arm_2dp_c8bit_fill_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR), \
(__COLOUR))
#define arm_2d_rgb16_fill_colour( __TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__COLOUR) /*!< colour */ \
#define arm_2d_rgb16_fill_colour( __TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__COLOUR) /* colour */ \
arm_2dp_rgb16_fill_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR), \
(__COLOUR))
#define arm_2d_rgb32_fill_colour( __TARGET_ADDR, /*!< target tile address*/ \
__REGION_ADDR, /*!< target region address*/\
__COLOUR) /*!< colour */ \
#define arm_2d_rgb32_fill_colour( __TARGET_ADDR, /* target tile address*/ \
__REGION_ADDR, /* target region address*/ \
__COLOUR) /* colour */ \
arm_2dp_rgb32_fill_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR), \
@ -142,18 +148,20 @@ extern "C" {
/*============================ TYPES =========================================*/
/*! \note arm_2d_op_fill_cl_t inherits from arm_2d_op_t explicitly
/*!
* \brief the control block for colour-filling-operations
* \note arm_2d_op_fill_cl_t inherits from arm_2d_op_t explicitly
*/
typedef struct arm_2d_op_fill_cl_t {
inherit(arm_2d_op_core_t);
inherit(arm_2d_op_core_t); //!< base
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
union {
uint8_t chColour;
uint16_t hwColour;
uint32_t wColour;
uint8_t chColour; //!< 8bit colour
uint16_t hwColour; //!< 16bit colour
uint32_t wColour; //!< 32bit colour
};
} arm_2d_op_fill_cl_t;
@ -161,10 +169,12 @@ typedef struct arm_2d_op_fill_cl_t {
*/
typedef arm_2d_op_fill_cl_t arm_2d_op_drw_pt_t;
/*! \note arm_2d_op_drw_patn_t inherits from arm_2d_op_src_t explicitly
/*!
* \brief the control block for draw-bit-pattern operations
* \note arm_2d_op_drw_patn_t inherits from arm_2d_op_src_t explicitly
*/
typedef struct arm_2d_op_drw_patn_t {
inherit(arm_2d_op_core_t);
inherit(arm_2d_op_core_t); //!< base
struct {
const arm_2d_tile_t *ptTile; //!< target tile
@ -173,34 +183,38 @@ typedef struct arm_2d_op_drw_patn_t {
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
uint32_t wMode; //!< mode of the operation
union {
uint8_t chColour;
uint16_t hwColour;
uint32_t wColour;
}Foreground;
uint8_t chColour; //!< 8bit colour
uint16_t hwColour; //!< 16bit colour
uint32_t wColour; //!< 32bit colour
}Foreground; //!< forground colour
union {
uint8_t chColour;
uint16_t hwColour;
uint32_t wColour;
}Background;
uint8_t chColour; //!< 8bit colour
uint16_t hwColour; //!< 16bit colour
uint32_t wColour; //!< 32bit colour
}Background; //!< background colour
} arm_2d_op_drw_patn_t;
/*!
* \brief modes for copying bit-patterns
*/
enum {
ARM_2D_DRW_PATN_MODE_COPY = 0,
//ARM_2D_DRW_PATN_MODE_FILL = _BV(0),
//ARM_2D_DRW_PATN_MODE_Y_MIRROR = _BV(2),
//ARM_2D_DRW_PATN_MODE_X_MIRROR = _BV(3),
ARM_2D_DRW_PATN_MODE_WITH_BG_COLOR = _BV(4), //!< do not use given background colour
ARM_2D_DRW_PATN_MODE_NO_FG_COLOR = _BV(5), //!< do not use given foreground colour
ARM_2D_DRW_PATN_MODE_COPY = 0, //!< copy bit pattern
//ARM_2D_DRW_PATN_MODE_FILL = _BV(0), //!< not support yet
//ARM_2D_DRW_PATN_MODE_Y_MIRROR = _BV(2), //!< not support yet
//ARM_2D_DRW_PATN_MODE_X_MIRROR = _BV(3), //!< not support yet
ARM_2D_DRW_PATN_MODE_WITH_BG_COLOR = _BV(4), //!< use user specified backgound colour
ARM_2D_DRW_PATN_MODE_NO_FG_COLOR = _BV(5), //!< no forground
/*! use complementary colour as foreground colour
*!
*! \note this option is only avaialble when ARM_2D_DRW_PATN_MODE_NO_FG_COLOR
*! is used together.
*
* \note this option is only avaialble when ARM_2D_DRW_PATN_MODE_NO_FG_COLOR
* is used together.
*/
ARM_2D_DRW_PATH_MODE_COMP_FG_COLOUR = _BV(6),
ARM_2D_DRW_PATH_MODE_COMP_FG_COLOUR = _BV(6),
};
/*============================ GLOBAL VARIABLES ==============================*/
@ -209,14 +223,21 @@ enum {
/*----------------------------------------------------------------------------*
* Draw a point with specified colour *
*----------------------------------------------------------------------------*/
/*!
* \brief draw a point on a root tile with a given 8bit colour
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \note the point must be inside the region of the target tile
* \param[in] chColour an 8bit colour
*/
ARM_NONNULL(1)
__STATIC_INLINE void arm_2d_c8bit_draw_point_fast(
const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint_fast8_t chColour)
__STATIC_INLINE void arm_2d_c8bit_draw_point_fast( const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint_fast8_t chColour)
{
assert(ptTarget->bIsRoot); //!< must be root tile
assert(NULL != ptTarget);
assert(ptTarget->bIsRoot); // must be root tile
assert(tLocation.iX < ptTarget->tRegion.tSize.iWidth);
assert(tLocation.iY < ptTarget->tRegion.tSize.iHeight);
@ -226,13 +247,21 @@ __STATIC_INLINE void arm_2d_c8bit_draw_point_fast(
*pchPoint = (uint8_t)chColour;
}
/*!
* \brief draw a point on a root tile with a given 16bit colour
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \note the point must be inside the region of the target tile
* \param[in] hwColour an 16bit colour
*/
ARM_NONNULL(1)
__STATIC_INLINE void arm_2d_rgb16_draw_point_fast(
const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint_fast16_t hwColour)
{
assert(ptTarget->bIsRoot); //!< must be root tile
assert(NULL != ptTarget);
assert(ptTarget->bIsRoot); // must be root tile
assert(tLocation.iX < ptTarget->tRegion.tSize.iWidth);
assert(tLocation.iY < ptTarget->tRegion.tSize.iHeight);
@ -241,14 +270,22 @@ __STATIC_INLINE void arm_2d_rgb16_draw_point_fast(
+ tLocation.iX;
*phwPoint = (uint16_t)hwColour;
}
/*!
* \brief draw a point on a root tile with a given 32bit colour
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \note the point must be inside the region of the target tile
* \param[in] wColour an 32bit colour
*/
ARM_NONNULL(1)
__STATIC_INLINE void arm_2d_rgb32_draw_point_fast(
const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint32_t wColour)
{
assert(ptTarget->bIsRoot); //!< must be root tile
assert(NULL != ptTarget);
assert(ptTarget->bIsRoot); // must be root tile
assert(tLocation.iX < ptTarget->tRegion.tSize.iWidth);
assert(tLocation.iY < ptTarget->tRegion.tSize.iHeight);
@ -258,27 +295,65 @@ __STATIC_INLINE void arm_2d_rgb32_draw_point_fast(
*pwPoint = wColour;
}
/*! \note Since those draw point APIs involve a lot of region calculations
*! which is only useful when partial framebuffer is used, please DO NOT
*! use those APIs for drawing unless you are using partial framebuffer.
*! For fast processing, as long as you have a root tile, please use the
*! functions with "_fast" posfix.
*!
*/
/*!
* \brief draw a point with a given 8bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] chColour an 8bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_c8bit_draw_point( arm_2d_op_drw_pt_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint_fast8_t chColour);
/*!
* \brief draw a point with a given 16bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] hwColour an 16bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb16_draw_point( arm_2d_op_drw_pt_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
uint_fast16_t hwColour);
/*!
* \brief draw a point with a given 32bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] wColour an 32bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb32_draw_point( arm_2d_op_drw_pt_t *ptOP,
@ -292,7 +367,7 @@ extern
ARM_NONNULL(1)
arm_fsm_rt_t arm_2d_rgba8888_draw_point(const arm_2d_tile_t *ptTarget,
const arm_2d_location_t tLocation,
arm_2d_color_rgba8888_t tColour);
arm_2d_color_bgra8888_t tColour);
#endif
@ -300,6 +375,17 @@ arm_fsm_rt_t arm_2d_rgba8888_draw_point(const arm_2d_tile_t *ptTarget,
* Draw a bit patterns *
*----------------------------------------------------------------------------*/
/*!
* \brief copy a bit-pattern with given 8bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] chForeColour the foreground colour
* \param[in] chBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_c8bit_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
@ -310,6 +396,17 @@ arm_fsm_rt_t arm_2dp_c8bit_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
uint8_t chForeColour,
uint8_t chBackColour);
/*!
* \brief copy a bit-pattern with given 16bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] hwForeColour the foreground colour
* \param[in] hwBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb16_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
@ -320,6 +417,17 @@ arm_fsm_rt_t arm_2dp_rgb16_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
uint16_t hwForeColour,
uint16_t hwBackColour);
/*!
* \brief copy a bit-pattern with given 32bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] wForeColour the foreground colour
* \param[in] wBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb32_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
@ -334,6 +442,14 @@ arm_fsm_rt_t arm_2dp_rgb32_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
* Fill tile with a specified colour *
*----------------------------------------------------------------------------*/
/*!
* \brief fill the target region with a given 8bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] chColour a 8bit colour
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_c8bit_fill_colour( arm_2d_op_fill_cl_t *ptOP,
@ -341,6 +457,14 @@ arm_fsm_rt_t arm_2dp_c8bit_fill_colour( arm_2d_op_fill_cl_t *ptOP,
const arm_2d_region_t *ptRegion,
uint_fast8_t chColour);
/*!
* \brief fill the target region with a given 16bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] hwColour a 16bit colour
* \return arm_fsm_rt_t the operation result
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb16_fill_colour( arm_2d_op_fill_cl_t *ptOP,
@ -348,6 +472,14 @@ arm_fsm_rt_t arm_2dp_rgb16_fill_colour( arm_2d_op_fill_cl_t *ptOP,
const arm_2d_region_t *ptRegion,
uint_fast16_t hwColour);
/*!
* \brief fill the target region with a given 32bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wColour a 32bit colour
* \return arm_fsm_rt_t the operations result
*/
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb32_fill_colour( arm_2d_op_fill_cl_t *ptOP,
@ -356,6 +488,8 @@ arm_fsm_rt_t arm_2dp_rgb32_fill_colour( arm_2d_op_fill_cl_t *ptOP,
uint32_t wColour);
/*! @} */
#if defined(__clang__)
# pragma clang diagnostic pop
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -22,8 +22,8 @@
* Description: Public header file to indicate features avaialble for this
* arm-2d library variant.
*
* $Date: 29. Jan 2020
* $Revision: V.0.5.0
* $Date: 18. July 2022
* $Revision: V.1.0.3
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
@ -38,6 +38,19 @@
extern "C" {
#endif
/*!
* \addtogroup gKernel 1 Kernel
* @{
*/
#ifndef __ARM_2D_SKIP_CFG_HEADER__
# ifndef __ARM_2D_USER_CFG_HEADER__
# include "arm_2d_cfg.h"
# else
# include __ARM_2D_USER_CFG_HEADER__
# endif
#endif
/*============================ MACROS ========================================*/
#undef __ARM_2D_HAS_HELIUM__
@ -81,9 +94,9 @@ extern "C" {
# define __ARM_2D_HAS_ASYNC__ 1
#endif
#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
# if !defined(__ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE) || \
__ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE < 4
# define __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE 4
# if !defined(__ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__) || \
__ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ < 4
# define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ 4
# endif
#endif
@ -95,41 +108,49 @@ extern "C" {
#endif
#undef __ARM_2D_HAS_DSP__
#if defined(__ARM_FEATURE_DSP)
#if defined(__ARM_FEATURE_DSP) && __ARM_FEATURE_DSP
#define __ARM_2D_HAS_DSP__ 1
#else
#define __ARM_2D_HAS_DSP__ 0
#endif
#ifndef __ARM_2D_HAS_INTERPOLATION_ROTATION__
# define __ARM_2D_HAS_INTERPOLATION_ROTATION__ 0
#ifndef __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
# ifdef __ARM_2D_HAS_INTERPOLATION_ROTATION__
# warning __ARM_2D_HAS_INTERPOLATION_ROTATION__ is deprecated, please use __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ instead.
/*! \brief __ARM_2D_HAS_INTERPOLATION_ROTATION__ is deprecated
*! add this for backward compatible
*/
# define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ \
__ARM_2D_HAS_INTERPOLATION_ROTATION__
# else
# define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ 0
# endif
#endif
/*! \note DO NOT define macro __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ unless
/*! \note DO NOT define macro __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ unless
*! you sure about what you are doing.
*/
#if !__ARM_2D_HAS_FPU__
# undef __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ 1
# undef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1
#elif !__ARM_2D_HAS_HELIUM__ \
&& !defined(__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__)
&& !defined(__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__)
/*! \note For Armv7-m processors and Armv8-m processors that have no Helium
*! extension but only FPU, fixed point rotation is faster than the
*! float point rotation even if FPU can accelerate float point
*! operations.
*/
# define __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ 1
# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1
#endif
#if __ARM_2D_HAS_HELIUM_INTEGER__ && !__ARM_2D_HAS_HELIUM_FLOAT__
# undef __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ 1
# undef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1
#endif
#ifndef __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ 0
#ifndef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1
#endif
/*! \note In your application, if you do need to use RGBA8888 for some resources
@ -137,7 +158,7 @@ extern "C" {
*! related APIs, please set this macro to 1 in your project.
*/
#ifndef __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
# define __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ 0
# define __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ 1
#endif
/*----------------------------------------------------------------------------*
@ -148,52 +169,63 @@ extern "C" {
* Those macros are undefined by defaults. Please use with cautions. *
*----------------------------------------------------------------------------*
* *
* 1. __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__ *
* 1. __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ *
* This option is used to remove calibration in angle computations to gain *
* a better performance, small error might be noticible for angles like *
* 90, 180, 270 etc. *
* *
* 2. __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__ *
* 2. __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ *
* This option is used to speed up M-cores without DSP support *
* It skips saturation in the QADD/QDADD/QDSUB involved in the rotation. *
* The chances of overflow remain low as elements involved are using *
* non-accumulating Q15.16 format and integer parts are in the range of *
* the screen size providing enough margin. *
* *
* 3. __ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__ *
* When define this macro, alpha value 0xFF will not be treated as opaque *
* in mask related operations you can barely see the background. Defining *
* this macro can get a big performance uplift. *
*----------------------------------------------------------------------------*/
/*! \note __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__ is
* deprecated.
* Please use __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ instead.
*/
#ifndef __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__
# ifdef __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__
# warning __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__\
is deprecated, please use __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__\
instead.
# define __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ \
__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__
# endif
#endif
/*! \note __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__ is
* deprecated.
* Please use __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ instead.
*/
#ifndef __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__
# ifdef __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__
# warning __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__\
is deprecated, please use __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__\
instead.
# define __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ \
__ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__
#endif
#endif
/*============================ MACROFIED FUNCTIONS ===========================*/
#if defined(__ARM_2D_HAS_CDE__) && !__ARM_2D_HAS_CDE__
# define __arm_2d_cde_init()
#endif
#if defined(__ARM_2D_HAS_HELIUM__) && !__ARM_2D_HAS_HELIUM__
# define __arm_2d_helium_init()
#endif
#if defined(__ARM_2D_HAS_HW_ACC__) && !__ARM_2D_HAS_HW_ACC__
# define __arm_2d_acc_init()
#endif
#if defined(__ARM_2D_HAS_ASYNC__) && !__ARM_2D_HAS_ASYNC__
# define __arm_2d_async_init()
#endif
#undef arm_2d_init
#define arm_2d_init() \
do { \
__arm_2d_init(); \
__arm_2d_async_init(); \
__arm_2d_helium_init(); \
__arm_2d_cde_init(); \
__arm_2d_acc_init(); \
} while(0)
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*! @} */
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,312 @@
/*
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d.h"
* Description: Public header file to contain the all avaialble Arm-2D
* interface header files
*
* $Date: 17. May 2022
* $Revision: V.1.2.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_OP_H__
#define __ARM_2D_OP_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
#define LOW_LEVEL_IO__ARM_2D_IO_NONE (*(void *)NULL)
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*----------------------------------------------------------------------------*
* Misc *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_BARRIER;
/*----------------------------------------------------------------------------*
* Basic Tile Operation (Core) *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32;
/*----------------------------------------------------------------------------*
* Alpha-Blending and Masks *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_CCCN888;
/*----------------------------------------------------------------------------*
* Basic Drawing *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_RGB32;
/*----------------------------------------------------------------------------*
* Colour Conversion *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB888;
/*----------------------------------------------------------------------------*
* Transform *
*----------------------------------------------------------------------------*/
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_CCCN888;
/*============================ PROTOTYPES ====================================*/
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,903 @@
/*
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: cmsis_nn_typs.h
* Description: Public header file to contain the Arm-2D structs
*
* $Date: 09. Aug 2022
* $Revision: V.1.0.4
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_TYPES_H__
#define __ARM_2D_TYPES_H__
/*============================ INCLUDES ======================================*/
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include "arm_2d_features.h"
#include "arm_2d_utils.h"
#include "__arm_2d_math.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wmissing-declarations"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc11-extensions"
#elif __IS_COMPILER_ARM_COMPILER_5__
# pragma diag_suppress 64
#elif __IS_COMPILER_GCC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# pragma GCC diagnostic ignored "-Wpadded"
#endif
/*!
* \addtogroup gKernel 1 Kernel
* @{
*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*----------------------------------------------------------------------------*
* Infrastructure *
*----------------------------------------------------------------------------*/
/*!
* \brief finite-state-machine status return (Compatible with arm_status, minimal integer: int8_t)
*
*/
typedef enum {
arm_fsm_rt_err = -1, //!< fsm error
arm_fsm_rt_cpl = 0, //!< fsm complete
arm_fsm_rt_on_going = 1, //!< fsm on-going
arm_fsm_rt_wait_for_obj = 2, //!< fsm wait for IPC object
arm_fsm_rt_async = 3, //!< fsm work asynchronously, please check it later.
arm_fsm_rt_wait_for_res = 4, //!< wait for resource
} arm_fsm_rt_t;
/*!
* \brief the error code for arm-2d (minimal integer: int8_t)
*
*/
typedef enum {
ARM_2D_ERR_UNSUPPORTED_COLOUR = -11, //!< the specified colour is not supported
ARM_2D_ERR_BUSY = -10, //!< service is busy
ARM_2D_ERR_INSUFFICIENT_RESOURCE = -9, //!< insufficient resource
ARM_2D_ERR_IO_BUSY = -8, //!< HW accelerator is busy
ARM_2D_ERR_IO_ERROR = -7, //!< Generic HW error
ARM_2D_ERR_MISSING_PARAM = -6, //!< missing mandatory parameter
ARM_2D_ERR_INVALID_OP = -5, //!< unsupported / invalid operation
ARM_2D_ERR_NOT_SUPPORT = -4, //!< feature/service/operation is not supported
ARM_2D_ERR_OUT_OF_REGION = -3, //!< the operation is out of target area
ARM_2D_ERR_INVALID_PARAM = -2, //!< invalid parameter
ARM_2D_ERR_UNKNOWN = -1, //!< generic or unknown errors
ARM_2D_ERR_NONE = 0, //!< no error
} arm_2d_err_t;
/*!
* \brief comparison result
*
*/
typedef enum {
ARM_2D_CMP_SMALLER = -1, //!< the target is smaller than the reference
ARM_2D_CMP_EQUALS = 0, //!< the target is equal to the reference
ARM_2D_CMP_LARGER = 1, //!< the target is larger than the reference
} arm_2d_cmp_t;
/*----------------------------------------------------------------------------*
* Colour definitions *
*----------------------------------------------------------------------------*/
/*!
* \brief the colour type for gray8 (8bit gray scale)
*
*/
typedef union arm_2d_color_gray8_t {
uint8_t tValue;
} arm_2d_color_gray8_t;
/*!
* \brief the colour type for rgb565
*
*/
typedef union arm_2d_color_rgb565_t {
uint16_t tValue;
struct {
uint16_t u5B : 5;
uint16_t u6G : 6;
uint16_t u5R : 5;
};
} arm_2d_color_rgb565_t;
/*!
* \brief the colour type for brga8888
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_bgra8888_t {
uint32_t tValue;
struct {
uint32_t u8B : 8;
uint32_t u8G : 8;
uint32_t u8R : 8;
uint32_t u8A : 8;
};
} arm_2d_color_bgra8888_t;
/*!
* \brief the colour type for rgb888 (compliant with ccca888 and bgra8888)
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_rgb888_t {
uint32_t tValue;
struct {
uint32_t u8B : 8;
uint32_t u8G : 8;
uint32_t u8R : 8;
uint32_t : 8;
};
} arm_2d_color_rgb888_t;
/*!
* \brief the colour type for any 32bit colour formats which has an alpha channel on its 3rd byte.
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_ccca8888_t {
uint32_t tValue;
struct {
uint8_t u8C[3];
uint8_t u8A;
};
} arm_2d_color_ccca8888_t;
/*!
* \brief the colour type for any 32bit colour formats which has an alpha channel on its first byte.
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_accc8888_t {
uint32_t tValue;
struct {
uint8_t u8A;
uint8_t u8C[3];
};
} arm_2d_color_accc8888_t;
/*!
* \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its 3rd byte.
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_cccn888_t {
uint32_t tValue;
struct {
uint8_t u8C[3];
uint8_t : 8;
};
} arm_2d_color_cccn888_t;
/*!
* \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its first byte.
*
* \details In most cases four equal-sized pieces of adjacent memory are used,
* one for each channel, and a 0 in a channel indicates black color or
* transparent alpha, while all-1 bits indicates white or fully opaque
* alpha. By far the most common format is to store 8 bits (one byte)
* for each channel, which is 32 bits for each pixel.
*
* (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_nccc888_t {
uint32_t tValue;
struct {
uint8_t : 8;
uint8_t u8C[3];
};
} arm_2d_color_nccc888_t;
/*!
* \brief enumerations for colour attributes
*/
enum {
ARM_2D_COLOUR_SZ_1BIT = 0, //!< 1 bit:black and white
ARM_2D_COLOUR_SZ_2BIT = 1, //!< 4 colours or 4 gray-levels
ARM_2D_COLOUR_SZ_4BIT = 2, //!< 16 colours or 16 gray-levels
ARM_2D_COLOUR_SZ_8BIT = 3, //!< 256 colours
ARM_2D_COLOUR_SZ_16BIT = 4, //!< 16bits
ARM_2D_COLOUR_SZ_32BIT = 5, //!< true colour
ARM_2D_COLOUR_SZ_1BIT_msk = ARM_2D_COLOUR_SZ_1BIT << 1,
ARM_2D_COLOUR_SZ_2BIT_msk = ARM_2D_COLOUR_SZ_2BIT << 1,
ARM_2D_COLOUR_SZ_4BIT_msk = ARM_2D_COLOUR_SZ_4BIT << 1,
ARM_2D_COLOUR_SZ_8BIT_msk = ARM_2D_COLOUR_SZ_8BIT << 1,
ARM_2D_COLOUR_SZ_16BIT_msk = ARM_2D_COLOUR_SZ_16BIT<< 1,
ARM_2D_COLOUR_SZ_32BIT_msk = ARM_2D_COLOUR_SZ_32BIT<< 1,
ARM_2D_COLOUR_SZ_msk = (0x07 << 1),
ARM_2D_COLOUR_LITTLE_ENDIAN = 0,
ARM_2D_COLOUR_BIG_ENDIAN = 1,
ARM_2D_COLOUR_LITTLE_ENDIAN_msk = ARM_2D_COLOUR_LITTLE_ENDIAN << 4,
ARM_2D_COLOUR_BIG_ENDIAN_msk = ARM_2D_COLOUR_BIG_ENDIAN << 4,
ARM_2D_COLOUR_NO_ALPHA = 0,
ARM_2D_COLOUR_HAS_ALPHA = 1,
ARM_2D_COLOUR_NO_ALPHA_msk = ARM_2D_COLOUR_NO_ALPHA << 0,
ARM_2D_COLOUR_HAS_ALPHA_msk = ARM_2D_COLOUR_HAS_ALPHA << 0,
ARM_2D_COLOUR_VARIANT_pos = 5,
ARM_2D_COLOUR_VARIANT_msk = 0x07 << ARM_2D_COLOUR_VARIANT_pos,
};
/* macros for colour attributes */
#define ARM_2D_M_COLOUR_SZ_1BIT 0 //!< 1 bit:black and white
#define ARM_2D_M_COLOUR_SZ_2BIT 1 //!< 4 colours or 4 gray-levels
#define ARM_2D_M_COLOUR_SZ_4BIT 2 //!< 16 colours or 16 gray-levels
#define ARM_2D_M_COLOUR_SZ_8BIT 3 //!< 256 colours
#define ARM_2D_M_COLOUR_SZ_16BIT 4 //!< 16bits
#define ARM_2D_M_COLOUR_SZ_32BIT 5 //!< true colour
#define ARM_2D_M_COLOUR_SZ_1BIT_msk (ARM_2D_M_COLOUR_SZ_1BIT << 1)
#define ARM_2D_M_COLOUR_SZ_2BIT_msk (ARM_2D_M_COLOUR_SZ_2BIT << 1)
#define ARM_2D_M_COLOUR_SZ_4BIT_msk (ARM_2D_M_COLOUR_SZ_4BIT << 1)
#define ARM_2D_M_COLOUR_SZ_8BIT_msk (ARM_2D_M_COLOUR_SZ_8BIT << 1)
#define ARM_2D_M_COLOUR_SZ_16BIT_msk (ARM_2D_M_COLOUR_SZ_16BIT<< 1)
#define ARM_2D_M_COLOUR_SZ_32BIT_msk (ARM_2D_M_COLOUR_SZ_32BIT<< 1)
#define ARM_2D_M_COLOUR_SZ_msk (0x07 << 1),
#define ARM_2D_M_COLOUR_LITTLE_ENDIAN 0
#define ARM_2D_M_COLOUR_BIG_ENDIAN 1
#define ARM_2D_M_COLOUR_LITTLE_ENDIAN_msk (ARM_2D_M_COLOUR_LITTLE_ENDIAN << 4)
#define ARM_2D_M_COLOUR_BIG_ENDIAN_msk (ARM_2D_M_COLOUR_BIG_ENDIAN << 4)
#define ARM_2D_M_COLOUR_NO_ALPHA 0
#define ARM_2D_M_COLOUR_HAS_ALPHA 1
#define ARM_2D_M_COLOUR_NO_ALPHA_msk (ARM_2D_M_COLOUR_NO_ALPHA << 0)
#define ARM_2D_M_COLOUR_HAS_ALPHA_msk (ARM_2D_M_COLOUR_HAS_ALPHA << 0)
#define ARM_2D_M_COLOUR_VARIANT_pos 5
#define ARM_2D_M_COLOUR_VARIANT_msk (0x07 << ARM_2D_M_COLOUR_VARIANT_pos)
/*!
* \brief enumerations for colour types
*
*/
enum {
ARM_2D_COLOUR_BIN = ARM_2D_COLOUR_SZ_1BIT_msk,
ARM_2D_COLOUR_1BIT = ARM_2D_COLOUR_SZ_1BIT_msk,
ARM_2D_COLOUR_8BIT = ARM_2D_COLOUR_SZ_8BIT_msk,
ARM_2D_COLOUR_GRAY8 = ARM_2D_COLOUR_SZ_8BIT_msk,
ARM_2D_COLOUR_16BIT = ARM_2D_COLOUR_SZ_16BIT_msk,
ARM_2D_COLOUR_RGB16 = ARM_2D_COLOUR_SZ_16BIT_msk,
ARM_2D_COLOUR_RGB565 = ARM_2D_COLOUR_RGB16,
/* won't support
ARM_2D_COLOUR_RGB565_BE = ARM_2D_COLOUR_SZ_16BIT_msk |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
*/
ARM_2D_COLOUR_32BIT = ARM_2D_COLOUR_SZ_32BIT_msk ,
ARM_2D_COLOUR_RGB32 = ARM_2D_COLOUR_SZ_32BIT_msk ,
ARM_2D_COLOUR_CCCN888 = ARM_2D_COLOUR_RGB32 ,
ARM_2D_COLOUR_CCCA8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA_msk ,
ARM_2D_COLOUR_RGB888 = ARM_2D_COLOUR_CCCN888 ,
ARM_2D_COLOUR_BGRA8888 = ARM_2D_COLOUR_CCCA8888 ,
/* not supported yet
ARM_2D_COLOUR_NCCC888 = ARM_2D_COLOUR_RGB32 |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
ARM_2D_COLOUR_ACCC8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA_msk |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
*/
ARM_2D_CHANNEL_8in32 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA_msk |
ARM_2D_COLOUR_VARIANT_msk ,
};
/* macros for colour formats */
#define ARM_2D_M_COLOUR_BIN ARM_2D_M_COLOUR_SZ_1BIT_msk
#define ARM_2D_M_COLOUR_1BIT ARM_2D_M_COLOUR_SZ_1BIT_msk
#define ARM_2D_M_COLOUR_8BIT ARM_2D_M_COLOUR_SZ_8BIT_msk
#define ARM_2D_M_COLOUR_GRAY8 ARM_2D_M_COLOUR_SZ_8BIT_msk
#define ARM_2D_M_COLOUR_16BIT ARM_2D_M_COLOUR_SZ_16BIT_msk
#define ARM_2D_M_COLOUR_RGB16 ARM_2D_M_COLOUR_SZ_16BIT_msk
#define ARM_2D_M_COLOUR_RGB565 ARM_2D_M_COLOUR_RGB16
/* won't support
#define ARM_2D_M_COLOUR_RGB565_BE ( ARM_2D_M_COLOUR_SZ_16BIT_msk \
| ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
*/
#define ARM_2D_M_COLOUR_32BIT ARM_2D_M_COLOUR_SZ_32BIT_msk
#define ARM_2D_M_COLOUR_RGB32 ARM_2D_M_COLOUR_SZ_32BIT_msk
#define ARM_2D_M_COLOUR_CCCN888 ARM_2D_M_COLOUR_RGB32
#define ARM_2D_M_COLOUR_CCCA8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
| ARM_2D_M_COLOUR_HAS_ALPHA_msk)
#define ARM_2D_M_COLOUR_RGB888 ARM_2D_M_COLOUR_CCCN888
#define ARM_2D_M_COLOUR_RGBA8888 ARM_2D_M_COLOUR_CCCA8888
/* not supported yet
#define ARM_2D_M_COLOUR_NCCC888 ( ARM_2D_M_COLOUR_RGB32 \
| ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
#define ARM_2D_M_COLOUR_ACCC8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
| ARM_2D_M_COLOUR_HAS_ALPHA_msk \
| ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
*/
#define ARM_2D_M_CHANNEL_8in32 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
| ARM_2D_M_COLOUR_HAS_ALPHA_msk) \
| ARM_2D_M_COLOUR_VARIANT_msk )
/*!
* \brief a type used as colour descriptor
*
*/
typedef union {
struct {
uint8_t bHasAlpha : 1; //!< whether the target colour has alpha channel
uint8_t u3ColourSZ : 3; //!< the size of the colour
uint8_t bBigEndian : 1; //!< whether the colour is stored in big endian
uint8_t u3Variant : 3;
};
uint8_t chScheme;
} arm_2d_color_info_t;
/*----------------------------------------------------------------------------*
* Tile and Regions *
*----------------------------------------------------------------------------*/
/*!
* \brief a type for coordinates (integer)
*
*/
typedef struct arm_2d_location_t {
int16_t iX; //!< x in Cartesian coordinate system
int16_t iY; //!< y in Cartesian coordinate system
} arm_2d_location_t;
/*!
* \brief a type for coordinates in floating point
*
*/
typedef struct arm_2d_point_float_t {
float fX; //!< x in Cartesian coordinate system
float fY; //!< y in Cartesian coordinate system
} arm_2d_point_float_t;
/*!
* \brief a type for coordinates in fixed point
*
*/
typedef struct arm_2d_point_fx_t {
int32_t X; //!< x in Cartesian coordinate system
int32_t Y; //!< y in Cartesian coordinate system
} arm_2d_point_fx_t;
/*!
* \brief a type for the size of an rectangular area
*
*/
typedef struct arm_2d_size_t {
int16_t iWidth; //!< width of an rectangular area
int16_t iHeight; //!< height of an rectangular area
} arm_2d_size_t;
/*!
* \brief a type for an rectangular area
*
*/
typedef struct arm_2d_region_t {
implement_ex(arm_2d_location_t, tLocation); //!< the location (top-left corner)
implement_ex(arm_2d_size_t, tSize); //!< the size
} arm_2d_region_t;
/*!
* \brief a type for tile
*
*/
typedef struct arm_2d_tile_t arm_2d_tile_t;
struct arm_2d_tile_t {
implement_ex(struct {
uint8_t bIsRoot : 1; //!< is this tile a root tile
uint8_t bHasEnforcedColour : 1; //!< does this tile contains enforced colour info
uint8_t bDerivedResource : 1; //!< indicate whether this is a derived resources (when bIsRoot == 0)
uint8_t bVirtualResource : 1; //!< indicate whether the resource should be loaded on-demand
uint8_t : 4;
uint8_t : 8;
uint8_t : 8;
arm_2d_color_info_t tColourInfo; //!< enforced colour
}, tInfo);
implement_ex(arm_2d_region_t, tRegion); //!< the region of the tile
union {
/* when bIsRoot is true, phwBuffer is available,
* otherwise ptParent is available
*/
arm_2d_tile_t *ptParent; //!< a pointer points to the parent tile
uint8_t *pchBuffer; //!< a pointer points to a buffer in a 8bit colour type
uint16_t *phwBuffer; //!< a pointer points to a buffer in a 16bit colour type
uint32_t *pwBuffer; //!< a pointer points to a buffer in a 32bit colour type
intptr_t nAddress; //!< a pointer in integer
};
};
/*!
* \brief a type for virtual resource
*
* \note the flag tTile.tInfo.bVirtualResource must be true (1)
*/
typedef struct arm_2d_vres_t arm_2d_vres_t;
struct arm_2d_vres_t {
/*! base class: tTile */
implement_ex( arm_2d_tile_t, tTile);
/*! a reference of an user object */
uintptr_t pTarget;
/*!
* \brief a method to load a specific part of an image
* \param[in] pTarget a reference of an user object
* \param[in] ptVRES a reference of this virtual resource
* \param[in] ptRegion the target region of the image
* \return intptr_t the address of a resource buffer which holds the content
*/
intptr_t (*Load) ( uintptr_t pTarget,
arm_2d_vres_t *ptVRES,
arm_2d_region_t *ptRegion);
/*!
* \brief a method to despose the buffer
* \param[in] pTarget a reference of an user object
* \param[in] ptVRES a reference of this virtual resource
* \param[in] pBuffer the target buffer
*/
void (*Depose) ( uintptr_t pTarget,
arm_2d_vres_t *ptVRES,
intptr_t pBuffer );
};
/*----------------------------------------------------------------------------*
* Task *
*----------------------------------------------------------------------------*/
/*!
* \brief arm-2d application level task control block
*
*/
typedef struct arm_2d_task_t {
ARM_PRIVATE(
arm_fsm_rt_t tResult; //!< the temporary result of the task
uint8_t chState; //!< the state of the FSM
void *ptTask; //!< a pointer for an internal object
)
} arm_2d_task_t;
/*----------------------------------------------------------------------------*
* Operation and Events Handling *
*----------------------------------------------------------------------------*/
typedef struct arm_2d_op_core_t arm_2d_op_core_t;
/*!
* \brief a prototype of event handlers for 2D operations
*
* \param[in] ptThisOP the target 2D operation descriptor
* \param[in] tResult the operation result
* \param[in] pTarget A user attached object
* \return bool a boolean value to indicate whether the event has been handled
*/
typedef bool arm_2d_op_evt_handler_t( arm_2d_op_core_t *ptThisOP,
arm_fsm_rt_t tResult,
void *pTarget);
/*!
* \brief a type for 2D operation event handling
*
*/
typedef struct arm_2d_op_evt_t {
arm_2d_op_evt_handler_t *fnHandler; //!< event handler
void *pTarget; //!< user attached target
} arm_2d_op_evt_t;
/*!
* \brief a prototype for generic event handlers
*
* \param pTarget A user attached object
* \return bool a boolean value to indicate whether the event has been handled
*/
typedef bool arm_2d_evt_handler_t(void *pTarget);
/*!
* \brief a type for generic event handling
*
*/
typedef struct arm_2d_evt_t {
arm_2d_evt_handler_t *fnHandler; //!< event handler
void *pTarget; //!< user attached target
} arm_2d_evt_t;
#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE _BV(0)
#define ARM_2D_OP_INFO_PARAM_HAS_TARGET _BV(1)
#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK _BV(2)
#define ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK _BV(3)
#define ARM_2D_OP_INFO_PARAM_HAS_ORIGIN _BV(4)
#define ARM_2D_OP_INFO_PARAM_TILES_MASK ( \
ARM_2D_OP_INFO_PARAM_HAS_SOURCE | \
ARM_2D_OP_INFO_PARAM_HAS_TARGET | \
ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK | \
ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK | \
ARM_2D_OP_INFO_PARAM_HAS_ORIGIN )
//! \brief an incomplete defintion which is only used for defining pointers
typedef struct __arm_2d_low_level_io_t __arm_2d_low_level_io_t;
/*!
* \brief A descriptive header for 2D operations
*/
typedef union __arm_2d_op_info_t {
struct {
arm_2d_color_info_t Colour; //!< the colour used in thie operation
union {
struct {
uint8_t bHasSource : 1; //!< whether this operation contains source tile
uint8_t bHasTarget : 1; //!< whether this operation contains target tile
uint8_t bHasSrcMask : 1; //!< whether this operation has Mask layer for source tile
uint8_t bHasDesMask : 1; //!< whether this operation has Mask layer for target tile
uint8_t bHasOrigin : 1; //!< whether the Source has an origin tile
uint8_t : 2;
uint8_t bAllowEnforcedColour : 1; //!< whether this operation allow enforced colours in tiles
};
uint8_t chValue; //!< feature value
}Param; //!< operation feature set
uint8_t chInClassOffset; //!< some operation uses this as the offset of the key member in the class
uint8_t chOpIndex; //!< __ARM_2D_OP_IDX_XXXXXX
union {
struct {
uint8_t CopyLike; //!< A copy-like interface contains the target tile, the source tile and the copy size
uint8_t FillLike; //!< A copy-like interface contains the target tile and the source tile
};
struct {
uint8_t CopyOrigLike; //!< A copy-like interface contains the target tile, the dummy tile, the reference to the original source tile and the copy size
uint8_t FillOrigLike; //!< A copy-like interface contains the target tile, the dummy tile and the reference to the original source tile
};
struct {
uint8_t TileProcessLike; //!< A simple interface contains only the target tile
};
}LowLevelInterfaceIndex; //!< Low level interface index
union {
const __arm_2d_low_level_io_t *IO[2]; //!< array of IOs
struct {
const __arm_2d_low_level_io_t *ptCopyLike; //!< the function pointer for a copy-like implementation
const __arm_2d_low_level_io_t *ptFillLike; //!< the function pointer for a fill-like implementation
};
struct {
const __arm_2d_low_level_io_t *ptCopyOrigLike; //!< the function pointer for a copy-orig-like implementation
const __arm_2d_low_level_io_t *ptFillOrigLike; //!< the function pointer for a fill-orig-like implementation
};
struct {
const __arm_2d_low_level_io_t *ptTileProcessLike; //!< the function pointer for the tile-process-like implementation
};
}LowLevelIO; //!< low level IO definition
}Info; //!< operation description
uint32_t wID; //!< Operation ID
} __arm_2d_op_info_t;
/*!
* \brief how would you want to accelerate the 2d-operation
*/
enum {
//! Use hardware acceleration if possible, even if there is a long queue to wait
ARM_2D_PREF_ACC_USE_HW_IF_POSSIBLE = 0,
//! Only use Hardware Acceleration, if it is not supported, IO error will be issued
ARM_2D_PREF_ACC_HW_ONLY = 1,
//! Only use software algorithm
ARM_2D_PREF_ACC_SW_ONLY = 2,
//!< don't care, let the arm-2d library decide
ARM_2D_PREF_ACC_DONT_CARE = 3,
};
#define __ARM_2D_OP_STATUS_BUSY_msk (1 << 4)
#define __ARM_2D_OP_STATUS_IO_ERROR_msk (1 << 5)
#define __ARM_2D_OP_STATUS_CPL_msk (1 << 6)
/*!
* \brief a type for 2D operation status
*
*/
typedef union arm_2d_op_status_t {
struct {
uint16_t u4SubTaskCount : 4; //!< sub task count
uint16_t bIsBusy : 1; //!< busy flag
uint16_t bIOError : 1; //!< HW IO Error
uint16_t bOpCpl : 1; //!< the whole operation complete
uint16_t : 9; //!< reserved
};
uint16_t tValue; //!< the host integer
} arm_2d_op_status_t;
/*!
* \brief the abstract class of 2D operations
*
*/
struct arm_2d_op_core_t {
ARM_PRIVATE(
arm_2d_op_core_t *ptNext; //!< a pointer for a single list
const __arm_2d_op_info_t *ptOp; //!< the pointer for the corresponding 2D operation description
struct {
uint8_t u2ACCMethods : 2; //!< acceleration Methods
uint8_t : 6; //!< reserved
}Preference;
int8_t tResult; //!< operation result
volatile arm_2d_op_status_t Status; //!< operation status
arm_2d_op_evt_t evt2DOpCpl; //!< operation-complete event
)
uintptr_t pUserParam; //!< user attached object
};
/*!
* \brief the base class for operations with only a target tile
* \note arm_2d_op_msk_t inherits from arm_2d_op_core_t
*/
typedef struct arm_2d_op_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
} arm_2d_op_t;
/*!
* \brief the base class for operations with a target tile and a target mask
* \note arm_2d_op_msk_t inherits from arm_2d_op_t
*/
typedef struct arm_2d_op_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
/* derived part */
struct {
const arm_2d_tile_t *ptTile; //!< target tile
} Mask;
} arm_2d_op_msk_t;
/*!
* \brief the base class for operations with a target tile and a source tile
* \note arm_2d_op_src_t inherits from arm_2d_op_t
*/
typedef struct arm_2d_op_src_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
/* derived part */
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
} arm_2d_op_src_t;
/*!
* \brief the base class for operations with a target tile, a source tile and masks
* \note arm_2d_op_src_msk_t inherits from arm_2d_op_src_t
*/
typedef struct arm_2d_op_src_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
/* derived part */
struct {
const arm_2d_tile_t *ptSourceSide; //!< source side mask
const arm_2d_tile_t *ptTargetSide; //!< target side mask
} Mask;
} arm_2d_op_src_msk_t;
/*!
* \brief the base class for operations with a target tile, a dummy tile and a reference to the original source tile
* \note arm_2d_op_src_orig_t inherits from arm_2d_op_src_t
*/
typedef struct arm_2d_op_src_orig_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< the dummy source tile
}Source;
uint32_t wMode;
/* derived part */
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
} arm_2d_op_src_orig_t;
/*!
* \brief the base class for operations with a target tile, a dummy tile, a reference to the original source tile and masks
* \note arm_2d_op_src_orig_msk_t inherits from arm_2d_op_src_orig_t
*/
typedef struct arm_2d_op_src_orig_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< the dummy source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
/* derived part */
struct {
const arm_2d_tile_t *ptOriginSide; //!< origin side mask
const arm_2d_tile_t *ptTargetSide; //!< target side mask
} Mask;
} arm_2d_op_src_orig_msk_t;
/*----------------------------------------------------------------------------*
* Fast Rotation linear regression structure
*----------------------------------------------------------------------------*/
#if (__ARM_2D_HAS_HELIUM_FLOAT__ || __ARM_2D_HAS_FPU__) \
&& !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
/*!
* \brief a type for parameters of linear interpolation (in floating point)
*
*/
typedef struct arm_2d_rot_linear_regr_t {
float slopeY;
float interceptY;
float slopeX;
float interceptX;
} arm_2d_rot_linear_regr_t;
#else
/*!
* \brief a type for parameters of linear interpolation (in fixed point)
*
*/
typedef struct arm_2d_rot_linear_regr_t {
int32_t slopeY;
int32_t interceptY;
int32_t slopeX;
int32_t interceptX;
} arm_2d_rot_linear_regr_t;
#endif
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*! @} */
#if defined(__clang__)
#pragma clang diagnostic pop
#elif __IS_COMPILER_ARM_COMPILER_5__
#pragma diag_warning 64
#elif __IS_COMPILER_GCC__
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif // __ARM_2D_TYPES_H__

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -21,8 +21,8 @@
* Title: arm_2d_utils.h
* Description: Public header file for Arm-2D Library
*
* $Date: 20. sep 2021
* $Revision: V.0.6.0
* $Date: 18. July 2022
* $Revision: V.1.0.3
*
* -------------------------------------------------------------------- */
@ -39,6 +39,7 @@
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
# pragma clang diagnostic ignored "-Wundef"
#elif defined(__IS_COMPILER_GCC__)
# pragma GCC diagnostic push
@ -53,13 +54,15 @@
/*! \note arm-2d relies on CMSIS 5.4.0 and above.
*/
#include "cmsis_compiler.h"
#include <arm_math.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \addtogroup gKernel 1 Kernel
* @{
*/
/*============================ MACROS ========================================*/
@ -68,59 +71,73 @@ extern "C" {
* Environment Detection *
*----------------------------------------------------------------------------*/
//! \name The macros to identify the compiler
//! @{
/* The macros to identify compilers */
//! \note for IAR
#ifdef __IS_COMPILER_IAR__
# undef __IS_COMPILER_IAR__
#endif
/*!
* \brief to detect IAR
*/
#undef __IS_COMPILER_IAR__
#if defined(__IAR_SYSTEMS_ICC__)
# define __IS_COMPILER_IAR__ 1
#endif
//! \note for arm compiler 5
#ifdef __IS_COMPILER_ARM_COMPILER_5__
# undef __IS_COMPILER_ARM_COMPILER_5__
#endif
/*!
* \brief to detect arm compiler 5
*
*/
#undef __IS_COMPILER_ARM_COMPILER_5__
#if ((__ARMCC_VERSION >= 5000000) && (__ARMCC_VERSION < 6000000))
# define __IS_COMPILER_ARM_COMPILER_5__ 1
#endif
//! @}
//! \note for arm compiler 6
#ifdef __IS_COMPILER_ARM_COMPILER_6__
# undef __IS_COMPILER_ARM_COMPILER_6__
#endif
/*!
* \brief to detect arm compiler 6
*
*/
#undef __IS_COMPILER_ARM_COMPILER_6__
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
# define __IS_COMPILER_ARM_COMPILER_6__ 1
#endif
#ifdef __IS_COMPILER_LLVM__
# undef __IS_COMPILER_LLVM__
/*!
* \brief to detect arm compilers
*
*/
#undef __IS_COMPILER_ARM_COMPILER__
#if defined(__IS_COMPILER_ARM_COMPILER_5__) && __IS_COMPILER_ARM_COMPILER_5__ \
|| defined(__IS_COMPILER_ARM_COMPILER_6__) && __IS_COMPILER_ARM_COMPILER_6__
# define __IS_COMPILER_ARM_COMPILER__ 1
#endif
/*!
* \brief to detect clang (llvm)
*
*/
#undef __IS_COMPILER_LLVM__
#if defined(__clang__) && !__IS_COMPILER_ARM_COMPILER_6__
# define __IS_COMPILER_LLVM__ 1
#else
//! \note for gcc
# ifdef __IS_COMPILER_GCC__
# undef __IS_COMPILER_GCC__
# endif
# if defined(__GNUC__) && !( defined(__IS_COMPILER_ARM_COMPILER_5__) \
|| defined(__IS_COMPILER_ARM_COMPILER_6__) \
|| defined(__IS_COMPILER_LLVM__))
/*!
* \brief to detect gcc
*
*/
# undef __IS_COMPILER_GCC__
# if defined(__GNUC__) && !( defined(__IS_COMPILER_ARM_COMPILER__) \
|| defined(__IS_COMPILER_LLVM__) \
|| defined(__IS_COMPILER_IAR__))
# define __IS_COMPILER_GCC__ 1
# endif
//! @}
#endif
//! @}
/*----------------------------------------------------------------------------*
* OOC and Private Protection *
*----------------------------------------------------------------------------*/
/*! \brief minimal support for OOPC
*/
/* minimal support for OOPC */
#undef __implement_ex
#undef __implement
#undef implement
@ -154,7 +171,7 @@ extern "C" {
*----------------------------------------------------------------------------*/
#ifndef ARM_2D_UNUSED
# define ARM_2D_UNUSED(__VAR) (__VAR) = (__VAR)
# define ARM_2D_UNUSED(__VAR) (void)(__VAR)
#endif
#ifndef ARM_TEST_BITS
@ -165,16 +182,52 @@ extern "C" {
# define dimof(__array) (sizeof(__array)/sizeof(__array[0]))
#endif
#define __ARM_TO_STRING(A) #A
#define TO_STRING(A) __ARM_TO_STRING(A)
#ifndef offsetof
# define offsetof(__type, __member) \
((uintptr_t)&(((__type *)NULL)->__member))
#endif
#define __ARM_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, \
_13,_14,_15,_16,__N,...) __N
#define __ARM_TO_STRING(__STR) #__STR
#define ARM_TO_STRING(__STR) __ARM_TO_STRING(__STR)
#define __ARM_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, \
_13,_14,_15,_16,__N,...) __N
/*!
* \brief A macro to count the number of parameters
*
* \note if GNU extension is not supported or enabled, the following express will
* be false: (__ARM_VA_NUM_ARGS() != 0)
* This might cause problems when in this library.
*/
#define __ARM_VA_NUM_ARGS(...) \
__ARM_VA_NUM_ARGS_IMPL( 0,##__VA_ARGS__,16,15,14,13,12,11,10,9, \
8,7,6,5,4,3,2,1,0)
/*!
* \brief detect whether GNU extension is enabled in compilation or not
*/
#if __ARM_VA_NUM_ARGS() != 0
# warning Please enable GNU extensions, it is required by the Arm-2D.
#endif
#ifndef ARM_2D_INVOKE
/*!
* \brief A macro to safely invode a function pointer
*
* \param[in] __FUNC_PTR the target function pointer
* \param[in] ... an optional parameter list
*/
# define ARM_2D_INVOKE(__FUNC_PTR, ...) \
do { \
if (NULL != (__FUNC_PTR)) { \
(*(__FUNC_PTR))(__VA_ARGS__); \
} \
} while(0)
#endif
#define __ARM_CONNECT2(__A, __B) __A##__B
#define __ARM_CONNECT2_ALT(__A, __B) __A##__B
#define __ARM_CONNECT3(__A, __B, __C) __A##__B##__C
#define __ARM_CONNECT4(__A, __B, __C, __D) __A##__B##__C##__D
#define __ARM_CONNECT5(__A, __B, __C, __D, __E) __A##__B##__C##__D##__E
@ -188,6 +241,7 @@ extern "C" {
__A##__B##__C##__D##__E##__F##__G##__H##__I
#define ARM_CONNECT2(__A, __B) __ARM_CONNECT2(__A, __B)
#define ARM_CONNECT2_ALT(__A, __B) __ARM_CONNECT2_ALT(__A, __B)
#define ARM_CONNECT3(__A, __B, __C) __ARM_CONNECT3(__A, __B, __C)
#define ARM_CONNECT4(__A, __B, __C, __D) __ARM_CONNECT4(__A, __B, __C, __D)
#define ARM_CONNECT5(__A, __B, __C, __D, __E) \
@ -202,7 +256,8 @@ extern "C" {
__ARM_CONNECT9(__A, __B, __C, __D, __E, __F, __G, __H, __I)
#define arm_connect(...) \
ARM_CONNECT2(ARM_CONNECT, __ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
ARM_CONNECT2_ALT(ARM_CONNECT, __ARM_VA_NUM_ARGS(__VA_ARGS__)) \
(__VA_ARGS__)
#define ARM_CONNECT(...) arm_connect(__VA_ARGS__)
@ -281,13 +336,13 @@ extern "C" {
#ifndef ARM_NOINIT
# if defined(__IS_COMPILER_ARM_COMPILER_5__)
# define ARM_NOINIT __attribute__(( section( ".bss.noinit"),zero_init))
# define ARM_NOINIT __attribute__(( section( ".bss.noinit"),zero_init))
# elif defined(__IS_COMPILER_ARM_COMPILER_6__)
# define ARM_NOINIT __attribute__(( section( ".bss.noinit")))
# define ARM_NOINIT __attribute__(( section( ".bss.noinit")))
# elif defined(__IS_COMPILER_IAR__)
# define ARM_NOINIT __no_init
# define ARM_NOINIT __no_init
# elif defined(__IS_COMPILER_GCC__) || defined(__IS_COMPILER_LLVM__)
# define ARM_NOINIT __attribute__(( section( ".bss.noinit")))
# define ARM_NOINIT __attribute__(( section( ".bss.noinit")))
# else
# define ARM_NOINIT
# endif
@ -305,30 +360,60 @@ extern "C" {
#endif
#ifndef __OVERRIDE_WEAK
# define __OVERRIDE_WEAK __USED
# define __OVERRIDE_WEAK
#endif
/*!
* \brief A macro to generate a safe name, usually used in macro template as the
* name of local variables
*
*/
#define ARM_2D_SAFE_NAME(...) ARM_CONNECT(__,__LINE__,##__VA_ARGS__)
#define arm_2d_safe_name(...) ARM_2D_SAFE_NAME(__VA_ARGS__)
#undef arm_irq_safe
/*!
* \brief a decoration to make the immediate following code irq-safe
*
* \code
arm_irq_safe {
// code inside the brackets are IRQ safe
...
}
// the printf is IRQ safe
arm_irq_safe printf("IRQ safe printf\n");
\endcode
*/
#define arm_irq_safe \
arm_using( uint32_t ARM_2D_SAFE_NAME(temp) = \
({uint32_t temp=__get_PRIMASK();__disable_irq();temp;}),\
__set_PRIMASK(ARM_2D_SAFE_NAME(temp)))
#undef ARM_2D_WRAP_FUNC
#undef __ARM_2D_WRAP_FUNC
#undef ARM_2D_ORIG_FUNC
#undef __ARM_2D_ORIG_FUNC
#if defined(__IS_COMPILER_ARM_COMPILER_6__)
# define __ARM_2D_WRAP_FUNC(__FUNC) $Sub$$##__FUNC
# define __ARM_2D_ORIG_FUNC(__FUNC) $Super$$## __FUNC
#else
# define __ARM_2D_WRAP_FUNC(x) __wrap_ ## x
# define __ARM_2D_ORIG_FUNC(x) __real_ ## x
#endif
#define ARM_2D_WRAP_FUNC(__FUNC) __ARM_2D_WRAP_FUNC(__FUNC)
#define ARM_2D_ORIG_FUNC(__FUNC) __ARM_2D_ORIG_FUNC(__FUNC)
/*----------------------------------------------------------------------------*
* List Operations *
*----------------------------------------------------------------------------*/
/*! \note ALL the parameters passed to following macros must be pointer
*! variables.
*/
/* ALL the parameters passed to following macros must be pointer variables. */
#define __ARM_LIST_STACK_PUSH(__P_TOP, __P_NODE) \
do { \
@ -352,7 +437,8 @@ extern "C" {
((__arm_slist_node_t *)(__P_NODE))->ptNext = NULL; \
} \
} while(0)
#define ARM_LIST_STACK_POP(__P_TOP, __P_NODE) __ARM_LIST_STACK_POP((__P_TOP), (__P_NODE))
#define ARM_LIST_STACK_POP(__P_TOP, __P_NODE) \
__ARM_LIST_STACK_POP((__P_TOP), (__P_NODE))
#define ARM_LIST_REMOVE_AFTER(__P_TARGET, __P_NODE) \
ARM_LIST_STACK_POP((__P_TARGET), (__P_NODE))
@ -362,18 +448,17 @@ extern "C" {
if (NULL == (__TAIL)) { \
(*((__arm_slist_node_t **)&(__TAIL))) = \
(__arm_slist_node_t *)(__ITEM); \
((__arm_slist_node_t *)(__ITEM))->ptNext = NULL; \
(*((__arm_slist_node_t **)&(__HEAD))) = \
(__arm_slist_node_t *)(__ITEM); \
} else { \
((__arm_slist_node_t *)(__TAIL))->ptNext = \
(__arm_slist_node_t *)(__ITEM); \
((__arm_slist_node_t *)(__ITEM))->ptNext = NULL; \
(*(__arm_slist_node_t **)&(__TAIL)) = \
(__arm_slist_node_t *)(__ITEM); \
} \
((__arm_slist_node_t *)(__ITEM))->ptNext = NULL; \
} while(0)
#define ARM_LIST_QUEUE_ENQUEUE(__HEAD, __TAIL, __ITEM) \
#define ARM_LIST_QUEUE_ENQUEUE(__HEAD, __TAIL, __ITEM) \
__ARM_LIST_QUEUE_ENQUEUE((__HEAD), (__TAIL), (__ITEM))
#define __ARM_LIST_QUEUE_DEQUEUE(__HEAD, __TAIL, __ITEM) \
@ -416,9 +501,15 @@ const __arm_2d_low_level_io_t LOW_LEVEL_IO##__NAME = {
/*============================ TYPES =========================================*/
/*!
* \brief a type for generic list
*
* \note to avoid using container_of() operand, please put __arm_slist_node_t
* at the beginning of a class/structure
*/
typedef struct __arm_slist_node_t __arm_slist_node_t;
struct __arm_slist_node_t {
__arm_slist_node_t *ptNext;
__arm_slist_node_t *ptNext; //!< the next node
};
@ -439,6 +530,8 @@ struct __arm_slist_node_t {
#endif /* end of __ARM_2D_UTILS_H__ */
/*! @} */
/*============================ MACROS ========================================*/
/*----------------------------------------------------------------------------*
* Reentrant Macros *
@ -449,8 +542,13 @@ struct __arm_slist_node_t {
/* redefine macros */
#if defined(__cplusplus)
# define ARM_PRIVATE(...) \
struct { \
__VA_ARGS__ \
};
#if defined(__ARM_2D_IMPL__) || defined(__IS_COMPILER_IAR__)
#elif defined(__ARM_2D_IMPL__) || defined(__IS_COMPILER_IAR__)
# define ARM_PRIVATE(...) \
struct { \

View File

@ -52,12 +52,17 @@ void __ARM_2D_FUNC(alpha_blending) (__API_INT_TYPE *__RESTRICT pSourceBase,
__API_INT_TYPE *__RESTRICT pTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize,
uint_fast8_t chRatio)
uint_fast16_t hwRatio)
{
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
uint16_t hwRatioCompl = 256 - chRatio;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
uint16_t hwRatioCompl = 256 - hwRatio;
for (int_fast16_t y = 0; y < iHeight; y++) {
for (int_fast16_t x = 0; x < iWidth; x++) {
@ -76,7 +81,7 @@ void __ARM_2D_FUNC(alpha_blending) (__API_INT_TYPE *__RESTRICT pSourceBase,
__API_INT_TYPE *__RESTRICT pTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize,
uint_fast8_t chRatio);
uint_fast16_t hwRatio);
#endif
@ -89,13 +94,18 @@ void __ARM_2D_FUNC(alpha_blending_colour_keying)(
__API_INT_TYPE * __RESTRICT pTargetBase,
int16_t iTargetStride,
arm_2d_size_t * __RESTRICT ptCopySize,
uint_fast8_t chRatio,
uint_fast16_t hwRatio,
__API_INT_TYPE Colour)
{
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
uint16_t hwRatioCompl = 256 - chRatio;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
uint16_t hwRatioCompl = 256 - hwRatio;
for (int_fast16_t y = 0; y < iHeight; y++) {
for (int_fast16_t x = 0; x < iWidth; x++) {
@ -118,7 +128,7 @@ void __ARM_2D_FUNC(alpha_blending_colour_keying)(
__API_INT_TYPE * __RESTRICT pTargetBase,
int16_t iTargetStride,
arm_2d_size_t * __RESTRICT ptCopySize,
uint_fast8_t chRatio,
uint_fast16_t hwRatio,
__API_INT_TYPE Colour);
#endif
@ -129,11 +139,16 @@ void __ARM_2D_FUNC(colour_filling_with_opacity)(
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint_fast8_t chRatio)
uint_fast16_t hwRatio)
{
uint16_t hwRatioCompl = 256 - chRatio;
int_fast16_t iWidth = ptCopySize->iWidth;
int_fast16_t iHeight = ptCopySize->iHeight;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
uint16_t hwRatioCompl = 256 - hwRatio;
for (int_fast16_t y = 0; y < iHeight; y++) {
@ -151,7 +166,7 @@ void __ARM_2D_FUNC(colour_filling_with_opacity)(
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint_fast8_t chRatio);
uint_fast16_t hwRatio);
#endif
#ifndef __PATCH_COLOUR_FILLING_ALPHA_MASK
@ -171,6 +186,9 @@ void __ARM_2D_FUNC(colour_filling_mask)(
for (int_fast16_t x = 0; x < iWidth; x++) {
uint16_t hwAlpha = 256 - (*pchAlpha++);
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwAlpha -= (hwAlpha == 1);
#endif
__API_PIXEL_BLENDING(&Colour, pTarget++, hwAlpha);
}
@ -200,15 +218,21 @@ void __ARM_2D_FUNC(colour_filling_mask_opacity)(
int16_t iAlphaStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint8_t chOpacity)
uint_fast16_t hwOpacity)
{
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
for (int_fast16_t y = 0; y < iHeight; y++) {
for (int_fast16_t x = 0; x < iWidth; x++) {
uint16_t hwAlpha = 256 - ((*pchAlpha++) * chOpacity >> 8);
uint16_t hwAlpha = 256 - ((*pchAlpha++) * hwOpacity >> 8);
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwAlpha -= (hwAlpha == 2) * 2;
#endif
__API_PIXEL_BLENDING(&Colour, pTarget++, hwAlpha);
}
@ -225,7 +249,7 @@ void __ARM_2D_FUNC(colour_filling_mask_opacity)(
int16_t iAlphaStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint8_t chOpacity);
uint_fast16_t hwOpacity);
#endif
@ -247,6 +271,11 @@ void __ARM_2D_FUNC(colour_filling_channel_mask)(
for (int_fast16_t x = 0; x < iWidth; x++) {
uint16_t hwAlpha = 256 - *(uint8_t *)(pwAlpha++);
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwAlpha -= (hwAlpha == 1);
#endif
__API_PIXEL_BLENDING(&Colour, pTarget++, hwAlpha);
}
@ -275,7 +304,7 @@ void __ARM_2D_FUNC(colour_filling_channel_mask_opacity)(
int16_t iAlphaStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint8_t chOpacity)
uint_fast16_t hwOpacity)
{
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
@ -283,7 +312,12 @@ void __ARM_2D_FUNC(colour_filling_channel_mask_opacity)(
for (int_fast16_t y = 0; y < iHeight; y++) {
for (int_fast16_t x = 0; x < iWidth; x++) {
uint16_t hwAlpha = 256 - (*(uint8_t *)(pwAlpha++) * chOpacity >> 8);
uint16_t hwAlpha = 256 - (*(uint8_t *)(pwAlpha++) * hwOpacity >> 8);
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwAlpha -= (hwAlpha == 2) * 2;
#endif
__API_PIXEL_BLENDING(&Colour, pTarget++, hwAlpha);
}
@ -300,7 +334,7 @@ void __ARM_2D_FUNC(colour_filling_channel_mask_opacity)(
int16_t iAlphaStride,
arm_2d_size_t *__RESTRICT ptCopySize,
__API_INT_TYPE Colour,
uint8_t chOpacity);
uint_fast16_t hwOpacity);
#endif

View File

@ -21,8 +21,8 @@
* Title: __arm_2d_alpha_mask.inc
* Description: c code template for copy and fill like operations
*
* $Date: 30. Sept 2021
* $Revision: V.1.0.0
* $Date: 25. March 2022
* $Revision: V.1.0.1
*
* -------------------------------------------------------------------- */
@ -382,6 +382,11 @@ void __CAFWM_FUNC(des_msk_fill)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity);
}
@ -462,6 +467,11 @@ void __CAFWM_FUNC(des_msk_fill_x_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity);
}
@ -543,6 +553,11 @@ void __CAFWM_FUNC(des_msk_fill_y_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity);
}
@ -624,6 +639,11 @@ void __CAFWM_FUNC(des_msk_fill_xy_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity);
}
@ -757,6 +777,11 @@ void __CAFWM_FUNC(src_msk_fill)(
#else
uint16_t hwOpacity = 256 - (*ptSrcMsk++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity);
}
@ -849,6 +874,11 @@ void __CAFWM_FUNC(src_msk_fill_x_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptSrcMsk--);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity);
}
@ -943,6 +973,11 @@ void __CAFWM_FUNC(src_msk_fill_y_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptSrcMsk++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity);
}
@ -1041,6 +1076,11 @@ void __CAFWM_FUNC(src_msk_fill_xy_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptSrcMsk--);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity);
}
@ -1163,6 +1203,11 @@ void __CAFWM_FUNC(des_msk_copy)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( pSourceBase++, pTargetBase++, hwOpacity);
}
@ -1220,6 +1265,11 @@ void __CAFWM_FUNC(des_msk_copy_x_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity);
}
@ -1273,6 +1323,11 @@ void __CAFWM_FUNC(des_msk_copy_y_mirror)(
#else
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur++, pTargetBase++, hwOpacity);
}
@ -1330,6 +1385,10 @@ void __CAFWM_FUNC(des_msk_copy_xy_mirror)(
uint16_t hwOpacity = 256 - (*ptTargetMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity);
}
@ -1436,6 +1495,11 @@ void __CAFWM_FUNC(src_msk_copy)(
#else
uint16_t hwOpacity = 256 - (*ptSourceMask++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( pSourceBase++, pTargetBase++, hwOpacity);
}
@ -1510,6 +1574,11 @@ void __CAFWM_FUNC(src_msk_copy_x_mirror)(
#else
uint16_t hwOpacity = 256 - (*pchSourceMaskCur--);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur--, ptTargetCur++, hwOpacity);
}
@ -1585,6 +1654,11 @@ void __CAFWM_FUNC(src_msk_copy_y_mirror)(
#else
uint16_t hwOpacity = 256 - (*pchSourceMaskCur++);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur++, pTargetBase++, hwOpacity);
}
@ -1665,6 +1739,10 @@ void __CAFWM_FUNC(src_msk_copy_xy_mirror)(
uint16_t hwOpacity = 256 - (*pchSourceMaskCur--);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwOpacity -= (hwOpacity == 1);
#endif
__API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,702 @@
/*
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: __arm-2d_conversion_helium.c
* Description: APIs for colour format conversion with Helium acceleration
*
* $Date: 08. Aug 2022
* $Revision: V.0.2.0
*
* Target Processor: Cortex-M cores with Helium
*
* -------------------------------------------------------------------- */
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#ifdef __ARM_2D_COMPILATION_UNIT
#undef __ARM_2D_COMPILATION_UNIT
#if defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
# pragma clang diagnostic ignored "-Wcast-qual"
# pragma clang diagnostic ignored "-Wcast-align"
# pragma clang diagnostic ignored "-Wextra-semi-stmt"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
# pragma clang diagnostic ignored "-Wdouble-promotion"
# pragma clang diagnostic ignored "-Wunused-parameter"
# pragma clang diagnostic ignored "-Wimplicit-float-conversion"
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
# pragma clang diagnostic ignored "-Wtautological-pointer-compare"
# pragma clang diagnostic ignored "-Wmissing-prototypes"
# pragma clang diagnostic ignored "-Wsign-compare"
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wvector-conversion"
# pragma clang diagnostic ignored "-Wundef"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#endif
/*============================ INCLUDES ======================================*/
#include "__arm_2d_utils_helium.h"
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/
__OVERRIDE_WEAK
void __MVE_WRAPPER( __arm_2d_impl_cccn888_to_rgb565)(uint32_t *__RESTRICT pwSourceBase,
int16_t iSourceStride,
uint16_t *__RESTRICT phwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
int32_t blkCnt;
uint32x4_t maskR = vdupq_n_u32(0x001f);
uint32x4_t maskG = vdupq_n_u32(0x07e0);
uint32x4_t maskB = vdupq_n_u32(0xf800);
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint32_t *pSource = pwSourceBase;
uint16_t *pTarget = phwTargetBase;
blkCnt = ptCopySize->iWidth;
#ifdef USE_MVE_INTRINSICS
do {
mve_pred16_t tailPred = vctp32q(blkCnt);
/* load a vector of 4 cccn888 pixels */
uint32x4_t vecIn = vld1q_z(pSource, tailPred);
/* extract individual channels and place them according */
/* to their relative position inside rgb565 */
uint32x4_t vecR = (vecIn >> 3) & maskR;
uint32x4_t vecG = (vecIn >> 5) & maskG;
uint32x4_t vecB = (vecIn >> 8) & maskB;
/* merge */
uint32x4_t vOut = vecR | vecG | vecB;
/* store a vector of 4 rgb565 pixels */
vstrhq_p_u32(pTarget, vOut, tailPred);
pSource += 4;
pTarget += 4;
blkCnt -= 4;
}
while (blkCnt > 0);
#else
/* constants allowing to replace right shifts with fixed-point multiplications */
/* enabling more beat overlap oportunities and reduce stalls */
const int32_t inv_2pow3 = 1 << (31-3); /*1/2^3 in Q.31 */
const int32_t inv_2pow5 = 1 << (31-5); /*1/2^5 in Q.31 */
const int32_t inv_2pow8 = 1 << (31-8); /*1/2^8 in Q.31 */
__asm volatile(
" wlstp.32 lr, %[loopCnt], 1f \n"
/* precompute for allowing filling stalls in the inner loop */
/* use vqdmulh to replace shifts to allow overlap with 'AND' */
/* load a vector of 4 cccn888 pixels */
" vldrw.u32 q0, [%[pSource]], #16 \n"
/* mimic right shift by 3 */
" vqdmulh.s32 q1, q0, %[inv_2pow3] \n"
".p2align 2 \n"
"2: \n"
" vand q1, q1, %[maskR] \n"
/* mimic right shift by 5 */
" vqdmulh.s32 q2, q0, %[inv_2pow5] \n"
" vand q2, q2, %[maskG] \n"
/* mimic right shift by 8 */
" vqdmulh.s32 q3, q0, %[inv_2pow8] \n"
/* accumulate R & G */
" vorr q2, q1, q2 \n"
/* load next vector of 4 cccn888 pixels */
" vldrw.u32 q0, [%[pSource]], #16 \n"
" vand q3, q3, %[maskB] \n"
/* mimic right shift by 3 */
" vqdmulh.s32 q1, q0, %[inv_2pow3] \n"
/* accumulate B */
" vorr q2, q2, q3 \n"
/* store a vector of 4 rgb565 pixels */
" vstrh.32 q2, [%[pTarget]], #8 \n"
" letp lr, 2b \n"
"1: \n"
: [pSource] "+r"(pSource), [pTarget] "+r" (pTarget)
: [loopCnt] "r"(blkCnt), [inv_2pow3] "r" (inv_2pow3),
[inv_2pow5] "r" (inv_2pow5), [inv_2pow8] "r" (inv_2pow8),
[maskR] "t" (maskR),[maskG] "t" (maskG),[maskB] "t" (maskB)
: "q0", "q1", "q2", "q3", "memory", "r14" );
#endif
pwSourceBase += iSourceStride;
phwTargetBase += iTargetStride;
}
}
__OVERRIDE_WEAK
void __MVE_WRAPPER( __arm_2d_impl_rgb565_to_cccn888)(uint16_t *__RESTRICT phwSourceBase,
int16_t iSourceStride,
uint32_t *__RESTRICT pwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
int32_t blkCnt;
uint32x4_t maskRB = vdupq_n_u32(0xf8);
uint32x4_t maskG = vdupq_n_u32(0xfc00);
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint16_t *__RESTRICT phwSource = phwSourceBase;
uint32_t *__RESTRICT pwTarget = pwTargetBase;
blkCnt = ptCopySize->iWidth;
#ifdef USE_MVE_INTRINSICS
do {
mve_pred16_t tailPred = vctp32q(blkCnt);
/* load a vector of 4 rgb565 pixels */
uint32x4_t vecIn = vldrhq_z_u32(phwSource, tailPred);
/* extract individual channels and place them according position */
uint32x4_t vecR = (vecIn << 3) & maskRB;
uint32x4_t vecG = (vecIn << 5) & maskG;
uint32x4_t vecB = ((vecIn >> 8) & maskRB) << 16;
/* merge and set n channel to 0xff */
uint32x4_t vOut = 0xff000000 | vecR | vecG | vecB;
/* store a vector of 4 cccn888 pixels */
vst1q_p(pwTarget, vOut, tailPred);
phwSource += 4;
pwTarget += 4;
blkCnt -= 4;
}
while (blkCnt > 0);
#else
__asm volatile(
" wlstp.32 lr, %[loopCnt], 1f \n"
/* preload & precompute for allowing filling stalls in the inner loop */
/* use vqdmulh & vmul to replace shifts to allow overlap with 'AND' */
/* load a vector of 4 rgb565 pixels */
" vldrh.u32 q0, [%[pSource]], #8 \n"
/* mimic left shift by 3 */
" vmul.u32 q1, q0, %[two_pow3] \n"
".p2align 2 \n"
"2: \n"
/* mimic left shift by 5 */
" vmul.u32 q2, q0, %[two_pow5] \n"
" vand q1, q1, %[maskRB] \n"
/* mimic right shift by 8 */
" vqdmulh.s32 q3, q0, %[inv_2pow8] \n"
" vand q2, q2, %[maskG] \n"
/* accumulate G & R, use vmla instead of vorr for best overlap */
" vmla.u32 q2, q1, %[one] \n"
" vand q3, q3, %[maskRB] \n"
/* accumulate B + left shift by 16 */
" vmla.u32 q2, q3, %[two_pow16] \n"
/* load next vector of 4 rgb565 pixels */
" vldrh.u32 q0, [%[pSource]], #8 \n"
/* merge and set n channel to 0xff */
" vorr.i32 q2, #0xff000000 \n"
/* mimic left shift by 3 */
" vmul.u32 q1, q0, %[two_pow3] \n"
/* store a vector of 4 cccn888 pixels */
" vstrw.32 q2, [%[pTarget]], #16 \n"
" letp lr, 2b \n"
"1: \n"
: [pSource] "+r"(phwSource), [pTarget] "+r" (pwTarget)
: [loopCnt] "r"(blkCnt),[two_pow3] "r" (1<<3), [two_pow5] "r" (1<<5),
[two_pow16] "r" (1<<16),[inv_2pow8] "r" (1 << (31-8)),
[maskRB] "t" (maskRB),[maskG] "t" (maskG), [one] "r" (1)
: "q0", "q1", "q2", "q3", "memory", "r14" );
#endif
phwSourceBase += iSourceStride;
pwTargetBase += iTargetStride;
}
}
__OVERRIDE_WEAK
void __MVE_WRAPPER(__arm_2d_impl_cccn888_to_gray8)(uint32_t *__RESTRICT pwSourceBase,
int16_t iSourceStride,
uint8_t *__RESTRICT pchTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
int32_t blkCnt;
#define ONE_THIRD_Q8 85
#ifdef USE_MVE_INTRINSICS
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint32_t *pSource = pwSourceBase;
uint8_t *pTarget = pchTargetBase;
blkCnt = ptCopySize->iWidth;
uint8x16_t vone_third = vdupq_n_u8(ONE_THIRD_Q8);
do {
mve_pred16_t tailPred = vctp8q(blkCnt);
/* load and de-interleave channels from 16 cccn888 pixels */
uint8x16x4_t vecIn = vld4q_u8((const uint8_t *) pSource);
/* Average R,G,B chans : scale by 1/3 and sum */
vecIn.val[0] = vrmulhq(vecIn.val[0], vone_third);
vecIn.val[0] = vecIn.val[0] + vrmulhq(vecIn.val[1], vone_third);
vecIn.val[0] = vecIn.val[0] + vrmulhq(vecIn.val[2], vone_third);
/* store a vector of 16 gray8 pixels */
vstrbq_p_u8(pTarget, vecIn.val[0], tailPred);
pSource += 16;
pTarget += 16;
blkCnt -= 16;
}
while (blkCnt > 0);
pwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
#else
if (ptCopySize->iWidth >= 32) {
/* use unrolled core loop for image with larger widths */
/* because of helium sequence optimization opportunities */
/* residual size < 32 */
int tailCnt = ptCopySize->iWidth & 0x1f;
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint32_t *pSource = pwSourceBase;
uint8_t *pTarget = pchTargetBase;
blkCnt = ptCopySize->iWidth;
/* de-interleave RGBA channels */
/* Core is unrolled to enable overlap between load and scale/accumulate operations */
/* handles block of 32-pixels line */
__asm volatile(
" vld40.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld41.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld42.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld43.8 {q0, q1, q2, q3}, [%[pSource]]! \n"
".p2align 2 \n"
" wls lr, %[loopCnt], 1f \n"
"2: \n"
/* overwrite unused Alpha channel */
" vmov.i8 q3, %[one_third] \n"
/* de-interleave next 16 pixels block */
/* load operations interleaved with scale of previously loaded channels */
" vld40.8 {q4, q5, q6, q7}, [%[pSource]] \n"
" vrmulh.u8 q0, q0, q3 \n"
" vld41.8 {q4, q5, q6, q7}, [%[pSource]] \n"
" vrmulh.u8 q1, q1, q3 \n"
" vld42.8 {q4, q5, q6, q7}, [%[pSource]] \n"
" vadd.i8 q0, q0, q1 \n"
" vrmulh.u8 q2, q2, q3 \n"
" vld43.8 {q4, q5, q6, q7}, [%[pSource]]! \n"
" vadd.i8 q0, q0, q2 \n"
/* store 16 Gray8 pixels */
" vstrb.8 q0, [%[pTarget]], #16 \n"
" vmov.i8 q7, %[one_third] \n"
" vrmulh.u8 q4, q4, q7 \n"
/* de-interleave next 16 pixels block */
" vld40.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vrmulh.u8 q5, q5, q7 \n"
" vld41.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vadd.i8 q4, q4, q5 \n"
" vld42.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vrmulh.u8 q6, q6, q7 \n"
" vld43.8 {q0, q1, q2, q3}, [%[pSource]]! \n"
" vadd.i8 q4, q4, q6 \n"
/* store 16 Gray8 pixels */
" vstrb.8 q4, [%[pTarget]], #16 \n"
" le lr, 2b \n"
"1: \n"
/* tail handling for [0-31] pixels residual */
/* 1/3 vector constant is in q7 and q0-q3 are already loaded */
" wlstp.8 lr, %[tailCnt], 1f \n"
"2: \n"
" vrmulh.u8 q0, q0, q7 \n"
" vrmulh.u8 q1, q1, q7 \n"
" vrmulh.u8 q2, q2, q7 \n"
" vadd.i8 q0, q0, q1 \n"
" vadd.i8 q0, q0, q2 \n"
" vstrb.8 q0, [%[pTarget]], #16 \n"
" vld40.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld41.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld42.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld43.8 {q0, q1, q2, q3}, [%[pSource]]! \n"
" letp lr, 2b \n"
"1: \n"
:[pSource] "+r"(pSource),[pTarget] "+r"(pTarget)
:[loopCnt] "r" (blkCnt / 32),[one_third] "i"(ONE_THIRD_Q8),
[tailCnt] "r"(tailCnt)
:"q0", "q1", "q2", "q3",
"q4", "q5", "q6", "q7",
"memory", "r14");
pwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
} else {
/* iWidth lower than 32 */
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint32_t *pSource = pwSourceBase;
uint8_t *pTarget = pchTargetBase;
blkCnt = ptCopySize->iWidth;
__asm volatile(
" vmov.i8 q4, %[one_third] \n"
".p2align 2 \n"
" wlstp.8 lr, %[loopCnt], 1f \n"
"2: \n"
/* de-interleave RGBA channels */
" vld40.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld41.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld42.8 {q0, q1, q2, q3}, [%[pSource]] \n"
" vld43.8 {q0, q1, q2, q3}, [%[pSource]]! \n"
/* scale and sum R,G,B chan */
" vrmulh.u8 q0, q0, q4 \n"
" vrmulh.u8 q1, q1, q4 \n"
" vrmulh.u8 q2, q2, q4 \n"
" vadd.i8 q0, q0, q1 \n"
" vadd.i8 q0, q0, q2 \n"
/* store 16 Gray8 pixels */
" vstrb.8 q0, [%[pTarget]], #16 \n"
" letp lr, 2b \n"
"1: \n"
:[pSource] "+r"(pSource),[pTarget] "+r"(pTarget)
:[loopCnt] "r" (blkCnt),[one_third] "i"(ONE_THIRD_Q8)
:"q0", "q1", "q2", "q3",
"q4", "memory", "r14");
pwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
}
#endif
}
__OVERRIDE_WEAK
void __MVE_WRAPPER(__arm_2d_impl_rgb565_to_gray8)( uint16_t *__RESTRICT phwSourceBase,
int16_t iSourceStride,
uint8_t *__RESTRICT pchTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
#define ONE_THIRD_Q16 21845
uint16x8_t vone_third = vdupq_n_u16(ONE_THIRD_Q16);
int32_t blkCnt;
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint16_t *__RESTRICT phwSource = phwSourceBase;
uint8_t *__RESTRICT pTarget = pchTargetBase;
blkCnt = ptCopySize->iWidth;
#ifdef USE_MVE_INTRINSICS
do {
mve_pred16_t tailPred = vctp16q(blkCnt);
uint16x8_t R, G, B, vecGray8;
/* load a vector of 8 rgb565 pixels */
uint16x8_t vecIn = vld1q_z_u16(phwSource, tailPred);
__arm_2d_rgb565_unpack_single_vec(vecIn, &R, &G, &B);
/* sum R,G,B contributions */
vecGray8 = R + G + B;
/* average */
vecGray8 = vrmulhq(vecGray8, vone_third);
/* store a vector of 8 x gray8 pixels */
vstrbq_p_u16(pTarget, vecGray8, tailPred);
phwSource += 8;
pTarget += 8;
blkCnt -= 8;
}
while (blkCnt > 0);
#else
uint16x8_t vecMaskR = vdupq_n_u16(0x001f);
uint16x8_t vecMaskG = vdupq_n_u16(0x003f);
__asm volatile(
/* preload pixel vector + mask R allowing more efficient pipelining */
" vldrh.u16 q0, [%[pSource]], #16 \n"
/* R ch */
" vand q1, q0, %[maskR] \n"
".p2align 2 \n"
" wlstp.16 lr, %[loopCnt], 1f \n"
"2: \n"
/* G ch */
" vshr.u16 q3, q0, #5 \n"
/* use vmul to replace left shift and allow overlap with vshr */
" vmul.u16 q1, q1, %[two_pow3] \n"
/* B ch */
" vshr.u16 q2, q0, #11 \n"
" vmul.u16 q2, q2, %[two_pow3] \n"
" vand q0, q3, %[maskG] \n"
/* summing */
" vmla.u16 q2, q0, %[four] \n"
" vadd.i16 q2, q1, q2 \n"
/* load next RGB565 pixel vector */
" vldrh.u16 q0, [%[pSource]], #16 \n"
/* averaging */
" vrmulh.u16 q2, q2, %[vone_third] \n"
/* R */
" vand q1, q0, %[maskR] \n"
/* store 8 Gray8 pixels */
" vstrb.16 q2, [%[pTarget]], #8 \n"
" letp lr, 2b \n"
"1: \n"
: [pSource] "+r"(phwSource), [pTarget] "+r" (pTarget)
: [loopCnt] "r"(blkCnt),[two_pow3] "r" (1<<3),
[four] "r" (4),
[maskR] "t" (vecMaskR),[maskG] "t" (vecMaskG),
[vone_third] "t" (vone_third)
: "q0", "q1", "q2", "q3", "memory", "r14" );
#endif
phwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
}
__OVERRIDE_WEAK
void __MVE_WRAPPER(__arm_2d_impl_gray8_to_rgb565)( uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint16_t *__RESTRICT phwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
int32_t blkCnt;
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint8_t *__RESTRICT pchSource = pchSourceBase;
uint16_t *__RESTRICT pTarget = phwTargetBase;
blkCnt = ptCopySize->iWidth;
#ifdef USE_MVE_INTRINSICS
do {
mve_pred16_t tailPred = vctp16q(blkCnt);
uint16x8_t vecRgb565;
/* load a vector of 8 gray pixels */
uint16x8_t vecGray8 = vldrbq_z_u16(pchSource, tailPred);
/* replication in all RGB565 components */
vecRgb565 =__arm_2d_rgb565_pack_single_vec(vecGray8, vecGray8, vecGray8);
/* store a vector of 8 x RGB565 pixels */
vst1q_p(pTarget, vecRgb565, tailPred);
pchSource += 8;
pTarget += 8;
blkCnt -= 8;
}
while (blkCnt > 0);
#else
uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8);
uint16x8_t vecMaskGpck = vdupq_n_u16(0x00fc);
__asm volatile(
".p2align 2 \n"
/* preload pixel vector + mask G allowing more efficient pipelining */
" vldrb.u16 q0, [%[pSource]], #8 \n"
/* G ch */
" vand q2, q0, %[maskG] \n"
" wlstp.16 lr, %[loopCnt], 1f \n"
"2: \n"
/* R ch */
" vshr.u16 q1, q0, #3 \n"
/* use VMLA to mimick left shift combined with OR */
" vmla.u16 q1, q2, %[eight] \n"
/* B ch */
" vand q2, q0, %[maskB] \n"
" vmla.u16 q1, q2, %[twofiftysix] \n"
/* load next Gray pixel vector */
" vldrb.u16 q0, [%[pSource]], #8 \n"
/* G ch */
" vand q2, q0, %[maskG] \n"
/* store 8 RGB565 pixels */
" vstrh.16 q1, [%[pTarget]], #16 \n"
" letp lr, 2b \n"
"1: \n"
: [pSource] "+r"(pchSource), [pTarget] "+r" (pTarget)
: [loopCnt] "r"(blkCnt),[twofiftysix] "r" (256),
[eight] "r" (8),
[maskG] "t" (vecMaskGpck),[maskB] "t" (vecMaskBpck)
: "q0", "q1", "q2", "q3", "memory", "r14" );
#endif
pchSourceBase += iSourceStride;
phwTargetBase += iTargetStride;
}
}
__OVERRIDE_WEAK
void __MVE_WRAPPER(__arm_2d_impl_gray8_to_cccn888)(uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint32_t *__RESTRICT pwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
int32_t blkCnt;
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint8_t *__RESTRICT pchSource = pchSourceBase;
uint32_t *__RESTRICT pTarget = pwTargetBase;
blkCnt = ptCopySize->iWidth;
#ifdef USE_MVE_INTRINSICS
do {
mve_pred16_t tailPred = vctp32q(blkCnt);
uint32x4_t vecCcn888;
/* load a vector of 4 gray8 pixels */
uint32x4_t vecGray8 = vldrbq_z_u32(pchSource, tailPred);
/* byte duplication inside 32-bit elements */
/* and set alpha chan to 0xff */
vecCcn888 = (vecGray8 * 0x00010101) | 0xff000000;
/* store a vector of 4 x ccc888 pixels */
vst1q_p(pTarget, vecCcn888, tailPred);
pchSource += 4;
pTarget += 4;
blkCnt -= 4;
}
while (blkCnt > 0);
#else
int tailCnt = ptCopySize->iWidth & 7;
__asm volatile(
".p2align 2 \n"
/* preload pixel vector allowing more efficient pipelining */
" vldrb.u32 q0, [%[pSource]], #4 \n"
" wls lr, %[loopCnt], 1f \n"
"2: \n"
" vmul.i32 q0, q0, %[byte_dup_cst] \n"
" vldrb.u32 q1, [%[pSource]], #4 \n"
" vorr.i32 q0, #0xff000000 \n"
/* store 4 CCN888 Gray8 pixels */
" vstrw.32 q0, [%[pTarget]], #16 \n"
" vmul.i32 q1, q1, %[byte_dup_cst] \n"
" vldrb.u32 q0, [%[pSource]], #4 \n"
" vorr.i32 q1, #0xff000000 \n"
/* store 4 CCN888 Gray8 pixels */
" vstrw.32 q1, [%[pTarget]], #16 \n"
" le lr, 2b \n"
"1: \n"
/* tail handling for [0-7] pixel residual */
/* q0 is already loaded */
" wlstp.32 lr, %[tailCnt], 1f \n"
"2: \n"
" vmul.i32 q0, q0, %[byte_dup_cst] \n"
" vorr.i32 q0, #0xff000000 \n"
/* store 4 CCN888 Gray8 pixels */
" vstrw.32 q0, [%[pTarget]], #16 \n"
" vldrb.u32 q0, [%[pSource]], #4 \n"
" letp lr, 2b \n"
"1: \n"
: [pSource] "+r"(pchSource), [pTarget] "+r" (pTarget)
: [loopCnt] "r"(blkCnt/8),[byte_dup_cst] "r" (0x00010101),
[tailCnt] "r" (tailCnt)
: "q0", "memory", "r14" );
#endif
pchSourceBase += iSourceStride;
pwTargetBase += iTargetStride;
}
}
#ifdef __cplusplus
}
#endif
#endif // __ARM_2D_HAS_HELIUM__
#endif // __ARM_2D_COMPILATION_UNIT

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -21,8 +21,8 @@
* Title: __arm_2d_copy_helium.inc
* Description: c code template for copy like operations
*
* $Date: 21 Sep 2021
* $Revision: V.0.0.2
* $Date: 12 July 2022
* $Revision: v1.0.0
*
* -------------------------------------------------------------------- */
@ -39,7 +39,7 @@
#undef ____ARM_2D_FUNC
#undef ___ARM_2D_FUNC
#undef __ARM_2D_FUNC
#define ____ARM_2D_FUNC(__NAME, __COLOUR) __arm_2d_impl_##__COLOUR##_##__NAME
#define ____ARM_2D_FUNC(__NAME, __COLOUR) __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME)
#define ___ARM_2D_FUNC(__NAME, __COLOUR) ____ARM_2D_FUNC(__NAME, __COLOUR)
#define __ARM_2D_FUNC(__NAME) ___ARM_2D_FUNC(__NAME, __API_COLOUR)

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -22,8 +22,8 @@
* Title: __arm_2d_draw_pattern_helium.inc
* Description: Helium code template for drawing pattern
*
* $Date: 29. sep 2021
* $Revision: V.0.0.3
* $Date: 12. July 2022
* $Revision: V.1.0.0
*
* -------------------------------------------------------------------- */
@ -38,7 +38,8 @@
#undef ____ARM_2D_FUNC
#undef ___ARM_2D_FUNC
#undef __ARM_2D_FUNC
#define ____ARM_2D_FUNC(__NAME, __COLOUR) __arm_2d_impl_##__COLOUR##_##__NAME
#define ____ARM_2D_FUNC(__NAME, __COLOUR) \
__MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME)
#define ___ARM_2D_FUNC(__NAME, __COLOUR) ____ARM_2D_FUNC(__NAME, __COLOUR)
#define __ARM_2D_FUNC(__NAME) ___ARM_2D_FUNC(__NAME, __API_COLOUR)
@ -96,7 +97,7 @@ void __ARM_2D_FUNC(draw_pattern_fg_only)(uint8_t *__RESTRICT pchSourceBase,
" q0, [%[src], %[offS]] \n"
" vand q0, q0, %[bitmask] \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
/* contigous vector load */
ARM_VLD1_ASM(__API_ELT_SZ) \
@ -114,7 +115,7 @@ void __ARM_2D_FUNC(draw_pattern_fg_only)(uint8_t *__RESTRICT pchSourceBase,
" le lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBase), [target] "+r" (pTargetBase)
: [src] "+l"(pchSourceBase), [target] "+r" (pTargetBase)
: [bitmask] "t" (vBitMask),[ForeG] "t"(vForeG),
[srcStride] "r" (iSourceStride >> 3),
[targStride] "r" (iTargetStride * (__API_ELT_SZ/8)),
@ -149,7 +150,7 @@ void __ARM_2D_FUNC(draw_pattern_fg_only)(uint8_t *__RESTRICT pchSourceBase,
__asm volatile(
".p2align 2 \n"
" wlstp."TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
" wlstp."ARM_TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
"2: \n"
/* widened vector load */
ARM_VLDWID_ASM(8,__API_ELT_SZ) \
@ -158,7 +159,7 @@ void __ARM_2D_FUNC(draw_pattern_fg_only)(uint8_t *__RESTRICT pchSourceBase,
" vand q0, q0, %[bitmask] \n"
" add %[src], %[src], %[incrSrc] \n"
" vpt.i" TO_STRING(__API_ELT_SZ) \
" vpt.i" ARM_TO_STRING(__API_ELT_SZ) \
" ne, q0, zr \n"
/* predicated contigous vector store */
@ -168,7 +169,7 @@ void __ARM_2D_FUNC(draw_pattern_fg_only)(uint8_t *__RESTRICT pchSourceBase,
" letp lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [src] "+l"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [bitmask] "t" (vBitMask),[ForeG] "t"(vForeG),
[cnt] "r" (cnt), [incrSrc] "i" (ARM_PIX_VECELT(__API_ELT_SZ) / 8),
[offS] "t" (offS)
@ -234,7 +235,7 @@ void __ARM_2D_FUNC(draw_pattern_no_bg_comp)(
ARM_VLD1_ASM(__API_ELT_SZ) \
" q1, [%[target]] \n"
" vpt.i" TO_STRING(__API_ELT_SZ) \
" vpt.i" ARM_TO_STRING(__API_ELT_SZ) \
" ne, q0, zr \n"
" vmvnt q1, q1 \n"
@ -250,7 +251,7 @@ void __ARM_2D_FUNC(draw_pattern_no_bg_comp)(
" le lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBase), [target] "+r" (pTargetBase)
: [src] "+l"(pchSourceBase), [target] "+r" (pTargetBase)
: [bitmask] "t" (vBitMask),
[srcStride] "r" (iSourceStride >> 3),
[targStride] "r" (iTargetStride*(__API_ELT_SZ/8)),
@ -287,7 +288,7 @@ void __ARM_2D_FUNC(draw_pattern_no_bg_comp)(
__asm volatile(
".p2align 2 \n"
" wlstp."TO_STRING(__API_ELT_SZ) \
" wlstp."ARM_TO_STRING(__API_ELT_SZ) \
" lr, %[cnt], 1f \n"
"2: \n"
/* widened vector load */
@ -300,7 +301,7 @@ void __ARM_2D_FUNC(draw_pattern_no_bg_comp)(
ARM_VLD1_ASM(__API_ELT_SZ) \
" q1, [%[target]] \n"
" vpt.i" TO_STRING(__API_ELT_SZ) \
" vpt.i" ARM_TO_STRING(__API_ELT_SZ) \
" ne, q0, zr \n"
" vmvnt q1, q1 \n"
/* contigous vector store */
@ -310,7 +311,7 @@ void __ARM_2D_FUNC(draw_pattern_no_bg_comp)(
" letp lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [src] "+l"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [bitmask] "t" (vBitMask),
[cnt] "r" (cnt), [incrSrc] "i" (ARM_PIX_VECELT(__API_ELT_SZ) / 8),
[offS] "t" (offS)
@ -375,7 +376,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_only)( uint8_t *__RESTRICT pchSourceBase,
" q0, [%[src], %[offS]] \n"
" vand q0, q0, %[bitmask] \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
/* contigous vector load */
ARM_VLD1_ASM(__API_ELT_SZ) \
@ -393,7 +394,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_only)( uint8_t *__RESTRICT pchSourceBase,
" le lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBase), [target] "+r" (pTargetBase)
: [src] "+l"(pchSourceBase), [target] "+r" (pTargetBase)
: [bitmask] "t" (vBitMask),[vBackG] "t"(vBackG),
[srcStride] "r" (iSourceStride >> 3),
[targStride] "r" (iTargetStride*(__API_ELT_SZ/8)),
@ -430,7 +431,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_only)( uint8_t *__RESTRICT pchSourceBase,
__asm volatile(
".p2align 2 \n"
" wlstp."TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
" wlstp."ARM_TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
"2: \n"
/* widened vector load */
ARM_VLDWID_ASM(8,__API_ELT_SZ) \
@ -439,7 +440,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_only)( uint8_t *__RESTRICT pchSourceBase,
" vand q0, q0, %[bitmask] \n"
" add %[src], %[src], %[incrSrc] \n"
" vpt.i" TO_STRING(__API_ELT_SZ) \
" vpt.i" ARM_TO_STRING(__API_ELT_SZ) \
" ne, q0, zr \n"
/* predicated contigous vector store */
@ -449,7 +450,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_only)( uint8_t *__RESTRICT pchSourceBase,
" letp lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [src] "+l"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [bitmask] "t" (vBitMask),[vBackG] "t"(vBackG),
[cnt] "r" (cnt), [incrSrc] "i" (ARM_PIX_VECELT(__API_ELT_SZ) / 8),
[offS] "t" (offS)
@ -519,7 +520,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_fg)( uint8_t *__RESTRICT pchSourceBase,
" q0, [%[src], %[offS]] \n"
" vand q0, q0, %[bitmask] \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
" vpsel q0, %[vBackG], %[vForeG] \n"
" vmsr P0, %[p] \n"
@ -534,7 +535,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_fg)( uint8_t *__RESTRICT pchSourceBase,
" le lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBase), [target] "+r" (pTargetBase)
: [src] "+l"(pchSourceBase), [target] "+r" (pTargetBase)
: [bitmask] "t" (vBitMask),[vBackG] "t"(vBgColor),
[vForeG] "t" (vFgColor),
[srcStride] "r" (iSourceStride >> 3),
@ -571,7 +572,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_fg)( uint8_t *__RESTRICT pchSourceBase,
#else
__asm volatile(
".p2align 2 \n"
" wlstp."TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
" wlstp."ARM_TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
"2: \n"
/* widened vector load */
ARM_VLDWID_ASM(8,__API_ELT_SZ) \
@ -580,7 +581,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_fg)( uint8_t *__RESTRICT pchSourceBase,
" vand q0, q0, %[bitmask] \n"
" add %[src], %[src], %[incrSrc] \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
" vpsel q0, %[vBackG], %[vForeG] \n"
@ -590,7 +591,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_fg)( uint8_t *__RESTRICT pchSourceBase,
" letp lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [src] "+l"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [bitmask] "t" (vBitMask),[vBackG] "t"(vBgColor),
[vForeG] "t" (vFgColor),
[cnt] "r" (cnt), [incrSrc] "i" (ARM_PIX_VECELT(__API_ELT_SZ) / 8),
@ -660,7 +661,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_comp)( uint8_t *__RESTRICT pchSourceBase,
" vmvn q1, q1 \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
" vpsel q1, %[vBackG], q1 \n"
@ -676,7 +677,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_comp)( uint8_t *__RESTRICT pchSourceBase,
" le lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBase), [target] "+r" (pTargetBase)
: [src] "+l"(pchSourceBase), [target] "+r" (pTargetBase)
: [bitmask] "t" (vBitMask), [vBackG] "t" (vBgColor),
[srcStride] "r" (iSourceStride >> 3),
[targStride] "r" (iTargetStride*(__API_ELT_SZ/8)),
@ -710,7 +711,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_comp)( uint8_t *__RESTRICT pchSourceBase,
#else
__asm volatile(
".p2align 2 \n"
" wlstp."TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
" wlstp."ARM_TO_STRING(__API_ELT_SZ) " lr, %[cnt], 1f \n"
"2: \n"
/* widened vector load */
ARM_VLDWID_ASM(8,__API_ELT_SZ) \
@ -724,7 +725,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_comp)( uint8_t *__RESTRICT pchSourceBase,
" vmvn q1, q1 \n"
" vcmp.i" TO_STRING(__API_ELT_SZ) \
" vcmp.i" ARM_TO_STRING(__API_ELT_SZ) \
" eq, q0, zr \n"
" vpsel q1, %[vBackG], q1 \n"
@ -734,7 +735,7 @@ void __ARM_2D_FUNC(draw_pattern_bg_comp)( uint8_t *__RESTRICT pchSourceBase,
" letp lr, 2b \n"
"1: \n"
: [src] "+r"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [src] "+l"(pchSourceBaseCur), [target] "+r" (pTargetBaseCur)
: [bitmask] "t" (vBitMask), [vBackG] "t" (vBgColor),
[cnt] "r" (cnt), [incrSrc] "i" (ARM_PIX_VECELT(__API_ELT_SZ) / 8),
[offS] "t" (offS)

View File

@ -76,7 +76,7 @@ void __ARM_2D_FUNC(colour_filling)( ARM_PIX_SCLTYP(__API_ELT_SZ) *__RESTRICT pT
__asm volatile(
".p2align 2 \n"
" wlstp." TO_STRING(__API_ELT_SZ) " lr, %[loopCnt], 1f \n"
" wlstp." ARM_TO_STRING(__API_ELT_SZ) " lr, %[loopCnt], 1f \n"
"2: \n"
" vstrb.u8 %[vColor], [%[pTarget]], #16 \n"
" letp lr, 2b \n"

View File

@ -0,0 +1,692 @@
/*
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: __arm_2d_meta_trans_with_masks.inc
* Description: c code template for copy and fill like operations
*
* $Date: 24. May 2022
* $Revision: V.1.1.1
*
* -------------------------------------------------------------------- */
#ifndef __API_MTWM_COLOUR
# error You have to define __API_MTWM_COLOUR before using this c template
#endif
#ifndef __API_MTWM_INT_TYPE
# error You have to define the __API_MTWM_INT_TYPE before using this c template
#endif
#ifndef __API_MTWM_INT_TYPE_BIT_NUM
# error You have to define the __API_MTWM_INT_TYPE_BIT_NUM before using this c template
#endif
#ifndef __API_MTWM_PIXEL_BLENDING
# error You have to define __API_MTWM_PIXEL_BLENDING before using this c template
#endif
#ifndef __API_MTWM_PIXEL_AVERAGE
# error You have to define __API_MTWM_PIXEL_AVERAGE before using this c template
#endif
#ifndef __API_MTWM_PIXEL_AVERAGE_RESULT
# error You have to define __API_MTWM_PIXEL_AVERAGE_RESULT before using this c template
#endif
#ifndef __API_MTWM_PIXEL_AVERAGE_INIT
# define __API_MTWM_PIXEL_AVERAGE_INIT() __arm_2d_color_fast_rgb_t tPixel = {0};
#endif
/*! disable this feature by default */
#ifndef __API_MTWM_CFG_SUPPORT_SRC_MSK_WRAPING
# define __API_MTWM_CFG_SUPPORT_SRC_MSK_WRAPING 0
#endif
//#ifndef __API_MTWM_CFG_1_HORIZONTAL_LINE
//# define __API_MTWM_CFG_1_HORIZONTAL_LINE 0
//#endif
//#ifndef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT
//# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT 0
//#endif
#ifndef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 0
#endif
//#ifndef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE
//# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 0
//#endif
#ifndef __API_MTWM_CFG_SUPPORT_SOURCE_MASK
# define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 0
#endif
//#ifndef __API_MTWM_CFG_SUPPORT_TARGET_MASK
//# define __API_MTWM_CFG_SUPPORT_TARGET_MASK 0
//#endif
#ifndef __API_MTWM_CFG_SUPPORT_OPACITY
# define __API_MTWM_CFG_SUPPORT_OPACITY 0
#endif
#undef ____MTWM_FUNC
#undef ___MTWM_FUNC
#undef __MTWM_FUNC
#ifndef __API_MTWM_OP_NAME
# define ____MTWM_FUNC(__NAME, __COLOUR) \
__arm_2d_impl_##__COLOUR##_##__NAME
# define ___MTWM_FUNC(__NAME, __COLOUR) ____MTWM_FUNC(__NAME, __COLOUR)
#else
# define _____MTWM_FUNC(__OP_NAME, __NAME, __COLOUR) \
__arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME
# define ____MTWM_FUNC(__OP_NAME, __NAME, __COLOUR) \
_____MTWM_FUNC(__OP_NAME, __NAME, __COLOUR)
# define ___MTWM_FUNC(__NAME, __COLOUR) \
____MTWM_FUNC(__API_MTWM_OP_NAME, __NAME, __COLOUR)
#endif
#define __MTWM_FUNC(__NAME) ___MTWM_FUNC(__NAME, __API_MTWM_COLOUR)
#undef ____MTWM_TYPE
#undef ___MTWM_TYPE
#undef __MTWM_TYPE
#ifndef __API_MTWM_OP_NAME
# define ____MTWM_TYPE(__NAME, __COLOUR) arm_2d_##__COLOUR##_##__NAME
# define ___MTWM_TYPE(__NAME, __COLOUR) ____MTWM_TYPE(__NAME, __COLOUR)
#else
# define _____MTWM_TYPE(__OP_NAME, __NAME, __COLOUR) \
arm_2d_##__COLOUR##_##__OP_NAME##_##__NAME
# define ____MTWM_TYPE(__OP_NAME, __NAME, __COLOUR) \
_____MTWM_TYPE(__OP_NAME, __NAME, __COLOUR)
# define ___MTWM_TYPE(__NAME, __COLOUR) \
____MTWM_TYPE(__API_MTWM_OP_NAME, __NAME, __COLOUR)
#endif
#define __MTWM_TYPE(__NAME) ___MTWM_TYPE(__NAME, __API_MTWM_COLOUR)
#define MASK_COLOR(sz) (sz == 8) ? ptInfo->Mask.chColour : ((sz == 16) ? ptInfo->Mask.hwColour : ptInfo->Mask.wColour)
/*============================ PROTOTYPES ====================================*/
extern
void __MTWM_FUNC(transform_with_mask)(
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK \
|| __API_MTWM_CFG_SUPPORT_TARGET_MASK
__arm_2d_param_copy_orig_msk_t *ptThis,
#else
__arm_2d_param_copy_orig_t *ptParam,
#endif
__arm_2d_transform_info_t *ptInfo
#if __API_MTWM_CFG_SUPPORT_OPACITY
,uint_fast16_t hwOpacity
#endif
);
/*============================ IMPLEMENTATION ================================*/
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
static
void __MTWM_FUNC(get_pixel_colour_mask)(arm_2d_point_float_t *ptPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
uint8_t *pchOrigMask,
int16_t iOrigMaskStride,
#else
__API_INT_TYPE MaskColour,
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
uint16_t hwOpacity,
#endif
__API_INT_TYPE *pTarget)
{
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
iOrigMaskStride *= 4;
#endif
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation;
tOriginLocation.iX = ptPoint->fX;
tOriginLocation.iY = ptPoint->fY;
__arm_2d_point_adj_alpha_t tAdjacentArray
= __arm_2d_point_get_adjacent_alpha_fp(ptPoint);
__API_PIXEL_AVERAGE_INIT();
//__API_INT_TYPE TempPixel;
bool bIsInside = false;
uint16_t hwTransparency = 0;
for (int_fast8_t n = 0; n < 4; n++) {
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
};
uint16_t hwPixelAlpha = 0;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tTemp)) {
__API_INT_TYPE Temp = pOrigin[ tTemp.iY * iOrigStride
+ tTemp.iX];
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX * 4];
#else
hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX];
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwPixelAlpha = hwPixelAlpha * hwOpacity >> 8;
assert(hwOpacity != 255);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwPixelAlpha += (hwPixelAlpha == 255);
#endif
hwPixelAlpha = hwPixelAlpha * hwAlpha >> 8;
__API_MTWM_PIXEL_AVERAGE(Temp, hwPixelAlpha);
bIsInside = true;
#else
if (Temp != MaskColour) {
bIsInside = true;
hwPixelAlpha = hwAlpha;
__API_MTWM_PIXEL_AVERAGE(Temp, hwAlpha);
}
#endif
}
hwTransparency += hwAlpha - hwPixelAlpha;
}
if (bIsInside) {
__API_MTWM_PIXEL_AVERAGE(*pTarget, hwTransparency);
#if __API_MTWM_CFG_SUPPORT_OPACITY && !__API_MTWM_CFG_SUPPORT_SOURCE_MASK
__API_INT_TYPE tSourcPixel = __API_PIXEL_AVERAGE_RESULT();
__API_MTWM_PIXEL_BLENDING( &tSourcPixel, pTarget, hwOpacity);
#else
*pTarget = __API_PIXEL_AVERAGE_RESULT();
#endif
}
#else
arm_2d_location_t tTemp;
tTemp.iX = ptPoint->fX;
tTemp.iY = ptPoint->fY;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tTemp)) {
__API_INT_TYPE Temp = pOrigin[ tTemp.iY * iOrigStride
+ tTemp.iX];
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
uint16_t hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX * 4];
#else
uint16_t hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX];
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwPixelAlpha = hwPixelAlpha * hwOpacity >> 8;
assert(hwOpacity != 255);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwPixelAlpha += (hwPixelAlpha == 255);
#endif
__API_MTWM_PIXEL_BLENDING( &Temp, pTarget, hwPixelAlpha);
#else
if (Temp != MaskColour) {
#if __API_MTWM_CFG_SUPPORT_OPACITY
__API_MTWM_PIXEL_BLENDING( &Temp, pTarget, hwOpacity);
#else
*pTarget = Temp;
#endif
}
#endif
}
#endif
}
__WEAK
void __MTWM_FUNC(transform_with_mask)(
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK \
|| __API_MTWM_CFG_SUPPORT_TARGET_MASK
__arm_2d_param_copy_orig_msk_t *ptThis,
#else
__arm_2d_param_copy_orig_t *ptParam,
#endif
__arm_2d_transform_info_t *ptInfo
#if __API_MTWM_CFG_SUPPORT_OPACITY
,uint_fast16_t hwOpacity
#endif
)
{
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK \
|| __API_MTWM_CFG_SUPPORT_TARGET_MASK
__arm_2d_param_copy_orig_t *ptParam =
&(ptThis->use_as____arm_2d_param_copy_orig_t);
#endif
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
int_fast16_t iTargetStride = ptParam->use_as____arm_2d_param_copy_t.tTarget.iStride;
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
uint8_t *pOriginMask = this.tOrigMask.pBuffer;
int_fast16_t iOrigMaskStride = this.tOrigMask.iStride;
#else
__API_INT_TYPE MaskColour = MASK_COLOR(__API_MTWM_INT_TYPE_BIT_NUM);
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwOpacity += (hwOpacity == 255);
#endif
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset = ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
float invIWidth = iWidth > 1 ? 1.0f / (float) (iWidth - 1) : __LARGEINVF32;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
float slopeY, slopeX;
slopeY = (regrCoefs[1].interceptY - regrCoefs[0].interceptY) * invIWidth;
slopeX = (regrCoefs[1].interceptX - regrCoefs[0].interceptX) * invIWidth;
for (int_fast16_t y = 0; y < iHeight; y++) {
/* 1st column estimates (intercepts for regression in X direction */
float colFirstY = regrCoefs[0].slopeY * y + regrCoefs[0].interceptY;
float colFirstX = regrCoefs[0].slopeX * y + regrCoefs[0].interceptX;
for (int_fast16_t x = 0; x < iWidth; x++) {
arm_2d_point_float_t tPoint;
/* linear interpolation thru first & last cols */
tPoint.fX = colFirstX + slopeX * x;
tPoint.fY = colFirstY + slopeY * x;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPoint.fX > 0) {
tPoint.fX += __CALIB;
} else {
tPoint.fX -= __CALIB;
}
if (tPoint.fY > 0) {
tPoint.fY += __CALIB;
} else {
tPoint.fY -= __CALIB;
}
#endif
__ARM_2D_FUNC(get_pixel_colour_mask)(
&tPoint,
&ptParam->tOrigin.tValidRegion,
ptParam->tOrigin.pBuffer,
iOrigStride,
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
pOriginMask,
iOrigMaskStride,
#else
MaskColour,
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwOpacity,
#endif
pTargetBase
);
pTargetBase++;
}
//phwSourceBase += (iSourceStride - iWidth);
pTargetBase += (iTargetStride - iWidth);
}
}
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
static
void __MTWM_FUNC(get_pixel_colour_mask)(arm_2d_point_fx_t *ptFxPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
uint8_t *pchOrigMask,
int16_t iOrigMaskStride,
#else
__API_INT_TYPE MaskColour,
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
uint16_t hwOpacity,
#endif
__API_INT_TYPE *pTarget
)
{
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
iOrigMaskStride *= 4;
#endif
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation = {
.iX = ptFxPoint->X >> 16,
.iY = ptFxPoint->Y >> 16,
};
__arm_2d_point_adj_alpha_t tAdjacentArray
= __arm_2d_point_get_adjacent_alpha_q16(ptFxPoint);
__API_PIXEL_AVERAGE_INIT();
//__API_INT_TYPE TempPixel;
bool bIsInside = false;
uint16_t hwTransparency = 0;
for (int_fast8_t n = 0; n < 4; n++) {
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
};
//TempPixel = (*pTarget);
uint16_t hwPixelAlpha = 0;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tTemp)) {
__API_INT_TYPE Temp = pOrigin[ tTemp.iY * iOrigStride
+ tTemp.iX];
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX * 4];
#else
hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX];
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwPixelAlpha = hwPixelAlpha * hwOpacity >> 8;
assert(hwOpacity != 255);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwPixelAlpha += (hwPixelAlpha == 255);
#endif
hwPixelAlpha = hwPixelAlpha * hwAlpha >> 8;
__API_MTWM_PIXEL_AVERAGE(Temp, hwPixelAlpha);
bIsInside = true;
#else
if (Temp != MaskColour) {
bIsInside = true;
hwPixelAlpha = hwAlpha;
__API_MTWM_PIXEL_AVERAGE(Temp, hwAlpha);
}
#endif
}
hwTransparency += hwAlpha - hwPixelAlpha;
}
if (bIsInside) {
__API_MTWM_PIXEL_AVERAGE(*pTarget, hwTransparency);
#if __API_MTWM_CFG_SUPPORT_OPACITY && !__API_MTWM_CFG_SUPPORT_SOURCE_MASK
__API_INT_TYPE tSourcPixel = __API_PIXEL_AVERAGE_RESULT();
__API_MTWM_PIXEL_BLENDING( &tSourcPixel, pTarget, hwOpacity);
#else
*pTarget = __API_PIXEL_AVERAGE_RESULT();
#endif
}
#else
arm_2d_location_t tTemp;
tTemp.iX = ptFxPoint->X >> 16;
tTemp.iY = ptFxPoint->Y >> 16;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tTemp)) {
__API_INT_TYPE Temp = pOrigin[ tTemp.iY * iOrigStride
+ tTemp.iX];
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
uint16_t hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX * 4];
#else
uint16_t hwPixelAlpha = pchOrigMask[tTemp.iY * iOrigMaskStride
+ tTemp.iX];
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwPixelAlpha = hwPixelAlpha * hwOpacity >> 8;
assert(hwOpacity != 255);
#endif
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwPixelAlpha += (hwPixelAlpha == 255);
#endif
__API_MTWM_PIXEL_BLENDING( &Temp, pTarget, hwPixelAlpha);
#else
if (Temp != MaskColour) {
#if __API_MTWM_CFG_SUPPORT_OPACITY
__API_MTWM_PIXEL_BLENDING( &Temp, pTarget, hwOpacity);
#else
*pTarget = Temp;
#endif
}
#endif
}
#endif
}
__WEAK
__WEAK
void __MTWM_FUNC(transform_with_mask)(
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK \
|| __API_MTWM_CFG_SUPPORT_TARGET_MASK
__arm_2d_param_copy_orig_msk_t *ptThis,
#else
__arm_2d_param_copy_orig_t *ptParam,
#endif
__arm_2d_transform_info_t *ptInfo
#if __API_MTWM_CFG_SUPPORT_OPACITY
,uint_fast16_t hwOpacity
#endif
)
{
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK \
|| __API_MTWM_CFG_SUPPORT_TARGET_MASK
__arm_2d_param_copy_orig_t *ptParam =
&(ptThis->use_as____arm_2d_param_copy_orig_t);
#endif
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
int_fast16_t iTargetStride = ptParam->use_as____arm_2d_param_copy_t.tTarget.iStride;
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
__API_INT_TYPE *pOrigin = ptParam->tOrigin.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
uint8_t *pOriginMask = this.tOrigMask.pBuffer;
int_fast16_t iOrigMaskStride = this.tOrigMask.iStride;
#else
__API_INT_TYPE MaskColour = MASK_COLOR(__API_MTWM_INT_TYPE_BIT_NUM);
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwOpacity += (hwOpacity == 255);
#endif
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset = ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
q31_t invIWidth = iWidth > 1 ? 0x7fffffff / (iWidth - 1) : 0x7fffffff;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
int32_t slopeY, slopeX;
slopeY =
MULTFX((regrCoefs[1].interceptY - regrCoefs[0].interceptY), invIWidth);
slopeX =
MULTFX((regrCoefs[1].interceptX - regrCoefs[0].interceptX), invIWidth);
for (int_fast16_t y = 0; y < iHeight; y++) {
/* 1st column estimates */
int32_t colFirstY =
__QADD((regrCoefs[0].slopeY * y), regrCoefs[0].interceptY);
int32_t colFirstX =
__QADD((regrCoefs[0].slopeX * y), regrCoefs[0].interceptX);
for (int_fast16_t x = 0; x < iWidth; x++) {
arm_2d_point_fx_t tPointFast;
tPointFast.X = __QDADD(colFirstX, slopeX * x);
tPointFast.Y = __QDADD(colFirstY, slopeY * x);
#define __CALIBFX 590
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPointFast.X > 0) {
tPointFast.X += __CALIBFX;
} else {
tPointFast.X -= __CALIBFX;
}
if (tPointFast.Y > 0) {
tPointFast.Y += __CALIBFX;
} else {
tPointFast.Y -= __CALIBFX;
}
#endif
__ARM_2D_FUNC(get_pixel_colour_mask)(
&tPointFast,
&ptParam->tOrigin.tValidRegion,
pOrigin,
iOrigStride,
#if __API_MTWM_CFG_SUPPORT_SOURCE_MASK
pOriginMask,
iOrigMaskStride,
#else
MaskColour,
#endif
#if __API_MTWM_CFG_SUPPORT_OPACITY
hwOpacity,
#endif
pTargetBase
);
pTargetBase++;
}
//phwSourceBase += (iSourceStride - iWidth);
pTargetBase += (iTargetStride - iWidth);
}
}
#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
#undef get_pixel_colour_mask
#undef transform_with_mask
#undef __API_MTWM_COPY_LIKE_OP_NAME
#undef __API_MTWM_OP_NAME
#undef __API_MTWM_PIXEL_BLENDING
#undef ____MTWM_FUNC
#undef ___MTWM_FUNC
#undef __MTWM_FUNC
#undef __API_MTWM_COLOUR
#undef __API_MTWM_INT_TYPE
#undef __API_MTWM_INT_TYPE_BIT_NUM
#undef ____MTWM_TYPE
#undef ___MTWM_TYPE
#undef __MTWM_TYPE
#undef __API_MTWM_CFG_SUPPORT_SRC_MSK_WRAPING
#undef __API_MTWM_CFG_1_HORIZONTAL_LINE
#undef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT
#undef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE
#undef __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE
#undef __API_MTWM_PIXEL_AVERAGE
#undef __API_MTWM_PIXEL_AVERAGE_RESULT
#undef __API_MTWM_PIXEL_AVERAGE_INIT
#undef __API_MTWM_CFG_SUPPORT_SOURCE_MASK
#undef __API_MTWM_CFG_SUPPORT_TARGET_MASK
#undef __API_MTWM_CFG_SUPPORT_OPACITY

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -22,8 +22,8 @@
* Title: __arm_2d_fill_colour.inc
* Description: c code template for drawing pattern
*
* $Date: 14. April 2020
* $Revision: V.1.0.0
* $Date: 20. May 2022
* $Revision: V.1.1.1
*
* -------------------------------------------------------------------- */
@ -34,6 +34,9 @@
#ifndef __API_INT_TYPE
# error You have to define the __API_INT_TYPE before using this c template
#endif
#ifndef __API_INT_TYPE_BIT_NUM
# error You have to define the __API_INT_TYPE_BIT_NUM before using this c template
#endif
#ifndef __API_PIXEL_BLENDING
# error You have to define __API_PIXEL_BLENDING before using this c template
#endif
@ -54,46 +57,55 @@
#define ___ARM_2D_FUNC(__NAME, __COLOUR) ____ARM_2D_FUNC(__NAME, __COLOUR)
#define __ARM_2D_FUNC(__NAME) ___ARM_2D_FUNC(__NAME, __API_COLOUR)
#define MASK_COLOR(sz) (sz == 8) ? ptInfo->Mask.chColour : ((sz == 16) ? ptInfo->Mask.hwColour : ptInfo->Mask.wColour)
static
arm_2d_point_float_t *__arm_2d_rotate_point(const arm_2d_location_t *ptLocation,
arm_2d_point_float_t *__arm_2d_transform_point(
const arm_2d_location_t *ptLocation,
const arm_2d_location_t *ptCenter,
float fAngle,
float fScale,
arm_2d_point_float_t *ptOutBuffer);
static
void __arm_2d_rotate_regression(arm_2d_size_t * __RESTRICT ptCopySize,
arm_2d_location_t * pSrcPoint,
float fAngle,
arm_2d_location_t * tOffset,
arm_2d_location_t * ptCenter,
arm_2d_rot_linear_regr_t regrCoefs[]);
void __arm_2d_transform_regression( arm_2d_size_t * __RESTRICT ptCopySize,
arm_2d_location_t * pSrcPoint,
float fAngle,
float fScale,
arm_2d_location_t * tOffset,
arm_2d_location_t * ptCenter,
arm_2d_rot_linear_regr_t regrCoefs[]);
/*! \note Please only set this to zero for function correctness verification of
*! __arm_2d_meta_trans_with_masks.inc
*/
#if 1
extern
void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo);
void __ARM_2D_FUNC(transform)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo);
extern
void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo,
uint_fast8_t chRatio);
void __ARM_2D_FUNC(transform_with_opacity)(__arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo,
uint_fast16_t hwRatio);
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
__WEAK
__API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)( arm_2d_point_float_t *ptPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
//arm_2d_location_t *ptTargetPoint,
//arm_2d_region_t *ptTargetValidRegion,
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour)
static
void __ARM_2D_FUNC(get_pixel_colour)( arm_2d_point_float_t *ptPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
//arm_2d_location_t *ptTargetPoint,
//arm_2d_region_t *ptTargetValidRegion,
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour)
{
#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) \
&& __ARM_2D_HAS_INTERPOLATION_ROTATION__
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation;
@ -109,7 +121,8 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)( arm_2d_point_float_t *ptPoint,
bool bIsInside = false;
for (int_fast8_t n = 0; n < 4; n++) {
uint8_t chAlpha = tAdjacentArray.tMatrix[n].chAlpha;
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
@ -127,39 +140,32 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)( arm_2d_point_float_t *ptPoint,
}
}
__API_PIXEL_AVERAGE(TempPixel, chAlpha);
__API_PIXEL_AVERAGE(TempPixel, hwAlpha);
}
if (bIsInside) {
TempPixel = __API_PIXEL_AVERAGE_RESULT();
} else {
TempPixel = *pTarget;
(*pTarget) = __API_PIXEL_AVERAGE_RESULT();
}
return TempPixel;
#else
arm_2d_location_t tOriginLocation;
tOriginLocation.iX = ptPoint->fX;
tOriginLocation.iY = ptPoint->fY;
__API_INT_TYPE Pixel = *pTarget;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tOriginLocation)) {
__API_INT_TYPE Temp = pOrigin[ tOriginLocation.iY * iOrigStride
+ tOriginLocation.iX];
if (Temp != MaskColour) {
Pixel = Temp;
*pTarget = Temp;
}
}
return Pixel;
#endif
}
__WEAK
void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo)
void __ARM_2D_FUNC(transform)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo)
{
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -167,17 +173,23 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
int_fast16_t iTargetStride = ptParam->use_as____arm_2d_param_copy_t.tTarget.iStride;
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
__API_INT_TYPE MaskColour = ptInfo->Mask.hwColour;
__API_INT_TYPE MaskColour = MASK_COLOR(__API_INT_TYPE_BIT_NUM);
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset = ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
float invIWidth = iWidth > 1 ? 1.0f / (float) (iWidth - 1) : 100.0f;
float invIWidth = iWidth > 1 ? 1.0f / (float) (iWidth - 1) : __LARGEINVF32;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, &(ptInfo->tCenter), regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
float slopeY, slopeX;
@ -197,7 +209,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
tPoint.fX = colFirstX + slopeX * x;
tPoint.fY = colFirstY + slopeY * x;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__)
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPoint.fX > 0) {
tPoint.fX += __CALIB;
} else {
@ -210,7 +222,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
}
#endif
*pTargetBase = __ARM_2D_FUNC(get_pixel_colour)(
__ARM_2D_FUNC(get_pixel_colour)(
&tPoint,
&ptParam->tOrigin.tValidRegion,
ptParam->tOrigin.pBuffer,
@ -227,20 +239,19 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
}
}
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
__WEAK
__API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)(
arm_2d_point_fx_t *ptFxPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour)
static
void __ARM_2D_FUNC(get_pixel_colour)( arm_2d_point_fx_t *ptFxPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
int16_t iOrigStride,
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour)
{
#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) \
&& __ARM_2D_HAS_INTERPOLATION_ROTATION__
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation = {
.iX = ptFxPoint->X >> 16,
@ -256,7 +267,8 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)(
bool bIsInside = false;
for (int_fast8_t n = 0; n < 4; n++) {
uint8_t chAlpha = tAdjacentArray.tMatrix[n].chAlpha;
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
@ -274,18 +286,13 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)(
}
}
__API_PIXEL_AVERAGE(TempPixel, chAlpha);
__API_PIXEL_AVERAGE(TempPixel, hwAlpha);
}
if (bIsInside) {
TempPixel = __API_PIXEL_AVERAGE_RESULT();
} else {
TempPixel = *pTarget;
*pTarget = __API_PIXEL_AVERAGE_RESULT();
}
return TempPixel;
#else
__API_INT_TYPE Pixel = *pTarget;
arm_2d_location_t tPoint = {
.iX = ptFxPoint->X >> 16,
.iY = ptFxPoint->Y >> 16,
@ -294,17 +301,15 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour)(
__API_INT_TYPE Temp = pOrigin[ tPoint.iY * iOrigStride
+ tPoint.iX];
if (Temp != MaskColour) {
Pixel = Temp;
*pTarget = Temp;
}
}
return Pixel;
#endif
}
__WEAK
void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo)
void __ARM_2D_FUNC(transform)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo)
{
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -313,7 +318,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
__API_INT_TYPE *pOrigin = ptParam->tOrigin.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
__API_INT_TYPE MaskColour = ptInfo->Mask.hwColour;
__API_INT_TYPE MaskColour = MASK_COLOR(__API_INT_TYPE_BIT_NUM);
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset = ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
q31_t invIWidth = iWidth > 1 ? 0x7fffffff / (iWidth - 1) : 0x7fffffff;
@ -321,8 +326,14 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, &(ptInfo->tCenter), regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
int32_t slopeY, slopeX;
@ -347,7 +358,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
tPointFast.Y = __QDADD(colFirstY, slopeY * x);
#define __CALIBFX 590
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__)
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPointFast.X > 0) {
tPointFast.X += __CALIBFX;
} else {
@ -360,7 +371,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
}
#endif
*pTargetBase = __ARM_2D_FUNC(get_pixel_colour)(
__ARM_2D_FUNC(get_pixel_colour)(
&tPointFast,
&ptParam->tOrigin.tValidRegion,
pOrigin,
@ -380,9 +391,9 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
__WEAK
__API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
static
void __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
arm_2d_point_float_t *ptPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
@ -390,10 +401,10 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour,
uint8_t chOpacity)
uint_fast16_t hwOpacity)
{
#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) \
&& __ARM_2D_HAS_INTERPOLATION_ROTATION__
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation;
tOriginLocation.iX = ptPoint->fX;
@ -408,7 +419,8 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
bool bIsInside = false;
for (int_fast8_t n = 0; n < 4; n++) {
uint8_t chAlpha = tAdjacentArray.tMatrix[n].chAlpha;
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
@ -426,25 +438,20 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
}
}
__API_PIXEL_AVERAGE(TempPixel, chAlpha);
__API_PIXEL_AVERAGE(TempPixel, hwAlpha);
}
if (bIsInside) {
TempPixel = *pTarget;
__API_INT_TYPE tSourcPixel = __API_PIXEL_AVERAGE_RESULT();
__API_PIXEL_BLENDING( &tSourcPixel, &TempPixel, chOpacity);
} else {
TempPixel = *pTarget;
__API_PIXEL_BLENDING( &tSourcPixel, pTarget, hwOpacity);
}
return TempPixel;
#else
arm_2d_location_t tOriginLocation;
tOriginLocation.iX = ptPoint->fX;
tOriginLocation.iY = ptPoint->fY;
__API_INT_TYPE Pixel = *pTarget;
if (arm_2d_is_point_inside_region(ptOrigValidRegion, &tOriginLocation)) {
__API_INT_TYPE Temp = pOrigin[ tOriginLocation.iY * iOrigStride
@ -452,16 +459,14 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
if (Temp != MaskColour) {
//Pixel = Temp;
__API_PIXEL_BLENDING( &Temp, &Pixel, chOpacity);
__API_PIXEL_BLENDING( &Temp, pTarget, hwOpacity);
}
}
return Pixel;
#endif
}
#else
__WEAK
__API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
void __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
arm_2d_point_fx_t *ptFxPoint,
arm_2d_region_t *ptOrigValidRegion,
__API_INT_TYPE *pOrigin,
@ -469,10 +474,10 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
__API_INT_TYPE *pTarget,
//int16_t iTargetSride,
__API_INT_TYPE MaskColour,
uint8_t chOpacity)
uint_fast16_t hwOpacity)
{
#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) \
&& __ARM_2D_HAS_INTERPOLATION_ROTATION__
#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) \
&& __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
arm_2d_location_t tOriginLocation = {
.iX = ptFxPoint->X >> 16,
.iY = ptFxPoint->Y >> 16,
@ -487,7 +492,8 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
bool bIsInside = false;
for (int_fast8_t n = 0; n < 4; n++) {
uint8_t chAlpha = tAdjacentArray.tMatrix[n].chAlpha;
uint16_t hwAlpha = tAdjacentArray.tMatrix[n].chAlpha;
arm_2d_location_t tTemp = {
.iX = tOriginLocation.iX + tAdjacentArray.tMatrix[n].tOffset.iX,
.iY = tOriginLocation.iY + tAdjacentArray.tMatrix[n].tOffset.iY,
@ -505,22 +511,17 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
}
}
__API_PIXEL_AVERAGE(TempPixel, chAlpha);
__API_PIXEL_AVERAGE(TempPixel, hwAlpha);
}
if (bIsInside) {
TempPixel = *pTarget;
__API_INT_TYPE tSourcPixel = __API_PIXEL_AVERAGE_RESULT();
__API_PIXEL_BLENDING( &tSourcPixel, &TempPixel, chOpacity);
} else {
TempPixel = *pTarget;
__API_PIXEL_BLENDING( &tSourcPixel, pTarget, hwOpacity);
}
return TempPixel;
#else
__API_INT_TYPE Pixel = *pTarget;
arm_2d_location_t tPoint = {
.iX = ptFxPoint->X >> 16,
.iY = ptFxPoint->Y >> 16,
@ -529,21 +530,20 @@ __API_INT_TYPE __ARM_2D_FUNC(get_pixel_colour_with_alpha)(
__API_INT_TYPE Temp = pOrigin[ tPoint.iY * iOrigStride
+ tPoint.iX];
if (Temp != MaskColour) {
__API_PIXEL_BLENDING( &Temp, &Pixel, chOpacity);
__API_PIXEL_BLENDING( &Temp, pTarget, hwOpacity);
}
}
return Pixel;
#endif
}
#endif
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
__WEAK
void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo,
uint_fast8_t chRatio)
void __ARM_2D_FUNC(transform_with_opacity)(__arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo,
uint_fast16_t hwRatio)
{
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -553,18 +553,28 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
__API_INT_TYPE *pOrigin = ptParam->tOrigin.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
__API_INT_TYPE MaskColour = ptInfo->Mask.hwColour;
__API_INT_TYPE MaskColour = MASK_COLOR(__API_INT_TYPE_BIT_NUM);
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset =
ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
uint16_t hwRatioCompl = 256 - chRatio;
float invIWidth = iWidth > 1 ? 1.0f / (float) (iWidth - 1) : 100.0f;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
float invIWidth = iWidth > 1 ? 1.0f / (float) (iWidth - 1) : __LARGEINVF32;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, &(ptInfo->tCenter), regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
float slopeY, slopeX;
@ -585,7 +595,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
tPoint.fX = colFirstX + slopeX * x;
tPoint.fY = colFirstY + slopeY * x;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__)
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPoint.fX > 0) {
tPoint.fX += __CALIB;
} else {
@ -598,7 +608,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
#endif
*pTargetBase = __ARM_2D_FUNC(get_pixel_colour_with_alpha) (
__ARM_2D_FUNC(get_pixel_colour_with_alpha) (
&tPoint,
&ptParam->tOrigin.
tValidRegion,
@ -606,19 +616,19 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
iOrigStride,
pTargetBase,
MaskColour,
hwRatioCompl);
hwRatio);
pTargetBase++;
}
pTargetBase += (iTargetStride - iWidth);
}
}
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
__WEAK
void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo,
uint_fast8_t chRatio)
void __ARM_2D_FUNC(transform_with_opacity)(__arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo,
uint_fast16_t hwRatio)
{
int_fast16_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int_fast16_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -628,18 +638,28 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__API_INT_TYPE *pTargetBase = ptParam->use_as____arm_2d_param_copy_t.tTarget.pBuffer;
__API_INT_TYPE *pOrigin = ptParam->tOrigin.pBuffer;
int_fast16_t iOrigStride = ptParam->tOrigin.iStride;
__API_INT_TYPE MaskColour = ptInfo->Mask.hwColour;
__API_INT_TYPE MaskColour = MASK_COLOR(__API_INT_TYPE_BIT_NUM);
float fAngle = -ptInfo->fAngle;
arm_2d_location_t tOffset =
ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
uint16_t hwRatioCompl = 256 - chRatio;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
q31_t invIWidth = iWidth > 1 ? 0x7fffffff / (iWidth - 1) : 0x7fffffff;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, &(ptInfo->tCenter), regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
&(ptInfo->tCenter),
regrCoefs);
/* slopes between 1st and last cols */
int32_t slopeY, slopeX;
@ -665,7 +685,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
#define __CALIBFX 590
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__)
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__)
if (tPointFast.X > 0) {
tPointFast.X += __CALIBFX;
} else {
@ -678,7 +698,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
#endif
*pTargetBase = __ARM_2D_FUNC(get_pixel_colour_with_alpha) (
__ARM_2D_FUNC(get_pixel_colour_with_alpha) (
&tPointFast,
&ptParam->tOrigin.
tValidRegion,
@ -686,14 +706,106 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
iOrigStride,
pTargetBase,
MaskColour,
hwRatioCompl);
hwRatio);
pTargetBase++;
}
pTargetBase += (iTargetStride - iWidth);
}
}
#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */
#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
#else
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
# define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
# define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
# define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
# define get_pixel_colour_mask get_pixel_colour
# define transform_with_mask transform
# include "__arm_2d_meta_trans_with_masks.inc"
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
# define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
# define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
# define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
# define __API_MTWM_CFG_SUPPORT_OPACITY 1
# define get_pixel_colour_mask get_pixel_colour_with_opacity
# define transform_with_mask transform_with_opacity
# include "__arm_2d_meta_trans_with_masks.inc"
#endif
#define __API_MTWM_COLOUR __API_COLOUR
#define __API_MTWM_INT_TYPE __API_INT_TYPE
#define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
#define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
#define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
#define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
#define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
#define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
#define get_pixel_colour_mask get_pixel_colour_src_mask
#define transform_with_mask transform_with_src_mask
#include "__arm_2d_meta_trans_with_masks.inc"
#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
# define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
# define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
# define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
# define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1
# define get_pixel_colour_mask get_pixel_colour_src_chn_mask
# define transform_with_mask transform_with_src_chn_mask
# include "__arm_2d_meta_trans_with_masks.inc"
#endif
#define __API_MTWM_COLOUR __API_COLOUR
#define __API_MTWM_INT_TYPE __API_INT_TYPE
#define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
#define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
#define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
#define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
#define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
#define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
#define __API_MTWM_CFG_SUPPORT_OPACITY 1
#define get_pixel_colour_mask get_pixel_colour_src_mask_opa
#define transform_with_mask transform_with_src_mask_and_opacity
#include "__arm_2d_meta_trans_with_masks.inc"
#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_PIXEL_BLENDING __API_PIXEL_BLENDING
# define __API_MTWM_PIXEL_AVERAGE __API_PIXEL_AVERAGE
# define __API_MTWM_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT
# define __API_MTWM_PIXEL_AVERAGE_INIT __API_PIXEL_AVERAGE_INIT
# define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
# define __API_MTWM_CFG_SUPPORT_OPACITY 1
# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1
# define get_pixel_colour_mask get_pixel_colour_src_chn_mask_opa
# define transform_with_mask transform_with_src_chn_mask_and_opacity
# include "__arm_2d_meta_trans_with_masks.inc"
#endif
#undef ____ARM_2D_FUNC
@ -701,6 +813,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
#undef __ARM_2D_FUNC
#undef __API_COLOUR
#undef __API_INT_TYPE
#undef __API_INT_TYPE_BIT_NUM
#undef __API_PIXEL_BLENDING
#undef __API_PIXEL_AVERAGE
#undef __API_PIXEL_AVERAGE_RESULT

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,11 @@
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: __arm_2d_rotate_helium.inc
* Description: c code template for rotation
* Title: __arm_2d_transform_helium.inc
* Description: c code template for transform
*
* $Date: 22. Sept 2020
* $Revision: V.1.0.0
* $Date: 12. July 2022
* $Revision: V.1.0.4
*
* -------------------------------------------------------------------- */
@ -33,14 +33,16 @@
#ifndef __API_COLOUR
# error You have to define __API_COLOUR before using this c template
#endif
#ifndef __API_COLOUR_NAME
# error You have to define __API_COLOUR_NAME before using this c template
#endif
#undef ____ARM_2D_FUNC
#undef ___ARM_2D_FUNC
#undef __ARM_2D_FUNC
#define ____ARM_2D_FUNC(__NAME, __COLOUR) __arm_2d_impl_##__COLOUR##_##__NAME
#define ____ARM_2D_FUNC(__NAME, __COLOUR) __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME)
#define ___ARM_2D_FUNC(__NAME, __COLOUR) ____ARM_2D_FUNC(__NAME, __COLOUR)
#define __ARM_2D_FUNC(__NAME) ___ARM_2D_FUNC(__NAME, __API_COLOUR)
#define __ARM_2D_FUNC(__NAME) ___ARM_2D_FUNC(__NAME, __API_COLOUR_NAME)
@ -49,12 +51,12 @@
#define MASK_COLOR(sz) (sz == 8) ? ptInfo->Mask.chColour : ((sz == 16) ? ptInfo->Mask.hwColour : ptInfo->Mask.wColour)
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
__OVERRIDE_WEAK
void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo)
void __ARM_2D_FUNC(transform)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo)
{
int32_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int32_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -75,13 +77,19 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
bool gatherLoadIdxOverflow;
gatherLoadIdxOverflow =
#endif
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, pCenter, iOrigStride,
regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
pCenter,
iOrigStride,
regrCoefs);
/* slopes between 1st and last columns */
@ -90,7 +98,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
slopeY = (float32_t) (regrCoefs[1].interceptY - regrCoefs[0].interceptY) * invIWidth;
slopeX = (float32_t) (regrCoefs[1].interceptX - regrCoefs[0].interceptX) * invIWidth;
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
if (!gatherLoadIdxOverflow) {
#endif
for (int32_t y = 0; y < iHeight; y++) {
@ -131,7 +139,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
}
pTargetBase += iTargetStride;
}
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
} else {
for (int32_t y = 0; y < iHeight; y++) {
@ -157,7 +165,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
tPointV.Y = vaddq_m_n_f16(tPointV.Y, tPointV.Y, __CALIB, vcmpgtq(tPointV.Y, 0));
tPointV.Y = vsubq_m_n_f16(tPointV.Y, tPointV.Y, __CALIB, vcmpleq(tPointV.Y, 0));
#endif
__arm_2d_impl_rgb565_get_pixel_colour_offs_compensated(&tPointV,
__MVE_WRAPPER(__arm_2d_impl_rgb565_get_pixel_colour_offs_compensated)(&tPointV,
&ptParam->tOrigin.
tValidRegion,
pOrigin,
@ -178,9 +186,9 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__OVERRIDE_WEAK
void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo,
uint_fast8_t chRatio)
void __ARM_2D_FUNC(transform_with_opacity)(__arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo,
uint_fast16_t hwRatio)
{
int32_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int32_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -195,20 +203,28 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
arm_2d_location_t tOffset =
ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
arm_2d_location_t *pCenter = &(ptInfo->tCenter);
uint16_t hwRatioCompl = 256 - chRatio;
float32_t invIWidth = iWidth > 1 ? 1.0f / (float32_t) (iWidth - 1) : __LARGEINVF32;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
/* get regression parameters over 1st and last column */
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
bool gatherLoadIdxOverflow;
gatherLoadIdxOverflow =
#endif
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, pCenter, iOrigStride,
regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
pCenter,
iOrigStride,
regrCoefs);
/* slopes between 1st and last columns */
float32_t slopeY, slopeX;
@ -216,7 +232,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
slopeY = (float32_t) (regrCoefs[1].interceptY - regrCoefs[0].interceptY) * invIWidth;
slopeX = (float32_t) (regrCoefs[1].interceptX - regrCoefs[0].interceptX) * invIWidth;
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
if (!gatherLoadIdxOverflow) {
#endif
for (int32_t y = 0; y < iHeight; y++) {
@ -252,7 +268,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
pOrigin, iOrigStride,
pTargetBaseCur,
MaskColour,
hwRatioCompl,
hwRatio,
nbVecElts);
pTargetBaseCur += 8;
vX += 8.0f16;
@ -260,7 +276,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
pTargetBase += iTargetStride;
}
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
} else {
/*
@ -299,14 +315,14 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
tPointV.Y = vaddq_m_n_f16(tPointV.Y, tPointV.Y, __CALIB, vcmpgtq(tPointV.Y, 0));
tPointV.Y = vsubq_m_n_f16(tPointV.Y, tPointV.Y, __CALIB, vcmpleq(tPointV.Y, 0));
#endif
__arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated(&tPointV,
__MVE_WRAPPER(__arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated)(&tPointV,
&ptParam->tOrigin.
tValidRegion,
pOrigin,
iOrigStride,
pTargetBaseCur,
MaskColour,
hwRatioCompl,
hwRatio,
nbVecElts);
pTargetBaseCur += 8;
vX += 8.0f16;
@ -319,11 +335,11 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */
#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
__OVERRIDE_WEAK
void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo)
void __ARM_2D_FUNC(transform)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo)
{
int32_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int32_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -342,14 +358,20 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
/* get regression parameters over 1st and last column */
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
bool gatherLoadIdxOverflow;
gatherLoadIdxOverflow =
#endif
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, pCenter, iOrigStride,
regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
pCenter,
iOrigStride,
regrCoefs);
/* slopes between 1st and last columns */
@ -366,7 +388,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
slopeX = ARSHIFT(slopeX, nrmSlopeX);
slopeY = ARSHIFT(slopeY, nrmSlopeY);
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
if (!gatherLoadIdxOverflow) {
#endif
@ -411,7 +433,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
}
pTargetBase += iTargetStride;
}
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
/* RGB565 specific */
} else {
for (int32_t y = 0; y < iHeight; y++) {
@ -442,7 +464,7 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
tPointV.Y = vqdmulhq_n_s16(vX, slopeY);
tPointV.Y = vaddq_n_s16(vqrshlq_n_s16(tPointV.Y, nrmSlopeY), colFirstY);
__arm_2d_impl_rgb565_get_pixel_colour_offs_compensated(&tPointV,
__MVE_WRAPPER(__arm_2d_impl_rgb565_get_pixel_colour_offs_compensated)(&tPointV,
&ptParam->tOrigin.
tValidRegion,
pOrigin,
@ -465,9 +487,9 @@ void __ARM_2D_FUNC(rotate)( __arm_2d_param_copy_orig_t *ptParam,
__OVERRIDE_WEAK
void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_rotate_info_t *ptInfo,
uint_fast8_t chRatio)
void __ARM_2D_FUNC(transform_with_opacity)( __arm_2d_param_copy_orig_t *ptParam,
__arm_2d_transform_info_t *ptInfo,
uint_fast16_t hwRatio)
{
int32_t iHeight = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iHeight;
int32_t iWidth = ptParam->use_as____arm_2d_param_copy_t.tCopySize.iWidth;
@ -483,19 +505,27 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
ptParam->use_as____arm_2d_param_copy_t.tSource.tValidRegion.tLocation;
arm_2d_location_t *pCenter = &(ptInfo->tCenter);
uint16_t hwRatioCompl = 256 - chRatio;
q31_t invIWidth = iWidth > 1 ? 0x7fffffff / (iWidth - 1) : 0x7fffffff;
arm_2d_rot_linear_regr_t regrCoefs[2];
arm_2d_location_t SrcPt = ptInfo->tDummySourceOffset;
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__)
hwRatio += (hwRatio == 255);
#endif
/* get regression parameters over 1st and last column */
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
bool gatherLoadIdxOverflow;
gatherLoadIdxOverflow =
#endif
__arm_2d_rotate_regression(&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt, fAngle, &tOffset, pCenter, iOrigStride,
regrCoefs);
__arm_2d_transform_regression(
&ptParam->use_as____arm_2d_param_copy_t.tCopySize,
&SrcPt,
fAngle,
ptInfo->fScale,
&tOffset,
pCenter,
iOrigStride,
regrCoefs);
/* slopes between 1st and last columns */
@ -510,7 +540,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
slopeX = ARSHIFT(slopeX, nrmSlopeX);
slopeY = ARSHIFT(slopeY, nrmSlopeY);
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
if (!gatherLoadIdxOverflow) {
#endif
for (int32_t y = 0; y < iHeight; y++) {
@ -545,7 +575,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
&ptParam->tOrigin.tValidRegion,
pOrigin, iOrigStride,
pTargetBaseCur,
MaskColour, hwRatioCompl,
MaskColour, hwRatio,
nbVecElts);
pTargetBaseCur += 8;
vX += SET_Q6INT(8);
@ -553,7 +583,7 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
pTargetBase += iTargetStride;
}
#if __API_INT_TYPE_BIT_NUM == 16
#if __API_COLOUR == ARM_2D_M_COLOUR_RGB565
} else {
/*
Large image / Large origin offsets
@ -592,9 +622,9 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
tPointV.Y = vqdmulhq_n_s16(vX, slopeY);
tPointV.Y = vaddq_n_s16(vqrshlq_n_s16(tPointV.Y, nrmSlopeY), colFirstY);
__arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated
__MVE_WRAPPER(__arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated)
(&tPointV, &ptParam->tOrigin.tValidRegion, pOrigin, iOrigStride,
pTargetBaseCur, MaskColour, hwRatioCompl, nbVecElts);
pTargetBaseCur, MaskColour, hwRatio, nbVecElts);
pTargetBaseCur += 8;
vX += SET_Q6INT(8);
@ -607,12 +637,65 @@ void __ARM_2D_FUNC(rotate_alpha)( __arm_2d_param_copy_orig_t *ptParam,
}
#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */
#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */
#define __API_MTWM_COLOUR __API_COLOUR
#define __API_MTWM_COLOUR_NAME __API_COLOUR_NAME
#define __API_MTWM_INT_TYPE __API_INT_TYPE
#define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
#define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
#define get_pixel_colour_mask get_pixel_colour_src_mask
#define transform_with_mask transform_with_src_mask
#include "__arm_2d_meta_trans_with_masks_helium.inc"
#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_COLOUR_NAME __API_COLOUR_NAME
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1
# define get_pixel_colour_mask get_pixel_colour_src_chn_mask
# define transform_with_mask transform_with_src_chn_mask
# include "__arm_2d_meta_trans_with_masks_helium.inc"
#endif
#define __API_MTWM_COLOUR __API_COLOUR
#define __API_MTWM_COLOUR_NAME __API_COLOUR_NAME
#define __API_MTWM_INT_TYPE __API_INT_TYPE
#define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
#define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
#define __API_MTWM_CFG_SUPPORT_OPACITY 1
#define get_pixel_colour_mask get_pixel_colour_src_mask_opa
#define transform_with_mask transform_with_src_mask_and_opacity
#include "__arm_2d_meta_trans_with_masks_helium.inc"
#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
# define __API_MTWM_COLOUR __API_COLOUR
# define __API_MTWM_COLOUR_NAME __API_COLOUR_NAME
# define __API_MTWM_INT_TYPE __API_INT_TYPE
# define __API_MTWM_INT_TYPE_BIT_NUM __API_INT_TYPE_BIT_NUM
# define __API_MTWM_CFG_SUPPORT_SOURCE_MASK 1
# define __API_MTWM_CFG_SUPPORT_OPACITY 1
# define __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1
# define get_pixel_colour_mask get_pixel_colour_src_chn_mask_opa
# define transform_with_mask transform_with_src_chn_mask_and_opacity
# include "__arm_2d_meta_trans_with_masks_helium.inc"
#endif
#undef ____ARM_2D_FUNC
#undef ___ARM_2D_FUNC
#undef __ARM_2D_FUNC
#undef __API_COLOUR
#undef __API_COLOUR_NAME
#undef __API_INT_TYPE
#undef __API_INT_TYPE_BIT_NUM

View File

@ -0,0 +1,154 @@
/*
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d.c
* Description: Tables for pixel pipeline OPs
*
* $Date: 11. Aug 2022
* $Revision: V.1.0.2
*
* Target Processor: Cortex-M cores
*
* -------------------------------------------------------------------- */
/*============================ INCLUDES ======================================*/
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#define __ARM_2D_COMPILATION_UNIT
#include "../Source/__arm_2d_core.c"
#define __ARM_2D_COMPILATION_UNIT
#include "../Source/__arm_2d_tile.c"
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
#if defined(__ARM_2D_HAS_CDE__) && !__ARM_2D_HAS_CDE__
# define __arm_2d_cde_init()
#endif
#if defined(__ARM_2D_HAS_HELIUM__) && !__ARM_2D_HAS_HELIUM__
# define __arm_2d_helium_init()
#endif
#if defined(__ARM_2D_HAS_HW_ACC__) && !__ARM_2D_HAS_HW_ACC__
# define __arm_2d_acc_init()
#endif
#if defined(__ARM_2D_HAS_ASYNC__) && !__ARM_2D_HAS_ASYNC__
# define __arm_2d_async_init(...)
#endif
#ifndef __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__
# define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ 4
#endif
#if __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ < 4
# warning The __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ should be larger than or\
equal to 4, set it to the default value 4.
# undef __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__
# define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ 4
#endif
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
/*!
* \brief initialise the arm-2d pipeline
* \param ptSubTasks an array of __arm_2d_sub_task_t objects
* \param hwCount the number of items in the array
* \return arm_2d_err_t error code
*/
extern
arm_2d_err_t __arm_2d_async_init( __arm_2d_sub_task_t *ptSubTasks,
uint_fast16_t hwCount);
#endif
#if defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__
/*!
* \brief initialise the helium acceleration
*/
extern
void __arm_2d_helium_init(void);
#endif
#if defined(__ARM_2D_HAS_CDE__) && __ARM_2D_HAS_CDE__
/*!
* \brief initialise the cde service
*/
extern
void __arm_2d_cde_init(void);
#endif
#if defined(__ARM_2D_HAS_HW_ACC__) && __ARM_2D_HAS_HW_ACC__
/*!
* \brief initialise the hardware accelerator adapter
*/
extern
void __arm_2d_acc_init(void);
#endif
/*!
* \brief initialise the arm-2d core service
*/
extern
void __arm_2d_init(void);
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/
/*!
* \brief initialise arm-2d
*/
void arm_2d_init(void)
{
__arm_2d_init();
do {
static __arm_2d_sub_task_t
s_tDefaultTaskPool[__ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__];
ARM_2D_UNUSED(s_tDefaultTaskPool);
__arm_2d_async_init(s_tDefaultTaskPool, dimof(s_tDefaultTaskPool));
} while(0);
__arm_2d_helium_init();
__arm_2d_cde_init();
__arm_2d_acc_init();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -21,8 +21,8 @@
* Title: arm-2d_async.c
* Description: Pixel pipeline extensions for support hardware acceleration.
*
* $Date: 29. April 2021
* $Revision: V.0.8.0
* $Date: 31. May 2022
* $Revision: V.1.0.2
*
* Target Processor: Cortex-M cores
*
@ -42,7 +42,6 @@ extern "C" {
#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
@ -64,10 +63,12 @@ extern "C" {
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wimplicit-fallthrough"
# pragma clang diagnostic ignored "-Wgnu-statement-expression"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_suppress 174,177,188,68,513,144
#elif defined(__IS_COMPILER_IAR__)
# pragma diag_suppress=Pa089,Pe188
#elif defined(__IS_COMPILER_GCC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wenum-compare"
# pragma GCC diagnostic ignored "-Wpedantic"
@ -75,16 +76,6 @@ extern "C" {
#endif
/*============================ MACROS ========================================*/
#ifndef __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE
# define __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE 4
#endif
#if __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE < 4
# warning The __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE should be larger than or\
equal to 3, set it to the default value 4.
# undef __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE
# define __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE 4
#endif
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
@ -376,9 +367,12 @@ void __arm_2d_notify_sub_task_cpl( __arm_2d_sub_task_t *ptTask,
assert(NULL != ptOP);
assert(ptOP->Status.u4SubTaskCount > 0);
//! free sub task
/* free sub task */
__arm_2d_sub_task_free(ptTask);
/* depose resources hold by the sub task */
__arm_2d_sub_task_depose(ptOP);
//if (bFromHW) {
arm_2d_notif_aync_sub_task_cpl(ptOP->pUserParam);
//}
@ -548,20 +542,17 @@ arm_fsm_rt_t __arm_2d_frontend_task(arm_2d_task_t *ptThis)
return arm_fsm_rt_on_going;
}
/*! \brief arm-2d pixel pipeline task entery
*! \note This function is *TRHEAD-SAFE*
*! \param none
*! \retval arm_fsm_rt_cpl The sub-task FIFO is empty, the caller, i.e. the host
*! RTOS thread can block itself by waiting for a semaphore which is
*! set by arm_2d_notif_sub_task_fifo_task_arrive()
*! \retval arm_fsm_rt_on_going The arm_2d_task issued one sub-task without
*! problem and it yields.
*! \retval arm_fsm_rt_async You shouldn't see this value
*! \retval arm_fsm_rt_wait_for_obj some algorithm or hardware accelerator wants
*! to sync-up with applications.
*! \retval (<0) Serious error is detected.
*/
/*!
* \brief arm-2d pixel pipeline task entery
* \note This function is *TRHEAD-SAFE*
* \param ptTask the address of an arm-2d task control block
* \retval arm_fsm_rt_cpl The sub-task FIFO is empty, the caller can wait for a
* semaphore set by arm_2d_notif_sub_task_fifo_task_arrive()
* \retval arm_fsm_rt_on_going The arm_2d_task yields
* \retval arm_fsm_rt_async You shouldn't see this value
* \retval arm_fsm_rt_wait_for_obj hardware accelerator wants to sync-up with applications.
* \retval (<0) Serious error is detected.
*/
arm_fsm_rt_t arm_2d_task(arm_2d_task_t *ptThis)
{
arm_fsm_rt_t tResult;
@ -886,24 +877,65 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_copy_origin(
}
__OVERRIDE_WEAK
arm_fsm_rt_t __arm_2d_issue_sub_task_copy_origin_masks(
arm_2d_op_cp_t *ptThis,
__arm_2d_tile_param_t *ptSource,
__arm_2d_tile_param_t *ptOrigin,
__arm_2d_tile_param_t *ptOriginMask,
__arm_2d_tile_param_t *ptTarget,
__arm_2d_tile_param_t *ptTargetMask,
arm_2d_size_t * __RESTRICT ptCopySize)
{
__arm_2d_sub_task_t *ptTask = __arm_2d_sub_task_new();
assert(NULL != ptTask);
(*ptTask) = (__arm_2d_sub_task_t) {
.ptOP = &(ptThis->use_as__arm_2d_op_core_t),
.chLowLeveIOIndex = 0,
.Param.tCopyOrigMask = {
.use_as____arm_2d_param_copy_orig_t = {
.use_as____arm_2d_param_copy_t = {
.tSource = *ptSource,
.tTarget = *ptTarget,
.tCopySize = *ptCopySize,
},
.tOrigin = *ptOrigin,
},
.tOrigMask = *ptOriginMask,
.tDesMask = *ptTargetMask,
},
};
OP_CORE.Status.u4SubTaskCount++;
__arm_2d_sub_task_add(ptTask);
return arm_fsm_rt_async;
}
/*! \brief initialise the whole arm-2d service
*! \param none
*! \return none
/*!
* \brief initialise the arm-2d pipeline
* \param ptSubTasks an array of __arm_2d_sub_task_t objects
* \param hwCount the number of items in the array
* \return arm_2d_err_t error code
*/
void __arm_2d_async_init(void)
arm_2d_err_t __arm_2d_async_init( __arm_2d_sub_task_t *ptSubTasks,
uint_fast16_t hwCount)
{
if ((NULL == ptSubTasks) || (0 == hwCount )) {
return ARM_2D_ERR_INSUFFICIENT_RESOURCE;
}
//! initialise sub task pool
do {
static __arm_2d_sub_task_t
s_tDefaultTaskPool[__ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE];
arm_foreach(__arm_2d_sub_task_t, s_tDefaultTaskPool) {
__arm_2d_sub_task_free(_);
}
} while(0);
__arm_2d_sub_task_free(ptSubTasks++);
} while(--hwCount);
return ARM_2D_ERR_NONE;
}
@ -914,9 +946,10 @@ bool arm_2d_port_wait_for_async(uintptr_t pUserParam)
}
__OVERRIDE_WEAK
/*! \brief sync up with operation
*! \retval true operation is busy
*! \retval false operation isn't busy
/*!
* \brief wait asynchronouse operation complete
* \retval true sync up with operation
* \retval false operation is busy
*/
bool arm_2d_op_wait_async(arm_2d_op_core_t *ptOP)
{
@ -979,16 +1012,6 @@ bool __arm_2d_op_acquire(arm_2d_op_core_t *ptOP)
return !bResult;
}
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_warning 174,177,188,68,513,144
#elif defined(__IS_COMPILER_GCC__)
# pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -21,8 +21,8 @@
* Title: arm-2d_draw.c
* Description: APIs for colour format conversion
*
* $Date: 29. April 2021
* $Revision: V.0.8.0
* $Date: 08. Aug 2022
* $Revision: V.1.0.2
*
* Target Processor: Cortex-M cores
*
@ -40,7 +40,6 @@ extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
@ -61,6 +60,7 @@ extern "C" {
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wswitch-enum"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_suppress 174,177,188,68,513,144
#endif
@ -71,6 +71,12 @@ extern "C" {
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
void __arm_2d_impl_gray8_to_rgb565( uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint16_t *__RESTRICT phwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize);
void __arm_2d_impl_cccn888_to_rgb565(uint32_t *__RESTRICT pwSource,
int16_t iSourceStride,
uint16_t *__RESTRICT phwTarget,
@ -83,6 +89,23 @@ void __arm_2d_impl_rgb565_to_cccn888(uint16_t *__RESTRICT phwSourceBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize);
void __arm_2d_impl_gray8_to_cccn888(uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint32_t *__RESTRICT pwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize);
void __arm_2d_impl_rgb565_to_gray8( uint16_t *__RESTRICT phwSourceBase,
int16_t iSourceStride,
uint8_t *__RESTRICT pchTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize);
void __arm_2d_impl_cccn888_to_gray8(uint32_t *__RESTRICT pwSource,
int16_t iSourceStride,
uint8_t *__RESTRICT pchwTarget,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize);
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/
@ -91,6 +114,13 @@ void __arm_2d_impl_rgb565_to_cccn888(uint16_t *__RESTRICT phwSourceBase,
* Convert Colour format *
*----------------------------------------------------------------------------*/
/*!
* \brief convert the colour format of a given tile to rgb888
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_rgb888( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
@ -116,7 +146,13 @@ arm_fsm_rt_t arm_2dp_convert_colour_to_rgb888( arm_2d_op_cl_convt_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief convert the colour format of a given tile to rgb565
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_rgb565( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
@ -142,10 +178,39 @@ arm_fsm_rt_t arm_2dp_convert_colour_to_rgb565( arm_2d_op_cl_convt_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief convert the colour format of a given tile to gray8
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptSource the source tile
* \param[out] ptTarget the output tile (holding a buffer)
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_convert_colour_to_gray8( arm_2d_op_cl_convt_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget)
{
assert(NULL != ptSource);
assert(NULL != ptTarget);
ARM_2D_IMPL(arm_2d_op_cl_convt_t, ptOP);
if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}
//memset(ptThis, 0, sizeof(*ptThis));
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(
__arm_2d_sub_task_t *ptTask)
OP_CORE.ptOp = &ARM_2D_OP_CONVERT_TO_GRAY8;
this.Target.ptTile = ptTarget;
this.Target.ptRegion = NULL;
this.Source.ptTile = ptSource;
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_gray8(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_cl_convt_t, ptTask->ptOP);
@ -155,6 +220,48 @@ arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(
switch ( this.Source.ptTile->tInfo.tColourInfo.u3ColourSZ) {
case ARM_2D_COLOUR_8BIT:
/* no need to convert, return cpl directly */
break;
case ARM_2D_COLOUR_SZ_16BIT:
__arm_2d_impl_rgb565_to_gray8( ptTask->Param.tCopy.tSource.pBuffer,
ptTask->Param.tCopy.tSource.iStride,
ptTask->Param.tCopy.tTarget.pBuffer,
ptTask->Param.tCopy.tTarget.iStride,
&(ptTask->Param.tCopy.tCopySize));
break;
case ARM_2D_COLOUR_SZ_32BIT:
__arm_2d_impl_cccn888_to_gray8( ptTask->Param.tCopy.tSource.pBuffer,
ptTask->Param.tCopy.tSource.iStride,
ptTask->Param.tCopy.tTarget.pBuffer,
ptTask->Param.tCopy.tTarget.iStride,
&(ptTask->Param.tCopy.tCopySize));
break;
default:
return (arm_fsm_rt_t)ARM_2D_ERR_UNSUPPORTED_COLOUR;
}
return arm_fsm_rt_cpl;
}
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_cl_convt_t, ptTask->ptOP);
if (!this.Source.ptTile->bHasEnforcedColour) {
return (arm_fsm_rt_t)ARM_2D_ERR_MISSING_PARAM;
}
switch ( this.Source.ptTile->tInfo.tColourInfo.u3ColourSZ) {
case ARM_2D_COLOUR_8BIT:
__arm_2d_impl_gray8_to_rgb565( ptTask->Param.tCopy.tSource.pBuffer,
ptTask->Param.tCopy.tSource.iStride,
ptTask->Param.tCopy.tTarget.pBuffer,
ptTask->Param.tCopy.tTarget.iStride,
&(ptTask->Param.tCopy.tCopySize));
break;
case ARM_2D_COLOUR_SZ_16BIT:
/* no need to convert, return cpl directly */
break;
@ -172,8 +279,7 @@ arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb565(
return arm_fsm_rt_cpl;
}
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(
__arm_2d_sub_task_t *ptTask)
arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_cl_convt_t, ptTask->ptOP);
@ -183,6 +289,13 @@ arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(
switch ( this.Source.ptTile->tInfo.tColourInfo.u3ColourSZ) {
case ARM_2D_COLOUR_8BIT:
__arm_2d_impl_gray8_to_cccn888( ptTask->Param.tCopy.tSource.pBuffer,
ptTask->Param.tCopy.tSource.iStride,
ptTask->Param.tCopy.tTarget.pBuffer,
ptTask->Param.tCopy.tTarget.iStride,
&(ptTask->Param.tCopy.tCopySize));
break;
case ARM_2D_COLOUR_SZ_16BIT:
__arm_2d_impl_rgb565_to_cccn888( ptTask->Param.tCopy.tSource.pBuffer,
ptTask->Param.tCopy.tSource.iStride,
@ -204,6 +317,35 @@ arm_fsm_rt_t __arm_2d_sw_convert_colour_to_rgb888(
* Accelerable Low Level APIs *
*----------------------------------------------------------------------------*/
__WEAK
void __arm_2d_impl_gray8_to_rgb565( uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint16_t *__RESTRICT phwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint8_t *__RESTRICT pchSource = pchSourceBase;
uint16_t *__RESTRICT phwTarget = phwTargetBase;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
__arm_2d_color_fast_rgb_t hwTargetPixel;
uint_fast8_t chColour = *pchSource++;
hwTargetPixel.R = chColour;
hwTargetPixel.G = chColour;
hwTargetPixel.B = chColour;
*phwTarget++ = __arm_2d_rgb565_pack(&hwTargetPixel);
}
pchSourceBase += iSourceStride;
phwTargetBase += iTargetStride;
}
}
__WEAK
void __arm_2d_impl_cccn888_to_rgb565(uint32_t *__RESTRICT pwSourceBase,
int16_t iSourceStride,
@ -217,7 +359,7 @@ void __arm_2d_impl_cccn888_to_rgb565(uint32_t *__RESTRICT pwSourceBase,
uint16_t *__RESTRICT phwTarget = phwTargetBase;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
arm_2d_color_rgba8888_t wSrcPixel;
arm_2d_color_bgra8888_t wSrcPixel;
__arm_2d_color_fast_rgb_t hwTargetPixel;
wSrcPixel.tValue = *pwSource++;
@ -233,6 +375,35 @@ void __arm_2d_impl_cccn888_to_rgb565(uint32_t *__RESTRICT pwSourceBase,
}
}
__WEAK
void __arm_2d_impl_gray8_to_cccn888(uint8_t *__RESTRICT pchSourceBase,
int16_t iSourceStride,
uint32_t *__RESTRICT pwTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint8_t *__RESTRICT pchSource = pchSourceBase;
uint32_t *__RESTRICT pwTarget = pwTargetBase;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
uint_fast8_t chPixel = *pchSource++;
arm_2d_color_bgra8888_t wTargetPixel;
wTargetPixel.u8R = chPixel;
wTargetPixel.u8G = chPixel;
wTargetPixel.u8B = chPixel;
wTargetPixel.u8A = 0xFF;
*pwTarget++ = wTargetPixel.tValue;
}
pchSourceBase += iSourceStride;
pwTargetBase += iTargetStride;
}
}
__WEAK
void __arm_2d_impl_rgb565_to_cccn888(uint16_t *__RESTRICT phwSourceBase,
int16_t iSourceStride,
@ -247,7 +418,7 @@ void __arm_2d_impl_rgb565_to_cccn888(uint16_t *__RESTRICT phwSourceBase,
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
__arm_2d_color_fast_rgb_t hwSrcPixel;
arm_2d_color_rgba8888_t wTargetPixel;
arm_2d_color_bgra8888_t wTargetPixel;
__arm_2d_rgb565_unpack(*phwSource++, &hwSrcPixel);
wTargetPixel.u8R = hwSrcPixel.R;
@ -263,18 +434,98 @@ void __arm_2d_impl_rgb565_to_cccn888(uint16_t *__RESTRICT phwSourceBase,
}
__WEAK
void __arm_2d_impl_rgb565_to_gray8( uint16_t *__RESTRICT phwSourceBase,
int16_t iSourceStride,
uint8_t *__RESTRICT pchTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint16_t *__RESTRICT phwSource = phwSourceBase;
uint8_t *__RESTRICT pchTarget = pchTargetBase;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
__arm_2d_color_fast_rgb_t hwSrcPixel;
uint_fast16_t hwPixel = 0;
__arm_2d_rgb565_unpack(*phwSource++, &hwSrcPixel);
hwPixel += hwSrcPixel.R;
hwPixel += hwSrcPixel.G;
hwPixel += hwSrcPixel.B;
*pchTarget++ = hwPixel / 3;
}
phwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
}
__WEAK
void __arm_2d_impl_cccn888_to_gray8(uint32_t *__RESTRICT pwSourceBase,
int16_t iSourceStride,
uint8_t *__RESTRICT pchTargetBase,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {
const uint32_t *__RESTRICT pwSource = pwSourceBase;
uint8_t *__RESTRICT pchTarget = pchTargetBase;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++) {
arm_2d_color_bgra8888_t wSrcPixel;
uint_fast16_t hwPixel = 0;
wSrcPixel.tValue = *pwSource++;
hwPixel += wSrcPixel.u8R;
hwPixel += wSrcPixel.u8G;
hwPixel += wSrcPixel.u8B;
*pchTarget++ = hwPixel / 3;
}
pwSourceBase += iSourceStride;
pchTargetBase += iTargetStride;
}
}
/*----------------------------------------------------------------------------*
* Low Level IO Interfaces *
*----------------------------------------------------------------------------*/
__WEAK
def_low_lv_io(__ARM_2D_IO_COLOUR_CONVERT_TO_RGB565,
def_low_lv_io( __ARM_2D_IO_COLOUR_CONVERT_TO_GRAY8,
__arm_2d_sw_convert_colour_to_gray8);
__WEAK
def_low_lv_io( __ARM_2D_IO_COLOUR_CONVERT_TO_RGB565,
__arm_2d_sw_convert_colour_to_rgb565);
__WEAK
def_low_lv_io(__ARM_2D_IO_COLOUR_CONVERT_TO_RGB888,
def_low_lv_io( __ARM_2D_IO_COLOUR_CONVERT_TO_RGB888,
__arm_2d_sw_convert_colour_to_rgb888);
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_GRAY8 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_GRAY8,
},
.Param = {
.bHasSource = true,
.bHasTarget = true,
.bAllowEnforcedColour = true,
},
.chOpIndex = __ARM_2D_OP_IDX_COLOUR_FORMAT_CONVERSION,
.LowLevelIO = {
.ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COLOUR_CONVERT_TO_GRAY8),
.ptFillLike = NULL,
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB565 = {
.Info = {
.Colour = {
@ -293,12 +544,12 @@ const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB565 = {
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB888 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_RGB888,
.chScheme = ARM_2D_COLOUR_CCCN888,
},
.Param = {
.bHasSource = true,
@ -314,12 +565,6 @@ const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB888 = {
},
};
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_warning 174,177,188,68,513,144
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@ -21,8 +21,8 @@
* Title: arm-2d_draw.c
* Description: APIs for basic drawing
*
* $Date: 08. Sep 2021
* $Revision: V.0.9.0
* $Date: 21. April 2022
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
*
@ -40,7 +40,6 @@ extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
@ -61,15 +60,13 @@ extern "C" {
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wswitch-enum"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_suppress 174,177,188,68,513,144
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define TO_Q16(x) ((int32_t)(x) << 16)
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
@ -113,141 +110,26 @@ extern "C" {
#define __API_INT_TYPE uint32_t
#include "__arm_2d_draw_pattern.inc"
/*----------------------------------------------------------------------------*
* Utilities *
*----------------------------------------------------------------------------*/
__arm_2d_point_adj_alpha_t
__arm_2d_point_get_adjacent_alpha_fp(arm_2d_point_float_t *ptPoint)
{
assert(NULL != ptPoint);
float x = ptPoint->fX - (int32_t)ptPoint->fX;
float y = ptPoint->fY - (int32_t)ptPoint->fY;
int16_t iXSign = x < 0 ? 1 : 0;
int16_t iYSign = y < 0 ? 1 : 0;
__arm_2d_point_adj_alpha_t tResult = {
.tMatrix = {
[0] = {
.tOffset = {
.iX = -iXSign,
.iY = -iYSign,
},
.chAlpha = (uint8_t)(
((float)(1-iXSign) - (float)x) //!< x
* ((float)(1-iYSign) - (float)y) //!< y
* 256.0f
),
},
[1] = {
.tOffset = {
.iX = -iXSign + 1,
.iY = -iYSign,
},
.chAlpha = (uint8_t)(
((float)iXSign + (float)x) //!< x
* ((float)(1-iYSign) - (float)y) //!< y
* 256.0f
),
},
[2] = {
.tOffset = {
.iX = -iXSign,
.iY = -iYSign + 1,
},
.chAlpha = (uint8_t)(
((float)(1-iXSign) - (float)x) //!< x
* ((float)iYSign + (float)y) //!< y
* 256.0f
),
},
[3] = {
.tOffset = {
.iX = -iXSign + 1,
.iY = -iYSign +1,
},
.chAlpha = (uint8_t)(
((float)iXSign + (float)x) //!< x
* ((float)iYSign + (float)y) //!< y
* 256.0f
),
},
},
};
return tResult;
}
__arm_2d_point_adj_alpha_t
__arm_2d_point_get_adjacent_alpha_q16(arm_2d_point_fx_t *ptPoint)
{
assert(NULL != ptPoint);
int32_t x = ptPoint->X & 0xFFFF;
int32_t y = ptPoint->Y & 0xFFFF;
x |= ((ptPoint->X < 0) * 0xFFFF0000);
y |= ((ptPoint->Y < 0) * 0xFFFF0000);
int_fast16_t iXSign = x < 0;// ? 1 : 0;
int_fast16_t iYSign = y < 0;// ? 1 : 0;
__arm_2d_point_adj_alpha_t tResult = {
.tMatrix = {
[0] = {
.tOffset = {
.iX = -iXSign,
.iY = -iYSign,
},
.chAlpha = (uint8_t)__USAT(
MUL_Q16(MUL_Q16( (TO_Q16(1-iXSign) - x) //!< x
, (TO_Q16(1-iYSign) - y)) //!< y
, TO_Q16(256)
) >> 16, 8),
},
[1] = {
.tOffset = {
.iX = -iXSign + 1,
.iY = -iYSign,
},
.chAlpha = (uint8_t)__USAT(
MUL_Q16(MUL_Q16( (TO_Q16(iXSign) + x) //!< x
, (TO_Q16(1-iYSign) - y)) //!< y
, TO_Q16(256)
) >> 16, 8),
},
[2] = {
.tOffset = {
.iX = -iXSign,
.iY = -iYSign + 1,
},
.chAlpha = (uint8_t)__USAT(
MUL_Q16(MUL_Q16( (TO_Q16(1-iXSign) - x) //!< x
, (TO_Q16(iYSign) + y)) //!< y
, TO_Q16(256)
) >> 16, 8),
},
[3] = {
.tOffset = {
.iX = -iXSign + 1,
.iY = -iYSign +1,
},
.chAlpha = (uint8_t)__USAT(
MUL_Q16(MUL_Q16( (TO_Q16(iXSign) + x) //!< x
, (TO_Q16(iYSign) + y)) //!< y
, TO_Q16(256)
) >> 16, 8),
},
},
};
return tResult;
}
/*----------------------------------------------------------------------------*
* Draw a point with specified colour *
*----------------------------------------------------------------------------*/
/*!
* \brief draw a point with a given 8bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] chColour an 8bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_c8bit_draw_point( arm_2d_op_drw_pt_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -279,6 +161,21 @@ arm_fsm_rt_t arm_2dp_c8bit_draw_point( arm_2d_op_drw_pt_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief draw a point with a given 16bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] hwColour an 16bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb16_draw_point( arm_2d_op_drw_pt_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -310,7 +207,21 @@ arm_fsm_rt_t arm_2dp_rgb16_draw_point( arm_2d_op_drw_pt_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief draw a point with a given 32bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target root tile
* \param[in] tLocation the target location
* \param[in] wColour an 32bit colour
* \return arm_fsm_rt_t the operation result
*
* \note As those draw point APIs involve the region calculation
* which is only useful when partial framebuffer is used, it is slow.
* For gettting better performance, if the target tile is root and the
* target location is inside the target region, please use the
* functions with "_fast" posfix.
*
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb32_draw_point( arm_2d_op_drw_pt_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -368,6 +279,14 @@ arm_fsm_rt_t __arm_2d_sw_draw_point(__arm_2d_sub_task_t *ptTask)
* Fill tile with a specified colour *
*----------------------------------------------------------------------------*/
/*!
* \brief fill the target region with a given 8bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] chColour a 8bit colour
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_c8bit_fill_colour( arm_2d_op_fill_cl_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -393,6 +312,14 @@ arm_fsm_rt_t arm_2dp_c8bit_fill_colour( arm_2d_op_fill_cl_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief fill the target region with a given 16bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] hwColour a 16bit colour
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb16_fill_colour( arm_2d_op_fill_cl_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -418,6 +345,14 @@ arm_fsm_rt_t arm_2dp_rgb16_fill_colour( arm_2d_op_fill_cl_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief fill the target region with a given 32bit colour
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wColour a 32bit colour
* \return arm_fsm_rt_t the operations result
*/
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb32_fill_colour( arm_2d_op_fill_cl_t *ptOP,
const arm_2d_tile_t *ptTarget,
@ -490,6 +425,17 @@ arm_fsm_rt_t __arm_2d_rgb32_sw_colour_filling(__arm_2d_sub_task_t *ptTask)
* Draw a bit patterns *
*----------------------------------------------------------------------------*/
/*!
* \brief copy a bit-pattern with given 8bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] chForeColour the foreground colour
* \param[in] chBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_c8bit_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
const arm_2d_tile_t *ptPattern,
@ -532,6 +478,17 @@ arm_fsm_rt_t arm_2dp_c8bit_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief copy a bit-pattern with given 16bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] hwForeColour the foreground colour
* \param[in] hwBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb16_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
const arm_2d_tile_t *ptPattern,
@ -573,7 +530,17 @@ arm_fsm_rt_t arm_2dp_rgb16_draw_pattern( arm_2d_op_drw_patn_t *ptOP,
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*!
* \brief copy a bit-pattern with given 32bit colours
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptPattern the source bit pattern
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] wMode the copy mode
* \param[in] wForeColour the foreground colour
* \param[in] wBackColour the background colour
* \return arm_fsm_rt_t the operation result
*/
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb32_draw_pattern(arm_2d_op_drw_patn_t *ptOP,
const arm_2d_tile_t *ptPattern,
@ -941,12 +908,6 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_RGB32 = {
},
};
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_warning 174,177,188,68,513,144
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,183 +0,0 @@
/*
* Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d_utils_helium.h
* Description: Provides helium utility routines
*
* $Date: 20. May 2021
* $Revision: V 0.0.1
*
* Target Processor: Cortex-M cores with Helium
*
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_UTILS_HELIUM_H__
#define __ARM_2D_UTILS_HELIUM_H__
#if __ARM_2D_HAS_HELIUM_INTEGER__ == 1
/*============================ INCLUDES ======================================*/
#include "arm_2d.h"
#include <arm_math.h>
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
__STATIC_FORCEINLINE
void __arm_2d_rgb565_unpack_single_vec(uint16x8_t in,
uint16x8_t * R, uint16x8_t * G, uint16x8_t * B)
{
uint16x8_t vecMaskR = vdupq_n_u16(0x001f);
uint16x8_t vecMaskG = vdupq_n_u16(0x003f);
*R = (in & vecMaskR) * 8;
*B = ((in >> 11)) * 8;
*G = ((in >> 5) & vecMaskG) * 4;
}
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_pack_single_vec(uint16x8_t R, uint16x8_t G, uint16x8_t B)
{
uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8);
uint16x8_t vecMaskGpck = vdupq_n_u16(0x00fc);
uint16x8_t vOut = vorrq(vshrq(R, 3),
vmulq(vandq(G, vecMaskGpck), 8));
vOut = vorrq(vOut, vmulq(vandq(B, vecMaskBpck), 256));
return vOut;
}
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_alpha_blending_single_vec(
uint16x8_t hwSource1,
uint16x8_t hwSource2,
uint_fast8_t chRatio)
{
uint16_t ratio1x8 = (256 - chRatio) * 8;
uint16_t ratio1x4 = (256 - chRatio) * 4;
uint16_t ratio2x8 = (chRatio) * 8;
uint16_t ratio2x4 = (chRatio) * 4;
uint16x8_t vecMaskR = vdupq_n_u16(0x001f);
uint16x8_t vecMaskG = vdupq_n_u16(0x003f);
uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8);
uint16x8_t vecMaskGpck = vdupq_n_u16(0x00fc);
uint16x8_t vecR0, vecB0, vecG0;
uint16x8_t vecR1, vecB1, vecG1;
/* unpack 1st stream */
vecR0 = hwSource1 & vecMaskR;
vecB0 = hwSource1 >> 11;
vecG0 = hwSource1 >> 5;
vecG0 = vecG0 & vecMaskG;
/* unpack 2nd stream */
vecR1 = hwSource2 & vecMaskR;
vecB1 = hwSource2 >> 11;
vecG1 = hwSource2 >> 5;
vecG1 = vecG1 & vecMaskG;
/* merge */
vecR0 = vecR0 * ratio1x8 + vecR1 * ratio2x8;
vecR0 = vecR0 >> 8;
vecG0 = vecG0 * ratio1x4 + vecG1 * ratio2x4;
vecG0 = vecG0 >> 8;
vecB0 = vecB0 * ratio1x8 + vecB1 * ratio2x8;
vecB0 = vecB0 >> 8;
/* pack */
return vecR0 >> 3 | vmulq((vecG0 & vecMaskGpck), 8)
| vmulq((vecB0 & vecMaskBpck), 256);
}
__STATIC_FORCEINLINE
uint16x8_t __arm_2d_rgb565_blending_opacity_single_vec(
uint16x8_t hwSource1,
uint16x8_t hwSource2,
uint16x8_t vecHwOpacity)
{
uint16x8_t vecAlpha = vsubq_u16(vdupq_n_u16(256), vecHwOpacity);
uint16x8_t vecR, vecG, vecB;
uint16x8_t vecSrcR, vecSrcG, vecSrcB;
/* unpack sources */
__arm_2d_rgb565_unpack_single_vec(hwSource1, &vecR, &vecG, &vecB);
__arm_2d_rgb565_unpack_single_vec(hwSource2, &vecSrcR, &vecSrcG, &vecSrcB);
/* merge */
vecR = vecR * vecHwOpacity + vecSrcR * vecAlpha;
vecR = vecR >> 8;
vecG = vecG * vecHwOpacity + vecSrcG * vecAlpha;
vecG = vecG >> 8;
vecB = vecB * vecHwOpacity + vecSrcB * vecAlpha;
vecB = vecB >> 8;
/* pack */
return __arm_2d_rgb565_pack_single_vec(vecR, vecG, vecB);
}
__STATIC_FORCEINLINE
uint16x8_t __rgb888_alpha_blending_direct_single_vec(
uint16x8_t wSource1, /* widened input bytes */
uint16x8_t wSource2, /* widened input bytes */
uint_fast8_t chRatio)
{
uint16_t chRatioCompl = 256 - (uint16_t) chRatio;
uint16x8_t vecOut;
vecOut = vmulq_n_u16(wSource1, (uint16_t) chRatio);
vecOut = vmlaq_n_u16(vecOut, wSource2, chRatioCompl);
/* widened output */
return vecOut >> 8;
}
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
#ifdef __cplusplus
}
#endif
#endif // (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI)
#endif // __ARM_2D_UTILS_HELIUM_H__

View File

@ -1,194 +0,0 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d.h"
* Description: Public header file to contain the all avaialble Arm-2D
* interface header files
*
* $Date: 01. December 2020
* $Revision: V.0.5.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_H__
#define __ARM_2D_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#include "arm_2d_op.h"
#include "arm_2d_tile.h"
#include "arm_2d_draw.h"
#include "arm_2d_conversion.h"
#include "arm_2d_alpha_blending.h"
#include "arm_2d_rotation.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
typedef struct {
uint8_t TREAT_OUT_OF_RANGE_AS_COMPLETE : 1;
uint8_t HAS_DEDICATED_THREAD_FOR_2D_TASK : 1;
uint8_t : 6;
} arm_2d_runtime_feature_t;
/*============================ GLOBAL VARIABLES ==============================*/
extern
arm_2d_runtime_feature_t ARM_2D_RUNTIME_FEATURE;
/*============================ PROTOTYPES ====================================*/
#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
/*! \brief initialise the whole arm-2d service
*! \param none
*! \return none
*/
extern
void __arm_2d_async_init(void);
#endif
#if defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__
/*! \brief initialise the helium service
*! \param none
*! \return none
*/
extern
void __arm_2d_helium_init(void);
#endif
#if defined(__ARM_2D_HAS_CDE__) && __ARM_2D_HAS_CDE__
/*! \brief initialise the cde service
*! \param none
*! \return none
*/
extern
void __arm_2d_cde_init(void);
#endif
#if defined(__ARM_2D_HAS_HW_ACC__) && __ARM_2D_HAS_HW_ACC__
/*! \brief initialise the hardware accelerator adapter
*! \param none
*! \return none
*/
extern
void __arm_2d_acc_init(void);
#endif
/*! \brief initialise the whole arm-2d service
*! \param none
*! \return none
*/
extern
void __arm_2d_init(void);
/*! \brief set the default frame buffer
*! \param ptFramebuffer the new frame buffer, if NULL is given, no default
*! frame buffer will be used
*! \return the address of the old frame buffer
*/
extern
arm_2d_tile_t *arm_2d_set_default_frame_buffer(
const arm_2d_tile_t *ptFrameBuffer);
/*! \brief get the default frame buffer
*! \return the address of the default frame buffer
*/
extern
arm_2d_tile_t *arm_2d_get_default_frame_buffer(void);
/*! \brief attach a user param (which could be a pointer) to specified OP
*! \param ptOP the address of the target OP (NULL means using the default OP)
*! \param pUserParam a user param (it can be used as a pointer)
*/
extern
void arm_2d_set_user_param(arm_2d_op_core_t *ptOP, uintptr_t pUserParam);
/*! \brief sync up with operation
*! \retval true sync up with operation
*! \retval false operation is busy
*/
extern
bool arm_2d_op_wait_async(arm_2d_op_core_t *ptOP);
/*! \brief get the status of a specified OP, usually, it is used after calling
*! arm_2d_op_wait_async().
*! E.g.
//! wait for previous operation complete
do {
arm_2d_op_wait_async();
arm_2d_op_status_t tStatus = arm_2d_get_op_status();
if (tStatus.bIOError) {
//! error detected
...
} else if (tStatus.bOpCpl) {
break;
}
} while(true);
*!
*! \param ptOP the address of the target OP (NULL means using the default OP)
*! \return the status
*/
extern
arm_2d_op_status_t arm_2d_get_op_status(arm_2d_op_core_t *ptOP);
/*! \brief arm-2d pixel pipeline task entery
*! \note This function is *TRHEAD-SAFE*
*! \param none
*! \retval arm_fsm_rt_cpl The sub-task FIFO is empty, the caller, i.e. the host
*! RTOS thread can block itself by waiting for a semaphore which is
*! set by arm_2d_notif_sub_task_fifo_task_arrive()
*! \retval arm_fsm_rt_on_going The arm_2d_task issued one sub-task without
*! problem and it yields.
*! \retval arm_fsm_rt_async You shouldn't see this value
*! \retval arm_fsm_rt_wait_for_obj some algorithm or hardware accelerator wants
*! to sync-up with applications.
*! \retval (<0) Serious error is detected.
*/
extern
arm_fsm_rt_t arm_2d_task(arm_2d_task_t *ptTask);
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,334 +0,0 @@
/*
* Copyright (c) 2009-2020 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ARM_2D_HELPER_PFB_H__
#define __ARM_2D_HELPER_PFB_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
# pragma clang diagnostic ignored "-Wpadded"
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define ARM_2D_HELPER_PFB_INIT( __CB_ADDR, /* PFB Helper object address */ \
__SCREEN_WIDTH, /* Screen width */ \
__SCREEN_HEIGHT,/* Screen height */ \
__PIXEL_TYPE, /* The type of the pixels */ \
__WIDTH, /* The width of the PFB block */\
__HEIGHT, /* The height of the PFB block*/\
__PFB_NUM, /* Block count in the PFB pool*/\
... /* Event Handler */ \
) \
({ \
__attribute__((section(".bss.noinit.arm_2d_pfb_pool"))) \
static struct { \
arm_2d_pfb_t tFPB; \
__ALIGNED(4) \
__PIXEL_TYPE tBuffer[(__WIDTH) * (__HEIGHT)]; \
} s_tPFBs[__PFB_NUM]; \
\
arm_2d_helper_pfb_cfg_t tCFG = { \
.tDisplayArea.tSize = { \
.iWidth = (__SCREEN_WIDTH), \
.iHeight = (__SCREEN_HEIGHT), \
}, \
\
.FrameBuffer.ptPFBs = (arm_2d_pfb_t *)s_tPFBs, \
.FrameBuffer.tFrameSize = { \
.iWidth = (__WIDTH), \
.iHeight = (__HEIGHT), \
}, \
.FrameBuffer.wBufferSize = sizeof(s_tPFBs[0].tBuffer), \
.FrameBuffer.hwPFBNum = dimof(s_tPFBs), \
.Dependency = \
__VA_ARGS__ \
}; \
\
arm_2d_helper_pfb_init((__CB_ADDR), &tCFG); \
})
#define ARM_2D_HELPER_PFB_UPDATE_ON_DRAW_HANDLER( \
__CB_ADDR, /* PFB Helper object address */ \
__HANDLER, /* new on-draw-handler function*/\
...) /* An optional target address */ \
arm_2d_helper_pfb_update_dependency((__CB_ADDR), \
ARM_2D_PFB_DEPEND_ON_DRAWING, \
&(arm_2d_helper_pfb_dependency_t) { \
.evtOnDrawing = { \
.fnHandler = __HANDLER, \
.pTarget = (NULL,##__VA_ARGS__),\
}, \
})
#define __IMPL_ARM_2D_REGION_LIST(__NAME, ...) \
enum { \
__NAME##_offset = __COUNTER__, \
}; \
__VA_ARGS__ \
arm_2d_region_list_item_t __NAME[] = {
#define IMPL_ARM_2D_REGION_LIST(__NAME, ...) \
__IMPL_ARM_2D_REGION_LIST(__NAME,##__VA_ARGS__)
#define END_IMPL_ARM_2D_REGION_LIST(...) \
};
#define __ADD_REGION_TO_LIST(__NAME, ...) \
{ \
.ptNext = (arm_2d_region_list_item_t *) \
&(__NAME[__COUNTER__ - __NAME##_offset]), \
.tRegion = { \
__VA_ARGS__ \
}, \
}
#define ADD_REGION_TO_LIST(__NAME, ...) \
__ADD_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define __ADD_LAST_REGION_TO_LIST(__NAME, ...) \
{ \
.ptNext = NULL, \
.tRegion = { \
__VA_ARGS__ \
}, \
}
#define ADD_LAST_REGION_TO_LIST(__NAME, ...) \
__ADD_LAST_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define IMPL_PFB_ON_DRAW(__NAME) \
arm_fsm_rt_t __NAME(void *pTarget, \
const arm_2d_tile_t *ptTile, \
bool bIsNewFrame)
#define IMPL_PFB_ON_LOW_LV_RENDERING(__NAME) \
void __NAME(void *pTarget, \
const arm_2d_pfb_t *ptPFB, \
bool bIsNewFrame)
#define IMPL_PFB_ON_FRAME_SYNC_UP(__NAME) \
bool __NAME(void *pTarget)
/*! \note add macros in lower-case and make sure everyone can choose what they
*! like.
*/
//@{
#define init_arm_2d_helper_pfb( __CB_ADDR, \
__SCREEN_WIDTH, \
__SCREEN_HEIGHT, \
__PIXEL_TYPE, \
__WIDTH, \
__HEIGHT, \
__PFB_NUM, \
... \
) \
ARM_2D_HELPER_PFB_INIT( \
__CB_ADDR, \
__SCREEN_WIDTH, \
__SCREEN_HEIGHT, \
__PIXEL_TYPE, \
__WIDTH, \
__HEIGHT, \
__PFB_NUM, \
##__VA_ARGS__ \
)
#define impl_arm_2d_region_list(__NAME, ...) \
IMPL_ARM_2D_REGION_LIST(__NAME,##__VA_ARGS__)
#define add_region_to_list(__NAME, ...) \
ADD_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define add_last_region_to_list(__NAME, ...) \
ADD_LAST_REGION_TO_LIST(__NAME, ##__VA_ARGS__)
#define end_impl_arm_2d_region_list(...) \
END_IMPL_ARM_2D_REGION_LIST(__VA_ARGS__)
#define impl_pfb_on_draw(__NAME) IMPL_PFB_ON_DRAW(__NAME)
#define impl_pfb_on_low_lv_rendering(__NAME) \
IMPL_PFB_ON_LOW_LV_RENDERING(__NAME)
//! @}
/*============================ TYPES =========================================*/
typedef struct arm_2d_pfb_t {
struct arm_2d_pfb_t *ptNext;
arm_2d_tile_t tTile;
bool bIsNewFrame;
}arm_2d_pfb_t;
typedef struct arm_2d_region_list_item_t {
struct arm_2d_region_list_item_t *ptNext;
arm_2d_region_t tRegion;
}arm_2d_region_list_item_t;
typedef arm_fsm_rt_t arm_2d_helper_draw_handler_t(
void *pTarget,
const arm_2d_tile_t *ptTile,
bool bIsNewFrame);
typedef void arm_2d_helper_render_handler_t(
void *pTarget,
const arm_2d_pfb_t *ptPFB,
bool bIsNewFrame);
typedef struct arm_2d_helper_render_evt_t {
arm_2d_helper_render_handler_t *fnHandler; //!< event handler function
void *pTarget; //!< user attached target
} arm_2d_helper_render_evt_t;
typedef struct arm_2d_helper_draw_evt_t {
arm_2d_helper_draw_handler_t *fnHandler; //!< event handler function
void *pTarget; //!< user attached target
} arm_2d_helper_draw_evt_t;
enum {
ARM_2D_PFB_DEPEND_ON_LOW_LEVEL_RENDERING = _BV(0),
ARM_2D_PFB_DEPEND_ON_DRAWING = _BV(1),
ARM_2D_PFB_DEPEND_ON_LOW_LEVEL_SYNC_UP = _BV(2),
ARM_2D_PFB_DEPEND_ON_FRAME_SYNC_UP = _BV(3),
};
typedef struct arm_2d_helper_pfb_dependency_t {
//! event handler for low level rendering
arm_2d_helper_render_evt_t evtOnLowLevelRendering;
//!< event handler for drawing GUI
arm_2d_helper_draw_evt_t evtOnDrawing;
//!< low level rendering handler wants to sync-up (return arm_fsm_rt_wait_for_obj)
arm_2d_evt_t evtOnLowLevelSyncUp;
} arm_2d_helper_pfb_dependency_t;
typedef struct arm_2d_helper_pfb_cfg_t {
arm_2d_region_t tDisplayArea;
struct {
arm_2d_pfb_t *ptPFBs;
arm_2d_size_t tFrameSize;
uint32_t wBufferSize;
uint16_t hwPFBNum;
uint16_t bDoNOTUpdateDefaultFrameBuffer : 1;
uint16_t bDisableDynamicFPBSize : 1;
uint16_t bSwapRGB16 : 1;
uint16_t : 13;
} FrameBuffer;
arm_2d_helper_pfb_dependency_t Dependency;
} arm_2d_helper_pfb_cfg_t;
typedef struct arm_2d_helper_pfb_t {
ARM_PRIVATE(
arm_2d_helper_pfb_cfg_t tCFG;
struct {
arm_2d_region_t tDrawRegion;
arm_2d_region_t tTargetRegion;
arm_2d_region_list_item_t *ptDirtyRegion;
arm_2d_tile_t tPFBTile;
arm_2d_size_t tFrameSize;
bool bFirstIteration;
bool bIsRegionChanged;
uint8_t chPT;
struct {
uint8_t bIsNewFrame : 1;
uint8_t bIsFlushRequested :1;
};
arm_2d_pfb_t *ptCurrent;
arm_2d_pfb_t *ptFreeList;
struct {
arm_2d_pfb_t *ptHead;
arm_2d_pfb_t *ptTail;
}FlushFIFO;
arm_2d_tile_t *ptFrameBuffer;
} Adapter;
)
struct {
int32_t nTotalCycle;
int32_t nRenderingCycle;
} Statistics;
} arm_2d_helper_pfb_t;
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
extern
ARM_NONNULL(1,2)
arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
arm_2d_helper_pfb_cfg_t *ptCFG);
extern
ARM_NONNULL(1)
arm_fsm_rt_t arm_2d_helper_pfb_task(arm_2d_helper_pfb_t *ptThis,
arm_2d_region_list_item_t *ptDirtyRegions);
extern
ARM_NONNULL(1,3)
arm_2d_err_t arm_2d_helper_pfb_update_dependency(
arm_2d_helper_pfb_t *ptThis,
uint_fast8_t chMask,
const arm_2d_helper_pfb_dependency_t *ptDependency);
extern
ARM_NONNULL(1,2)
void arm_2d_helper_pfb_report_rendering_complete( arm_2d_helper_pfb_t *ptThis,
arm_2d_pfb_t *ptPFB);
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,202 +0,0 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d.h"
* Description: Public header file to contain the all avaialble Arm-2D
* interface header files
*
* $Date: 08. Sept 2021
* $Revision: V.0.9.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_OP_H__
#define __ARM_2D_OP_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
#define LOW_LEVEL_IO__ARM_2D_IO_NONE (*(void *)NULL)
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
extern
const __arm_2d_op_info_t ARM_2D_OP_BARRIER;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_CCCN888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_POINT_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_C8BIT;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_RGB16;
extern
const __arm_2d_op_info_t ARM_2D_OP_DRAW_PATTERN_RGB32;
extern
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_CONVERT_TO_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_GRAY8;
extern
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_RGB888;
extern
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_WITH_ALPHA_RGB565;
extern
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_WITH_ALPHA_RGB888;
/*============================ PROTOTYPES ====================================*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,937 +0,0 @@
/*
* Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm-2d_rotation.c
* Description: APIs for tile rotation
*
* $Date: 29 April 2021
* $Revision: V.0.1.0
*
* Target Processor: Cortex-M cores
*
* -------------------------------------------------------------------- */
/*============================ INCLUDES ======================================*/
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#include "math.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
# pragma clang diagnostic ignored "-Wmissing-variable-declarations"
# pragma clang diagnostic ignored "-Wcast-qual"
# pragma clang diagnostic ignored "-Wcast-align"
# pragma clang diagnostic ignored "-Wextra-semi-stmt"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
# pragma clang diagnostic ignored "-Wdouble-promotion"
# pragma clang diagnostic ignored "-Wunused-parameter"
# pragma clang diagnostic ignored "-Wimplicit-float-conversion"
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
# pragma clang diagnostic ignored "-Wtautological-pointer-compare"
# pragma clang diagnostic ignored "-Wsign-compare"
# pragma clang diagnostic ignored "-Wfloat-conversion"
# pragma clang diagnostic ignored "-Wmissing-prototypes"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wundef"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_suppress 174,177,188,68,513,144
#elif defined(__IS_COMPILER_GCC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#endif
#include <arm_math.h>
/*============================ MACROS ========================================*/
#undef __PI
#define __PI 3.1415926f
#define __CALIB 0.009f
/* faster ATAN */
#define FAST_ATAN_F32_1(x, xabs) \
(x * (PI / 4.0f) + 0.273f * x * (1.0f - xabs))
#define EPS_ATAN2 1e-5f
/*----------------------------------------------------------------------------*
* Code Template *
*----------------------------------------------------------------------------*/
#define __API_PIXEL_AVERAGE_RESULT_GRAY8() \
( tPixel >> 8)
#define __API_PIXEL_AVERAGE_RESULT_RGB565() \
( tPixel.R >>= 8, \
tPixel.G >>= 8, \
tPixel.B >>= 8, \
__arm_2d_rgb565_pack(&tPixel));
#define __API_PIXEL_AVERAGE_RESULT_RGB888() \
( tPixel.R >>= 8, \
tPixel.G >>= 8, \
tPixel.B >>= 8, \
__arm_2d_cccn888_pack(&tPixel));
#define __API_COLOUR gray8
#define __API_INT_TYPE uint8_t
#define __API_PIXEL_AVERAGE_INIT() uint16_t tPixel = 0;
#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_GRAY8
#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_GRAY8
#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_GRAY8
#include "__arm_2d_rotate.inc"
#define __API_COLOUR rgb565
#define __API_INT_TYPE uint16_t
#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_RGB565
#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_RGB565
#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_RGB565
#include "__arm_2d_rotate.inc"
#define __API_COLOUR cccn888
#define __API_INT_TYPE uint32_t
#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_CCCN888
#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_CCCN888
#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_RGB888
#include "__arm_2d_rotate.inc"
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/
#if __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
static
void __arm_2d_rotate_regression(arm_2d_size_t * __RESTRICT ptCopySize,
arm_2d_location_t * pSrcPoint,
float fAngle,
arm_2d_location_t * tOffset,
arm_2d_location_t * center,
arm_2d_rot_linear_regr_t regrCoefs[]
)
{
#define ONE_BY_2PI_Q31 341782637.0f
#define TO_Q16(x) ((x) << 16)
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
q31_t invHeightFx = 0x7fffffff / (iHeight - 1);
int32_t AngleFx = lroundf(fAngle * ONE_BY_2PI_Q31);
q31_t cosAngleFx = arm_cos_q31(AngleFx);
q31_t sinAngleFx = arm_sin_q31(AngleFx);
arm_2d_point_fx_t tPointCornerFx[2][2];
arm_2d_point_fx_t centerQ16;
arm_2d_point_fx_t srcPointQ16;
arm_2d_point_fx_t tOffsetQ16;
arm_2d_point_fx_t tmp;
int32_t iXQ16, iYQ16;
/* Q16 conversion */
centerQ16.X = TO_Q16(center->iX);
centerQ16.Y = TO_Q16(center->iY);
srcPointQ16.X = TO_Q16(pSrcPoint->iX);
srcPointQ16.Y = TO_Q16(pSrcPoint->iY);
tOffsetQ16.X = TO_Q16(tOffset->iX);
tOffsetQ16.Y = TO_Q16(tOffset->iY);
/* (0,0) corner */
tmp.X = srcPointQ16.X + 0 + tOffsetQ16.X;
tmp.Y = srcPointQ16.Y + 0 + tOffsetQ16.Y;
iXQ16 = tmp.X - centerQ16.X;
iYQ16 = tmp.Y - centerQ16.Y;
tPointCornerFx[0][0].Y =
__QDADD(__QDADD(centerQ16.Y, MULTFX(iYQ16, cosAngleFx)), MULTFX(iXQ16, sinAngleFx));
tPointCornerFx[0][0].X =
__QDSUB(__QDADD(centerQ16.X, MULTFX(iXQ16, cosAngleFx)), MULTFX(iYQ16, sinAngleFx));
/* ((iWidth - 1),0) corner */
tmp.X = srcPointQ16.X + 0 + tOffsetQ16.X + TO_Q16(iWidth - 1);
iXQ16 = tmp.X - centerQ16.X;
tPointCornerFx[1][0].Y =
__QDADD(__QDADD(centerQ16.Y, MULTFX(iYQ16, cosAngleFx)), MULTFX(iXQ16, sinAngleFx));
tPointCornerFx[1][0].X =
__QDSUB(__QDADD(centerQ16.X, MULTFX(iXQ16, cosAngleFx)), MULTFX(iYQ16, sinAngleFx));
/* ((iWidth - 1),(iHeight - 1)) corner */
tmp.Y = srcPointQ16.Y + tOffsetQ16.Y + TO_Q16(iHeight - 1);
iYQ16 = tmp.Y - centerQ16.Y;
tPointCornerFx[1][1].Y =
__QDADD(__QDADD(centerQ16.Y, MULTFX(iYQ16, cosAngleFx)), MULTFX(iXQ16, sinAngleFx));
tPointCornerFx[1][1].X =
__QDSUB(__QDADD(centerQ16.X, MULTFX(iXQ16, cosAngleFx)), MULTFX(iYQ16, sinAngleFx));
/* (0,(iHeight - 1)) corner */
tmp.X = srcPointQ16.X + 0 + tOffsetQ16.X;
iXQ16 = tmp.X - centerQ16.X;
tPointCornerFx[0][1].Y =
__QDADD(__QDADD(centerQ16.Y, MULTFX(iYQ16, cosAngleFx)), MULTFX(iXQ16, sinAngleFx));
tPointCornerFx[0][1].X =
__QDSUB(__QDADD(centerQ16.X, MULTFX(iXQ16, cosAngleFx)), MULTFX(iYQ16, sinAngleFx));
/* regression */
int32_t slopeXFx, slopeYFx;
/* interpolation in Y direction for 1st elements column */
slopeXFx = MULTFX((tPointCornerFx[0][1].X - tPointCornerFx[0][0].X), invHeightFx);
slopeYFx = MULTFX((tPointCornerFx[0][1].Y - tPointCornerFx[0][0].Y), invHeightFx);
regrCoefs[0].slopeY = slopeYFx * 2;
regrCoefs[0].slopeX = slopeXFx * 2;
regrCoefs[0].interceptY = tPointCornerFx[0][0].Y;
regrCoefs[0].interceptX = tPointCornerFx[0][0].X;
/* interpolation in Y direction for the last elements column */
slopeXFx = MULTFX((tPointCornerFx[1][1].X - tPointCornerFx[1][0].X), invHeightFx);
slopeYFx = MULTFX((tPointCornerFx[1][1].Y - tPointCornerFx[1][0].Y), invHeightFx);
regrCoefs[1].slopeY = slopeYFx* 2;
regrCoefs[1].slopeX = slopeXFx* 2;
regrCoefs[1].interceptY = tPointCornerFx[1][0].Y;
regrCoefs[1].interceptX = tPointCornerFx[1][0].X;
}
#else
static
void __arm_2d_rotate_regression(arm_2d_size_t * __RESTRICT ptCopySize,
arm_2d_location_t * pSrcPoint,
float fAngle,
arm_2d_location_t * tOffset,
arm_2d_location_t * ptCenter,
arm_2d_rot_linear_regr_t regrCoefs[])
{
int_fast16_t iHeight = ptCopySize->iHeight;
int_fast16_t iWidth = ptCopySize->iWidth;
float invHeight = 1.0f / (float) (iHeight - 1);
float cosAngle = arm_cos_f32(fAngle);
float sinAngle = arm_sin_f32(fAngle);
arm_2d_location_t tSrcPoint;
arm_2d_point_float_t tPointCorner[2][2];
int16_t iX, iY;
tSrcPoint.iX = pSrcPoint->iX + 0 + tOffset->iX;
tSrcPoint.iY = pSrcPoint->iY + 0 + tOffset->iY;
iX = tSrcPoint.iX - ptCenter->iX;
iY = tSrcPoint.iY - ptCenter->iY;
tPointCorner[0][0].fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY);
tPointCorner[0][0].fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX);
tSrcPoint.iX = pSrcPoint->iX + (iWidth - 1) + tOffset->iX;
iX = tSrcPoint.iX - ptCenter->iX;
tPointCorner[1][0].fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY);
tPointCorner[1][0].fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX);
tSrcPoint.iY = pSrcPoint->iY + (iHeight - 1) + tOffset->iY;
iY = tSrcPoint.iY - ptCenter->iY;
tPointCorner[1][1].fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY);
tPointCorner[1][1].fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX);
tSrcPoint.iX = pSrcPoint->iX + 0 + tOffset->iX;
iX = tSrcPoint.iX - ptCenter->iX;
tPointCorner[0][1].fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY);
tPointCorner[0][1].fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX);
float slopeX, slopeY;
/* interpolation in Y direction for 1st elements column */
slopeX = (tPointCorner[0][1].fX - tPointCorner[0][0].fX) * invHeight;
slopeY = (tPointCorner[0][1].fY - tPointCorner[0][0].fY) * invHeight;
regrCoefs[0].slopeY = slopeY;
regrCoefs[0].slopeX = slopeX;
regrCoefs[0].interceptY = tPointCorner[0][0].fY;
regrCoefs[0].interceptX = tPointCorner[0][0].fX;
/* interpolation in Y direction for the last elements column */
slopeX = (tPointCorner[1][1].fX - tPointCorner[1][0].fX) * invHeight;
slopeY = (tPointCorner[1][1].fY - tPointCorner[1][0].fY) * invHeight;
regrCoefs[1].slopeY = slopeY;
regrCoefs[1].slopeX = slopeX;
regrCoefs[1].interceptY = tPointCorner[1][0].fY;
regrCoefs[1].interceptX = tPointCorner[1][0].fX;
}
#endif
ARM_NONNULL(1,2,4)
static
arm_2d_point_float_t *__arm_2d_rotate_point(const arm_2d_location_t *ptLocation,
const arm_2d_location_t *ptCenter,
float fAngle,
arm_2d_point_float_t *ptOutBuffer)
{
int16_t iX = ptLocation->iX - ptCenter->iX;
int16_t iY = ptLocation->iY - ptCenter->iY;
float fX,fY;
float cosAngle = arm_cos_f32(fAngle);
float sinAngle = arm_sin_f32(fAngle);
fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY);
fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX);
#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__)
if (fX > 0) {
ptOutBuffer->fX = fX + __CALIB;
} else {
ptOutBuffer->fX = fX - __CALIB;
}
if (fY > 0) {
ptOutBuffer->fY = fY + __CALIB;
} else {
ptOutBuffer->fY = fY - __CALIB;
}
#else
ptOutBuffer->fX = fX;
ptOutBuffer->fY = fY;
#endif
return ptOutBuffer;
}
static arm_2d_err_t __arm_2d_rotate_preprocess_source(arm_2d_op_rotate_t *ptThis)
{
arm_2d_tile_t *ptSource = this.Source.ptTile;
memset(ptSource, 0, sizeof(*ptSource));
ptSource->tInfo = this.Origin.ptTile->tInfo;
ptSource->bIsRoot = true;
ptSource->pchBuffer = NULL; //!< special case
arm_2d_region_t tOrigValidRegion;
if (NULL == arm_2d_tile_get_root(this.Origin.ptTile, &tOrigValidRegion, NULL)) {
return ARM_2D_ERR_OUT_OF_REGION;
}
//! angle validation
this.tRotate.fAngle = fmodf(this.tRotate.fAngle, ARM_2D_ANGLE(360));
//! calculate the source region
do {
arm_2d_point_float_t tPoint;
arm_2d_location_t tTopLeft = {.iX = INT16_MAX, .iY = INT16_MAX};
arm_2d_location_t tBottomRight = {.iX = INT16_MIN, .iY = INT16_MIN};
//! Top Left
arm_2d_location_t tCornerPoint = tOrigValidRegion.tLocation;
__arm_2d_rotate_point( &tCornerPoint,
&this.tRotate.tCenter,
this.tRotate.fAngle,
&tPoint);
do {
tTopLeft.iX = MIN(tTopLeft.iX, tPoint.fX);
tTopLeft.iY = MIN(tTopLeft.iY, tPoint.fY);
tBottomRight.iX = MAX(tBottomRight.iX, tPoint.fX);
tBottomRight.iY = MAX(tBottomRight.iY, tPoint.fY);
} while(0);
//! Bottom Left
tCornerPoint.iY += tOrigValidRegion.tSize.iHeight - 1;
__arm_2d_rotate_point( &tCornerPoint,
&this.tRotate.tCenter,
this.tRotate.fAngle,
&tPoint);
do {
tTopLeft.iX = MIN(tTopLeft.iX, tPoint.fX);
tTopLeft.iY = MIN(tTopLeft.iY, tPoint.fY);
tBottomRight.iX = MAX(tBottomRight.iX, tPoint.fX);
tBottomRight.iY = MAX(tBottomRight.iY, tPoint.fY);
} while(0);
//! Top Right
tCornerPoint = tOrigValidRegion.tLocation;
tCornerPoint.iX += tOrigValidRegion.tSize.iWidth - 1;
__arm_2d_rotate_point( &tCornerPoint,
&this.tRotate.tCenter,
this.tRotate.fAngle,
&tPoint);
do {
tTopLeft.iX = MIN(tTopLeft.iX, tPoint.fX);
tTopLeft.iY = MIN(tTopLeft.iY, tPoint.fY);
tBottomRight.iX = MAX(tBottomRight.iX, tPoint.fX);
tBottomRight.iY = MAX(tBottomRight.iY, tPoint.fY);
} while(0);
//! Bottom Right
tCornerPoint.iY += tOrigValidRegion.tSize.iHeight - 1;
__arm_2d_rotate_point( &tCornerPoint,
&this.tRotate.tCenter,
this.tRotate.fAngle,
&tPoint);
do {
tTopLeft.iX = MIN(tTopLeft.iX, tPoint.fX);
tTopLeft.iY = MIN(tTopLeft.iY, tPoint.fY);
tBottomRight.iX = MAX(tBottomRight.iX, tPoint.fX);
tBottomRight.iY = MAX(tBottomRight.iY, tPoint.fY);
} while(0);
//! calculate the region
this.tRotate.tDummySourceOffset = tTopLeft;
ptSource->tRegion.tSize.iHeight = tBottomRight.iY - tTopLeft.iY + 1;
ptSource->tRegion.tSize.iWidth = tBottomRight.iX - tTopLeft.iX + 1;
//this.tRotate.tTargetRegion.tSize = ptSource->tRegion.tSize;
} while(0);
return ARM_2D_ERR_NONE;
}
static void __arm_2d_rotate_preprocess_target(
arm_2d_op_rotate_t *ptThis,
const arm_2d_location_t *ptTargetCentre)
{
this.tRotate.Target.tRegion.tSize = this.Source.ptTile->tRegion.tSize;
#if 0 //!< please keep this code for understanding the original meaning
arm_2d_region_t tTargetRegion = {0};
if (NULL != this.Target.ptRegion) {
tTargetRegion = *this.Target.ptRegion;
} else {
tTargetRegion.tSize = this.Target.ptTile->tRegion.tSize;
}
#else
//! equivalent code
assert(NULL == this.Target.ptRegion);
arm_2d_region_t tTargetRegion = {
.tSize = this.Target.ptTile->tRegion.tSize,
};
#endif
this.Target.ptRegion = &this.tRotate.Target.tRegion;
this.tRotate.Target.tRegion.tLocation = tTargetRegion.tLocation;
//! align with the specified center point
do {
arm_2d_location_t tOffset = {
.iX = this.tRotate.tCenter.iX - this.tRotate.tDummySourceOffset.iX,
.iY = this.tRotate.tCenter.iY - this.tRotate.tDummySourceOffset.iY,
};
if (NULL == ptTargetCentre) {
arm_2d_location_t tTargetCenter = {
.iX = tTargetRegion.tSize.iWidth >> 1,
.iY = tTargetRegion.tSize.iHeight >> 1,
};
tOffset.iX = tTargetCenter.iX - tOffset.iX;
tOffset.iY = tTargetCenter.iY - tOffset.iY;
} else {
tOffset.iX = ptTargetCentre->iX - tOffset.iX;
tOffset.iY = ptTargetCentre->iY - tOffset.iY;
}
this.tRotate.Target.tRegion.tLocation.iX += tOffset.iX;
this.tRotate.Target.tRegion.tLocation.iY += tOffset.iY;
} while(0);
}
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_gray8_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint8_t chFillColour)
{
assert(NULL != ptSource);
ARM_2D_IMPL(arm_2d_op_rotate_t, ptOP);
if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) {
return ARM_2D_ERR_BUSY;
}
OP_CORE.ptOp = &ARM_2D_OP_ROTATE_GRAY8;
this.Source.ptTile = &this.Origin.tDummySource;
this.Origin.ptTile = ptSource;
this.wMode = 0;
this.tRotate.fAngle = fAngle;
this.tRotate.tCenter = tCentre;
this.tRotate.Mask.hwColour = chFillColour;
return __arm_2d_rotate_preprocess_source(ptThis);
}
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_rgb565_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint16_t hwFillColour)
{
assert(NULL != ptSource);
ARM_2D_IMPL(arm_2d_op_rotate_t, ptOP);
if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) {
return ARM_2D_ERR_BUSY;
}
OP_CORE.ptOp = &ARM_2D_OP_ROTATE_RGB565;
this.Source.ptTile = &this.Origin.tDummySource;
this.Origin.ptTile = ptSource;
this.wMode = 0;
this.tRotate.fAngle = fAngle;
this.tRotate.tCenter = tCentre;
this.tRotate.Mask.hwColour = hwFillColour;
return __arm_2d_rotate_preprocess_source(ptThis);
}
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_cccn888_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint32_t wFillColour)
{
assert(NULL != ptSource);
ARM_2D_IMPL(arm_2d_op_rotate_t, ptOP);
if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) {
return ARM_2D_ERR_BUSY;
}
OP_CORE.ptOp = &ARM_2D_OP_ROTATE_RGB888;
this.Source.ptTile = &this.Origin.tDummySource;
this.Origin.ptTile = ptSource;
this.wMode = 0;
this.tRotate.fAngle = fAngle;
this.tRotate.tCenter = tCentre;
this.tRotate.Mask.hwColour = wFillColour;
return __arm_2d_rotate_preprocess_source(ptThis);
}
arm_fsm_rt_t __arm_2d_gray8_sw_rotate(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_rotate_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_8BIT == OP_CORE.ptOp->Info.Colour.chScheme);
__arm_2d_impl_gray8_rotate(&(ptTask->Param.tCopyOrig),
&this.tRotate);
return arm_fsm_rt_cpl;
}
arm_fsm_rt_t __arm_2d_rgb565_sw_rotate(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_rotate_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme);
__arm_2d_impl_rgb565_rotate(&(ptTask->Param.tCopyOrig),
&this.tRotate);
return arm_fsm_rt_cpl;
}
arm_fsm_rt_t __arm_2d_cccn888_sw_rotate(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_rotate_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ);
__arm_2d_impl_cccn888_rotate(&(ptTask->Param.tCopyOrig),
&this.tRotate);
return arm_fsm_rt_cpl;
}
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_rgb565_tile_rotation_with_opacity_prepare(
arm_2d_op_rotate_opacity_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint16_t hwFillColour,
uint_fast8_t chRatio)
{
assert(NULL != ptSource);
ARM_2D_IMPL(arm_2d_op_rotate_opacity_t, ptOP);
if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) {
return ARM_2D_ERR_BUSY;
}
OP_CORE.ptOp = &ARM_2D_OP_ROTATE_WITH_ALPHA_RGB565;
this.Source.ptTile = &this.Origin.tDummySource;
this.Origin.ptTile = ptSource;
this.wMode = 0;
this.tRotate.fAngle = fAngle;
this.tRotate.tCenter = tCentre;
this.tRotate.Mask.hwColour = hwFillColour;
this.chRatio = chRatio;
return __arm_2d_rotate_preprocess_source((arm_2d_op_rotate_t *)ptThis);
}
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_cccn888_tile_rotation_with_opacity_prepare(
arm_2d_op_rotate_opacity_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint32_t wFillColour,
uint_fast8_t chRatio)
{
assert(NULL != ptSource);
ARM_2D_IMPL(arm_2d_op_rotate_opacity_t, ptOP);
if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) {
return ARM_2D_ERR_BUSY;
}
OP_CORE.ptOp = &ARM_2D_OP_ROTATE_WITH_ALPHA_RGB888;
this.Source.ptTile = &this.Origin.tDummySource;
this.Origin.ptTile = ptSource;
this.wMode = 0;
this.tRotate.fAngle = fAngle;
this.tRotate.tCenter = tCentre;
this.tRotate.Mask.wColour = wFillColour;
this.chRatio = chRatio;
return __arm_2d_rotate_preprocess_source((arm_2d_op_rotate_t *)ptThis);
}
arm_fsm_rt_t __arm_2d_rgb565_sw_rotate_with_alpha(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_rotate_opacity_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme);
__arm_2d_impl_rgb565_rotate_alpha( &(ptTask->Param.tCopyOrig),
&this.tRotate,
this.chRatio);
return arm_fsm_rt_cpl;
}
arm_fsm_rt_t __arm_2d_cccn888_sw_rotate_with_alpha(__arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_rotate_opacity_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ);
__arm_2d_impl_cccn888_rotate_alpha(&(ptTask->Param.tCopyOrig),
&this.tRotate,
this.chRatio);
return arm_fsm_rt_cpl;
}
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_tile_rotate(arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
const arm_2d_location_t *ptTargetCentre)
{
assert(NULL != ptTarget);
ARM_2D_IMPL(arm_2d_op_rotate_t, ptOP);
arm_2d_location_t tTargetCentre;
if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}
if (NULL != ptRegion) {
this.Target.ptTile = arm_2d_tile_generate_child(
ptTarget,
ptRegion,
&this.tRotate.Target.tTile,
false);
if (NULL == this.Target.ptTile) {
arm_fsm_rt_t tResult = (arm_fsm_rt_t)ARM_2D_ERR_OUT_OF_REGION;
if (ARM_2D_RUNTIME_FEATURE.TREAT_OUT_OF_RANGE_AS_COMPLETE) {
tResult = arm_fsm_rt_cpl;
}
return __arm_2d_op_depose((arm_2d_op_core_t *)ptThis, tResult);
}
if (NULL != ptTargetCentre) {
tTargetCentre.iX = ptTargetCentre->iX - ptRegion->tLocation.iX;
tTargetCentre.iY = ptTargetCentre->iY - ptRegion->tLocation.iY;
ptTargetCentre = &tTargetCentre;
}
} else {
this.Target.ptTile = ptTarget;
//this.Target.ptRegion = ptRegion;
}
this.Target.ptRegion = NULL;
__arm_2d_rotate_preprocess_target(ptThis, ptTargetCentre);
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}
/*----------------------------------------------------------------------------*
* Accelerable Low Level APIs *
*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*
* Draw a point whose cordinates is stored as float point. *
*----------------------------------------------------------------------------*/
#if 0
static arm_2d_region_t *__arm_2d_calculate_region( const arm_2d_point_float_t *ptLocation,
arm_2d_region_t *ptRegion)
{
assert(NULL != ptLocation);
assert(NULL != ptRegion);
/* +-----+-----+
* | P0 | P1 |
* +---- p ----+
* | P2 | -- |
* +-----+-----+
*/
arm_2d_location_t tPoints[3];
tPoints[0].iX = (int16_t)ptLocation->fX;
tPoints[2].iX = (int16_t)ptLocation->fX;
tPoints[1].iX = (int16_t)(ptLocation->fX + 0.99f);
ptRegion->tSize.iWidth = tPoints[1].iX - tPoints[0].iX + 1;
tPoints[0].iY = (int16_t)ptLocation->fY;
tPoints[2].iY = (int16_t)ptLocation->fY;
tPoints[1].iY = (int16_t)(ptLocation->fY + 0.99f);
ptRegion->tSize.iHeight = tPoints[2].iY - tPoints[0].iY + 1;
ptRegion->tLocation = tPoints[0];
return ptRegion;
}
#endif
/*----------------------------------------------------------------------------*
* Low Level IO Interfaces *
*----------------------------------------------------------------------------*/
__WEAK
def_low_lv_io(__ARM_2D_IO_ROTATE_GRAY8,
__arm_2d_gray8_sw_rotate);
__WEAK
def_low_lv_io(__ARM_2D_IO_ROTATE_RGB565,
__arm_2d_rgb565_sw_rotate);
__WEAK
def_low_lv_io(__ARM_2D_IO_ROTATE_RGB888,
__arm_2d_cccn888_sw_rotate);
__WEAK
def_low_lv_io(__ARM_2D_IO_ROTATE_WITH_ALPHA_RGB565,
__arm_2d_rgb565_sw_rotate_with_alpha);
__WEAK
def_low_lv_io(__ARM_2D_IO_ROTATE_WITH_ALPHA_RGB888,
__arm_2d_cccn888_sw_rotate_with_alpha);
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_GRAY8 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_8BIT,
},
.Param = {
.bHasSource = true,
.bHasOrigin = true,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_ROTATE,
.LowLevelIO = {
.ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_ROTATE_GRAY8),
.ptFillOrigLike = NULL,
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_RGB565 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_RGB565,
},
.Param = {
.bHasSource = true,
.bHasOrigin = true,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_ROTATE,
.LowLevelIO = {
.ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_ROTATE_RGB565),
.ptFillOrigLike = NULL,
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_RGB888 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_RGB888,
},
.Param = {
.bHasSource = true,
.bHasOrigin = true,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_ROTATE,
.LowLevelIO = {
.ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_ROTATE_RGB888),
.ptFillOrigLike = NULL,
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_WITH_ALPHA_RGB565 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_RGB565,
},
.Param = {
.bHasSource = true,
.bHasOrigin = true,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_ROTATE_WITH_ALPHA,
.LowLevelIO = {
.ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_ROTATE_WITH_ALPHA_RGB565),
.ptFillOrigLike = NULL,
},
},
};
const __arm_2d_op_info_t ARM_2D_OP_ROTATE_WITH_ALPHA_RGB888 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_RGB888,
},
.Param = {
.bHasSource = true,
.bHasOrigin = true,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_ROTATE_WITH_ALPHA,
.LowLevelIO = {
.ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_ROTATE_WITH_ALPHA_RGB888),
.ptFillOrigLike = NULL,
},
},
};
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
# pragma diag_warning 174,177,188,68,513,144
#elif defined(__IS_COMPILER_GCC__)
# pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,729 +0,0 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: #include "arm_2d_rotation.h"
* Description: Public header file to contain the APIs for rotation
*
* $Date: 29 April 2021
* $Revision: V.0.5.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_ROTATION_H__
#define __ARM_2D_ROTATION_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define arm_2d_gray8_tile_rotation_prepare(__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR) \
arm_2dp_gray8_tile_rotation_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR))
#define arm_2d_rgb565_tile_rotation_prepare(__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR) \
arm_2dp_rgb565_tile_rotation_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR))
#define arm_2d_rgb888_tile_rotation_prepare(__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR) \
arm_2dp_cccn888_tile_rotation_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR))
#define arm_2d_rgb565_tile_rotation_with_alpha_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_rgb565_tile_rotation_with_opacity_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_rgb888_tile_rotation_with_alpha_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_rgb888_tile_rotation_with_opacity_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_cccn888_tile_rotation_with_alpha_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_cccn888_tile_rotation_with_opacity_prepare( \
__SRC_TILE_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO) \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(float)(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO))
#define arm_2d_tile_rotate( __DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__DES_CENTRE_ADDR) \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(__DES_CENTRE_ADDR))
/*! \note arm_2dp_gray8_tile_rotation(), arm_2dp_rgb565_tile_rotation() and
*! arm_2d_2dp_rgb888_tile_rotation() relies on the boolean variable
*! bIsNewFrame. Please make sure you have define it with the correct
*! name and the corresponding value. If you don't use the PFB interfaces
*! for neight the low level rendering nor the high level GUI drawing,
*! please find such variable with the value "true".
*/
#define arm_2dp_gray8_tile_rotation( __CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_gray8_tile_rotation_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_rgb565_tile_rotation( __CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_rgb565_tile_rotation_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_cccn888_tile_rotation( __CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR,...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_cccn888_tile_rotation_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_rgb565_tile_rotation_with_alpha( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO,...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_rgb565_tile_rotation_with_opacity( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO,...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_rgb888_tile_rotation_with_alpha( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_rgb888_tile_rotation_with_opacity( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_cccn888_tile_rotation_with_alpha( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2dp_cccn888_tile_rotation_with_opacity( \
__CB_ADDR, \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
(__CB_ADDR), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate((arm_2d_op_rotate_t *)(__CB_ADDR), \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_gray8_tile_rotation( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, ...) \
({{ \
arm_2dp_gray8_tile_rotation_prepare( \
(NULL), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb565_tile_rotation( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, ...) \
({{ \
arm_2dp_rgb565_tile_rotation_prepare( \
(NULL), \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb888_tile_rotation( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, ...) \
({{ \
arm_2dp_cccn888_tile_rotation_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb565_tile_rotation_with_alpha( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb565_tile_rotation_with_opacity( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_rgb565_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb888_tile_rotation_with_alpha( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_rgb888_tile_rotation_with_opacity( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_cccn888_tile_rotation_with_alpha( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
#define arm_2d_cccn888_tile_rotation_with_opacity( \
__SRC_TILE_ADDR, \
__DES_TILE_ADDR, \
__DES_REGION_ADDR, \
__CENTRE, \
__ANGLE, \
__MSK_COLOUR, \
__RATIO, ...) \
({{ \
arm_2dp_cccn888_tile_rotation_with_opacity_prepare( \
NULL, \
(__SRC_TILE_ADDR), \
(__CENTRE), \
(__ANGLE), \
(__MSK_COLOUR), \
(__RATIO)); \
}; \
arm_2dp_tile_rotate(NULL, \
(__DES_TILE_ADDR), \
(__DES_REGION_ADDR), \
(NULL,##__VA_ARGS__)); \
})
/*============================ TYPES =========================================*/
typedef struct __arm_2d_rotate_info_t {
float fAngle; //!< target angle
arm_2d_location_t tCenter;
union {
uint8_t chColour;
uint32_t wColour;
uint16_t hwColour;
} Mask; //!< the colour to fill when out of range
ARM_PRIVATE(
arm_2d_location_t tDummySourceOffset;
struct {
arm_2d_region_t tRegion;
arm_2d_tile_t tTile;
} Target;
)
} __arm_2d_rotate_info_t;
/*! \brief arm_2d_op_rotat_t is inherit from arm_2d_op_src_orig_t
*/
typedef struct arm_2d_op_rotate_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
__arm_2d_rotate_info_t tRotate;
} arm_2d_op_rotate_t;
/*! \brief arm_2d_op_rotate_opacity_t is inherit from arm_2d_op_rotate_t
*/
typedef struct arm_2d_op_rotate_opacity_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
__arm_2d_rotate_info_t tRotate;
uint8_t chRatio;
} arm_2d_op_rotate_opacity_t;
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
extern
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_gray8_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint8_t chFillColour);
extern
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_rgb565_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint16_t hwFillColour);
extern
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_cccn888_tile_rotation_prepare(
arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint32_t wFillColour);
extern
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_rgb565_tile_rotation_with_opacity_prepare(
arm_2d_op_rotate_opacity_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint16_t hwFillColour,
uint_fast8_t chRatio);
extern
ARM_NONNULL(2)
arm_2d_err_t arm_2dp_cccn888_tile_rotation_with_opacity_prepare(
arm_2d_op_rotate_opacity_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_location_t tCentre,
float fAngle,
uint32_t wFillColour,
uint_fast8_t chRatio);
extern
ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_tile_rotate(arm_2d_op_rotate_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
const arm_2d_location_t *ptTargetCentre);
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,503 +0,0 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: arm_2d_tile.h
* Description: Public header file to contain the basic tile operations
*
* $Date: 01. December 2020
* $Revision: V.0.9.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_TILE_H__
#define __ARM_2D_TILE_H__
/*============================ INCLUDES ======================================*/
#include "arm_2d_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#define arm_2d_c8bit_tile_copy( __SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MODE) /*!< mode */ \
arm_2dp_c8bit_tile_copy(NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MODE))
#define arm_2d_rgb16_tile_copy( __SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MODE) /*!< mode */ \
arm_2dp_rgb16_tile_copy(NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MODE))
#define arm_2d_rgb32_tile_copy( __SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MODE) /*!< mode */ \
arm_2dp_rgb32_tile_copy(NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MODE))
#define arm_2d_c8bit_tile_copy_with_colour_masking( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_c8bit_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
#define arm_2d_c8bit_tile_copy_with_colour_keying( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_c8bit_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
#define arm_2d_rgb16_tile_copy_with_colour_masking( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_rgb16_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
#define arm_2d_rgb16_tile_copy_with_colour_keying( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_rgb16_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
#define arm_2d_rgb32_tile_copy_with_colour_masking( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_rgb32_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
#define arm_2d_rgb32_tile_copy_with_colour_keying( \
__SRC_ADDR, /*!< source tile address */ \
__DES_ADDR, /*!< target tile address */ \
__DES_REGION_ADDR, /*!< target region address*/\
__MSK_COLOUR, /*!< mask(key) colour */ \
__MODE) /*!< mode */ \
arm_2dp_rgb32_tile_copy_with_colour_keying( \
NULL, \
(__SRC_ADDR), \
(__DES_ADDR), \
(__DES_REGION_ADDR), \
(__MSK_COLOUR), \
(__MODE))
/*
calculate the start address
HOW IT WORKS:
Base Address
+------------------------------------------------------------------------+
| |
|<------------------------------- iWidth ------------------------------->|
| |
| |
| Start Address = Base Address + iX + iY * iWidth |
| (iX,iY) |
|<-------- iX --------->+------------------------------+ |
| | | |
| | Valid Region | |
| | | |
| +------------------------------+ |
... ...
| |
+------------------------------------------------------------------------+
*/
#define __arm_2d_get_address_and_region_from_tile( __TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME) \
arm_2d_region_t __VALID_REGION_NAME; \
assert(NULL != (__TILE_PTR)); \
__TYPE *(__BUF_PTR_NAME) = NULL; \
\
(__TILE_PTR) = arm_2d_tile_get_root((__TILE_PTR), \
&__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR); \
\
if (NULL != (__TILE_PTR)) { \
(__BUF_PTR_NAME) = ((__TYPE *)((__TILE_PTR)->pchBuffer)) \
+ (__TILE_PTR)->tRegion.tSize.iWidth * \
__VALID_REGION_NAME.tLocation.iY \
+ __VALID_REGION_NAME.tLocation.iX; \
}
#define arm_2d_get_address_and_region_from_tile(__TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME) \
__arm_2d_get_address_and_region_from_tile( __TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME)
#define __arm_2d_get_address_and_region_from_tile_with_mirroring( \
__TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME, \
__MODE) \
arm_2d_region_t __VALID_REGION_NAME; \
assert(NULL != (__TILE_PTR)); \
__TYPE *(__BUF_PTR_NAME) = NULL; \
\
(__TILE_PTR) = arm_2d_tile_get_root((__TILE_PTR), \
&__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR); \
\
if (NULL != (__TILE_PTR)) { \
arm_2d_location_t tOffset = __VALID_REGION_NAME.tLocation; \
if ((__MODE) & ARM_2D_CP_MODE_X_MIRROR) { \
tOffset.iX = 0; \
} \
if ((__MODE) & ARM_2D_CP_MODE_Y_MIRROR) { \
tOffset.iY = 0; \
} \
(__BUF_PTR_NAME) = ((__TYPE *)((__TILE_PTR)->pchBuffer)) \
+ (__TILE_PTR)->tRegion.tSize.iWidth * tOffset.iY \
+ tOffset.iX; \
}
#define arm_2d_get_address_and_region_from_tile_with_mirroring( \
__TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME, \
__MODE) \
__arm_2d_get_address_and_region_from_tile_with_mirroring( \
__TILE_PTR, \
__VALID_REGION_NAME, \
__LOCATION_OFFSET_PTR, \
__TYPE, \
__BUF_PTR_NAME, \
(__MODE))
/*============================ TYPES =========================================*/
typedef arm_2d_op_src_t arm_2d_op_cp_t;
/*! \note arm_2d_op_cp_cl_key_t inherits from arm_2d_op_src_t explicitly
*/
typedef struct arm_2d_op_cp_cl_key_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
union {
uint8_t chColour;
uint16_t hwColour;
uint32_t wColour;
};
} arm_2d_op_cp_cl_key_t;
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*----------------------------------------------------------------------------*
* Tile Operations *
*----------------------------------------------------------------------------*/
ARM_NONNULL(1)
__STATIC_INLINE bool arm_2d_is_root_tile(const arm_2d_tile_t *ptTile)
{
return ptTile->tInfo.bIsRoot;
}
/*
HOW IT WORKS:
Input Region 0
+------------------------------------------------------+
| |
| |
| |
| +------------------------------+---------+
| | |/////////|
| | Output Region |/////////|
| | |/////////|
+-----------------------+------------------------------+/////////|
|////////////////////////////////////////|
|////////////////////////////////////////|
+----------------------------------------+
Input Region 1
*/
extern
ARM_NONNULL(1,2)
bool arm_2d_region_intersect( const arm_2d_region_t *ptRegionIn0,
const arm_2d_region_t *ptRegionIn1,
arm_2d_region_t *ptRegionOut);
extern
ARM_NONNULL(1,2)
bool arm_2d_is_point_inside_region( const arm_2d_region_t *ptRegion,
const arm_2d_location_t *ptPoint);
/*
HOW IT WORKS:
Root Tile (Output Tile)
+------------------------------------------------------------------------+
| ... ... |
| |
| Parent Tile' (Child Tile of Parent Tile'') |
| +------------------------------------+ |
| | Child Tile of Parent Tile' | |
| | +------------------------------+---------+ |
| | | |/////////| |
| | | Valid Region |/////////| |
| | | |/////////| |
| +-----+------------------------------+/////////| |
| |////////////////////////////////////////| |
| |////////////////////////////////////////| |
| +----------------------------------------+ |
| |
+------------------------------------------------------------------------+
*/
extern
ARM_NONNULL(1,2)
const arm_2d_tile_t *arm_2d_tile_get_root( const arm_2d_tile_t *ptTile,
arm_2d_region_t *ptValidRegion,
arm_2d_location_t *ptOffset);
/*
HOW IT WORKS:
Parent Tile (Are NOT necessarily a ROOT tile )
+------------------------------------------------------+
| |
| |
| Target Region |
| +------------------------------+---------+
| | |/////////|
| | New Child Tile (Output) |/////////|
| | |/////////|
+-----------------------+------------------------------+/////////|
|////////////////////////////////////////|
|////////////////////////////////////////|
+----------------------------------------+
*/
extern
ARM_NONNULL(1,2,3)
arm_2d_tile_t *arm_2d_tile_generate_child(
const arm_2d_tile_t *ptTargetTile,
const arm_2d_region_t *ptRegion,
arm_2d_tile_t *ptOutput,
bool bClipRegion);
extern
ARM_NONNULL(1,2)
arm_2d_cmp_t arm_2d_tile_width_compare( const arm_2d_tile_t *ptTarget,
const arm_2d_tile_t *ptReference);
extern
ARM_NONNULL(1,2)
arm_2d_cmp_t arm_2d_tile_height_compare(const arm_2d_tile_t *ptTarget,
const arm_2d_tile_t *ptReference);
extern
ARM_NONNULL(1,2)
arm_2d_cmp_t arm_2d_tile_shape_compare( const arm_2d_tile_t *ptTarget,
const arm_2d_tile_t *ptReference);
extern
ARM_NONNULL(1,2)
const arm_2d_tile_t * arm_2d_get_absolute_location(
const arm_2d_tile_t *ptTile,
arm_2d_location_t *ptLocation);
extern
ARM_NONNULL(1,2,3)
arm_2d_region_t *arm_2d_tile_region_diff( const arm_2d_tile_t *ptTarget,
const arm_2d_tile_t *ptReference,
arm_2d_region_t *ptBuffer);
/*----------------------------------------------------------------------------*
* Copy tile to destination directly *
*----------------------------------------------------------------------------*/
enum {
ARM_2D_CP_MODE_COPY = 0,
ARM_2D_CP_MODE_FILL = _BV(0),
ARM_2D_CP_MODE_Y_MIRROR = _BV(2),
ARM_2D_CP_MODE_X_MIRROR = _BV(3),
};
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_c8bit_tile_copy(arm_2d_op_cp_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint32_t wMode);
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb16_tile_copy(arm_2d_op_cp_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint32_t wMode);
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb32_tile_copy(arm_2d_op_cp_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint32_t wMode);
/*----------------------------------------------------------------------------*
* Copy tile to destination with specified transparency color mask *
*----------------------------------------------------------------------------*/
/*! \brief copy source tile to destination tile and use destination tile as
*! background. When encountering specified mask colour, the background
*! pixel should be used, otherwise the foreground pixel from source tile
*! is used.
*!
*! \note All color formats which using 8bits per pixel are treated equally.
*!
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_colour_keying(
arm_2d_op_cp_cl_key_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint8_t chMaskColour,
uint32_t wMode);
/*! \brief copy source tile to destination tile and use destination tile as
*! background. When encountering specified mask colour, the background
*! pixel should be used, otherwise the foreground pixel from source tile
*! is used.
*!
*! \note All color formats which using 16bits per pixel are treated equally.
*!
*! \note alpha channel is not handled, i.e. rgba5551
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_colour_keying(
arm_2d_op_cp_cl_key_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint16_t hwMaskColour,
uint32_t wMode);
/*! \brief copy source tile to destination tile and use destination tile as
*! background. When encountering specified mask colour, the background
*! pixel should be used, otherwise the foreground pixel from source tile
*! is used.
*!
*! \note All color formats which using 32bits per pixel are treated equally.
*!
*! \note alpha channel is not handled.
*/
extern
ARM_NONNULL(2,3)
arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_colour_keying(
arm_2d_op_cp_cl_key_t *ptOP,
const arm_2d_tile_t *ptSource,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion,
uint32_t wMaskColour,
uint32_t wMode);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,627 +0,0 @@
/*
* Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: Arm-2D Library
* Title: cmsis_nn_typs.h
* Description: Public header file to contain the Arm-2D structs
*
* $Date: 01. December 2020
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#ifndef __ARM_2D_TYPES_H__
#define __ARM_2D_TYPES_H__
/*============================ INCLUDES ======================================*/
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include "arm_2d_features.h"
#include "arm_2d_utils.h"
#include "__arm_2d_math.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wreserved-identifier"
# pragma clang diagnostic ignored "-Wmissing-declarations"
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc11-extensions"
#elif __IS_COMPILER_ARM_COMPILER_5__
# pragma diag_suppress 64
#elif __IS_COMPILER_GCC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# pragma GCC diagnostic ignored "-Wpadded"
#endif
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*----------------------------------------------------------------------------*
* Infrastructure *
*----------------------------------------------------------------------------*/
//! \name finite-state-machine status return (Compatible with arm_status), int8_t
//! @{
typedef enum {
arm_fsm_rt_err = -1, //!< fsm error
arm_fsm_rt_cpl = 0, //!< fsm complete
arm_fsm_rt_on_going = 1, //!< fsm on-going
arm_fsm_rt_wait_for_obj = 2, //!< fsm wait for IPC object
arm_fsm_rt_async = 3, //!< fsm work asynchronosely, please check it later.
arm_fsm_rt_wait_for_res = 4, //!< wait for resource
} arm_fsm_rt_t;
//! @}
//! \name error code for arm-2d, int8_t
//! \note arm_2d_err_t is compatible with arm_fsm_rt_t
//! @{
typedef enum {
ARM_2D_ERR_UNSUPPORTED_COLOUR = -11, //!< the specified colour is not supported
ARM_2D_ERR_BUSY = -10, //!< service is busy
ARM_2D_ERR_INSUFFICIENT_RESOURCE = -9, //!< insufficient resource
ARM_2D_ERR_IO_BUSY = -8, //!< HW accelerator is busy
ARM_2D_ERR_IO_ERROR = -7, //!< Generic HW error
ARM_2D_ERR_MISSING_PARAM = -6, //!< missing mandatory parameter
ARM_2D_ERR_INVALID_OP = -5, //!< unsupported / invalid operation
ARM_2D_ERR_NOT_SUPPORT = -4, //!< feature/service/operation is not supported
ARM_2D_ERR_OUT_OF_REGION = -3, //!< the operation is out of target area
ARM_2D_ERR_INVALID_PARAM = -2, //!< invalid parameter
ARM_2D_ERR_UNKNOWN = -1, //!< generic or unknown errors
ARM_2D_ERR_NONE = 0, //!< no error
} arm_2d_err_t;
//! @}
//! \name compare result
//! @{
typedef enum {
ARM_2D_CMP_SMALLER = -1, //!< the target is smaller than the reference
ARM_2D_CMP_EQUALS = 0, //!< the target is equal to the reference
ARM_2D_CMP_LARGER = 1, //!< the target is larger than the reference
} arm_2d_cmp_t;
//! @}
/*----------------------------------------------------------------------------*
* Colour definitions *
*----------------------------------------------------------------------------*/
typedef union arm_2d_color_rgb565_t {
uint16_t tValue;
struct {
uint16_t u5R : 5;
uint16_t u6G : 6;
uint16_t u5B : 5;
};
} arm_2d_color_rgb565_t;
/*! \brief In most cases four equal-sized pieces of adjacent memory are used,
*! one for each channel, and a 0 in a channel indicates black color or
*! transparent alpha, while all-1 bits indicates white or fully opaque
*! alpha. By far the most common format is to store 8 bits (one byte)
*! for each channel, which is 32 bits for each pixel.
*!
*! (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
*/
typedef union arm_2d_color_rgba8888_t {
uint32_t tValue;
struct {
uint32_t u8R : 8;
uint32_t u8G : 8;
uint32_t u8B : 8;
uint32_t u8A : 8;
};
} arm_2d_color_rgba8888_t;
typedef union arm_2d_color_rgb888_t {
uint32_t tValue;
struct {
uint32_t u8R : 8;
uint32_t u8G : 8;
uint32_t u8B : 8;
uint32_t : 8;
};
} arm_2d_color_rgb888_t;
typedef union arm_2d_color_ccca8888_t {
uint32_t tValue;
struct {
uint8_t u8C[3];
uint8_t u8A;
};
} arm_2d_color_ccca8888_t;
typedef union arm_2d_color_accc8888_t {
uint32_t tValue;
struct {
uint8_t u8A;
uint8_t u8C[3];
};
} arm_2d_color_accc8888_t;
typedef union arm_2d_color_cccn888_t {
uint32_t tValue;
struct {
uint8_t u8C[3];
uint8_t : 8;
};
} arm_2d_color_cccn888_t;
typedef union arm_2d_color_nccc888_t {
uint32_t tValue;
struct {
uint8_t : 8;
uint8_t u8C[3];
};
} arm_2d_color_nccc888_t;
//! \name colour size
//! @{
enum {
ARM_2D_COLOUR_SZ_1BIT = 0, //!< 1 bit:black and white
ARM_2D_COLOUR_SZ_2BIT = 1, //!< 4 colours or 4 gray-levels
ARM_2D_COLOUR_SZ_4BIT = 2, //!< 16 colours or 16 gray-levels
ARM_2D_COLOUR_SZ_8BIT = 3, //!< 256 colours
ARM_2D_COLOUR_SZ_16BIT = 4, //!< 16bits
ARM_2D_COLOUR_SZ_32BIT = 5, //!< true colour
ARM_2D_COLOUR_SZ_1BIT_msk = ARM_2D_COLOUR_SZ_1BIT << 1,
ARM_2D_COLOUR_SZ_2BIT_msk = ARM_2D_COLOUR_SZ_2BIT << 1,
ARM_2D_COLOUR_SZ_4BIT_msk = ARM_2D_COLOUR_SZ_4BIT << 1,
ARM_2D_COLOUR_SZ_8BIT_msk = ARM_2D_COLOUR_SZ_8BIT << 1,
ARM_2D_COLOUR_SZ_16BIT_msk = ARM_2D_COLOUR_SZ_16BIT<< 1,
ARM_2D_COLOUR_SZ_32BIT_msk = ARM_2D_COLOUR_SZ_32BIT<< 1,
ARM_2D_COLOUR_SZ_msk = (0x07 << 1),
ARM_2D_COLOUR_LITTLE_ENDIAN = 0,
ARM_2D_COLOUR_BIG_ENDIAN = 1,
ARM_2D_COLOUR_LITTLE_ENDIAN_msk = ARM_2D_COLOUR_LITTLE_ENDIAN << 4,
ARM_2D_COLOUR_BIG_ENDIAN_msk = ARM_2D_COLOUR_BIG_ENDIAN << 4,
ARM_2D_COLOUR_NO_ALPHA = 0,
ARM_2D_COLOUR_HAS_ALPHA = 1,
ARM_2D_COLOUR_NO_ALPHA_msk = ARM_2D_COLOUR_NO_ALPHA << 0,
ARM_2D_COLOUR_HAS_ALPHA_msk = ARM_2D_COLOUR_HAS_ALPHA << 0,
ARM_2D_COLOUR_VARIANT = 5,
ARM_2D_COLOUR_VARIANT_msk = 0x07 << ARM_2D_COLOUR_VARIANT,
};
//! @}
//! \name colour scheme
//! @{
enum {
ARM_2D_COLOUR_BIN = ARM_2D_COLOUR_SZ_1BIT_msk,
ARM_2D_COLOUR_1BIT = ARM_2D_COLOUR_SZ_1BIT_msk,
ARM_2D_COLOUR_8BIT = ARM_2D_COLOUR_SZ_8BIT_msk,
ARM_2D_COLOUR_GRAY8 = ARM_2D_COLOUR_SZ_8BIT_msk,
ARM_2D_COLOUR_16BIT = ARM_2D_COLOUR_SZ_16BIT_msk,
ARM_2D_COLOUR_RGB16 = ARM_2D_COLOUR_SZ_16BIT_msk,
ARM_2D_COLOUR_RGB565 = ARM_2D_COLOUR_RGB16,
ARM_2D_COLOUR_RGB565_BE = ARM_2D_COLOUR_SZ_16BIT_msk |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
ARM_2D_COLOUR_32BIT = ARM_2D_COLOUR_SZ_32BIT_msk ,
ARM_2D_COLOUR_RGB32 = ARM_2D_COLOUR_SZ_32BIT_msk ,
ARM_2D_COLOUR_RGB888 = ARM_2D_COLOUR_RGB32 ,
ARM_2D_COLOUR_RGBA8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA ,
ARM_2D_COLOUR_CCCN888 = ARM_2D_COLOUR_RGB32 ,
ARM_2D_COLOUR_CCCA8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA ,
ARM_2D_COLOUR_NCCC888 = ARM_2D_COLOUR_RGB32 |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
ARM_2D_COLOUR_ACCC8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA |
ARM_2D_COLOUR_BIG_ENDIAN_msk ,
ARM_2D_CHANNEL_8in32 = ARM_2D_COLOUR_SZ_32BIT_msk |
ARM_2D_COLOUR_HAS_ALPHA |
(0x07 << ARM_2D_COLOUR_VARIANT) ,
};
//! @}
typedef union {
struct {
uint8_t bHasAlpha : 1; //!< whether the target colour has alpha channel
uint8_t u3ColourSZ : 3; //!< the size of the colour
uint8_t bBigEndian : 1; //!< whether the colour is stored in big endian
uint8_t u3Variant : 3;
};
uint8_t chScheme;
} arm_2d_color_info_t;
/*----------------------------------------------------------------------------*
* Tile and Regions *
*----------------------------------------------------------------------------*/
typedef struct arm_2d_location_t {
int16_t iX;
int16_t iY;
} arm_2d_location_t;
typedef struct arm_2d_point_float_t {
float fX;
float fY;
} arm_2d_point_float_t;
typedef struct arm_2d_point_fx_t {
int32_t X;
int32_t Y;
} arm_2d_point_fx_t;
typedef struct arm_2d_size_t {
int16_t iWidth;
int16_t iHeight;
} arm_2d_size_t;
typedef struct arm_2d_region_t {
implement_ex(arm_2d_location_t, tLocation);
implement_ex(arm_2d_size_t, tSize);
} arm_2d_region_t;
typedef struct arm_2d_tile_t arm_2d_tile_t;
struct arm_2d_tile_t {
implement_ex(struct {
uint8_t bIsRoot : 1; //!< is this tile a root tile
uint8_t bHasEnforcedColour : 1; //!< does this tile contains enforced colour info
uint8_t bDerivedResource : 1; //!< indicate whether this is a derived resources (when bIsRoot == 0)
uint8_t : 5;
uint8_t : 8;
uint8_t : 8;
arm_2d_color_info_t tColourInfo; //!< enforced colour
}, tInfo);
implement_ex(arm_2d_region_t, tRegion);
union {
/*! when bIsRoot is true, phwBuffer is available,
*! otherwise ptParent is available
*/
arm_2d_tile_t *ptParent;
uint16_t *phwBuffer;
uint32_t *pwBuffer;
uint8_t *pchBuffer;
intptr_t nAddress;
};
};
/*----------------------------------------------------------------------------*
* Task *
*----------------------------------------------------------------------------*/
typedef struct arm_2d_task_t {
ARM_PRIVATE(
arm_fsm_rt_t tResult;
uint8_t chState;
void *ptTask;
)
} arm_2d_task_t;
/*----------------------------------------------------------------------------*
* Operation and Events Handling *
*----------------------------------------------------------------------------*/
typedef struct arm_2d_op_core_t arm_2d_op_core_t;
typedef bool arm_2d_op_evt_handler_t( arm_2d_op_core_t *ptThisOP,
arm_fsm_rt_t tResult,
void *pTarget);
typedef struct arm_2d_op_evt_t {
arm_2d_op_evt_handler_t *fnHandler; //!< event handler
void *pTarget; //!< user attached target
} arm_2d_op_evt_t;
typedef bool arm_2d_evt_handler_t(void *pTarget);
typedef struct arm_2d_evt_t {
arm_2d_evt_handler_t *fnHandler; //!< event handler
void *pTarget; //!< user attached target
} arm_2d_evt_t;
#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE _BV(0)
#define ARM_2D_OP_INFO_PARAM_HAS_TARGET _BV(1)
#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK _BV(2)
#define ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK _BV(3)
#define ARM_2D_OP_INFO_PARAM_HAS_ORIGIN _BV(4)
//! an imcomplete defintion which is only used for defining pointers
typedef struct __arm_2d_low_level_io_t __arm_2d_low_level_io_t;
typedef union __arm_2d_op_info_t {
struct {
arm_2d_color_info_t Colour; //!< the colour used in thie operation
union {
struct {
uint8_t bHasSource : 1; //!< whether this operation contains source tile
uint8_t bHasTarget : 1; //!< whether this operation contains target tile
uint8_t bHasSrcMask : 1; //!< whether this operation has Mask layer for source tile
uint8_t bHasDesMask : 1; //!< whether this operation has Mask layer for target tile
uint8_t bHasOrigin : 1; //!< whether the Source has an origin tile
uint8_t : 2;
uint8_t bAllowEnforcedColour : 1; //!< whether this operation allow enforced colours in tiles
};
uint8_t chValue;
}Param;
uint8_t : 8; //!< reserved
uint8_t chOpIndex; //!< __ARM_2D_OP_IDX_XXXXXX
union {
struct {
uint8_t CopyLike;
uint8_t FillLike;
};
struct {
uint8_t CopyOrigLike;
uint8_t FillOrigLike;
};
struct {
uint8_t TileProcessLike;
};
}LowLevelInterfaceIndex;
union {
const __arm_2d_low_level_io_t *IO[2];
struct {
const __arm_2d_low_level_io_t *ptCopyLike;
const __arm_2d_low_level_io_t *ptFillLike;
};
struct {
const __arm_2d_low_level_io_t *ptCopyOrigLike;
const __arm_2d_low_level_io_t *ptFillOrigLike;
};
struct {
const __arm_2d_low_level_io_t *ptTileProcessLike;
};
}LowLevelIO;
}Info;
uint32_t wID; //!< ID for a specific operation
} __arm_2d_op_info_t;
//! \name how would you want to accelerate the 2d-operation
//! @{
enum {
//! Use hardware acceleration if possible, even if there is a long queue to wait
ARM_2D_PREF_ACC_USE_HW_IF_POSSIBLE = 0,
//! Only use Hardware Acceleration, if it is not supported, IO error will be issued
ARM_2D_PREF_ACC_HW_ONLY = 1,
//! Only use software algorithm
ARM_2D_PREF_ACC_SW_ONLY = 2,
//!< don't care, let the arm-2d library decide
ARM_2D_PREF_ACC_DONT_CARE = 3,
};
//! @}
#define __ARM_2D_OP_STATUS_BUSY_msk (1 << 4)
#define __ARM_2D_OP_STATUS_IO_ERROR_msk (1 << 5)
#define __ARM_2D_OP_STATUS_CPL_msk (1 << 6)
typedef union arm_2d_op_status_t {
struct {
uint16_t u4SubTaskCount : 4; //!< sub task count
uint16_t bIsBusy : 1; //!< busy flag
uint16_t bIOError : 1; //!< HW IO Error
uint16_t bOpCpl : 1; //!< the whole operation complete
uint16_t : 9; //!< reserved
};
uint16_t tValue;
} arm_2d_op_status_t;
struct arm_2d_op_core_t {
ARM_PRIVATE(
arm_2d_op_core_t *ptNext; //!< pointer for a single list
const __arm_2d_op_info_t *ptOp;
struct {
uint8_t u2ACCMethods : 2; //!< acceleration Methods
uint8_t : 6; //!< reserved
}Preference;
int8_t tResult; //!< operation result
volatile arm_2d_op_status_t Status;
arm_2d_op_evt_t evt2DOpCpl; //!< operation complete event
)
uintptr_t pUserParam;
};
typedef struct arm_2d_op_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
} arm_2d_op_t;
/*! \brief arm_2d_op_msk_t is inherit from arm_2d_op_t
*/
typedef struct arm_2d_op_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< target tile
} Mask;
} arm_2d_op_msk_t;
/*! \brief arm_2d_op_src_t is inherit from arm_2d_op_t
*/
typedef struct arm_2d_op_src_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
} arm_2d_op_src_t;
/*! \brief arm_2d_op_src_msk_t is inherit from arm_2d_op_src_t
*/
typedef struct arm_2d_op_src_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptSourceSide; //!< source side mask
const arm_2d_tile_t *ptTargetSide; //!< target side mask
} Mask;
} arm_2d_op_src_msk_t;
/*! \brief arm_2d_op_src_orig_t is inherit from arm_2d_op_src_t
*/
typedef struct arm_2d_op_src_orig_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
} arm_2d_op_src_orig_t;
/*! \brief arm_2d_op_src_orig_msk_t is inherit from arm_2d_op_src_orig_t
*/
typedef struct arm_2d_op_src_orig_msk_t {
inherit(arm_2d_op_core_t);
struct {
const arm_2d_tile_t *ptTile; //!< target tile
const arm_2d_region_t *ptRegion; //!< target region
} Target;
struct {
const arm_2d_tile_t *ptTile; //!< source tile
}Source;
uint32_t wMode;
struct {
const arm_2d_tile_t *ptTile; //!< the origin tile
arm_2d_tile_t tDummySource; //!< the buffer for the source
}Origin;
struct {
const arm_2d_tile_t *ptSourceSide; //!< source side mask
const arm_2d_tile_t *ptTargetSide; //!< target side mask
} Mask;
} arm_2d_op_src_orig_msk_t;
/*----------------------------------------------------------------------------*
* Fast Rotation linear regression structure
*----------------------------------------------------------------------------*/
#if (__ARM_2D_HAS_HELIUM_FLOAT__ || __ARM_2D_HAS_FPU__) \
&& !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__
typedef struct arm_2d_rot_linear_regr_t {
float slopeY;
float interceptY;
float slopeX;
float interceptX;
} arm_2d_rot_linear_regr_t;
#else
/* fixed point */
typedef struct arm_2d_rot_linear_regr_t {
int32_t slopeY;
int32_t interceptY;
int32_t slopeX;
int32_t interceptX;
} arm_2d_rot_linear_regr_t;
#endif
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
#if defined(__clang__)
#pragma clang diagnostic pop
#elif __IS_COMPILER_ARM_COMPILER_5__
#pragma diag_warning 64
#elif __IS_COMPILER_GCC__
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif // __ARM_2D_TYPES_H__