diff --git a/package/Arm2D/Arm2D.c b/package/Arm2D/Arm2D.c new file mode 100644 index 000000000..c6b25b585 --- /dev/null +++ b/package/Arm2D/Arm2D.c @@ -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; +} diff --git a/package/Arm2D/Arm2D.pyi b/package/Arm2D/Arm2D.pyi deleted file mode 100644 index 018dd8aed..000000000 --- a/package/Arm2D/Arm2D.pyi +++ /dev/null @@ -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 diff --git a/package/Arm2D/Arm2D_Background.c b/package/Arm2D/Arm2D_Background.c index 8596f3136..056ee1056 100644 --- a/package/Arm2D/Arm2D_Background.c +++ b/package/Arm2D/Arm2D_Background.c @@ -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"); } diff --git a/package/Arm2D/Arm2D_Box.c b/package/Arm2D/Arm2D_Box.c index 9ae0c608a..a7bf8431c 100644 --- a/package/Arm2D/Arm2D_Box.c +++ b/package/Arm2D/Arm2D_Box.c @@ -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); diff --git a/package/Arm2D/Arm2D_Element.c b/package/Arm2D/Arm2D_Element.c index 279aaf4cd..0c1feb229 100644 --- a/package/Arm2D/Arm2D_Element.c +++ b/package/Arm2D/Arm2D_Element.c @@ -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); diff --git a/package/Arm2D/Arm2D_ElementList.c b/package/Arm2D/Arm2D_ElementList.c index 9f6bf443c..c983350bd 100644 --- a/package/Arm2D/Arm2D_ElementList.c +++ b/package/Arm2D/Arm2D_ElementList.c @@ -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; } diff --git a/package/Arm2D/Arm2D_Location.c b/package/Arm2D/Arm2D_Location.c new file mode 100644 index 000000000..93493d3ef --- /dev/null +++ b/package/Arm2D/Arm2D_Location.c @@ -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); + } +} diff --git a/package/Arm2D/Arm2D_Region.c b/package/Arm2D/Arm2D_Region.c new file mode 100644 index 000000000..e4cadf730 --- /dev/null +++ b/package/Arm2D/Arm2D_Region.c @@ -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; +} diff --git a/package/Arm2D/Arm2D_Tile.c b/package/Arm2D/Arm2D_Tile.c new file mode 100644 index 000000000..0fe420c8c --- /dev/null +++ b/package/Arm2D/Arm2D_Tile.c @@ -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); +} diff --git a/package/Arm2D/Arm2D_Window.c b/package/Arm2D/Arm2D_Window.c index 38617d2ed..9d5087429 100644 --- a/package/Arm2D/Arm2D_Window.c +++ b/package/Arm2D/Arm2D_Window.c @@ -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"); diff --git a/package/Arm2D/Arm2D_common.h b/package/Arm2D/Arm2D_common.h index 6341d1b17..d9ef9f4a6 100644 --- a/package/Arm2D/Arm2D_common.h +++ b/package/Arm2D/Arm2D_common.h @@ -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 diff --git a/package/Arm2D/arm_2d.c b/package/Arm2D/Helper/Include/arm_2d_disp_adapters.h similarity index 55% rename from package/Arm2D/arm_2d.c rename to package/Arm2D/Helper/Include/arm_2d_disp_adapters.h index 8082c658b..e5948594f 100644 --- a/package/Arm2D/arm_2d.c +++ b/package/Arm2D/Helper/Include/arm_2d_disp_adapters.h @@ -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 diff --git a/package/Arm2D/arm_2d_helper.h b/package/Arm2D/Helper/Include/arm_2d_helper.h similarity index 55% rename from package/Arm2D/arm_2d_helper.h rename to package/Arm2D/Helper/Include/arm_2d_helper.h index 7ea8c66bc..06c1a4e14 100644 --- a/package/Arm2D/arm_2d_helper.h +++ b/package/Arm2D/Helper/Include/arm_2d_helper.h @@ -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 diff --git a/package/Arm2D/Helper/Include/arm_2d_helper_pfb.h b/package/Arm2D/Helper/Include/arm_2d_helper_pfb.h new file mode 100644 index 000000000..2986c248e --- /dev/null +++ b/package/Arm2D/Helper/Include/arm_2d_helper_pfb.h @@ -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 diff --git a/package/Arm2D/Helper/Include/arm_2d_helper_scene.h b/package/Arm2D/Helper/Include/arm_2d_helper_scene.h new file mode 100644 index 000000000..d9381c876 --- /dev/null +++ b/package/Arm2D/Helper/Include/arm_2d_helper_scene.h @@ -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 diff --git a/package/Arm2D/arm_2d_helper_pfb.c b/package/Arm2D/Helper/Source/arm_2d_helper_pfb.c similarity index 72% rename from package/Arm2D/arm_2d_helper_pfb.c rename to package/Arm2D/Helper/Source/arm_2d_helper_pfb.c index 9904d3e84..92134985b 100644 --- a/package/Arm2D/arm_2d_helper_pfb.c +++ b/package/Arm2D/Helper/Source/arm_2d_helper_pfb.c @@ -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 #include "arm_2d_helper.h" +#if defined(__PERF_COUNTER__) +# include "perf_counter.h" +#else +# include +#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 diff --git a/package/Arm2D/LICENSE b/package/Arm2D/LICENSE new file mode 100644 index 000000000..58aaf9511 --- /dev/null +++ b/package/Arm2D/LICENSE @@ -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. \ No newline at end of file diff --git a/package/Arm2D/Library/Include/README.md b/package/Arm2D/Library/Include/README.md new file mode 100644 index 000000000..8f5d9211f --- /dev/null +++ b/package/Arm2D/Library/Include/README.md @@ -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. | | diff --git a/package/Arm2D/Library/Include/__arm_2d_direct.h b/package/Arm2D/Library/Include/__arm_2d_direct.h new file mode 100644 index 000000000..73dc92aa9 --- /dev/null +++ b/package/Arm2D/Library/Include/__arm_2d_direct.h @@ -0,0 +1,9317 @@ +/* + * 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_direct.h + * Description: header files for internal users or professional developers + * + * $Date: 29. April 2022 + * $Revision: V.1.0.2 + * + * Target Processor: Cortex-M cores + * + * -------------------------------------------------------------------- */ + +#ifndef __ARM_2D_DIRECT_H__ +#define __ARM_2D_DIRECT_H__ + +/*============================ INCLUDES ======================================*/ +#include "arm_2d.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 "-Wgnu-zero-variadic-macro-arguments" +# pragma clang diagnostic ignored "-Wmissing-declarations" +# 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" +#endif + +/*============================ MACROS ========================================*/ +/*============================ MACROFIED FUNCTIONS ===========================*/ +/*============================ TYPES =========================================*/ +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ + + +void __arm_2d_impl_c8bit_1x1_paving(const uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_c8bit_1x1_paving_x_mirror(const uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_c8bit_1x1_paving_xy_mirror(const uint8_t * + __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_c8bit_1x1_paving_y_mirror(const uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_c8bit_1x2_paving(const uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_c8bit_1x2_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_c8bit_1x2_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_c8bit_1x2_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_c8bit_2x1_paving(const uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, uint16_t destHeight); + +void __arm_2d_impl_c8bit_2x1_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_c8bit_2x1_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_c8bit_2x1_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_c8bit_2x2_paving(const uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_c8bit_2x2_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_c8bit_2x2_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_c8bit_2x2_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_c8bit_cl_key_1x1_paving(const uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x1_paving_x_mirror(const uint8_t * + __restrict pSource, + int16_t iSourceStride, + uint8_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x1_paving_xy_mirror(const uint8_t * + __restrict pSource, + int16_t iSourceStride, + uint8_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x1_paving_y_mirror(const uint8_t * + __restrict pSource, + int16_t iSourceStride, + uint8_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x2_paving(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x2_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x2_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_1x2_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x1_paving(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x1_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x1_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x1_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x2_paving(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x2_paving_x_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x2_paving_xy_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_2x2_paving_y_mirror(const uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_copy(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_copy_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode, uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_copy_x_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_copy_xy_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_copy_y_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_fill(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_fill_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode, uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_fill_x_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_fill_xy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_cl_key_fill_y_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_colour_filling(uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_c8bit_copy(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_c8bit_copy_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_c8bit_copy_x_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_c8bit_copy_xy_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_c8bit_copy_y_mirror(uint8_t * __restrict pSource, + int16_t iSourceStride, + uint8_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_c8bit_draw_pattern(uint8_t * __restrict pchSourceBase, + int32_t iOffset, int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint8_t chMode, uint8_t ForeColour, + uint8_t BackColour); + +void __arm_2d_impl_c8bit_draw_pattern_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t BackColour); + +void __arm_2d_impl_c8bit_draw_pattern_bg_fg(uint8_t * __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t ForeColour, + uint8_t BackColour); + +void __arm_2d_impl_c8bit_draw_pattern_bg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t BackColour); + +void __arm_2d_impl_c8bit_draw_pattern_fg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t ForeColour); + +void __arm_2d_impl_c8bit_draw_pattern_no_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_c8bit_fill(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_c8bit_fill_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_c8bit_fill_x_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_c8bit_fill_xy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_c8bit_fill_y_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_1h_des_msk_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_1h_des_msk_copy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_1h_des_msk_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_1h_des_msk_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_1h_des_msk_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_1h_des_msk_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_1h_des_msk_fill_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_1h_des_msk_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_1h_des_msk_fill_xy_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_1h_des_msk_fill_y_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_alpha_blending(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint_fast16_t chRatio); + +void __arm_2d_impl_cccn888_alpha_blending(uint32_t * pwSourceBase, + int16_t iSourceStride, + uint32_t * pwTargetBase, + int16_t iTargetStride, + arm_2d_size_t * ptCopySize, + uint_fast16_t chRatio); + +void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint_fast16_t chRatio, + uint32_t Colour); + +void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * + __restrict pTarget, + int16_t iTargetStride, + uint32_t * + __restrict pwAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * + __restrict + pTarget, + int16_t + iTargetStride, + uint32_t * + __restrict + pwAlpha, + int16_t + iAlphaStride, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __restrict pTarget, + int16_t iTargetStride, + uint8_t * __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * + __restrict pTarget, + int16_t iTargetStride, + uint8_t * + __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_cccn888_colour_filling_with_opacity(uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour, + uint_fast16_t hwRatio); + +void __arm_2d_impl_cccn888_des_chn_msk_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_chn_msk_copy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_des_chn_msk_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_chn_msk_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_chn_msk_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_chn_msk_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_chn_msk_fill_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_des_chn_msk_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_chn_msk_fill_xy_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_chn_msk_fill_y_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_msk_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_msk_copy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_des_msk_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_msk_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_msk_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_des_msk_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_msk_fill_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_des_msk_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_msk_fill_xy_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_des_msk_fill_y_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_masks_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_cccn888_masks_copy_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_masks_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_masks_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_masks_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_masks_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_masks_fill_mirror(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_masks_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_masks_fill_xy_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_masks_fill_y_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_copy(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_copy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_copy_x_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_copy_xy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_copy_y_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_fill(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_fill_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_fill_x_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_fill_xy_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_1h_des_msk_fill_y_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_copy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_copy(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_copy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_copy_x_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_copy_xy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t + * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t + * + __restrict + ptTargetMaskSize, + arm_2d_size_t + * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_copy_y_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_fill(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_fill_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_fill_x_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_fill_xy_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t + * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t + * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t + * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t + * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_chn_msk_fill_y_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_copy(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_copy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_copy_x_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_copy_xy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_copy_y_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_fill(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_fill_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_fill_x_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_fill_xy_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_des_msk_fill_y_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_chn_msk_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_chn_msk_fill_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_chn_msk_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_chn_msk_fill_xy_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_chn_msk_fill_y_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_copy(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_copy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_copy_x_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_copy_xy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_copy_y_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_fill(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_fill_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_fill_x_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_fill_xy_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_1h_des_msk_fill_y_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_copy(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_copy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_copy_x_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_copy_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_copy_y_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_copy(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_copy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_copy_x_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_copy_xy_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_copy_y_mirror(uint32_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_fill(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_fill_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_fill_x_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_fill_xy_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_des_chn_msk_fill_y_mirror(uint32_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint32_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_cccn888_src_msk_fill(uint32_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_msk_fill_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_cccn888_src_msk_fill_x_mirror(uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_msk_fill_xy_mirror( uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_cccn888_src_msk_fill_y_mirror( uint32_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint32_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +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 pwSourceBase, + int16_t iSourceStride, + uint16_t * __restrict phwTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_cccn888_transform(__arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_cccn888_transform_with_opacity( + __arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_cccn888_transform_with_src_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_cccn888_transform_with_src_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_cccn888_transform_with_src_chn_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_cccn888_transform_with_src_chn_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_gray8_1h_des_msk_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_gray8_1h_des_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_1h_des_msk_copy_x_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_1h_des_msk_copy_xy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_1h_des_msk_copy_y_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_1h_des_msk_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_1h_des_msk_fill_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_1h_des_msk_fill_x_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_1h_des_msk_fill_xy_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_1h_des_msk_fill_y_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_alpha_blending(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint_fast16_t hwRatio); + +void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint_fast16_t hwRatio, + uint8_t Colour); + +void __arm_2d_impl_gray8_colour_filling_channel_mask(uint8_t * + __restrict pTarget, + int16_t iTargetStride, + uint32_t * + __restrict pwAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_gray8_colour_filling_channel_mask_opacity(uint8_t * + __restrict pTarget, + int16_t + iTargetStride, + uint32_t * + __restrict pwAlpha, + int16_t + iAlphaStride, + arm_2d_size_t * + __restrict + ptCopySize, + uint8_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_gray8_colour_filling_mask(uint8_t * __restrict pTarget, + int16_t iTargetStride, + uint8_t * __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour); + +void __arm_2d_impl_gray8_colour_filling_mask_opacity(uint8_t * + __restrict pTarget, + int16_t iTargetStride, + uint8_t * + __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint8_t Colour, + uint_fast16_t hwRatio); + +void __arm_2d_impl_gray8_des_chn_msk_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_chn_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_des_chn_msk_copy_x_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_chn_msk_copy_xy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_chn_msk_copy_y_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_chn_msk_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_chn_msk_fill_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_des_chn_msk_fill_x_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_chn_msk_fill_xy_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_chn_msk_fill_y_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_msk_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_msk_copy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_des_msk_copy_x_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_msk_copy_xy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_msk_copy_y_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_des_msk_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_msk_fill_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_des_msk_fill_x_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_msk_fill_xy_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_des_msk_fill_y_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_masks_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_gray8_masks_copy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_masks_copy_x_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_masks_copy_xy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_masks_copy_y_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_masks_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_masks_fill_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_masks_fill_x_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_masks_fill_xy_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_masks_fill_y_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_copy(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_copy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_copy_x_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_copy_xy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_copy_y_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_fill(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_fill_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_fill_x_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_fill_xy_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_1h_des_msk_fill_y_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_copy_x_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_copy_xy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_copy_y_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_copy(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_copy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_copy_x_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_copy_xy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_copy_y_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_fill(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_fill_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_fill_x_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_fill_xy_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_chn_msk_fill_y_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_copy(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_copy_x_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_copy_xy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_copy_y_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_fill(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_fill_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_fill_x_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_fill_xy_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_des_msk_fill_y_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_chn_msk_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_chn_msk_fill_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_chn_msk_fill_x_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_chn_msk_fill_xy_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_chn_msk_fill_y_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_copy(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_copy_x_mirror(uint8_t * + __restrict + pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_copy_xy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_copy_y_mirror(uint8_t * + __restrict + pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_fill(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_fill_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_fill_x_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_fill_xy_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_1h_des_msk_fill_y_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_copy(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_copy_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_copy_x_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_copy_xy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_copy_y_mirror(uint8_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_copy(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_copy_mirror(uint8_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_copy_x_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_copy_xy_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_copy_y_mirror(uint8_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_fill(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_fill_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_fill_x_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_fill_xy_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_des_chn_msk_fill_y_mirror(uint8_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint8_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_gray8_src_msk_fill(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_msk_fill_mirror(uint8_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_gray8_src_msk_fill_x_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_msk_fill_xy_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_src_msk_fill_y_mirror(uint8_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint8_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_gray8_transform( __arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_gray8_transform_with_opacity( + __arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_gray8_transform_with_src_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_gray8_transform_with_src_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_gray8_transform_with_src_chn_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_gray8_transform_with_src_chn_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb16_1x1_paving(const uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb16_1x1_paving_x_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb16_1x1_paving_xy_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb16_1x1_paving_y_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb16_1x2_paving(const uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb16_1x2_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb16_1x2_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb16_1x2_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb16_2x1_paving(const uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, uint16_t destHeight); + +void __arm_2d_impl_rgb16_2x1_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb16_2x1_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb16_2x1_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb16_2x2_paving(const uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb16_2x2_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb16_2x2_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb16_2x2_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb16_cl_key_1x1_paving(const uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x1_paving_x_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x1_paving_xy_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x1_paving_y_mirror(const uint16_t * + __restrict pSource, + int16_t iSourceStride, + uint16_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x2_paving(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x2_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x2_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_1x2_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x1_paving(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x1_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x1_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x1_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x2_paving(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x2_paving_x_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x2_paving_xy_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_2x2_paving_y_mirror(const uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_copy(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_copy_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode, uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_copy_x_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_copy_xy_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_copy_y_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_fill(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_fill_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode, uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_fill_x_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_fill_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_cl_key_fill_y_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_colour_filling(uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb16_copy(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb16_copy(uint16_t * phwSource, int16_t iSourceStride, + uint16_t * phwTarget, int16_t iTargetStride, + arm_2d_size_t * ptCopySize); + +void __arm_2d_impl_rgb16_copy_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb16_copy_x_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb16_copy_xy_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb16_copy_y_mirror(uint16_t * __restrict pSource, + int16_t iSourceStride, + uint16_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb16_draw_pattern(uint8_t * __restrict pchSourceBase, + int32_t iOffset, int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint8_t chMode, uint16_t ForeColour, + uint16_t BackColour); + +void __arm_2d_impl_rgb16_draw_pattern_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t BackColour); + +void __arm_2d_impl_rgb16_draw_pattern_bg_fg(uint8_t * __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t ForeColour, + uint16_t BackColour); + +void __arm_2d_impl_rgb16_draw_pattern_bg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t BackColour); + +void __arm_2d_impl_rgb16_draw_pattern_fg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t ForeColour); + +void __arm_2d_impl_rgb16_draw_pattern_no_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb16_fill(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb16_fill_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_rgb16_fill_x_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb16_fill_xy_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb16_fill_y_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb32_1x1_paving(const uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb32_1x1_paving_x_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb32_1x1_paving_xy_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb32_1x1_paving_y_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize); + +void __arm_2d_impl_rgb32_1x2_paving(const uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb32_1x2_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb32_1x2_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb32_1x2_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows); + +void __arm_2d_impl_rgb32_2x1_paving(const uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, uint16_t destHeight); + +void __arm_2d_impl_rgb32_2x1_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb32_2x1_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb32_2x1_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight); + +void __arm_2d_impl_rgb32_2x2_paving(const uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb32_2x2_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb32_2x2_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb32_2x2_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols); + +void __arm_2d_impl_rgb32_cl_key_1x1_paving(const uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x1_paving_x_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x1_paving_xy_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x1_paving_y_mirror(const uint32_t * + __restrict pSource, + int16_t iSourceStride, + uint32_t * + __restrict pTarget, + int16_t iTargetStride, + const arm_2d_size_t * + __restrict ptSrcCopySize, + const arm_2d_size_t * + __restrict ptDstCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x2_paving(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x2_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x2_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_1x2_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t destWidth, + uint16_t tilePairRows, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x1_paving(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x1_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x1_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x1_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairCols, + uint16_t destHeight, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x2_paving(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x2_paving_x_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x2_paving_xy_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_2x2_paving_y_mirror(const uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + const arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint16_t tilePairRows, + uint16_t tilePairCols, + uint32_t Colour); + + +void __arm_2d_impl_rgb32_cl_key_copy(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_copy_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode, uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_copy_x_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_copy_xy_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_copy_y_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_fill(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_fill_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode, uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_fill_x_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_fill_xy_mirror(uint32_t * + __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_cl_key_fill_y_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_colour_filling(uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint32_t Colour); + +void __arm_2d_impl_rgb32_copy(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb32_copy(uint32_t * pwSource, int16_t iSourceStride, + uint32_t * pwTarget, int16_t iTargetStride, + arm_2d_size_t * ptCopySize); + +void __arm_2d_impl_rgb32_copy_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb32_copy_x_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb32_copy_xy_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb32_copy_y_mirror(uint32_t * __restrict pSource, + int16_t iSourceStride, + uint32_t * __restrict pTarget, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb32_draw_pattern(uint8_t * __restrict pchSourceBase, + int32_t iOffset, int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint8_t chMode, uint32_t ForeColour, + uint32_t BackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t BackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t hwBackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_fg(uint8_t * __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t ForeColour, + uint32_t BackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_fg(uint8_t * __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t hwForeColour, + uint32_t hwBackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t BackColour); + +void __arm_2d_impl_rgb32_draw_pattern_bg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t hwBackColour); + +void __arm_2d_impl_rgb32_draw_pattern_fg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t ForeColour); + +void __arm_2d_impl_rgb32_draw_pattern_fg_only(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t hwForeColour); + +void __arm_2d_impl_rgb32_draw_pattern_no_bg_comp(uint8_t * + __restrict pchSourceBase, + int32_t iOffset, + int16_t iSourceStride, + uint32_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb32_fill(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb32_fill_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_rgb32_fill_x_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb32_fill_xy_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb32_fill_y_mirror(uint32_t * __restrict pSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint32_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_1h_des_msk_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_1h_des_msk_copy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_1h_des_msk_copy_x_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_1h_des_msk_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_1h_des_msk_copy_y_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_1h_des_msk_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_1h_des_msk_fill_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_1h_des_msk_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_1h_des_msk_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_1h_des_msk_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_alpha_blending(uint16_t * __restrict phwSourceBase, + int16_t iSourceStride, + uint16_t * __restrict phwTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb565_alpha_blending(uint16_t * phwSourceBase, + int16_t iSourceStride, + uint16_t * phwTargetBase, + int16_t iTargetStride, + arm_2d_size_t * ptCopySize, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb565_alpha_blending_colour_keying(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint_fast16_t hwRatio, + uint16_t hwColour); + +void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * + __restrict pTarget, + int16_t iTargetStride, + uint32_t * + __restrict pwAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * + __restrict + pTarget, + int16_t + iTargetStride, + uint32_t * + __restrict + pwAlpha, + int16_t + iAlphaStride, + arm_2d_size_t * + __restrict + ptCopySize, + uint16_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __restrict pTarget, + int16_t iTargetStride, + uint8_t * __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour); + +void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * + __restrict pTarget, + int16_t iTargetStride, + uint8_t * + __restrict pchAlpha, + int16_t iAlphaStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour, + uint_fast16_t hwOpacity); + +void __arm_2d_impl_rgb565_colour_filling_with_opacity(uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint16_t Colour, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb565_des_chn_msk_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_chn_msk_copy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_des_chn_msk_copy_x_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_chn_msk_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_chn_msk_copy_y_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_chn_msk_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_chn_msk_fill_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_des_chn_msk_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_chn_msk_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_chn_msk_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_msk_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_msk_copy_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_des_msk_copy_x_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_msk_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_msk_copy_y_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_des_msk_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_msk_fill_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_des_msk_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_msk_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_des_msk_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_masks_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb565_masks_copy_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_masks_copy_x_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_masks_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_masks_copy_y_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_masks_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize, + uint8_t * __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_masks_fill_mirror(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_masks_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_masks_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_masks_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_copy(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_copy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_copy_x_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_copy_xy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_copy_y_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_fill(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_fill_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_fill_x_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_fill_xy_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_1h_des_msk_fill_y_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_copy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_copy_x_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_copy_y_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_copy(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_copy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_copy_x_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_copy_xy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_copy_y_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_fill(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_fill_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_fill_x_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_fill_xy_mirror( + uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_chn_msk_fill_y_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_copy(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_copy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_copy_x_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_copy_xy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_copy_y_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_fill(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_fill_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_fill_x_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_fill_xy_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_des_msk_fill_y_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_chn_msk_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_chn_msk_fill_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_chn_msk_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_chn_msk_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict + ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_chn_msk_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint32_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_copy(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_copy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_copy_x_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_copy_xy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_copy_y_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint8_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill_x_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill_xy_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill_y_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint8_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_copy(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_copy_mirror(uint16_t * __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_copy_x_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_copy_xy_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_copy_y_mirror(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_copy(uint16_t * + __restrict pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_copy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict ptCopySize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_copy_x_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_copy_xy_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_copy_y_mirror(uint16_t * + __restrict + pSourceBase, + int16_t + iSourceStride, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + pTargetBase, + int16_t + iTargetStride, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + arm_2d_size_t * + __restrict + ptCopySize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_fill(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t * + __restrict ptTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * + __restrict ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_fill_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_fill_x_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_fill_xy_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_des_chn_msk_fill_y_mirror(uint16_t * + __restrict + ptSourceBase, + int16_t + iSourceStride, + arm_2d_size_t * + __restrict + ptSourceSize, + uint8_t * + __restrict + ptSourceMaskBase, + int16_t + iSourceMaskStride, + arm_2d_size_t * + __restrict + ptSourceMaskSize, + uint16_t * + __restrict + ptTargetBase, + int16_t + iTargetStride, + arm_2d_size_t * + __restrict + ptTargetSize, + uint32_t * + __restrict + ptTargetMaskBase, + int16_t + iTargetMaskStride, + arm_2d_size_t * + __restrict + ptTargetMaskSize); + +void __arm_2d_impl_rgb565_src_msk_fill(uint16_t * __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __restrict ptSourceSize, + uint8_t * __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_msk_fill_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize, + uint32_t wMode); + +void __arm_2d_impl_rgb565_src_msk_fill_x_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_msk_fill_xy_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +void __arm_2d_impl_rgb565_src_msk_fill_y_mirror(uint16_t * + __restrict ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * + __restrict ptSourceSize, + uint8_t * + __restrict ptSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * + __restrict ptSourceMaskSize, + uint16_t * + __restrict ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * + __restrict ptTargetSize); + +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); + +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_cccn888(uint16_t * __restrict phwSourceBase, + int16_t iSourceStride, + uint32_t * __restrict pwTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __restrict ptCopySize); + +void __arm_2d_impl_rgb565_transform(__arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_rgb565_transform_with_opacity( + __arm_2d_param_copy_orig_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb565_transform_with_src_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_rgb565_transform_with_src_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +void __arm_2d_impl_rgb565_transform_with_src_chn_mask( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo); + +void __arm_2d_impl_rgb565_transform_with_src_chn_mask_and_opacity( + __arm_2d_param_copy_orig_msk_t * ptParam, + __arm_2d_transform_info_t * ptInfo, + uint_fast16_t hwRatio); + +#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 +} +#endif + +#endif diff --git a/package/Arm2D/__arm_2d_impl.h b/package/Arm2D/Library/Include/__arm_2d_impl.h similarity index 66% rename from package/Arm2D/__arm_2d_impl.h rename to package/Arm2D/Library/Include/__arm_2d_impl.h index ab99c0710..ae177a578 100644 --- a/package/Arm2D/__arm_2d_impl.h +++ b/package/Arm2D/Library/Include/__arm_2d_impl.h @@ -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 diff --git a/package/Arm2D/__arm_2d_math.h b/package/Arm2D/Library/Include/__arm_2d_math.h similarity index 92% rename from package/Arm2D/__arm_2d_math.h rename to package/Arm2D/Library/Include/__arm_2d_math.h index 858d07138..632bb5247 100644 --- a/package/Arm2D/__arm_2d_math.h +++ b/package/Arm2D/Library/Include/__arm_2d_math.h @@ -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 - #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 */ diff --git a/package/Arm2D/__arm_2d_math_helium.h b/package/Arm2D/Library/Include/__arm_2d_math_helium.h similarity index 95% rename from package/Arm2D/__arm_2d_math_helium.h rename to package/Arm2D/Library/Include/__arm_2d_math_helium.h index 5079bd705..965c60dc6 100644 --- a/package/Arm2D/__arm_2d_math_helium.h +++ b/package/Arm2D/Library/Include/__arm_2d_math_helium.h @@ -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()) diff --git a/package/Arm2D/__arm_2d_paving.h b/package/Arm2D/Library/Include/__arm_2d_paving.h similarity index 99% rename from package/Arm2D/__arm_2d_paving.h rename to package/Arm2D/Library/Include/__arm_2d_paving.h index 4ddc827aa..c2ca67c6d 100644 --- a/package/Arm2D/__arm_2d_paving.h +++ b/package/Arm2D/Library/Include/__arm_2d_paving.h @@ -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; \ \ diff --git a/package/Arm2D/__arm_2d_paving_helium.h b/package/Arm2D/Library/Include/__arm_2d_paving_helium.h similarity index 100% rename from package/Arm2D/__arm_2d_paving_helium.h rename to package/Arm2D/Library/Include/__arm_2d_paving_helium.h diff --git a/package/Arm2D/Library/Include/__arm_2d_utils_helium.h b/package/Arm2D/Library/Include/__arm_2d_utils_helium.h new file mode 100644 index 000000000..234cb3403 --- /dev/null +++ b/package/Arm2D/Library/Include/__arm_2d_utils_helium.h @@ -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 + +#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__ + diff --git a/package/Arm2D/Library/Include/arm_2d.h b/package/Arm2D/Library/Include/arm_2d.h new file mode 100644 index 000000000..75fff3d4e --- /dev/null +++ b/package/Arm2D/Library/Include/arm_2d.h @@ -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 diff --git a/package/Arm2D/arm_2d_alpha_blending.h b/package/Arm2D/Library/Include/arm_2d_alpha_blending.h similarity index 51% rename from package/Arm2D/arm_2d_alpha_blending.h rename to package/Arm2D/Library/Include/arm_2d_alpha_blending.h index 6ba04357f..595fd3890 100644 --- a/package/Arm2D/arm_2d_alpha_blending.h +++ b/package/Arm2D/Library/Include/arm_2d_alpha_blending.h @@ -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 alpha-blending related * APIs * - * $Date: 03. Oct 2021 - * $Revision: V.1.0.0 + * $Date: 17. June 2022 + * $Revision: V.1.0.1 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ @@ -49,142 +49,167 @@ extern "C" { #endif /*============================ MACROS ========================================*/ + +/*! + * \addtogroup Deprecated + * @{ + */ +#define arm_2d_rgb565_fill_colour_with_alpha \ + arm_2d_rgb565_fill_colour_with_opacity + +#define arm_2d_rgb888_fill_colour_with_alpha \ + arm_2d_rgb888_fill_colour_with_opacity + +#define arm_2d_cccn888_fill_colour_with_alpha \ + arm_2d_cccn888_fill_colour_with_opacity + +#define arm_2d_gray8_fill_colour_with_alpha_mask \ + arm_2d_gray8_fill_colour_with_mask + +#define arm_2d_rgb565_fill_colour_with_alpha_mask \ + arm_2d_rgb565_fill_colour_with_mask + +#define arm_2d_rgb888_fill_colour_with_alpha_mask \ + arm_2d_rgb888_fill_colour_with_mask + +#define arm_2d_cccn888_fill_colour_with_alpha_mask \ + arm_2d_cccn888_fill_colour_with_mask + +#define arm_2d_gray8_fill_colour_with_alpha_mask_and_opacity \ + arm_2d_gray8_fill_colour_with_mask_and_opacity + +#define arm_2d_rgb565_fill_colour_with_alpha_mask_and_opacity \ + arm_2d_rgb565_fill_colour_with_mask_and_opacity + +#define arm_2d_rgb888_fill_colour_with_alpha_mask_and_opacity \ + arm_2d_rgb888_fill_colour_with_mask_and_opacity + +#define arm_2d_cccn888_fill_colour_with_alpha_mask_and_opacity \ + arm_2d_cccn888_fill_colour_with_mask_and_opacity + +#define arm_2d_gray8_alpha_blending_with_colour_masking \ + arm_2d_gray8_alpha_blending_with_colour_keying + +#define arm_2d_rgb565_alpha_blending_with_colour_masking \ + arm_2d_rgb565_alpha_blending_with_colour_keying + +#define arm_2d_rgb888_alpha_blending_with_colour_masking \ + arm_2d_rgb888_alpha_blending_with_colour_keying + +#define arm_2d_cccn888_alpha_blending_with_colour_masking \ + arm_2d_cccn888_alpha_blending_with_colour_keying + +#define arm_2d_gray8_tile_copy_with_alpha_masks \ + arm_2d_gray8_tile_copy_with_masks + +#define arm_2d_rgb565_tile_copy_with_alpha_masks \ + arm_2d_rgb565_tile_copy_with_masks + +#define arm_2d_cccn888_tile_copy_with_alpha_masks \ + arm_2d_cccn888_tile_copy_with_masks + +#define arm_2d_rgb888_tile_copy_with_alpha_mask \ + arm_2d_rgb888_tile_copy_with_masks + +/*! @} */ + +/*! + * \addtogroup gAlpha 4 Alpha Blending Operations + * @{ + */ + /*============================ MACROFIED FUNCTIONS ===========================*/ -#define arm_2d_gray8_alpha_blending( __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA) /*!< alpha */ \ +#define arm_2d_gray8_alpha_blending( __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA) /* alpha */ \ arm_2dp_gray8_alpha_blending( NULL, \ (__SRC_ADDR), \ (__DES_ADDR), \ (__REGION_ADDR), \ (__ALPHA)) -#define arm_2d_rgb565_alpha_blending( __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA) /*!< alpha */ \ +#define arm_2d_rgb565_alpha_blending( __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA) /* alpha */ \ arm_2dp_rgb565_alpha_blending( NULL, \ (__SRC_ADDR), \ (__DES_ADDR), \ (__REGION_ADDR), \ (__ALPHA)) -#define arm_2d_rgb888_alpha_blending( __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA) /*!< alpha */ \ +#define arm_2d_rgb888_alpha_blending( __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA) /* alpha */ \ arm_2dp_cccn888_alpha_blending( NULL, \ (__SRC_ADDR), \ (__DES_ADDR), \ (__REGION_ADDR), \ (__ALPHA)) -#define arm_2d_cccn888_alpha_blending( __SRC_ADDR, /*!< source tile address */\ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA) /*!< alpha */ \ +#define arm_2d_cccn888_alpha_blending( __SRC_ADDR, /* source tile address */\ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA) /* alpha */ \ arm_2dp_cccn888_alpha_blending( NULL, \ (__SRC_ADDR), \ (__DES_ADDR), \ (__REGION_ADDR), \ (__ALPHA)) -#define arm_2d_gray8_fill_colour_with_alpha( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ +#define arm_2d_gray8_fill_colour_with_opacity( \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __COLOUR, /* colour */ \ + __ALPHA) /* alpha */ \ arm_2dp_gray8_fill_colour_with_opacity( NULL, \ (__DES_ADDR), \ (__REGION_ADDR), \ (__COLOUR), \ (__ALPHA)) -#define arm_2d_rgb565_fill_colour_with_alpha( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ - arm_2dp_rgb565_fill_colour_with_opacity( NULL, \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__COLOUR), \ - (__ALPHA)) - #define arm_2d_rgb565_fill_colour_with_opacity( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __COLOUR, /* colour */ \ + __ALPHA) /* alpha */ \ arm_2dp_rgb565_fill_colour_with_opacity( NULL, \ (__DES_ADDR), \ (__REGION_ADDR), \ (__COLOUR), \ (__ALPHA)) -#define arm_2d_rgb888_fill_colour_with_alpha( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ - arm_2dp_cccn888_fill_colour_with_opacity( NULL, \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__COLOUR), \ - (__ALPHA)) - #define arm_2d_rgb888_fill_colour_with_opacity( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __COLOUR, /* colour */ \ + __ALPHA) /* alpha */ \ arm_2dp_cccn888_fill_colour_with_opacity( NULL, \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__COLOUR), \ - (__ALPHA)) + (__DES_ADDR), \ + (__REGION_ADDR), \ + (arm_2d_color_cccn888_t){(__COLOUR).tValue}, \ + (__ALPHA)) -#define arm_2d_cccn888_fill_colour_with_alpha( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ - arm_2dp_cccn888_fill_colour_with_opacity( NULL, \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__COLOUR), \ - (__ALPHA)) #define arm_2d_cccn888_fill_colour_with_opacity( \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __COLOUR, /*!< colour */ \ - __ALPHA) /*!< alpha */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __COLOUR, /* colour */ \ + __ALPHA) /* alpha */ \ arm_2dp_cccn888_fill_colour_with_opacity( NULL, \ (__DES_ADDR), \ (__REGION_ADDR), \ (__COLOUR), \ (__ALPHA)) -#define arm_2d_gray8_fill_colour_with_alpha_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ - arm_2dp_gray8_fill_colour_with_mask( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR)) - #define arm_2d_gray8_fill_colour_with_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR) /* colour */ \ arm_2dp_gray8_fill_colour_with_mask( \ NULL, \ (__TARGET_ADDR), \ @@ -192,23 +217,11 @@ extern "C" { (__ALPHA_ADDR), \ (__COLOUR)) -#define arm_2d_rgb565_fill_colour_with_alpha_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ - arm_2dp_rgb565_fill_colour_with_mask( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR)) - #define arm_2d_rgb565_fill_colour_with_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR) /* colour */ \ arm_2dp_rgb565_fill_colour_with_mask( \ NULL, \ (__TARGET_ADDR), \ @@ -216,47 +229,23 @@ extern "C" { (__ALPHA_ADDR), \ (__COLOUR)) -#define arm_2d_rgb888_fill_colour_with_alpha_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ - arm_2dp_cccn888_fill_colour_with_mask( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR)) - #define arm_2d_rgb888_fill_colour_with_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR) /* colour */ \ arm_2dp_cccn888_fill_colour_with_mask( \ NULL, \ (__TARGET_ADDR), \ (__REGION_ADDR), \ (__ALPHA_ADDR), \ - (__COLOUR)) - -#define arm_2d_cccn888_fill_colour_with_alpha_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ - arm_2dp_cccn888_fill_colour_with_mask( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR)) + (arm_2d_color_cccn888_t){(__COLOUR).tValue}) #define arm_2d_cccn888_fill_colour_with_mask( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR) /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR) /* colour */ \ arm_2dp_cccn888_fill_colour_with_mask( \ NULL, \ (__TARGET_ADDR), \ @@ -264,26 +253,11 @@ extern "C" { (__ALPHA_ADDR), \ (__COLOUR)) - -#define arm_2d_gray8_fill_colour_with_alpha_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ - __OPACITY) \ - arm_2dp_gray8_fill_colour_with_mask_and_opacity( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR), \ - (__OPACITY)) - #define arm_2d_gray8_fill_colour_with_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR, /* colour */ \ __OPACITY) \ arm_2dp_gray8_fill_colour_with_mask_and_opacity( \ NULL, \ @@ -293,25 +267,11 @@ extern "C" { (__COLOUR), \ (__OPACITY)) -#define arm_2d_rgb565_fill_colour_with_alpha_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ - __OPACITY) \ - arm_2dp_rgb565_fill_colour_with_mask_and_opacity( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR), \ - (__OPACITY)) - #define arm_2d_rgb565_fill_colour_with_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR, /* colour */ \ __OPACITY) \ arm_2dp_rgb565_fill_colour_with_mask_and_opacity( \ NULL, \ @@ -321,53 +281,25 @@ extern "C" { (__COLOUR), \ (__OPACITY)) -#define arm_2d_rgb888_fill_colour_with_alpha_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ - __OPACITY) \ - arm_2dp_cccn888_fill_colour_with_mask_and_opacity( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR), \ - (__OPACITY)) - #define arm_2d_rgb888_fill_colour_with_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR, /* colour */ \ __OPACITY) \ arm_2dp_cccn888_fill_colour_with_mask_and_opacity( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR), \ - (__OPACITY)) - -#define arm_2d_cccn888_fill_colour_with_alpha_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ - __OPACITY) \ - arm_2dp_cccn888_fill_colour_with_mask_and_opacity( \ - NULL, \ - (__TARGET_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA_ADDR), \ - (__COLOUR), \ - (__OPACITY)) + NULL, \ + (__TARGET_ADDR), \ + (__REGION_ADDR), \ + (__ALPHA_ADDR), \ + (arm_2d_color_cccn888_t){(__COLOUR).tValue}, \ + (__OPACITY)) #define arm_2d_cccn888_fill_colour_with_mask_and_opacity( \ - __TARGET_ADDR, /*!< target tile address*/ \ - __REGION_ADDR, /*!< target region address*/\ - __ALPHA_ADDR, /*!< alpha tile address */ \ - __COLOUR, /*!< colour */ \ + __TARGET_ADDR, /* target tile address*/ \ + __REGION_ADDR, /* target region address*/\ + __ALPHA_ADDR, /* alpha tile address */ \ + __COLOUR, /* colour */ \ __OPACITY) \ arm_2dp_cccn888_fill_colour_with_mask_and_opacity( \ NULL, \ @@ -378,11 +310,11 @@ extern "C" { (__OPACITY)) #define arm_2d_gray8_alpha_blending_with_colour_keying( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA, /* colour */ \ + __COLOUR) /* alpha */ \ arm_2dp_gray8_alpha_blending_with_colour_keying( \ NULL, \ (__SRC_ADDR), \ @@ -391,27 +323,12 @@ extern "C" { (__ALPHA), \ (__COLOUR)) -#define arm_2d_gray8_alpha_blending_with_colour_masking( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ - arm_2dp_gray8_alpha_blending_with_colour_keying( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA), \ - (__COLOUR)) - - #define arm_2d_rgb565_alpha_blending_with_colour_keying( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA, /* colour */ \ + __COLOUR) /* alpha */ \ arm_2dp_rgb565_alpha_blending_with_colour_keying( \ NULL, \ (__SRC_ADDR), \ @@ -420,68 +337,26 @@ extern "C" { (__ALPHA), \ (__COLOUR)) -#define arm_2d_rgb565_alpha_blending_with_colour_masking( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ - arm_2dp_rgb565_alpha_blending_with_colour_keying( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA), \ - (__COLOUR)) - -#define arm_2d_rgb888_alpha_blending_with_colour_masking( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ - arm_2dp_cccn888_alpha_blending_with_colour_keying( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA), \ - (__COLOUR)) - #define arm_2d_rgb888_alpha_blending_with_colour_keying( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA, /* colour */ \ + __COLOUR) /* alpha */ \ arm_2dp_cccn888_alpha_blending_with_colour_keying( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA), \ - (__COLOUR)) - -#define arm_2d_cccn888_alpha_blending_with_colour_masking( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ - arm_2dp_cccn888_alpha_blending_with_colour_keying( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__REGION_ADDR), \ - (__ALPHA), \ - (__COLOUR)) + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__REGION_ADDR), \ + (__ALPHA), \ + (arm_2d_color_cccn888_t){(__COLOUR).tValue}) #define arm_2d_cccn888_alpha_blending_with_colour_keying( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION_ADDR,/*!< region address */ \ - __ALPHA, /*!< colour */ \ - __COLOUR) /*!< alpha */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION_ADDR,/* region address */ \ + __ALPHA, /* colour */ \ + __COLOUR) /* alpha */ \ arm_2dp_cccn888_alpha_blending_with_colour_keying( \ NULL, \ (__SRC_ADDR), \ @@ -491,28 +366,12 @@ extern "C" { (__COLOUR)) #define arm_2d_gray8_tile_copy_with_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_gray8_tile_copy_with_masks( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) - -#define arm_2d_gray8_tile_copy_with_alpha_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_gray8_tile_copy_with_masks( \ NULL, \ (__SRC_ADDR), \ @@ -523,12 +382,12 @@ extern "C" { (__MODE)) #define arm_2d_rgb565_tile_copy_with_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_rgb565_tile_copy_with_masks( \ NULL, \ (__SRC_ADDR), \ @@ -538,29 +397,16 @@ extern "C" { (__REGION), \ (__MODE)) -#define arm_2d_rgb565_tile_copy_with_alpha_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_rgb565_tile_copy_with_masks( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) +#define arm_2d_rgb888_tile_copy_with_masks \ + arm_2d_cccn888_tile_copy_with_masks #define arm_2d_cccn888_tile_copy_with_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_cccn888_tile_copy_with_masks( \ NULL, \ (__SRC_ADDR), \ @@ -570,61 +416,12 @@ extern "C" { (__REGION), \ (__MODE)) -#define arm_2d_cccn888_tile_copy_with_alpha_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_cccn888_tile_copy_with_masks( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) - -#define arm_2d_rgb888_tile_copy_with_masks( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_cccn888_tile_copy_with_masks( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) - -#define arm_2d_rgb888_tile_copy_with_alpha_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_cccn888_tile_copy_with_masks( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) - - #define arm_2d_gray8_tile_copy_with_src_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_gray8_tile_copy_with_src_mask( \ NULL, \ (__SRC_ADDR), \ @@ -635,11 +432,11 @@ extern "C" { #define arm_2d_rgb565_tile_copy_with_src_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_rgb565_tile_copy_with_src_mask( \ NULL, \ (__SRC_ADDR), \ @@ -649,12 +446,15 @@ extern "C" { (__MODE)) +#define arm_2d_rgb888_tile_copy_with_src_mask \ + arm_2d_cccn888_tile_copy_with_src_mask + #define arm_2d_cccn888_tile_copy_with_src_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __SRC_MSK_ADDR, /* source mask address */ \ + __DES_ADDR, /* target tile address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_cccn888_tile_copy_with_src_mask( \ NULL, \ (__SRC_ADDR), \ @@ -663,28 +463,12 @@ extern "C" { (__REGION), \ (__MODE)) - -#define arm_2d_rgb888_tile_copy_with_src_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __SRC_MSK_ADDR, /*!< source mask address */ \ - __DES_ADDR, /*!< target tile address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_cccn888_tile_copy_with_src_mask( \ - NULL, \ - (__SRC_ADDR), \ - (__SRC_MSK_ADDR), \ - (__DES_ADDR), \ - (__REGION), \ - (__MODE)) - - #define arm_2d_gray8_tile_copy_with_des_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_gray8_tile_copy_with_des_mask( \ NULL, \ (__SRC_ADDR), \ @@ -695,11 +479,11 @@ extern "C" { #define arm_2d_rgb565_tile_copy_with_des_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_rgb565_tile_copy_with_des_mask( \ NULL, \ (__SRC_ADDR), \ @@ -708,27 +492,15 @@ extern "C" { (__REGION), \ (__MODE)) +#define arm_2d_rgb888_tile_copy_with_des_mask \ + arm_2d_cccn888_tile_copy_with_des_mask #define arm_2d_cccn888_tile_copy_with_des_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ - arm_2dp_cccn888_tile_copy_with_des_mask( \ - NULL, \ - (__SRC_ADDR), \ - (__DES_ADDR), \ - (__DES_MSK_ADDR), \ - (__REGION), \ - (__MODE)) - -#define arm_2d_rgb888_tile_copy_with_des_mask( \ - __SRC_ADDR, /*!< source tile address */ \ - __DES_ADDR, /*!< target tile address */ \ - __DES_MSK_ADDR, /*!< target mask address */ \ - __REGION, /*!< region address */ \ - __MODE) /*!< copy mode */ \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_MSK_ADDR, /* target mask address */ \ + __REGION, /* region address */ \ + __MODE) /* copy mode */ \ arm_2dp_cccn888_tile_copy_with_des_mask( \ NULL, \ (__SRC_ADDR), \ @@ -739,100 +511,115 @@ extern "C" { /*============================ TYPES =========================================*/ -/*! \note arm_2d_op_alpha_t inherits from arm_2d_op_src_t explicitly +/*! + * \brief control block for alpha-blending operations + * \note arm_2d_op_alpha_t inherits from arm_2d_op_src_t explicitly */ typedef struct arm_2d_op_alpha_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; + } Target; //!< target struct { const arm_2d_tile_t *ptTile; //!< source tile - }Source; - uint32_t wMode; - uint8_t chRatio; + }Source; //!< source + uint32_t wMode; //!< copy mode + uint8_t chRatio; //!< opacity } arm_2d_op_alpha_t; -/*! \note arm_2d_op_alpha_cl_key_t inherits from arm_2d_op_src_t explicitly +/*! + * \brief control block for alpha-blending-with-colour-keying operations + * \note arm_2d_op_alpha_cl_key_t inherits from arm_2d_op_src_t explicitly */ typedef struct arm_2d_op_alpha_cl_key_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; + } Target; //!< target struct { const arm_2d_tile_t *ptTile; //!< source tile - }Source; - uint32_t wMode; - uint8_t chRatio; + }Source; //!< source + uint32_t wMode; //!< copy mode + uint8_t chRatio; //!< opacity + union { - uint8_t chColour; - uint16_t hwColour; - uint32_t wColour; + uint8_t chColour; //!< 8bit key colour + uint16_t hwColour; //!< 16bit key colour + uint32_t wColour; //!< 32bit key colour }; } arm_2d_op_alpha_cl_key_t; -/*! \note arm_2d_op_fill_cl_msk_t inherits from arm_2d_op_src_t explicitly +/*! + * \brief control block for colour-filling-with-mask operations + * \note arm_2d_op_fill_cl_msk_t inherits from arm_2d_op_src_t explicitly */ typedef struct arm_2d_op_fill_cl_msk_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; + } Target; //!< target struct { const arm_2d_tile_t *ptTile; //!< Alpha Mask tile - } Mask; - uint32_t wMode; + } Mask; //!< mask + uint32_t wMode; //!< copy mode + union { - uint8_t chColour; - uint16_t hwColour; - uint32_t wColour; + uint8_t chColour; //!< 8bit key colour + uint16_t hwColour; //!< 16bit key colour + uint32_t wColour; //!< 32bit key colour }; } arm_2d_op_fill_cl_msk_t; -/*! \note arm_2d_op_fill_cl_msk_t inherits from arm_2d_op_src_t explicitly +/*! + * \brief control block for colour-filling-with-mask-and-opacity operations + * \note arm_2d_op_fill_cl_msk_t inherits from arm_2d_op_src_t explicitly */ typedef struct arm_2d_op_alpha_fill_cl_msk_opc_t { - inherit(arm_2d_op_core_t); + inherit(arm_2d_op_core_t); //!< core struct { const arm_2d_tile_t *ptTile; //!< target tile const arm_2d_region_t *ptRegion; //!< target region - } Target; + } Target; //!< target struct { const arm_2d_tile_t *ptTile; //!< Alpha Mask tile - } Mask; - uint32_t wMode; + } Mask; //!< mask + uint32_t wMode; //!< copy mode union { - uint8_t chColour; - uint16_t hwColour; - uint32_t wColour; + uint8_t chColour; //!< 8bit key colour + uint16_t hwColour; //!< 16bit key colour + uint32_t wColour; //!< 32bit key colour }; - uint8_t chOpacity; + uint8_t chRatio; //!< opacity } arm_2d_op_alpha_fill_cl_msk_opc_t; -/*! \note arm_2d_op_fill_cl_t inherits from arm_2d_op_t explicitly +/*! + * \brief control block for colour-filling-with-opacity operations + * \note arm_2d_op_fill_cl_t inherits from arm_2d_op_t explicitly */ typedef struct arm_2d_op_fill_cl_opc_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; + } Target; //!< target union { - uint8_t chColour; - uint16_t hwColour; - uint32_t wColour; + uint8_t chColour; //!< 8bit key colour + uint16_t hwColour; //!< 16bit key colour + uint32_t wColour; //!< 32bit key colour }; - uint_fast8_t chRatio; //!< transparency ratio + uint8_t chRatio; //!< opacity } arm_2d_op_fill_cl_opc_t; - +/*! + * \brief control block for copy with masks operations + * + */ typedef arm_2d_op_src_msk_t arm_2d_op_cp_msk_t; /*============================ GLOBAL VARIABLES ==============================*/ @@ -842,6 +629,15 @@ typedef arm_2d_op_src_msk_t arm_2d_op_cp_msk_t; * Copy tile to destination with specified transparency ratio (0~255) * *----------------------------------------------------------------------------*/ +/*! + * \brief blend a source tile to a target tile with a specified opacity + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_gray8_alpha_blending( arm_2d_op_alpha_t *ptOP, @@ -849,7 +645,16 @@ arm_fsm_rt_t arm_2dp_gray8_alpha_blending( arm_2d_op_alpha_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio); - + +/*! + * \brief blend a source tile to a target tile with a specified opacity + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_rgb565_alpha_blending( arm_2d_op_alpha_t *ptOP, @@ -858,6 +663,15 @@ arm_fsm_rt_t arm_2dp_rgb565_alpha_blending( arm_2d_op_alpha_t *ptOP, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio); +/*! + * \brief blend a source tile to a target tile with a specified opacity + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_cccn888_alpha_blending( arm_2d_op_alpha_t *ptOP, @@ -871,15 +685,33 @@ arm_fsm_rt_t arm_2dp_cccn888_alpha_blending( arm_2d_op_alpha_t *ptOP, * Fill a specified region with a given colour and transparency ratio (0~255) * *----------------------------------------------------------------------------*/ +/*! + * \brief fill a target tile with a given gray8 colour and a specified opacity + * \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] tColour a gray8 colour + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2) arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_opacity( arm_2d_op_fill_cl_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, - uint8_t chColour, + arm_2d_color_gray8_t tColour, uint_fast8_t chRatio); +/*! + * \brief fill a target tile with a given rgb565 colour and a specified opacity + * \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] tColour a rgb565 colour + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2) arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_opacity( @@ -889,19 +721,37 @@ arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_opacity( arm_2d_color_rgb565_t tColour, uint_fast8_t chRatio); +/*! + * \brief fill a target tile with a given cccn888 colour and a specified opacity + * \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] tColour a cccn888 colour + * \param[in] chRatio the opacity + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2) arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_opacity( arm_2d_op_fill_cl_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, - arm_2d_color_rgb888_t tColour, + arm_2d_color_cccn888_t tColour, uint_fast8_t chRatio); /*----------------------------------------------------------------------------* * Fill tile with a specified colour and an alpha mask * *----------------------------------------------------------------------------*/ +/*! + * \brief fill a target tile with a given gray8 colour and a mask on target side + * \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] ptAlpha the mask on the target side + * \param[in] tColour a gray8 colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_mask( @@ -909,8 +759,17 @@ arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_mask( const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - uint8_t chColour); + arm_2d_color_gray8_t tColour); +/*! + * \brief fill a target tile with a given rgb565 colour and a mask on target side + * \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] ptAlpha the mask on the target side + * \param[in] tColour a rgb565 colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask( @@ -920,6 +779,15 @@ arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask( const arm_2d_tile_t *ptAlpha, arm_2d_color_rgb565_t tColour); +/*! + * \brief fill a target tile with a given cccn888 colour and a mask on target side + * \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] ptAlpha the mask on the target side + * \param[in] tColour a cccn888 colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask( @@ -929,23 +797,42 @@ arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask( const arm_2d_tile_t *ptAlpha, arm_2d_color_cccn888_t tColour); - /*----------------------------------------------------------------------------* * Fill tile with a specified colour, an alpha mask and a specified opacity * *----------------------------------------------------------------------------*/ +/*! + * \brief fill a target tile with a given gray8 colour, a mask on target side and an opacity + * \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] ptAlpha the mask on the target side + * \param[in] tColour a gray8 colour + * \param[in] chOpacity the opacity + * \return arm_fsm_rt_t the operation result + */ extern -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - uint8_t chColour, + arm_2d_color_gray8_t tColour, uint8_t chOpacity); - + +/*! + * \brief fill a target tile with a given rgb565 colour, a mask on target side and an opacity + * \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] ptAlpha the mask on the target side + * \param[in] tColour a rgb565 colour + * \param[in] chOpacity the opacity + * \return arm_fsm_rt_t the operation result + */ extern -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, @@ -954,14 +841,24 @@ arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask_and_opacity( arm_2d_color_rgb565_t tColour, uint8_t chOpacity); +/*! + * \brief fill a target tile with a given cccn888 colour, a mask on target side and an opacity + * \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] ptAlpha the mask on the target side + * \param[in] tColour a cccn888 colour + * \param[in] chOpacity the opacity + * \return arm_fsm_rt_t the operation result + */ extern -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - arm_2d_color_rgb888_t tColour, + arm_2d_color_cccn888_t tColour, uint8_t chOpacity); /*----------------------------------------------------------------------------* @@ -969,6 +866,16 @@ arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask_and_opacity( * specified transparency color mask * *----------------------------------------------------------------------------*/ +/*! + * \brief blend a source tile to a target tile with a opacity and colour keying + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \param[in] tColour the key colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_gray8_alpha_blending_with_colour_keying( @@ -977,8 +884,18 @@ arm_fsm_rt_t arm_2dp_gray8_alpha_blending_with_colour_keying( const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio, - uint8_t chColour); + arm_2d_color_gray8_t tColour); +/*! + * \brief blend a source tile to a target tile with a opacity and colour keying + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \param[in] tColour the key colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_rgb565_alpha_blending_with_colour_keying( @@ -988,7 +905,17 @@ arm_fsm_rt_t arm_2dp_rgb565_alpha_blending_with_colour_keying( const arm_2d_region_t *ptRegion, uint_fast8_t chRatio, arm_2d_color_rgb565_t tColour); - + +/*! + * \brief blend a source tile to a target tile with a opacity and colour keying + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] chRatio the opacity + * \param[in] tColour the key colour + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3) arm_fsm_rt_t arm_2dp_cccn888_alpha_blending_with_colour_keying( @@ -997,12 +924,23 @@ arm_fsm_rt_t arm_2dp_cccn888_alpha_blending_with_colour_keying( const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio, - arm_2d_color_rgb888_t tColour); + arm_2d_color_cccn888_t tColour); /*----------------------------------------------------------------------------* * Copy tile to destination with both a source mask and a target mask * *----------------------------------------------------------------------------*/ +/*! + * \brief copy a source tile to a target tile with masks in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4,5) arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_masks( @@ -1014,6 +952,17 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_masks( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with masks in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4,5) arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_masks( @@ -1025,6 +974,17 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_masks( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with masks in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4,5) arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_masks( @@ -1039,7 +999,16 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_masks( /*----------------------------------------------------------------------------* * Copy tile to destination with a specified source mask * *----------------------------------------------------------------------------*/ - +/*! + * \brief copy a source tile to a target tile with a source mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_src_mask( @@ -1050,6 +1019,16 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_src_mask( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with a source mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_src_mask( @@ -1060,6 +1039,16 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_src_mask( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with a source mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSrcMask the mask on the source side + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_src_mask( @@ -1074,6 +1063,16 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_src_mask( * Copy tile to destination with a specified target mask * *----------------------------------------------------------------------------*/ +/*! + * \brief copy a source tile to a target tile with a target mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_des_mask( @@ -1084,6 +1083,16 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_des_mask( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with a target mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_des_mask( @@ -1094,6 +1103,16 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_des_mask( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! + * \brief copy a source tile to a target tile with a target mask in a given mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptDesMask the mask on the target side + * \param[in] ptRegion the target region + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ extern ARM_NONNULL(2,3,4) arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_des_mask( @@ -1104,6 +1123,7 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_des_mask( const arm_2d_region_t *ptRegion, uint32_t wMode); +/*! @} */ #if defined(__clang__) #pragma clang diagnostic pop diff --git a/package/Arm2D/arm_2d_conversion.h b/package/Arm2D/Library/Include/arm_2d_conversion.h similarity index 60% rename from package/Arm2D/arm_2d_conversion.h rename to package/Arm2D/Library/Include/arm_2d_conversion.h index 3fa556a91..9c78a9be6 100644 --- a/package/Arm2D/arm_2d_conversion.h +++ b/package/Arm2D/Library/Include/arm_2d_conversion.h @@ -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 diff --git a/package/Arm2D/arm_2d_draw.h b/package/Arm2D/Library/Include/arm_2d_draw.h similarity index 53% rename from package/Arm2D/arm_2d_draw.h rename to package/Arm2D/Library/Include/arm_2d_draw.h index 045dc5bfe..057214466 100644 --- a/package/Arm2D/arm_2d_draw.h +++ b/package/Arm2D/Library/Include/arm_2d_draw.h @@ -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 diff --git a/package/Arm2D/arm_2d_features.h b/package/Arm2D/Library/Include/arm_2d_features.h similarity index 61% rename from package/Arm2D/arm_2d_features.h rename to package/Arm2D/Library/Include/arm_2d_features.h index 39435a89e..8e224d18b 100644 --- a/package/Arm2D/arm_2d_features.h +++ b/package/Arm2D/Library/Include/arm_2d_features.h @@ -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 diff --git a/package/Arm2D/Library/Include/arm_2d_op.h b/package/Arm2D/Library/Include/arm_2d_op.h new file mode 100644 index 000000000..4bf7d7c85 --- /dev/null +++ b/package/Arm2D/Library/Include/arm_2d_op.h @@ -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 diff --git a/package/Arm2D/Library/Include/arm_2d_tile.h b/package/Arm2D/Library/Include/arm_2d_tile.h new file mode 100644 index 000000000..83ab8e40b --- /dev/null +++ b/package/Arm2D/Library/Include/arm_2d_tile.h @@ -0,0 +1,1274 @@ +/* + * 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_tile.h + * Description: Public header file to contain the basic tile operations + * + * $Date: 09. Aug 2022 + * $Revision: V.1.0.3 + * + * 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 ========================================*/ + +/*! + * \addtogroup Deprecated + * @{ + */ +#define arm_2d_c8bit_tile_copy_with_colour_masking \ + arm_2d_c8bit_tile_copy_with_colour_keying + +#define arm_2d_rgb16_tile_copy_with_colour_masking \ + arm_2d_rgb16_tile_copy_with_colour_keying + +#define arm_2d_rgb32_tile_copy_with_colour_masking \ + arm_2d_rgb32_tile_copy_with_colour_keying +/*! @} */ + +/*! + * \addtogroup Tile 2 Tile Operations + * @{ + */ +/*============================ 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_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_copy_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_copy_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_copy_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_copy_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_copy_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_copy_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_copy_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_copy_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_copy_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_copy_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_copy_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_copy_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_copy_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_copy_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_copy_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_copy_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_copy_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_copy_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_copy_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_copy_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_copy_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_copy_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_copy_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_fill_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_fill_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_fill_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_fill_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_fill_only( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_fill_only(NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_fill_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_fill_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_fill_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_fill_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_fill_with_x_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_fill_with_x_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_fill_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_fill_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_fill_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_fill_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_fill_with_y_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_fill_with_y_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_c8bit_tile_fill_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_c8bit_tile_fill_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb16_tile_fill_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb16_tile_fill_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#define arm_2d_rgb32_tile_fill_with_xy_mirror( \ + __SRC_ADDR, /* source tile address */ \ + __DES_ADDR, /* target tile address */ \ + __DES_REGION_ADDR) /* target region address*/\ + arm_2dp_rgb32_tile_fill_with_xy_mirror( \ + NULL, \ + (__SRC_ADDR), \ + (__DES_ADDR), \ + (__DES_REGION_ADDR)) + +#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_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_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); //!< base + 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; //!< copy mode + union { + uint8_t chColour; //!< 8bit colour + uint16_t hwColour; //!< 16bit colour + uint32_t wColour; //!< 32bit colour + }; +} arm_2d_op_cp_cl_key_t; + +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ + + +/*----------------------------------------------------------------------------* + * Tile Operations * + *----------------------------------------------------------------------------*/ + +/*! + * \brief check whether a given tile is root or not + * \param[in] ptTile the target tile + * \retval true the target tile is a root tile + * \retval false the target tile is a child tile + */ +ARM_NONNULL(1) +__STATIC_INLINE bool arm_2d_is_root_tile(const arm_2d_tile_t *ptTile) +{ + return ptTile->tInfo.bIsRoot; +} + + +/*! + * \brief intersect two regions and find the overlapped region + * \param[in] ptRegionIn0 the input region 0 + * \param[in] ptRegionIn1 the input region 1 + * \param[out] ptRegionOut the overlapped region + * \retval false the two regions do not overlap + * \retval true the two regions overlap + * + * \code + + HOW IT WORKS: + + Input Region 0 + +------------------------------------------------------+ + | | + | | + | | + | +------------------------------+---------+ + | | |/////////| + | | Output Region |/////////| + | | |/////////| + +-----------------------+------------------------------+/////////| + |////////////////////////////////////////| + |////////////////////////////////////////| + +----------------------------------------+ + Input Region 1 + * \endcode + */ +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); + +/*! + * \brief check whether a point is inside a given region + * \param[in] ptRegion the target region + * \param[in] ptPoint the target point + * \retval true the point is inside the target region + * \retval false the point is outside the target region + */ +extern +ARM_NONNULL(1,2) +bool arm_2d_is_point_inside_region( const arm_2d_region_t *ptRegion, + const arm_2d_location_t *ptPoint); + +/*! + * \brief get the root tile and the valid region for a given tile + * \param[in] ptTile the target tile + * \param[out] ptValidRegion the valid region inside the root tile + * \param[out] ptOffset the offsite of the root tile as if the root tile is inside the target tile + * \return const arm_2d_tile_t* the root tile + * + * \code + HOW IT WORKS: + + Root Tile (Output Tile) + +------------------------------------------------------------------------+ + | ... ... | + | | + | Child Tile of Parent Tile | + | +------------------------------------+ | + | | Child Tile of Parent Tile | | + | | +------------------------------+---------+ | + | | | |/////////| | + | | | Valid Region |/////////| | + | | | |/////////| | + | +-----+------------------------------+/////////| | + | |////////////////////////////////////////| | + | |////////////////////////////////////////| | + | +----------------------------------------+ | + | | + +------------------------------------------------------------------------+ + \endcode + */ +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); + +/*! + * \brief generate a child tile from the target tile with a given region + * \param[in] ptTargetTile the target tile + * \param[in] ptRegion the target region + * \param[out] ptOutput the child tile + * \param[in] bClipRegion whether clip the region for the child tile + * \note We highly recommend that please DO NOT clip the child tile if + * you don't know what you are doing. + * \retval non-NULL the child tile + * \retval NULL the given region is outside the target tile + * + * \note If you want to use the child tile generated by + * arm_2d_tile_generate_child() as a source tile / mask, please set the + * bDerivedResource to true manually, otherwise all mirror related + * operation will NOT work correctly. + * + * \code + HOW IT WORKS: + + Parent Tile (NOT necessarily a ROOT tile ) + +------------------------------------------------------+ + | | + | | + | Target Region | + | +------------------------------+---------+ + | | |/////////| + | | New Child Tile (Output) |/////////| + | | |/////////| + +-----------------------+------------------------------+/////////| + |////////////////////////////////////////| + |////////////////////////////////////////| + +----------------------------------------+ + \endcode + */ +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); + +/*! + * \brief compare the widths of two tiles + * \param[in] ptTarget the target tile + * \param[in] ptReference the reference tile + * \return arm_2d_cmp_t the comparision result + */ +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); +/*! + * \brief compare the heights of two tiles + * \param[in] ptTarget the target tile + * \param[in] ptReference the reference tile + * \return arm_2d_cmp_t the comparision result + */ +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); + +/*! + * \brief compare the shape (both widths and heights) of two tiles + * \param[in] ptTarget the target tile + * \param[in] ptReference the reference tile + * \return arm_2d_cmp_t the comparision result + */ +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); + +/*! + * \brief get the absolute location of a given tile + * \param[in] ptTile the target tile + * \param[out] ptLocation the absolute location in the root tile + * \return const arm_2d_tile_t * the root tile + */ +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); + +/*! + * \brief calculate the region differences between two tiles + * \param[in] ptTarget the target tile + * \param[in] ptReference the reference tile + * \param[out] ptBuffer the difference stored in a region + * \return arm_2d_region_t * the ptBuffer passed to this function + */ +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/Fill tile to destination with Mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief tile copy modes + */ +enum __arm_2d_copy_mode_t { + 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), + ARM_2D_CP_MODE_XY_MIRROR = ARM_2D_CP_MODE_X_MIRROR | + ARM_2D_CP_MODE_Y_MIRROR, +}; + +/*! + * \brief tile copy with specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ +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); + +/*! + * \brief tile copy with specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ +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); + +/*! + * \brief tile copy with specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ +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 Only * + *----------------------------------------------------------------------------*/ +/*! + * \brief tile copy only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Copy with X mirroring * + *----------------------------------------------------------------------------*/ +/*! + * \brief tile copy with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Copy with Y mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief tile copy with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Copy with XY mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief tile copy with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief tile copy with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Fill Only * + *----------------------------------------------------------------------------*/ + +/*! + * \brief Tiling only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling only + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Fill with X mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief Tiling with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with x-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Fill with Y mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief Tiling with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with y-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Fill with XY mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief Tiling with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*! + * \brief Tiling with xy-mirroring + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion); + +/*----------------------------------------------------------------------------* + * Copy/Fill tile to destination with colour-keying and mirroring * + *----------------------------------------------------------------------------*/ + +/*! + * \brief tile copy with colour-keying and specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] chMaskColour the key colour in any 8bit colour format + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + */ +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 tile copy with colour-keying and specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] hwMaskColour the key colour in any 16bit colour format + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + * + * \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 tile copy with colour-keying and specified mode + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptTarget the target tile + * \param[in] ptRegion the target region, NULL means using the region of the + * target tile. + * \param[in] wMaskColour the key colour in any 32bit colour format + * \param[in] wMode the copy mode + * \return arm_fsm_rt_t the operation result + * + * \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 diff --git a/package/Arm2D/Library/Include/arm_2d_transform.h b/package/Arm2D/Library/Include/arm_2d_transform.h new file mode 100644 index 000000000..a795e01d2 --- /dev/null +++ b/package/Arm2D/Library/Include/arm_2d_transform.h @@ -0,0 +1,3119 @@ +/* + * 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: #include "arm_2d_transform.h" + * Description: Public header file to contain the APIs for transform + * + * $Date: 17 June 2022 + * $Revision: V.1.0.1 + * + * 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 ========================================*/ +/*! + * \addtogroup Deprecated + * @{ + */ +#define arm_2d_op_rotate_t arm_2d_op_trans_t +#define arm_2d_op_rotate_opacity_t arm_2d_op_trans_opa_t +/*! @} */ + +/*! + * \addtogroup Deprecated + * @{ + */ +#define arm_2dp_tile_rotate arm_2dp_tile_transform + +#define arm_2dp_gray8_tile_rotate_prepare \ + arm_2dp_gray8_tile_transform_prepare + +#define arm_2dp_rgb565_tile_rotate_prepare \ + arm_2dp_rgb565_tile_transform_prepare + +#define arm_2dp_cccn888_tile_rotate_prepare \ + arm_2dp_cccn888_tile_transform_prepare + +#define arm_2dp_gray8_tile_rotate_with_opacity_prepare \ + arm_2dp_gray8_tile_transform_with_opacity_prepare + +#define arm_2dp_rgb565_tile_rotate_with_opacity_prepare \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare + +#define arm_2dp_cccn888_tile_rotate_with_opacity_prepare \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare + +#define arm_2d_gray8_tile_rotation_with_alpha_prepare \ + arm_2d_gray8_tile_rotation_with_opacity_prepare + +#define arm_2d_rgb565_tile_rotation_with_alpha_prepare \ + arm_2d_rgb565_tile_rotation_with_opacity_prepare + +#define arm_2d_rgb888_tile_rotation_with_alpha_prepare \ + arm_2d_rgb888_tile_rotation_with_opacity_prepare + +#define arm_2d_cccn888_tile_rotation_with_alpha_prepare \ + arm_2d_cccn888_tile_rotation_with_opacity_prepare + +#define arm_2dp_gray8_tile_rotation_with_alpha \ + arm_2dp_gray8_tile_rotation_with_opacity + +#define arm_2dp_rgb565_tile_rotation_with_alpha \ + arm_2dp_rgb565_tile_rotation_with_opacity + +#define arm_2dp_rgb888_tile_rotation_with_alpha \ + arm_2dp_rgb888_tile_rotation_with_opacity + +#define arm_2dp_cccn888_tile_rotation_with_alpha \ + arm_2dp_cccn888_tile_rotation_with_opacity + +#define arm_2d_gray8_tile_rotation_with_alpha \ + arm_2d_gray8_tile_rotation_with_opacity + +#define arm_2d_rgb565_tile_rotation_with_alpha \ + arm_2d_rgb565_tile_rotation_with_opacity + +#define arm_2d_rgb888_tile_rotation_with_alpha \ + arm_2d_rgb888_tile_rotation_with_opacity + +#define arm_2d_cccn888_tile_rotation_with_alpha \ + arm_2d_cccn888_tile_rotation_with_opacity + +#define arm_2d_gray8_tile_transform_with_alpha_prepare \ + arm_2d_gray8_tile_transform_with_opacity_prepare + +#define arm_2d_rgb565_tile_transform_with_alpha_prepare \ + arm_2d_rgb565_tile_transform_with_opacity_prepare + +#define arm_2d_rgb888_tile_transform_with_alpha_prepare \ + arm_2d_rgb888_tile_transform_with_opacity_prepare + +#define arm_2d_cccn888_tile_transform_with_alpha_prepare \ + arm_2d_cccn888_tile_transform_with_opacity_prepare + +#define arm_2d_gray8_tile_transform_with_alpha \ + arm_2d_gray8_tile_transform_with_opacity + +#define arm_2d_rgb565_tile_transform_with_alpha \ + arm_2d_rgb565_tile_transform_with_opacity + +#define arm_2d_rgb888_tile_transform_with_alpha \ + arm_2d_rgb888_tile_transform_with_opacity + +#define arm_2d_cccn888_tile_transform_with_alpha \ + arm_2d_cccn888_tile_transform_with_opacity + +#define arm_2dp_gray8_tile_transform_with_alpha \ + arm_2dp_gray8_tile_transform_with_opacity + +#define arm_2dp_rgb565_tile_transform_with_alpha \ + arm_2dp_rgb565_tile_transform_with_opacity + +#define arm_2dp_rgb888_tile_transform_with_alpha \ + arm_2dp_rgb888_tile_transform_with_opacity + +#define arm_2dp_cccn888_tile_transform_with_alpha \ + arm_2dp_cccn888_tile_transform_with_opacity + +#define arm_2d_gray8_tile_scaling_with_alpha_prepare \ + arm_2d_gray8_tile_scaling_with_opacity_prepare + +#define arm_2d_rgb565_tile_scaling_with_alpha_prepare \ + arm_2d_rgb565_tile_scaling_with_opacity_prepare + +#define arm_2d_rgb888_tile_scaling_with_alpha_prepare \ + arm_2d_rgb888_tile_scaling_with_opacity_prepare + +#define arm_2d_cccn888_tile_scaling_with_alpha_prepare \ + arm_2d_cccn888_tile_scaling_with_opacity_prepare + +#define arm_2dp_gray8_tile_scaling_with_alpha \ + arm_2dp_gray8_tile_scaling_with_opacity + +#define arm_2dp_rgb565_tile_scaling_with_alpha \ + arm_2dp_rgb565_tile_scaling_with_opacity + +#define arm_2dp_rgb888_tile_scaling_with_alpha \ + arm_2dp_rgb888_tile_scaling_with_opacity + +#define arm_2dp_cccn888_tile_scaling_with_alpha \ + arm_2dp_cccn888_tile_scaling_with_opacity + +#define arm_2d_gray8_tile_scaling_with_alpha \ + arm_2d_gray8_tile_scaling_with_opacity + +#define arm_2d_rgb565_tile_scaling_with_alpha \ + arm_2d_rgb565_tile_scaling_with_opacity + +#define arm_2d_rgb888_tile_scaling_with_alpha \ + arm_2d_rgb888_tile_scaling_with_opacity + +#define arm_2d_cccn888_tile_scaling_with_alpha \ + arm_2d_cccn888_tile_scaling_with_opacity +/*! @} */ + +/*! + * \addtogroup gTransform 5 Transform Operations + * @{ + */ + +/*============================ MACROFIED FUNCTIONS ===========================*/ + +/*----------------------------------------------------------------------------* + * API wrappers: Rotation * + *----------------------------------------------------------------------------*/ + +#define arm_2d_gray8_tile_rotation_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR) \ + arm_2dp_gray8_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)) + +#define arm_2d_rgb565_tile_rotation_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR) \ + arm_2dp_rgb565_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)) + +#define arm_2d_rgb888_tile_rotation_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR) \ + arm_2dp_cccn888_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)) + +#define arm_2d_gray8_tile_rotation_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_rgb565_tile_rotation_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)) + + +#define arm_2d_rgb888_tile_rotation_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)) + + +#define arm_2d_cccn888_tile_rotation_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_gray8_tile_rotation_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE) \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f) + +#define arm_2d_rgb565_tile_rotation_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE) \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f) + +#define arm_2d_cccn888_tile_rotation_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE) \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f) + +#define arm_2d_gray8_tile_rotation_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY) \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__OPACITY)) + +#define arm_2d_rgb565_tile_rotation_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY) \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__OPACITY)) + +#define arm_2d_cccn888_tile_rotation_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY) \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + 1.0f, \ + (__OPACITY)) + +#define arm_2d_tile_rotate( __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __DES_CENTRE_ADDR) \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (__DES_CENTRE_ADDR)) + + +/* following macro APIs rely 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_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + + +#define arm_2dp_gray8_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_gray8_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_gray8_tile_rotation_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_rotation_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_rotation_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_gray8_tile_rotation_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_rotation_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_rotation_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_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_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(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_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(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_transform_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_rotation_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(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_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(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_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(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_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_rotation_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_rotation_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_rotation_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_rotation_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_rotation_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_rotation_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (__ANGLE), \ + 1.0f, \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +/*----------------------------------------------------------------------------* + * API wrappers: Transform * + *----------------------------------------------------------------------------*/ + +#define arm_2d_gray8_tile_transform_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_gray8_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + +#define arm_2d_rgb565_tile_transform_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_rgb565_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + + +#define arm_2d_rgb888_tile_transform_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_cccn888_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + + +#define arm_2d_gray8_tile_transform_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_rgb565_tile_transform_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + + +#define arm_2d_rgb888_tile_transform_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + + +#define arm_2d_cccn888_tile_transform_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_gray8_tile_transform_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE) \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)) + +#define arm_2d_rgb565_tile_transform_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE) \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)) + +#define arm_2d_cccn888_tile_transform_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE) \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)) + +#define arm_2d_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_tile_transform( __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __DES_CENTRE_ADDR) \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (__DES_CENTRE_ADDR)) + + +/* following macro APIs rely 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 neither + * the low level rendering nor the high level GUI drawing, please find + * such variable with the value "true". + */ + +#define arm_2dp_gray8_tile_transform( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_transform( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_cccn888_tile_transform( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_gray8_tile_transform_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_rgb565_tile_transform_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb888_tile_transform_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_transform_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_gray8_tile_transform_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_transform_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_cccn888_tile_transform_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_gray8_tile_transform_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2d_gray8_tile_transform( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_transform( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2d_rgb888_tile_transform( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_transform_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_transform_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb888_tile_transform_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + + +#define arm_2d_cccn888_tile_transform_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2d_gray8_tile_transform_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_transform_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_transform_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_transform_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_transform_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_transform_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __ANGLE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + (float)(__ANGLE), \ + (float)(__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +/*----------------------------------------------------------------------------* + * API wrappers: Scaling * + *----------------------------------------------------------------------------*/ +#define arm_2d_gray8_tile_scaling_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_gray8_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + +#define arm_2d_rgb565_tile_scaling_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_rgb565_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + +#define arm_2d_rgb888_tile_scaling_prepare(__SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR) \ + arm_2dp_cccn888_tile_transform_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR)) + + + +#define arm_2d_gray8_tile_scaling_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_rgb565_tile_scaling_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + + +#define arm_2d_rgb888_tile_scaling_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_cccn888_tile_scaling_with_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO) \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)) + +#define arm_2d_gray8_tile_scaling_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE) \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE)) + +#define arm_2d_rgb565_tile_scaling_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE) \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE)) + +#define arm_2d_cccn888_tile_scaling_with_src_mask_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE) \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE)) + +#define arm_2d_gray8_tile_scaling_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_rgb565_tile_scaling_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_cccn888_tile_scaling_with_src_mask_and_opacity_prepare( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY) \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (float)(__SCALE), \ + (__OPACITY)) + +#define arm_2d_tile_scale( __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __DES_CENTRE_ADDR) \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (__DES_CENTRE_ADDR)) + + +/* following macro APIs rely 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 neither + * the low level rendering nor the high level GUI drawing, please find + * such variable with the value "true". + */ + +#define arm_2dp_gray8_tile_scaling( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_scaling( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_cccn888_tile_scaling( __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_gray8_tile_scaling_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_scaling_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO,...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb888_tile_scaling_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_scaling_with_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2dp_gray8_tile_scaling_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_scaling_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_scaling_with_src_mask( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_gray8_tile_scaling_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_rgb565_tile_scaling_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2dp_cccn888_tile_scaling_with_src_mask_and_opacity( \ + __CB_ADDR, \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({assert(NULL != (__CB_ADDR)); if (bIsNewFrame) { \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (__CB_ADDR), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform((arm_2d_op_trans_t *)(__CB_ADDR), \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_scaling( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_scaling( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2d_rgb888_tile_scaling( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_scaling_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + +#define arm_2d_rgb565_tile_scaling_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + + + +#define arm_2d_rgb888_tile_scaling_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_scaling_with_opacity( \ + __SRC_TILE_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __MSK_COLOUR, \ + __RATIO, ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_opacity_prepare( \ + NULL, \ + (__SRC_TILE_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__MSK_COLOUR), \ + (__RATIO)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_scaling_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_scaling_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_scaling_with_src_mask( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_gray8_tile_scaling_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_rgb565_tile_scaling_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +#define arm_2d_cccn888_tile_scaling_with_src_mask_and_opacity( \ + __SRC_TILE_ADDR, \ + __SRC_MASK_ADDR, \ + __DES_TILE_ADDR, \ + __DES_REGION_ADDR, \ + __CENTRE, \ + __SCALE, \ + __OPACITY, \ + ...) \ + ({{ \ + arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( \ + (NULL), \ + (__SRC_TILE_ADDR), \ + (__SRC_MASK_ADDR), \ + (__CENTRE), \ + 0.0f, \ + (__SCALE), \ + (__OPACITY)); \ + }; \ + arm_2dp_tile_transform(NULL, \ + (__DES_TILE_ADDR), \ + (__DES_REGION_ADDR), \ + (NULL,##__VA_ARGS__)); \ + }) + +/*============================ TYPES =========================================*/ + +/*! + * \brief transform runtime context + * + */ +typedef struct __arm_2d_transform_info_t { + float fAngle; //!< target angle + float fScale; //!< scaling factor + arm_2d_location_t tCenter; //!< pivot + union { + uint8_t chColour; //!< the key colour in 8bit + uint32_t wColour; //!< the key colour in 16bit + uint16_t hwColour; //!< the key colour in 32bit + } Mask; + + /* private members used by runtime */ +ARM_PRIVATE( + arm_2d_location_t tDummySourceOffset; + struct { + arm_2d_region_t tRegion; + arm_2d_tile_t tTile; + } Target; +) + +} __arm_2d_transform_info_t; + +/*! \brief arm_2d_op_trans_t is inherit from arm_2d_op_src_orig_t + */ +typedef struct arm_2d_op_trans_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; + struct { + const arm_2d_tile_t *ptTile; //!< source tile + }Source; + uint32_t wMode; //!< not used + + struct { + const arm_2d_tile_t *ptTile; //!< the origin tile + arm_2d_tile_t tDummySource; //!< the buffer for the source + }Origin; + + __arm_2d_transform_info_t tTransform; //!< transform context + +} arm_2d_op_trans_t; + + +/*! \brief arm_2d_op_trans_opa_t is inherit from arm_2d_op_trans_t + */ +typedef struct arm_2d_op_trans_opa_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; + struct { + const arm_2d_tile_t *ptTile; //!< source tile + }Source; + uint32_t wMode; //!< not used + + struct { + const arm_2d_tile_t *ptTile; //!< the origin tile + arm_2d_tile_t tDummySource; //!< the buffer for the source + }Origin; + + __arm_2d_transform_info_t tTransform; //!< transform context + uint8_t chOpacity; //!< opacity + +} arm_2d_op_trans_opa_t; + + +/*! \brief arm_2d_op_trans_msk_t is inherit from arm_2d_op_src_orig_msk_t + */ +typedef struct arm_2d_op_trans_msk_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; + struct { + const arm_2d_tile_t *ptTile; //!< source tile + }Source; + uint32_t wMode; //!< not used + 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 *ptOriginSide; //!< origin side mask + const arm_2d_tile_t *ptTargetSide; //!< target side mask + } Mask; + + __arm_2d_transform_info_t tTransform; //!< transform context + +} arm_2d_op_trans_msk_t; + + +/*! \brief arm_2d_op_trans_msk_t is inherit from arm_2d_op_trans_msk_t + */ +typedef struct arm_2d_op_trans_msk_opa_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; + struct { + const arm_2d_tile_t *ptTile; //!< source tile + }Source; + uint32_t wMode; //!< not used + 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 *ptOriginSide; //!< origin side mask + const arm_2d_tile_t *ptTargetSide; //!< target side mask + } Mask; + + __arm_2d_transform_info_t tTransform; //!< transform context + uint8_t chOpacity; //!< opacity + +} arm_2d_op_trans_msk_opa_t; + +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ + +/*! + * \brief prepare for a transform in gray8 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] chFillColour the key colour + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_gray8_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chFillColour); + +/*! + * \brief prepare for a transform in rgb565 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] hwFillColour the key colour + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_rgb565_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast16_t hwFillColour); + +/*! + * \brief prepare for a transform in cccn888 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] wFillColour the key colour + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_cccn888_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint32_t wFillColour); + +/*! + * \brief prepare for a transform with opacity in gray8 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] chFillColour the key colour + * \param[in] chRatio the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chFillColour, + uint_fast8_t chRatio); + +/*! + * \brief prepare for a transform with opacity in rgb565 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] hwFillColour the key colour + * \param[in] chRatio the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast16_t hwFillColour, + uint_fast8_t chRatio); + +/*! + * \brief prepare for a transform with opacity in cccn888 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] wFillColour the key colour + * \param[in] chRatio the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint32_t wFillColour, + uint_fast8_t chRatio); + +/*! + * \brief prepare for a transform with a source mask in gray8 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale); + +/*! + * \brief prepare for a transform with a source mask in rgb565 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale); + +/*! + * \brief prepare for a transform with a source mask in cccn888 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale); + +/*! + * \brief prepare for a transform with a source mask and opacity in gray8 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] chOpacity the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity); + +/*! + * \brief prepare for a transform with a source mask and opacity in rgb565 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] chOpacity the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity); + +/*! + * \brief prepare for a transform with a source mask and opacity in cccn888 + * \param[in] ptOP the control block, NULL means using the default control block + * \param[in] ptSource the source tile + * \param[in] ptSourceMask the source mask + * \param[in] tCentre the pivot in the source tile + * \param[in] fAngle the rotation angle + * \param[in] fScale the scaling factor + * \param[in] chOpacity the opacity + * \return arm_2d_err_t the result of the preparing process + */ +extern +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity); + +/*! + * \brief start a transform operation + * \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] ptTargetCentre the pivot in the target region + * \return arm_fsm_rt_t the operation result + */ +extern +ARM_NONNULL(2) +arm_fsm_rt_t arm_2dp_tile_transform( arm_2d_op_trans_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 diff --git a/package/Arm2D/Library/Include/arm_2d_types.h b/package/Arm2D/Library/Include/arm_2d_types.h new file mode 100644 index 000000000..9a1acec65 --- /dev/null +++ b/package/Arm2D/Library/Include/arm_2d_types.h @@ -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 +#include +#include +#include + +#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__ + + diff --git a/package/Arm2D/arm_2d_utils.h b/package/Arm2D/Library/Include/arm_2d_utils.h similarity index 78% rename from package/Arm2D/arm_2d_utils.h rename to package/Arm2D/Library/Include/arm_2d_utils.h index b33597edf..57b7a18bf 100644 --- a/package/Arm2D/arm_2d_utils.h +++ b/package/Arm2D/Library/Include/arm_2d_utils.h @@ -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 #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 { \ diff --git a/package/Arm2D/__arm_2d_alpha_blending.inc b/package/Arm2D/Library/Source/__arm_2d_alpha_blending.inc similarity index 87% rename from package/Arm2D/__arm_2d_alpha_blending.inc rename to package/Arm2D/Library/Source/__arm_2d_alpha_blending.inc index 853f6fe90..44f6924d6 100644 --- a/package/Arm2D/__arm_2d_alpha_blending.inc +++ b/package/Arm2D/Library/Source/__arm_2d_alpha_blending.inc @@ -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 diff --git a/package/Arm2D/__arm_2d_alpha_blending_wrapper.inc b/package/Arm2D/Library/Source/__arm_2d_alpha_blending_wrapper.inc similarity index 100% rename from package/Arm2D/__arm_2d_alpha_blending_wrapper.inc rename to package/Arm2D/Library/Source/__arm_2d_alpha_blending_wrapper.inc diff --git a/package/Arm2D/__arm_2d_alpha_mask.inc b/package/Arm2D/Library/Source/__arm_2d_alpha_mask.inc similarity index 96% rename from package/Arm2D/__arm_2d_alpha_mask.inc rename to package/Arm2D/Library/Source/__arm_2d_alpha_mask.inc index 0194f0646..55ea23573 100644 --- a/package/Arm2D/__arm_2d_alpha_mask.inc +++ b/package/Arm2D/Library/Source/__arm_2d_alpha_mask.inc @@ -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); } diff --git a/package/Arm2D/Library/Source/__arm_2d_alpha_mask_helium.inc b/package/Arm2D/Library/Source/__arm_2d_alpha_mask_helium.inc new file mode 100644 index 000000000..cd3c3b4bf --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_alpha_mask_helium.inc @@ -0,0 +1,2441 @@ +/* + * 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_alpha_mask_helium.inc + * Description: c code template for copy and fill like operations + * + * $Date: 12. July 2022 + * $Revision: v1.0.1 + * + * -------------------------------------------------------------------- */ + +#ifndef __API_CAFWM_COLOUR +# error You have to define __API_CAFWM_COLOUR before using this c template +#endif + +#define PIXTYP_IS_gray8 1 +#define PIXTYP_IS_rgb565 2 +#define PIXTYP_IS_cccn888 3 + +#define CHECKPIXTYP(NAME1, NAME2) CHECKPIXTYP_impl(NAME1, NAME2) +#define CHECKPIXTYP_impl(NAME1, NAME2) PIXTYP_IS_ ## NAME1 == PIXTYP_IS_ ## NAME2 + +#define CHECKPIXTYP_NOT(NAME1, NAME2) CHECKPIXTYP_NOT_impl(NAME1, NAME2) +#define CHECKPIXTYP_NOT_impl(NAME1, NAME2) PIXTYP_IS_ ## NAME1 != PIXTYP_IS_ ## NAME2 + + +#if CHECKPIXTYP(__API_CAFWM_COLOUR, rgb565) +#define __API_CAFWM_INT_TYPE uint16_t +#define __API_CAFWM_PIXEL_BIT_NUM 16 +#define __API_CAFWM_PIXEL_VECLOAD vld1q +#define __API_CAFWM_PIXEL_GATHVECLOAD vldrhq_gather_shifted_offset +#define __API_CAFWM_PIXEL_PVECSTORE vst1q_p +#define __API_CAFWM_PIXEL_BLENDING __arm_2d_rgb565_blending_opacity_single_vec + +#elif CHECKPIXTYP(__API_CAFWM_COLOUR, gray8) +#define __API_CAFWM_INT_TYPE uint8_t +#define __API_CAFWM_PIXEL_BIT_NUM 16 /* widening involved */ +#define __API_CAFWM_PIXEL_VECLOAD vldrbq_u16 +#define __API_CAFWM_PIXEL_GATHVECLOAD vldrbq_gather_offset_u16 +#define __API_CAFWM_PIXEL_PVECSTORE vstrbq_p_u16 +#define __API_CAFWM_PIXEL_BLENDING __arm_2d_gray8_blending_opacity_single_vec + +#elif CHECKPIXTYP(__API_CAFWM_COLOUR, cccn888) +#define __API_CAFWM_INT_TYPE uint32_t +#if !ENABLE_ALT_MASK_FILL +#define __API_CAFWM_PIXEL_BIT_NUM 32 +#define __API_CAFWM_PIXEL_VECLOAD vld1q +#define __API_CAFWM_PIXEL_GATHVECLOAD vldrwq_gather_shifted_offset +#define __API_CAFWM_PIXEL_PVECSTORE vst1q_p +#define __API_CAFWM_PIXEL_BLENDING __arm_2d_cccn888_blending_opacity_single_vec +#else +#define __API_CAFWM_PIXEL_BIT_NUM 16 /* widening involved */ +#define __API_CAFWM_PIXEL_VECLOAD vldrbq_u16 +#define __API_CAFWM_PIXEL_GATHVECLOAD vldrbq_gather_offset_u16 +#define __API_CAFWM_PIXEL_PVECSTORE vstrbq_p_u16 +#define __API_CAFWM_PIXEL_BLENDING __arm_2d_gray8_blending_opacity_single_vec +#endif + +#else +#error Unknown colour +#endif + +#define __API_CAFWM_PIXEL_VECTYP ARM_PIX_VECTYP(__API_CAFWM_PIXEL_BIT_NUM) +#define __API_CAFWM_VEC_INCR ARM_PIX_VECELT(__API_CAFWM_PIXEL_BIT_NUM) + +/*! disable this feature by default */ +#ifndef __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +# define __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING 0 +#endif + +#ifndef __API_CAFWM_CFG_1_HORIZONTAL_LINE +# define __API_CAFWM_CFG_1_HORIZONTAL_LINE 0 +#endif + +#ifndef __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT +# define __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT 0 +#endif + + +#if __API_CAFWM_CFG_1_HORIZONTAL_LINE && !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT +//! rename functions for 'c8bit' 1 horizontal line target mask +# define masks_fill src_msk_1h_des_msk_fill +# define masks_fill_x_mirror src_msk_1h_des_msk_fill_x_mirror +# define masks_fill_y_mirror src_msk_1h_des_msk_fill_y_mirror +# define masks_fill_xy_mirror src_msk_1h_des_msk_fill_xy_mirror +# define masks_fill_mirror src_msk_1h_des_msk_fill_mirror + +# define des_msk_fill 1h_des_msk_fill +# define des_msk_fill_x_mirror 1h_des_msk_fill_x_mirror +# define des_msk_fill_y_mirror 1h_des_msk_fill_y_mirror +# define des_msk_fill_xy_mirror 1h_des_msk_fill_xy_mirror +# define des_msk_fill_mirror 1h_des_msk_fill_mirror + + +# define masks_copy src_msk_1h_des_msk_copy +# define masks_copy_x_mirror src_msk_1h_des_msk_copy_x_mirror +# define masks_copy_y_mirror src_msk_1h_des_msk_copy_y_mirror +# define masks_copy_xy_mirror src_msk_1h_des_msk_copy_xy_mirror +# define masks_copy_mirror src_msk_1h_des_msk_copy_mirror + +# define des_msk_copy 1h_des_msk_copy +# define des_msk_copy_x_mirror 1h_des_msk_copy_x_mirror +# define des_msk_copy_y_mirror 1h_des_msk_copy_y_mirror +# define des_msk_copy_xy_mirror 1h_des_msk_copy_xy_mirror +# define des_msk_copy_mirror 1h_des_msk_copy_mirror + +#elif __API_CAFWM_CFG_1_HORIZONTAL_LINE && __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT +//! rename functions for '8in32 channel' 1 horizontal line target mask + +# error Do NOT Support this combination: __API_CAFWM_CFG_1_HORIZONTAL_LINE=1 \ + and __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT=1 ! + +#elif !__API_CAFWM_CFG_1_HORIZONTAL_LINE && __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT +//! rename functions for '8in32 channel' + +# define des_msk_fill des_chn_msk_fill +# define des_msk_fill_x_mirror des_chn_msk_fill_x_mirror +# define des_msk_fill_y_mirror des_chn_msk_fill_y_mirror +# define des_msk_fill_xy_mirror des_chn_msk_fill_xy_mirror +# define des_msk_fill_mirror des_chn_msk_fill_mirror + +# define des_msk_copy des_chn_msk_copy +# define des_msk_copy_x_mirror des_chn_msk_copy_x_mirror +# define des_msk_copy_y_mirror des_chn_msk_copy_y_mirror +# define des_msk_copy_xy_mirror des_chn_msk_copy_xy_mirror +# define des_msk_copy_mirror des_chn_msk_copy_mirror + +# define src_msk_fill src_chn_msk_fill +# define src_msk_fill_x_mirror src_chn_msk_fill_x_mirror +# define src_msk_fill_y_mirror src_chn_msk_fill_y_mirror +# define src_msk_fill_xy_mirror src_chn_msk_fill_xy_mirror +# define src_msk_fill_mirror src_chn_msk_fill_mirror + +# define src_msk_copy src_chn_msk_copy +# define src_msk_copy_x_mirror src_chn_msk_copy_x_mirror +# define src_msk_copy_y_mirror src_chn_msk_copy_y_mirror +# define src_msk_copy_xy_mirror src_chn_msk_copy_xy_mirror +# define src_msk_copy_mirror src_chn_msk_copy_mirror + +#endif + + + +#undef ____CAFWM_FUNC +#undef ___CAFWM_FUNC +#undef __CAFWM_FUNC + + + +#ifndef __API_CAFWM_OP_NAME +# define ____CAFWM_FUNC(__NAME, __COLOUR) \ + __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME) +# define ___CAFWM_FUNC(__NAME, __COLOUR) ____CAFWM_FUNC(__NAME, __COLOUR) +#else +# define _____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ + __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME) +# define ____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ + _____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) +# define ___CAFWM_FUNC(__NAME, __COLOUR) \ + ____CAFWM_FUNC(__API_CAFWM_OP_NAME, __NAME, __COLOUR) +#endif + +#define __CAFWM_FUNC(__NAME) ___CAFWM_FUNC(__NAME, __API_CAFWM_COLOUR) + + +#undef ____CAFWM_TYPE +#undef ___CAFWM_TYPE +#undef __CAFWM_TYPE + +#ifndef __API_CAFWM_OP_NAME +# define ____CAFWM_TYPE(__NAME, __COLOUR) arm_2d_##__COLOUR##_##__NAME +# define ___CAFWM_TYPE(__NAME, __COLOUR) ____CAFWM_TYPE(__NAME, __COLOUR) +#else +# define _____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ + arm_2d_##__COLOUR##_##__OP_NAME##_##__NAME +# define ____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ + _____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) +# define ___CAFWM_TYPE(__NAME, __COLOUR) \ + ____CAFWM_TYPE(__API_CAFWM_OP_NAME, __NAME, __COLOUR) +#endif + + +#define __CAFWM_TYPE(__NAME) ___CAFWM_TYPE(__NAME, __API_CAFWM_COLOUR) + +/*----------------------------------------------------------------------------* + * Fill with Mirroring (both masks) * + *----------------------------------------------------------------------------*/ + + + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + +/*! \note source mask only */ +# define __API_MCWM_COLOUR __API_CAFWM_COLOUR +# define __API_MCWM_INT_TYPE __API_CAFWM_INT_TYPE + +# if defined(__API_CAFWM_OP_NAME) +# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME +# endif + +# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ + __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 + +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 0 + +# define masks_fill src_chn_msk_des_msk_fill +# define masks_fill_x_mirror src_chn_msk_des_msk_fill_x_mirror +# define masks_fill_y_mirror src_chn_msk_des_msk_fill_y_mirror +# define masks_fill_xy_mirror src_chn_msk_des_msk_fill_xy_mirror +# define masks_fill_mirror src_chn_msk_des_msk_fill_mirror + +# define masks_copy src_chn_msk_des_msk_copy +# define masks_copy_x_mirror src_chn_msk_des_msk_copy_x_mirror +# define masks_copy_y_mirror src_chn_msk_des_msk_copy_y_mirror +# define masks_copy_xy_mirror src_chn_msk_des_msk_copy_xy_mirror +# define masks_copy_mirror src_chn_msk_des_msk_copy_mirror + + +# include "__arm_2d_meta_copy_with_masks_helium.inc" + + + +/*! \note source mask only */ +# define __API_MCWM_COLOUR __API_CAFWM_COLOUR +# define __API_MCWM_INT_TYPE __API_CAFWM_INT_TYPE + +# if defined(__API_CAFWM_OP_NAME) +# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME +# endif + +# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ + __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + +# define __API_MCWM_CFG_1_HORIZONTAL_LINE 1 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 + +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 0 + +# define masks_fill src_chn_msk_1h_des_msk_fill +# define masks_fill_x_mirror src_chn_msk_1h_des_msk_fill_x_mirror +# define masks_fill_y_mirror src_chn_msk_1h_des_msk_fill_y_mirror +# define masks_fill_xy_mirror src_chn_msk_1h_des_msk_fill_xy_mirror +# define masks_fill_mirror src_chn_msk_1h_des_msk_fill_mirror + +# define masks_copy src_chn_msk_1h_des_msk_copy +# define masks_copy_x_mirror src_chn_msk_1h_des_msk_copy_x_mirror +# define masks_copy_y_mirror src_chn_msk_1h_des_msk_copy_y_mirror +# define masks_copy_xy_mirror src_chn_msk_1h_des_msk_copy_xy_mirror +# define masks_copy_mirror src_chn_msk_1h_des_msk_copy_mirror + + +# include "__arm_2d_meta_copy_with_masks_helium.inc" + + +/*! \note des mask only */ +# define __API_MCWM_COLOUR __API_CAFWM_COLOUR +# define __API_MCWM_INT_TYPE __API_CAFWM_INT_TYPE + +# if defined(__API_CAFWM_OP_NAME) +# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME +# endif + +# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ + __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 + +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 0 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 1 + +# define masks_fill src_msk_des_chn_msk_fill +# define masks_fill_x_mirror src_msk_des_chn_msk_fill_x_mirror +# define masks_fill_y_mirror src_msk_des_chn_msk_fill_y_mirror +# define masks_fill_xy_mirror src_msk_des_chn_msk_fill_xy_mirror +# define masks_fill_mirror src_msk_des_chn_msk_fill_mirror + +# define masks_copy src_msk_des_chn_msk_copy +# define masks_copy_x_mirror src_msk_des_chn_msk_copy_x_mirror +# define masks_copy_y_mirror src_msk_des_chn_msk_copy_y_mirror +# define masks_copy_xy_mirror src_msk_des_chn_msk_copy_xy_mirror +# define masks_copy_mirror src_msk_des_chn_msk_copy_mirror + + +# include "__arm_2d_meta_copy_with_masks_helium.inc" + + +/*! \note both masks */ +# define __API_MCWM_COLOUR __API_CAFWM_COLOUR +# define __API_MCWM_INT_TYPE __API_CAFWM_INT_TYPE + +# if defined(__API_CAFWM_OP_NAME) +# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME +# endif + +# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ + __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 + +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 1 + +# define masks_fill src_chn_msk_des_chn_msk_fill +# define masks_fill_x_mirror src_chn_msk_des_chn_msk_fill_x_mirror +# define masks_fill_y_mirror src_chn_msk_des_chn_msk_fill_y_mirror +# define masks_fill_xy_mirror src_chn_msk_des_chn_msk_fill_xy_mirror +# define masks_fill_mirror src_chn_msk_des_chn_msk_fill_mirror + +# define masks_copy src_chn_msk_des_chn_msk_copy +# define masks_copy_x_mirror src_chn_msk_des_chn_msk_copy_x_mirror +# define masks_copy_y_mirror src_chn_msk_des_chn_msk_copy_y_mirror +# define masks_copy_xy_mirror src_chn_msk_des_chn_msk_copy_xy_mirror +# define masks_copy_mirror src_chn_msk_des_chn_msk_copy_mirror + + +# include "__arm_2d_meta_copy_with_masks_helium.inc" + +#else + +# define __API_MCWM_COLOUR __API_CAFWM_COLOUR +# define __API_MCWM_INT_TYPE __API_CAFWM_INT_TYPE + +# if defined(__API_CAFWM_OP_NAME) +# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME +# endif + +# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ + __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +# define __API_MCWM_CFG_1_HORIZONTAL_LINE \ + __API_CAFWM_CFG_1_HORIZONTAL_LINE +# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 0 + +# include "__arm_2d_meta_copy_with_masks_helium.inc" + +#endif + + + + +/*----------------------------------------------------------------------------* + * Fill with Mirroring (target mask only) * + *----------------------------------------------------------------------------*/ + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_fill)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskBase, + #else + uint8_t *__RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#else + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#endif + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #else + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #endif + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + int32_t blkCnt = wLength; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, + __API_CAFWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + ptTarget += wLength; + ptTargetMask += wLength; + + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource += iSourceStride; + ptTargetBase += iTargetStride; + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMaskLineBase = ptTargetMaskBase; + #else + ptTargetMaskLineBase += iTargetMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_fill_x_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskBase, + #else + uint8_t *__RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + uint16_t srcWidth = ptSourceSize->iWidth; +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#else + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#endif + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #else + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #endif + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + + uint32_t curDecrStride1Idx = srcWidth - 1; + int32_t blkCnt = wLength; + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #else + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + ptTarget += wLength; + ptTargetMask += wLength; + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource += iSourceStride; + ptTargetBase += iTargetStride; + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMaskLineBase = ptTargetMaskBase; + #else + ptTargetMaskLineBase += iTargetMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_fill_y_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskBase, + #else + uint8_t *__RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#else + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#endif + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #else + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #endif + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + int32_t blkCnt = wLength; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + ptTarget += wLength; + ptTargetMask += wLength; + + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource -= iSourceStride; + ptTargetBase += iTargetStride; + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMaskLineBase = ptTargetMaskBase; + #else + ptTargetMaskLineBase += iTargetMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_fill_xy_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskBase, + #else + uint8_t *__RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + __API_CAFWM_INT_TYPE srcWidth = ptSourceSize->iWidth; +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#else + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#endif + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #else + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #endif + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + + uint32_t curDecrStride1Idx = srcWidth - 1; + int32_t blkCnt = wLength; + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #else + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + ptTarget += wLength; + ptTargetMask += wLength; + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource -= iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMaskLineBase = ptTargetMaskBase; + #else + ptTargetMaskLineBase += iTargetMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + + +/*----------------------------------------------------------------------------* + * Fill with Mirroring (src mask only) * + *----------------------------------------------------------------------------*/ +#if !__API_CAFWM_CFG_1_HORIZONTAL_LINE +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_fill)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; + #else + uint8_t *ptSourceMask = ptSourceMaskBase; + #endif + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + int32_t blkCnt = wLength; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, + __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptSrcMsk += __API_CAFWM_VEC_INCR; + #endif + + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + ptTarget += wLength; + + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource += iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + iSourceMaskY++; + //! handle source mask + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= ptSourceSize->iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask += iSourceMaskStride; + } + #else + ptSourceMask += iSourceMaskStride; + #endif + + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_fill_x_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + uint16_t srcWidth = ptSourceSize->iWidth; + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; + #else + uint8_t *ptSourceMask = ptSourceMaskBase; + #endif + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + + uint32_t curDecrStride1Idx = srcWidth - 1; + int32_t blkCnt = wLength; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curDecrStride4Idx = 4*(srcWidth - 1); + __API_CAFWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM) + ((uint8_t *)ptSrcMsk, vDecrStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM) + (ptSrcMsk, vDecrStride1Offs); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + ptTarget += wLength; + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource += iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + iSourceMaskY++; + //! handle source mask + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= ptSourceSize->iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask += iSourceMaskStride; + } + #else + ptSourceMask += iSourceMaskStride; + #endif + + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_fill_y_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize) +{ + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); + ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); + + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; + #else + uint8_t *ptSourceMask = ptSourceMaskBase; + #endif + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + int32_t blkCnt = wLength; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptSrcMsk += __API_CAFWM_VEC_INCR; + #endif + + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + ptTarget += wLength; + + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource -= iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + iSourceMaskY++; + //! handle source mask + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= ptSourceSize->iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask -= iSourceMaskStride; + } + #else + ptSourceMask -= iSourceMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_fill_xy_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize) +{ + assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); + ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); + + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + __API_CAFWM_INT_TYPE srcWidth = ptSourceSize->iWidth; + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_CAFWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; + #else + uint8_t *ptSourceMask = ptSourceMaskBase; + #endif + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + + uint32_t curDecrStride1Idx = srcWidth - 1; + int32_t blkCnt = wLength; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curDecrStride4Idx = 4*(srcWidth - 1); + __API_CAFWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); + + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + ptTarget += wLength; + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource -= iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + iSourceMaskY++; + //! handle source mask + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= ptSourceSize->iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask -= iSourceMaskStride; + } + #else + ptSourceMask -= iSourceMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + + +#endif + + + + + + +/*----------------------------------------------------------------------------* + * Copy with Mirroring (target mask only) * + *----------------------------------------------------------------------------*/ + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_copy)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptTargetMaskBase, + #else + uint8_t * __RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptTargetMask = ptTargetMaskBase; +#else + uint8_t *ptTargetMask = ptTargetMaskBase; +#endif + + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + int32_t blkCnt = iWidth; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase += (iSourceStride); + pTargetBase += (iTargetStride); + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMask = ptTargetMaskBase; + #else + ptTargetMask += (iTargetMaskStride); + #endif + } +} + + + + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_copy_x_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptTargetMaskBase, + #else + uint8_t * __RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptTargetMask = ptTargetMaskBase; +#else + uint8_t *ptTargetMask = ptTargetMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + + uint32_t curDecrStride1Idx = iWidth - 1; + int32_t blkCnt = iWidth; + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #else + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + pSourceBase += iSourceStride; + pTargetBase += iTargetStride; + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMask = ptTargetMaskBase; + #else + ptTargetMask += (iTargetMaskStride); + #endif + + } +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_copy_y_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptTargetMaskBase, + #else + uint8_t * __RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); + + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptTargetMask = ptTargetMaskBase; +#else + uint8_t *ptTargetMask = ptTargetMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + int32_t blkCnt = iWidth; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase -= iSourceStride; + pTargetBase += (iTargetStride); + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMask = ptTargetMaskBase; + #else + ptTargetMask += (iTargetMaskStride); + #endif + } + +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(des_msk_copy_xy_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptTargetMaskBase, + #else + uint8_t * __RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); + + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptTargetMask = ptTargetMaskBase; +#else + uint8_t *ptTargetMask = ptTargetMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + + uint32_t curDecrStride1Idx = iWidth - 1; + int32_t blkCnt = iWidth; + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecTargetMask); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #else + ptTargetMaskCur += __API_CAFWM_VEC_INCR; + #endif + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase -= iSourceStride; + pTargetBase += (iTargetStride); + + + #if __API_CAFWM_CFG_1_HORIZONTAL_LINE + ptTargetMask = ptTargetMaskBase; + #else + ptTargetMask += (iTargetMaskStride); + #endif + } + +} + + + +/*----------------------------------------------------------------------------* + * Copy with Mirroring (src mask only) * + *----------------------------------------------------------------------------*/ +#if !__API_CAFWM_CFG_1_HORIZONTAL_LINE +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_copy)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; +#else + uint8_t *ptSourceMask = ptSourceMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + int32_t blkCnt = iWidth; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptSrcMsk += __API_CAFWM_VEC_INCR; + #endif + + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase += (iSourceStride); + pTargetBase += (iTargetStride); + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + //! handle source mask + iSourceMaskY++; + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask += (iSourceMaskStride); + } + #else + ptSourceMask += (iSourceMaskStride); + #endif + + } +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_copy_x_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; +#else + uint8_t *ptSourceMask = ptSourceMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + + uint32_t curDecrStride1Idx = iWidth - 1; + int32_t blkCnt = iWidth; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curDecrStride4Idx = 4*(iWidth - 1); + __API_CAFWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + + pSourceBase += iSourceStride; + pTargetBase += iTargetStride; + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + //! handle source mask + iSourceMaskY++; + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask += iSourceMaskStride; + } + #else + ptSourceMask += iSourceMaskStride; + #endif + + } +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_copy_y_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); + + assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); + ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; +#else + uint8_t *ptSourceMask = ptSourceMaskBase; +#endif + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curIncStride4Idx = 0; + __API_CAFWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + int32_t blkCnt = iWidth; + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = __API_CAFWM_PIXEL_VECLOAD(ptSrc); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = __API_CAFWM_PIXEL_BLENDING( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + #endif + + #if !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + ptSrcMsk += __API_CAFWM_VEC_INCR; + #endif + + + ptTargetCur += __API_CAFWM_VEC_INCR; + ptSrc += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase -= iSourceStride; + pTargetBase += (iTargetStride); + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + //! handle source mask + iSourceMaskY++; + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask -= iSourceMaskStride; + } + #else + ptSourceMask -= iSourceMaskStride; + #endif + } +} + + +__OVERRIDE_WEAK +void __CAFWM_FUNC(src_msk_copy_xy_mirror)( + __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, + int16_t iSourceStride, + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, + int16_t iTargetStride, + + arm_2d_size_t * __RESTRICT ptCopySize) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + __API_CAFWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(256); + + pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); + + assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); + ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); + + +#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *ptSourceMask = ptSourceMaskBase; +#else + uint8_t *ptSourceMask = ptSourceMaskBase; +#endif + + +#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; + y++) { + __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_CAFWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; + + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + uint32_t curDecrStride1Idx = iWidth - 1; + int32_t blkCnt = iWidth; + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + uint32_t curDecrStride4Idx = 4*(iWidth - 1); + __API_CAFWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + __API_CAFWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + + do { + __API_CAFWM_PIXEL_VECTYP vecTarget = __API_CAFWM_PIXEL_VECLOAD(ptTargetCur); + __API_CAFWM_PIXEL_VECTYP vecSource = + __API_CAFWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); + #else + __API_CAFWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_CAFWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); + #endif + __API_CAFWM_PIXEL_VECTYP vecHwOpacity = vsubq(v256, vecSrcMsk); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_CAFWM_PIXEL_BIT_NUM)(vecHwOpacity, 1)); + #endif + + vecTarget = + __API_CAFWM_PIXEL_BLENDING(vecTarget, vecSource, + vecHwOpacity); + + /* tail predication */ + __API_CAFWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_CAFWM_PIXEL_BIT_NUM, q)(blkCnt)); + + #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); + #endif + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_CAFWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); + + ptTargetCur += __API_CAFWM_VEC_INCR; + + blkCnt -= __API_CAFWM_VEC_INCR; + } + while (blkCnt > 0); + + pSourceBase -= iSourceStride; + pTargetBase += (iTargetStride); + + #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING + //! handle source mask + iSourceMaskY++; + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask -= iSourceMaskStride; + } + #else + ptSourceMask -= iSourceMaskStride; + #endif + } +} + + + + +#endif + +#undef masks_fill +#undef masks_fill_x_mirror +#undef masks_fill_y_mirror +#undef masks_fill_xy_mirror +#undef masks_fill_mirror + +#undef des_msk_fill +#undef des_msk_fill_x_mirror +#undef des_msk_fill_y_mirror +#undef des_msk_fill_xy_mirror +#undef des_msk_fill_mirror + + +#undef masks_copy +#undef masks_copy_x_mirror +#undef masks_copy_y_mirror +#undef masks_copy_xy_mirror +#undef masks_copy_mirror + +#undef des_msk_copy +#undef des_msk_copy_x_mirror +#undef des_msk_copy_y_mirror +#undef des_msk_copy_xy_mirror +#undef des_msk_copy_mirror + +#undef src_msk_fill +#undef src_msk_fill_x_mirror +#undef src_msk_fill_y_mirror +#undef src_msk_fill_xy_mirror +#undef src_msk_fill_mirror + +#undef src_msk_copy +#undef src_msk_copy_x_mirror +#undef src_msk_copy_y_mirror +#undef src_msk_copy_xy_mirror +#undef src_msk_copy_mirror + + +#undef __API_CAFWM_COPY_LIKE_OP_NAME +#undef __API_CAFWM_OP_NAME +#undef __API_CAFWM_PIXEL_BLENDING +#undef ____CAFWM_FUNC +#undef ___CAFWM_FUNC +#undef __CAFWM_FUNC +#undef __API_CAFWM_COLOUR +#undef __API_CAFWM_INT_TYPE +#undef __API_CAFWM_PIXEL_BIT_NUM +#undef __API_CAFWM_PIXEL_VECLOAD +#undef __API_CAFWM_PIXEL_GATHVECLOAD +#undef __API_CAFWM_PIXEL_PVECSTORE +#undef ____CAFWM_TYPE +#undef ___CAFWM_TYPE +#undef __CAFWM_TYPE +#undef __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING +#undef __API_CAFWM_CFG_1_HORIZONTAL_LINE +#undef __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT + diff --git a/package/Arm2D/Library/Source/__arm_2d_conversion_helium.c b/package/Arm2D/Library/Source/__arm_2d_conversion_helium.c new file mode 100644 index 000000000..94a6281b6 --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_conversion_helium.c @@ -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 diff --git a/package/Arm2D/__arm_2d_copy.inc b/package/Arm2D/Library/Source/__arm_2d_copy.inc similarity index 100% rename from package/Arm2D/__arm_2d_copy.inc rename to package/Arm2D/Library/Source/__arm_2d_copy.inc diff --git a/package/Arm2D/__arm_2d_copy_helium.inc b/package/Arm2D/Library/Source/__arm_2d_copy_helium.inc similarity index 99% rename from package/Arm2D/__arm_2d_copy_helium.inc rename to package/Arm2D/Library/Source/__arm_2d_copy_helium.inc index 068cf4d69..e7c4ecdd0 100644 --- a/package/Arm2D/__arm_2d_copy_helium.inc +++ b/package/Arm2D/Library/Source/__arm_2d_copy_helium.inc @@ -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) diff --git a/package/Arm2D/__arm_2d_core.c b/package/Arm2D/Library/Source/__arm_2d_core.c similarity index 62% rename from package/Arm2D/__arm_2d_core.c rename to package/Arm2D/Library/Source/__arm_2d_core.c index 11387fe07..6b2faaaca 100644 --- a/package/Arm2D/__arm_2d_core.c +++ b/package/Arm2D/Library/Source/__arm_2d_core.c @@ -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_core.c * Description: Basic Tile operations * - * $Date: 02. Oct 2021 - * $Revision: V.0.9.0 + * $Date: 29. Aug 2022 + * $Revision: V.1.3.1 * * Target Processor: Cortex-M cores * @@ -36,7 +36,7 @@ #endif #ifdef __ARM_2D_COMPILATION_UNIT - +#undef __ARM_2D_COMPILATION_UNIT #define __ARM_2D_IMPL__ @@ -48,7 +48,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" @@ -69,20 +68,18 @@ extern "C" { # pragma clang diagnostic ignored "-Wgnu-statement-expression" # 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 +#elif defined(__IS_COMPILER_IAR__) +# pragma diag_suppress=Pa089 #elif defined(__IS_COMPILER_GCC__) -# pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wenum-compare" # pragma GCC diagnostic ignored "-Wpedantic" # pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif /*============================ MACROS ========================================*/ -#ifndef __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE -# define __ARM_2D_DEFAULT_SUB_TASK_POOL_SIZE 3 -#endif - /*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ TYPES =========================================*/ /*============================ GLOBAL VARIABLES ==============================*/ @@ -92,6 +89,14 @@ arm_2d_runtime_feature_t ARM_2D_RUNTIME_FEATURE = { .TREAT_OUT_OF_RANGE_AS_COMPLETE = 1, .HAS_DEDICATED_THREAD_FOR_2D_TASK = 0, }; + + +const arm_2d_version_t ARM_2D_VERSION = { + .Major = ARM_2D_VERSION_MAJOR, + .Minor = ARM_2D_VERSION_MINOR, + .Patch = ARM_2D_VERSION_PATCH, +}; + /*============================ PROTOTYPES ====================================*/ /*============================ LOCAL VARIABLES ===============================*/ /*============================ IMPLEMENTATION ================================*/ @@ -120,9 +125,154 @@ struct __arm_2d_op_control ARM_2D_CTRL; } + /*----------------------------------------------------------------------------* - * Region Calculation * + * Virtual Resource * *----------------------------------------------------------------------------*/ +static arm_2d_err_t __load_virtual_resource(const arm_2d_tile_t *ptRootTile, + __arm_2d_tile_param_t *ptParam) +{ + if (NULL == ptRootTile || NULL == ptParam) { + return ARM_2D_ERR_NONE; + } + + if (!ptRootTile->tInfo.bIsRoot) { + return ARM_2D_ERR_NONE; + } + + if (!ptRootTile->tInfo.bVirtualResource) { + return ARM_2D_ERR_NONE; + } + + /* a virtual resource must be marked as root tile */ + arm_2d_vres_t *ptRes = (arm_2d_vres_t *)ptRootTile; + + if (NULL == ptRes->Load) { + return ARM_2D_ERR_MISSING_PARAM; + } + + /* load virtual resource */ + intptr_t nAddress = (ptRes->Load)( ptRes->pTarget, + ptRes, + &ptParam->tValidRegion); + + if ((intptr_t)NULL == nAddress) { + return ARM_2D_ERR_IO_ERROR; + } + + ptRes->tTile.nAddress = nAddress; + /* update param */ + ptParam->pBuffer = (void *)nAddress; + ptParam->nOffset = 0; + ptParam->iStride = ptParam->tValidRegion.tSize.iWidth; + ptParam->tValidRegion.tLocation = (arm_2d_location_t){0,0}; + + return ARM_2D_ERR_NONE; +} + +static void __depose_virtual_resource(const arm_2d_tile_t *ptSourceTile) +{ + if (NULL == ptSourceTile) { + return; + } + arm_2d_region_t tValidRegion; + ptSourceTile = __arm_2d_tile_get_root( ptSourceTile, + &tValidRegion, + NULL, + NULL); + + if (NULL == ptSourceTile) { + return ; + } + + if (!ptSourceTile->tInfo.bVirtualResource) { + return ; + } + + /* a virtual resource must be marked as root tile */ + arm_2d_vres_t *ptRes = (arm_2d_vres_t *)ptSourceTile; + + intptr_t nAddress = ptRes->tTile.nAddress; + ptRes->tTile.nAddress = (intptr_t)NULL; + + + + if (NULL == ptRes->Depose) { + return ; + } + + /* depose virtual resource */ + (ptRes->Depose)(ptRes->pTarget, ptRes, nAddress); +} + +/*----------------------------------------------------------------------------* + * Invoking Low level operations * + *----------------------------------------------------------------------------*/ + +void __arm_2d_sub_task_depose(arm_2d_op_core_t *ptOP) +{ + assert(NULL != ptOP); + switch(ptOP->ptOp->Info.Param.chValue & ARM_2D_OP_INFO_PARAM_TILES_MASK) { + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK: { + arm_2d_op_msk_t *ptThis = (arm_2d_op_msk_t *)ptOP; + __depose_virtual_resource(this.Mask.ptTile); + } + break; + + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE: { + arm_2d_op_src_t *ptThis = (arm_2d_op_src_t *)ptOP; + __depose_virtual_resource(this.Source.ptTile); + } + break; + + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK: + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK: + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK: { + arm_2d_op_src_msk_t *ptThis = (arm_2d_op_src_msk_t *)ptOP; + __depose_virtual_resource(this.Source.ptTile); + __depose_virtual_resource(this.Mask.ptSourceSide); + __depose_virtual_resource(this.Mask.ptTargetSide); + } + break; + + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_ORIGIN:{ + arm_2d_op_src_orig_t *ptThis = (arm_2d_op_src_orig_t *)ptOP; + __depose_virtual_resource(this.Origin.ptTile); + } + break; + + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_ORIGIN + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK: + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_ORIGIN + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK: + case ARM_2D_OP_INFO_PARAM_HAS_TARGET + | ARM_2D_OP_INFO_PARAM_HAS_ORIGIN + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE + | ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK + | ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK: { + arm_2d_op_src_orig_msk_t *ptThis = (arm_2d_op_src_orig_msk_t *)ptOP; + __depose_virtual_resource(this.Origin.ptTile); + __depose_virtual_resource(this.Mask.ptOriginSide); + __depose_virtual_resource(this.Mask.ptTargetSide); + } + break; + } +} __WEAK arm_fsm_rt_t __arm_2d_issue_sub_task_tile_process( @@ -139,6 +289,8 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_tile_process( /* call default software implementation */ ARM_2D_RUN_DEFAULT( 0, __arm_2d_io_func_t); + + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); return tResult; } @@ -162,6 +314,8 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_fill( /* call default software implementation */ ARM_2D_RUN_DEFAULT( 1,__arm_2d_io_func_t ); + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); + return tResult; } @@ -200,6 +354,8 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_fill_with_mask( /* call default software implementation */ ARM_2D_RUN_DEFAULT( 1,__arm_2d_io_func_t ); + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); + return tResult; } @@ -221,7 +377,9 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_copy(arm_2d_op_cp_t *ptThis, /* call default software implementation */ ARM_2D_RUN_DEFAULT(0,__arm_2d_io_func_t ); - + + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); + return tResult; } @@ -260,7 +418,8 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_copy_with_mask( /* call default software implementation */ ARM_2D_RUN_DEFAULT(0,__arm_2d_io_func_t ); - + + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); return tResult; } @@ -288,6 +447,7 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_fill_origin( /* call default software implementation */ ARM_2D_RUN_DEFAULT( 1,__arm_2d_io_func_t ); + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); return tResult; } @@ -314,11 +474,49 @@ arm_fsm_rt_t __arm_2d_issue_sub_task_copy_origin( /* call default software implementation */ ARM_2D_RUN_DEFAULT(0,__arm_2d_io_func_t ); - + + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); return tResult; } +__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_fsm_rt_t tResult = (arm_fsm_rt_t)ARM_2D_ERR_NOT_SUPPORT; + __arm_2d_sub_task_t *ptTask = &(__arm_2d_sub_task_t){ + .ptOP = (arm_2d_op_core_t *)ptThis, + .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, + }, + }; + + /* call default software implementation */ + ARM_2D_RUN_DEFAULT(0,__arm_2d_io_func_t ); + __arm_2d_sub_task_depose((arm_2d_op_core_t *)ptThis); + return tResult; +} + +/*----------------------------------------------------------------------------* + * Region Calculation * + *----------------------------------------------------------------------------*/ ARM_NONNULL(1,2) static const arm_2d_tile_t * __arm_2d_tile_region_caculator( @@ -335,16 +533,23 @@ static const arm_2d_tile_t * __arm_2d_tile_region_caculator( assert(NULL != ptTile); assert(NULL != ptOut); - bool bDerivedResource = ptTile->tInfo.bDerivedResource - & !ptTile->tInfo.bIsRoot; - + //memset(ptOut, 0, sizeof(__arm_2d_tile_param_t)); - ptTile = arm_2d_tile_get_root( ptTile, + ptTile = __arm_2d_tile_get_root( ptTile, &tValidRegion, - NULL); - + NULL, + &ptOut->ptDerivedResource); + + bool bDerivedResource = false; + + if (NULL != ptOut->ptDerivedResource) { + if (!ptOut->ptDerivedResource->tInfo.bIsRoot) { + bDerivedResource = true; + } + } + if (NULL != ptTile) { //! check if enforced colour is allowed @@ -356,13 +561,18 @@ static const arm_2d_tile_t * __arm_2d_tile_region_caculator( uint_fast8_t chPixelLenInBit = *pchPixelLenInBit; - arm_2d_location_t tOffset = tValidRegion.tLocation; + arm_2d_location_t tOffset = tValidRegion.tLocation; + + /* root tile can have offset location */ + tOffset.iX -= ptTile->tRegion.tLocation.iX; + tOffset.iY -= ptTile->tRegion.tLocation.iY; + if ((wMode) & ARM_2D_CP_MODE_X_MIRROR) { tOffset.iX = 0; } if ((wMode) & ARM_2D_CP_MODE_Y_MIRROR) { tOffset.iY = 0; - } + } if (chPixelLenInBit >= 8) { nOffset = ptTile->tRegion.tSize.iWidth * tOffset.iY + tOffset.iX; @@ -390,7 +600,6 @@ static const arm_2d_tile_t * __arm_2d_tile_region_caculator( return ptTile; } - ARM_NONNULL(1,2) static arm_fsm_rt_t __arm_2d_tile_process( arm_2d_op_t *ptThis, @@ -410,7 +619,7 @@ arm_fsm_rt_t __arm_2d_tile_process( arm_2d_op_t *ptThis, &chPixelLenInBit, OP_CORE.ptOp->Info.Param.bAllowEnforcedColour, 0); - + tResult = __arm_2d_issue_sub_task_tile_process( ptThis, &tTileParam); return tResult; @@ -425,61 +634,71 @@ static void __arm_2d_source_side_tile_mirror_preprocess( uint32_t wMode) { //! right and/or bottom alignment - arm_2d_size_t tOffset = {0}; + arm_2d_location_t tOffset = {0}; if (ptTileParam->bDerivedResource) { //!< treat the content inside the valid region as the one to be mirrored //! right alignment if (wMode & ARM_2D_CP_MODE_X_MIRROR) { - tOffset.iWidth = ptTileParam->tValidRegion.tLocation.iX; - tOffset.iWidth += ptTileParam->tValidRegion.tSize.iWidth - - ptActualSize->iWidth; + + tOffset.iX = ptTileParam->ptDerivedResource->tRegion.tLocation.iX; + tOffset.iX += ( ptTileParam->ptDerivedResource->tRegion.tLocation.iX + + ptTileParam->ptDerivedResource->tRegion.tSize.iWidth) + - ( ptTileParam->tValidRegion.tLocation.iX + + ptActualSize->iWidth); + + ptTileParam->tValidRegion.tLocation.iX = tOffset.iX; } //! bottom alignment if (wMode & ARM_2D_CP_MODE_Y_MIRROR) { - tOffset.iHeight = ptTileParam->tValidRegion.tLocation.iY; - tOffset.iHeight += ptTileParam->tValidRegion.tSize.iHeight - - ptActualSize->iHeight; + tOffset.iY = ptTileParam->ptDerivedResource->tRegion.tLocation.iY; + tOffset.iY += ( ptTileParam->ptDerivedResource->tRegion.tLocation.iY + + ptTileParam->ptDerivedResource->tRegion.tSize.iHeight) + - ( ptTileParam->tValidRegion.tLocation.iY + + ptActualSize->iHeight); + ptTileParam->tValidRegion.tLocation.iY = tOffset.iY; } } else { //!< treat valid region as a logic region to indicate the area for mirroring. //! right alignment if (wMode & ARM_2D_CP_MODE_X_MIRROR) { - tOffset.iWidth = ptTile->tRegion.tSize.iWidth + tOffset.iX = ptTile->tRegion.tSize.iWidth - ( ptTileParam->tValidRegion.tLocation.iX + ptActualSize->iWidth); + ptTileParam->tValidRegion.tLocation.iX = tOffset.iX; } //! bottom alignment if (wMode & ARM_2D_CP_MODE_Y_MIRROR) { - tOffset.iHeight = ptTile->tRegion.tSize.iHeight + tOffset.iY = ptTile->tRegion.tSize.iHeight - ( ptTileParam->tValidRegion.tLocation.iY + ptActualSize->iHeight); + ptTileParam->tValidRegion.tLocation.iY = tOffset.iY; } } if (chPixelLenInBit >= 8) { - ptTileParam->nOffset += ( tOffset.iHeight * ptTile->tRegion.tSize.iWidth - + tOffset.iWidth); + ptTileParam->nOffset += ( tOffset.iY * ptTile->tRegion.tSize.iWidth + + tOffset.iX); ptTileParam->pBuffer = ptTile->pchBuffer + (ptTileParam->nOffset * chPixelLenInBit >> 3); } else { - ptTileParam->nOffset += tOffset.iWidth; + ptTileParam->nOffset += tOffset.iX; (*(uintptr_t *)&(ptTileParam->pBuffer)) += + ((ptTile->tRegion.tSize.iWidth - * chPixelLenInBit + 7) >> 3) * tOffset.iHeight - + ((tOffset.iWidth * chPixelLenInBit) >> 3); + * chPixelLenInBit + 7) >> 3) * tOffset.iY + + ((tOffset.iX * chPixelLenInBit) >> 3); } } ARM_NONNULL(1,2) static -arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, +arm_fsm_rt_t __arm_2d_region_calculator( arm_2d_op_cp_t *ptThis, const arm_2d_tile_t *ptSource, const arm_2d_tile_t *ptSourceMask, const arm_2d_tile_t *ptTarget, @@ -493,6 +712,7 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, arm_fsm_rt_t tResult = (arm_fsm_rt_t)ARM_2D_ERR_NOT_SUPPORT; uint_fast8_t chTargetPixelLenInBit = _BV(OP_CORE.ptOp->Info.Colour.u3ColourSZ); uint_fast8_t chSourcePixelLenInBit = chTargetPixelLenInBit; + uint_fast8_t chOriginPixelLenInBit = chTargetPixelLenInBit; uint_fast8_t chSourceMaskPixelLenInBit = 8; __arm_2d_tile_param_t tSourceTileParam; @@ -510,7 +730,7 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, if (OP_CORE.ptOp->Info.Param.bHasOrigin) { arm_2d_op_src_orig_t *ptOP = (arm_2d_op_src_orig_t *)ptThis; - uint_fast8_t chOriginPixelLenInBit = chSourcePixelLenInBit; + //uint_fast8_t chOriginPixelLenInBit = chSourcePixelLenInBit; ptOrigin = __arm_2d_tile_region_caculator( ptOP->Origin.ptTile, &tOriginTileParam, @@ -544,14 +764,15 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, } - if (!OP_CORE.ptOp->Info.Param.bHasOrigin) { + if (!OP_CORE.ptOp->Info.Param.bHasOrigin) { //!< no origin if (OP_CORE.ptOp->Info.Param.bHasSrcMask) { arm_2d_op_src_msk_t *ptOP = (arm_2d_op_src_msk_t *)ptThis; ptSourceMask = ptOP->Mask.ptSourceSide; if (NULL != ptSourceMask) { - ptSourceMask = arm_2d_tile_generate_child( ptSourceMask, + ptSourceMask = arm_2d_tile_generate_child( + ptSourceMask, &tSourceTileParam.tValidRegion, &tSourceMask, false); @@ -582,28 +803,31 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, tTempRegion.tLocation.iX = tTargetTileParam.tValidRegion.tLocation.iX - tTempRegion.tLocation.iX; - - - + tTempRegion.tSize.iWidth = tTargetTileParam.tValidRegion.tSize.iWidth - tTempRegion.tSize.iWidth; - #if 0 //! no use for now - tTempRegion.tLocation.iY - = tTargetTileParam.tValidRegion.tLocation.iY - - tTempRegion.tLocation.iY; - - tTempRegion.tSize.iHeight - = tTargetTileParam.tValidRegion.tSize.iHeight - - tTempRegion.tSize.iHeight; - #endif - + arm_2d_region_t tNewTargetMaskRegion = ptTargetMask->tRegion; tNewTargetMaskRegion.tLocation.iX += tTempRegion.tLocation.iX; tNewTargetMaskRegion.tSize.iWidth += tTempRegion.tSize.iWidth; + // when the target mask is not 1-horizontal line mask + if (ptTargetMask->tRegion.tSize.iHeight != 1 ) { + tTempRegion.tLocation.iY + = tTargetTileParam.tValidRegion.tLocation.iY + - tTempRegion.tLocation.iY; + + tTempRegion.tSize.iHeight + = tTargetTileParam.tValidRegion.tSize.iHeight + - tTempRegion.tSize.iHeight; + + + tNewTargetMaskRegion.tLocation.iY += tTempRegion.tLocation.iY; + tNewTargetMaskRegion.tSize.iHeight += tTempRegion.tSize.iHeight; + } ptTargetMask = arm_2d_tile_generate_child( ptTargetMask, @@ -622,37 +846,203 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, 0); } } - } //!else { //! todo } + } else { //!< has origin + if (OP_CORE.ptOp->Info.Param.bHasSrcMask) { + arm_2d_op_src_orig_msk_t *ptOP = (arm_2d_op_src_orig_msk_t *)ptThis; + + ptSourceMask = ptOP->Mask.ptOriginSide; + + if (NULL != ptSourceMask) { + ptSourceMask = arm_2d_tile_generate_child( + ptSourceMask, + &tOriginTileParam.tValidRegion, + &tSourceMask, + false); - if (wMode & ARM_2D_CP_MODE_FILL) { - - //! handle mirroring - do { - __arm_2d_source_side_tile_mirror_preprocess( - ptSource, - &tSourceTileParam, - chSourcePixelLenInBit, - &tSourceTileParam.tValidRegion.tSize, - wMode); - - if ( OP_CORE.ptOp->Info.Param.bHasSrcMask - && (NULL != ptSourceMask)) { - __arm_2d_source_side_tile_mirror_preprocess( - ptSourceMask, - &tSourceMaskParam, - chSourceMaskPixelLenInBit, - &tSourceMaskParam.tValidRegion.tSize, - wMode); + ptSourceMask = __arm_2d_tile_region_caculator( + ptSourceMask, + &tSourceMaskParam, + &chSourceMaskPixelLenInBit, + true, + wMode); } - } while(0); + } + + if (OP_CORE.ptOp->Info.Param.bHasDesMask) { + arm_2d_op_src_orig_msk_t *ptOP = (arm_2d_op_src_orig_msk_t *)ptThis; + ptTargetMask = ptOP->Mask.ptTargetSide; + if (NULL != ptTargetMask) { + uint_fast8_t chTargetMaskPixelLenInBit = 8; + + do { + arm_2d_region_t tTempRegion= { + .tSize = ptThis->Target.ptTile->tRegion.tSize, + }; + + arm_2d_get_absolute_location(ptThis->Target.ptTile, + &tTempRegion.tLocation); + + tTempRegion.tLocation.iX + = tTargetTileParam.tValidRegion.tLocation.iX + - tTempRegion.tLocation.iX; + + tTempRegion.tSize.iWidth + = tTargetTileParam.tValidRegion.tSize.iWidth + - tTempRegion.tSize.iWidth; + + + arm_2d_region_t tNewTargetMaskRegion = ptTargetMask->tRegion; + + tNewTargetMaskRegion.tLocation.iX += tTempRegion.tLocation.iX; + tNewTargetMaskRegion.tSize.iWidth += tTempRegion.tSize.iWidth; + + // when the target mask is not 1-horizontal line mask + if (ptTargetMask->tRegion.tSize.iHeight != 1 ) { + tTempRegion.tLocation.iY + = tTargetTileParam.tValidRegion.tLocation.iY + - tTempRegion.tLocation.iY; + + tTempRegion.tSize.iHeight + = tTargetTileParam.tValidRegion.tSize.iHeight + - tTempRegion.tSize.iHeight; + + + tNewTargetMaskRegion.tLocation.iY += tTempRegion.tLocation.iY; + tNewTargetMaskRegion.tSize.iHeight += tTempRegion.tSize.iHeight; + } + + ptTargetMask = arm_2d_tile_generate_child( + ptTargetMask, + &tNewTargetMaskRegion, + &tTargetMask, + false); + + } while(0); + + + ptTargetMask = __arm_2d_tile_region_caculator( + ptTargetMask, + &tTargetMaskParam, + &chTargetMaskPixelLenInBit, + true, + 0); + } + } + } + arm_2d_size_t tActualSize = { + .iWidth = MIN( tSourceTileParam.tValidRegion.tSize.iWidth, + tTargetTileParam.tValidRegion.tSize.iWidth), + .iHeight = MIN( tSourceTileParam.tValidRegion.tSize.iHeight, + tTargetTileParam.tValidRegion.tSize.iHeight), + }; + + /* trim source valid region */ + tSourceTileParam.tValidRegion.tSize = tActualSize; + + if (wMode & ARM_2D_CP_MODE_FILL) { //!< tiling (tile fill) operation + if (OP_CORE.ptOp->Info.Param.bHasOrigin) { + /*! \brief masks are not supported in fill with origin mode */ + assert(!OP_CORE.ptOp->Info.Param.bHasSrcMask); + assert(!OP_CORE.ptOp->Info.Param.bHasDesMask); + + //! handle mirroring + do { + __arm_2d_source_side_tile_mirror_preprocess( + ptOrigin, + &tOriginTileParam, + chOriginPixelLenInBit, + &tOriginTileParam.tValidRegion.tSize, + wMode); + + /*! \note NOT SUPPORTED YET + if ( OP_CORE.ptOp->Info.Param.bHasSrcMask + && (NULL != ptSourceMask)) { + __arm_2d_source_side_tile_mirror_preprocess( + ptSourceMask, + &tSourceMaskParam, + chSourceMaskPixelLenInBit, + &tSourceMaskParam.tValidRegion.tSize, + wMode); + } + */ + } while(0); + + /* load virtual resource if any */ + do { + arm_2d_err_t tErr = + __load_virtual_resource(ptOrigin, &tOriginTileParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + } while(0); + tResult = __arm_2d_issue_sub_task_fill_origin( ptThis, &tSourceTileParam, &tOriginTileParam, &tTargetTileParam); } else { + + //! handle mirroring + do { + __arm_2d_source_side_tile_mirror_preprocess( + ptSource, + &tSourceTileParam, + chSourcePixelLenInBit, + &tSourceTileParam.tValidRegion.tSize, + wMode); + + if ( OP_CORE.ptOp->Info.Param.bHasSrcMask + && (NULL != ptSourceMask)) { + __arm_2d_source_side_tile_mirror_preprocess( + ptSourceMask, + &tSourceMaskParam, + chSourceMaskPixelLenInBit, + &tSourceMaskParam.tValidRegion.tSize, + wMode); + } + } while(0); + + /* trim source mask valid region */ + if (NULL != ptSourceMask) { + tSourceMaskParam.tValidRegion.tSize.iWidth = + MIN(tSourceMaskParam.tValidRegion.tSize.iWidth, + tSourceTileParam.tValidRegion.tSize.iWidth); + tSourceMaskParam.tValidRegion.tSize.iHeight = + MIN(tSourceMaskParam.tValidRegion.tSize.iHeight, + tSourceTileParam.tValidRegion.tSize.iHeight); + } + + if (NULL != ptTargetMask) { + tTargetMaskParam.tValidRegion.tSize.iWidth = + MIN(tTargetMaskParam.tValidRegion.tSize.iWidth, + tTargetTileParam.tValidRegion.tSize.iWidth); + tTargetMaskParam.tValidRegion.tSize.iHeight = + MIN(tTargetMaskParam.tValidRegion.tSize.iHeight, + tTargetTileParam.tValidRegion.tSize.iHeight); + } + + /* load virtual resource if any */ + do { + arm_2d_err_t tErr = + __load_virtual_resource(ptSource, &tSourceTileParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptSourceMask, &tSourceMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptTargetMask, &tTargetMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + } while(0); + if ( (OP_CORE.ptOp->Info.Param.bHasSrcMask) || (OP_CORE.ptOp->Info.Param.bHasDesMask)){ @@ -669,49 +1059,155 @@ arm_fsm_rt_t __arm_2d_big_pixel_tile_pave( arm_2d_op_cp_t *ptThis, &tTargetTileParam); } } - } else { - arm_2d_size_t tActualSize = { - .iWidth = MIN( tSourceTileParam.tValidRegion.tSize.iWidth, - tTargetTileParam.tValidRegion.tSize.iWidth), - .iHeight = MIN( tSourceTileParam.tValidRegion.tSize.iHeight, - tTargetTileParam.tValidRegion.tSize.iHeight), - }; - - //! handle mirroring - do { - __arm_2d_source_side_tile_mirror_preprocess( - ptSource, - &tSourceTileParam, - chSourcePixelLenInBit, - &tActualSize, - wMode); - - if ( OP_CORE.ptOp->Info.Param.bHasSrcMask - && (NULL != ptSourceMask)) { - arm_2d_size_t tMaskActualSize = { - .iWidth = MIN(tActualSize.iWidth, - tSourceMaskParam.tValidRegion.tSize.iWidth), - .iHeight = MIN(tActualSize.iHeight, - tSourceMaskParam.tValidRegion.tSize.iHeight), - }; - __arm_2d_source_side_tile_mirror_preprocess( - ptSourceMask, - &tSourceMaskParam, - chSourceMaskPixelLenInBit, - &tMaskActualSize, - wMode); - } - } while(0); - + } else { //!< normal tile copy operation + if (OP_CORE.ptOp->Info.Param.bHasOrigin) { - - tResult = __arm_2d_issue_sub_task_copy_origin( ptThis, - &tSourceTileParam, - &tOriginTileParam, - &tTargetTileParam, - &tActualSize); + //! handle mirroring + do { + __arm_2d_source_side_tile_mirror_preprocess( + ptOrigin, + &tOriginTileParam, + chOriginPixelLenInBit, + &tActualSize, + wMode); + + if ( OP_CORE.ptOp->Info.Param.bHasSrcMask + && (NULL != ptSourceMask)) { + arm_2d_size_t tMaskActualSize = { + .iWidth = MIN(tActualSize.iWidth, + tSourceMaskParam.tValidRegion.tSize.iWidth), + .iHeight = MIN(tActualSize.iHeight, + tSourceMaskParam.tValidRegion.tSize.iHeight), + }; + __arm_2d_source_side_tile_mirror_preprocess( + ptSourceMask, + &tSourceMaskParam, + chSourceMaskPixelLenInBit, + &tMaskActualSize, + wMode); + } + } while(0); + +// /* trim source valid region */ +// tSourceTileParam.tValidRegion.tSize = tActualSize; + + /* trim source mask valid region */ + if (NULL != ptTargetMask) { + tTargetMaskParam.tValidRegion.tSize.iWidth = + MIN(tTargetMaskParam.tValidRegion.tSize.iWidth, + tTargetTileParam.tValidRegion.tSize.iWidth); + tTargetMaskParam.tValidRegion.tSize.iHeight = + MIN(tTargetMaskParam.tValidRegion.tSize.iHeight, + tTargetTileParam.tValidRegion.tSize.iHeight); + } + + /* load virtual resource if any */ + do { + arm_2d_err_t tErr = + __load_virtual_resource(ptOrigin, &tOriginTileParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptSourceMask, &tSourceMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptTargetMask, &tTargetMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + } while(0); + + if ( (OP_CORE.ptOp->Info.Param.bHasSrcMask) + || (OP_CORE.ptOp->Info.Param.bHasDesMask)){ + tResult = __arm_2d_issue_sub_task_copy_origin_masks( + ptThis, + &tSourceTileParam, + &tOriginTileParam, + ((NULL != ptSourceMask) ? &tSourceMaskParam : NULL), + &tTargetTileParam, + ((NULL != ptTargetMask) ? &tTargetMaskParam : NULL), + &tActualSize); + } else { + tResult = __arm_2d_issue_sub_task_copy_origin( + ptThis, + &tSourceTileParam, + &tOriginTileParam, + &tTargetTileParam, + &tActualSize); + } } else { - + + + + //! handle mirroring + do { + __arm_2d_source_side_tile_mirror_preprocess( + ptSource, + &tSourceTileParam, + chSourcePixelLenInBit, + &tActualSize, + wMode); + + if ( OP_CORE.ptOp->Info.Param.bHasSrcMask + && (NULL != ptSourceMask)) { + arm_2d_size_t tMaskActualSize = { + .iWidth = MIN(tActualSize.iWidth, + tSourceMaskParam.tValidRegion.tSize.iWidth), + .iHeight = MIN(tActualSize.iHeight, + tSourceMaskParam.tValidRegion.tSize.iHeight), + }; + __arm_2d_source_side_tile_mirror_preprocess( + ptSourceMask, + &tSourceMaskParam, + chSourceMaskPixelLenInBit, + &tMaskActualSize, + wMode); + } + } while(0); + +// /* trim source valid region */ +// tSourceTileParam.tValidRegion.tSize = tActualSize; + + if (NULL != ptSourceMask) { + tSourceMaskParam.tValidRegion.tSize.iWidth = + MIN(tSourceMaskParam.tValidRegion.tSize.iWidth, + tSourceTileParam.tValidRegion.tSize.iWidth); + tSourceMaskParam.tValidRegion.tSize.iHeight = + MIN(tSourceMaskParam.tValidRegion.tSize.iHeight, + tSourceTileParam.tValidRegion.tSize.iHeight); + } + + if (NULL != ptTargetMask) { + tTargetMaskParam.tValidRegion.tSize.iWidth = + MIN(tTargetMaskParam.tValidRegion.tSize.iWidth, + tTargetTileParam.tValidRegion.tSize.iWidth); + tTargetMaskParam.tValidRegion.tSize.iHeight = + MIN(tTargetMaskParam.tValidRegion.tSize.iHeight, + tTargetTileParam.tValidRegion.tSize.iHeight); + } + + /* load virtual resource if any */ + do { + arm_2d_err_t tErr = + __load_virtual_resource(ptSource, &tSourceTileParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptSourceMask, &tSourceMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + + tErr = __load_virtual_resource(ptTargetMask, &tTargetMaskParam); + if (tErr != ARM_2D_ERR_NONE) { + return (arm_fsm_rt_t)tErr; + } + } while(0); + if ( (OP_CORE.ptOp->Info.Param.bHasSrcMask) || (OP_CORE.ptOp->Info.Param.bHasDesMask)){ tResult = __arm_2d_issue_sub_task_copy_with_mask( @@ -786,7 +1282,7 @@ arm_fsm_rt_t __tile_clipped_pave( case ARM_2D_COLOUR_SZ_8BIT: case ARM_2D_COLOUR_SZ_16BIT: case ARM_2D_COLOUR_SZ_32BIT: - tResult = __arm_2d_big_pixel_tile_pave( ptThis, + tResult = __arm_2d_region_calculator( ptThis, &tTempSourceTile, &tTargetTile, wMode); @@ -797,7 +1293,7 @@ arm_fsm_rt_t __tile_clipped_pave( } #else if (OP_CORE.ptOp->Info.Colour.u3ColourSZ >= ARM_2D_COLOUR_SZ_8BIT) { - tResult = __arm_2d_big_pixel_tile_pave( ptThis, + tResult = __arm_2d_region_calculator( ptThis, &tTempSourceTile, NULL, //!< source mask &tTargetTile, @@ -830,7 +1326,7 @@ static arm_fsm_rt_t __tile_non_negtive_location_pave( case ARM_2D_COLOUR_SZ_8BIT: case ARM_2D_COLOUR_SZ_16BIT: case ARM_2D_COLOUR_SZ_32BIT: - tResult = __arm_2d_big_pixel_tile_pave(ptThis, ptSource, &tTile, wMode); + tResult = __arm_2d_region_calculator(ptThis, ptSource, &tTile, wMode); break; default: tResult = (arm_fsm_rt_t)ARM_2D_ERR_NOT_SUPPORT; @@ -838,7 +1334,7 @@ static arm_fsm_rt_t __tile_non_negtive_location_pave( } #else if (OP_CORE.ptOp->Info.Colour.u3ColourSZ >= ARM_2D_COLOUR_SZ_8BIT) { - tResult = __arm_2d_big_pixel_tile_pave( ptThis, + tResult = __arm_2d_region_calculator( ptThis, ptSource, NULL, //!< source mask &tTile, @@ -950,7 +1446,7 @@ arm_fsm_rt_t __arm_2d_op_frontend_region_process( arm_2d_op_core_t *ptOP) case ARM_2D_COLOUR_SZ_8BIT: case ARM_2D_COLOUR_SZ_16BIT: case ARM_2D_COLOUR_SZ_32BIT: - tResult = __arm_2d_big_pixel_tile_pave(ptThis, ptSource, &tTile, wMode); + tResult = __arm_2d_region_calculator(ptThis, ptSource, &tTile, wMode); break; default: tResult = (arm_fsm_rt_t)ARM_2D_ERR_NOT_SUPPORT; @@ -1328,9 +1824,10 @@ arm_fsm_rt_t __arm_2d_op_frontend_op_decoder(arm_2d_op_core_t *ptThis) __WEAK -/*! \brief sync up with operation - *! \retval true sync up with operation - *! \retval false operation is 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) { @@ -1393,21 +1890,20 @@ arm_fsm_rt_t __arm_2d_op_invoke(arm_2d_op_core_t *ptOP) } -/*! \brief initialise the whole arm-2d service - *! \param none - *! \return none +/*! + * \brief initialise the arm-2d core service */ - void __arm_2d_init(void) { /*! initialise arm-2d control block */ memset(&ARM_2D_CTRL, 0, sizeof(struct __arm_2d_op_control)); } -/*! \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 +/*! + * \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 */ arm_2d_tile_t *arm_2d_set_default_frame_buffer(const arm_2d_tile_t *ptFrameBuffer) { @@ -1421,17 +1917,19 @@ arm_2d_tile_t *arm_2d_set_default_frame_buffer(const arm_2d_tile_t *ptFrameBuffe return ptOldBuffer; } -/*! \brief get the default frame buffer - *! \return the address of the default frame buffer +/*! + * \brief get the default frame buffer + * \return arm_2d_tile_t* the address of the default frame buffer */ arm_2d_tile_t *arm_2d_get_default_frame_buffer(void) { return ARM_2D_CTRL.ptDefaultFrameBuffer; } -/*! \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) +/*! + * \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) */ void arm_2d_set_user_param(arm_2d_op_core_t *ptOP, uintptr_t pUserParam) { @@ -1440,9 +1938,25 @@ void arm_2d_set_user_param(arm_2d_op_core_t *ptOP, uintptr_t pUserParam) this.pUserParam = pUserParam; } -/*! \brief get the status of a specified OP - *! \param ptOP the address of the target OP (NULL means using the default OP) - *! \return the status +/*! + \brief get the status of a specified OP, + \param ptOP the address of the target OP (NULL means using the default OP) + \return arm_2d_op_status_t the operation status + */ +/* + 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); */ arm_2d_op_status_t arm_2d_get_op_status(arm_2d_op_core_t *ptOP) { @@ -1456,25 +1970,93 @@ arm_2d_op_status_t arm_2d_get_op_status(arm_2d_op_core_t *ptOP) __WEAK - /*! \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 *ptTask) { ARM_2D_UNUSED(ptTask); return arm_fsm_rt_cpl; } +/*----------------------------------------------------------------------------* + * Utilieis * + *----------------------------------------------------------------------------*/ + +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) +{ + ARM_2D_UNUSED(wMode); + + if (NULL != ptSrcMask) { + //! valid source mask tile + if (0 == ptSrcMask->bHasEnforcedColour) { + return ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptSrcMask->tColourInfo.u3ColourSZ) + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + && (ARM_2D_CHANNEL_8in32 != ptSrcMask->tColourInfo.chScheme) + #endif + ) { + return ARM_2D_ERR_INVALID_PARAM; + } + + arm_2d_cmp_t tCompare = arm_2d_tile_shape_compare(ptSrcMask, ptSource); + + /*! \note the source mask tile should be bigger than or equals to the + *! source tile + */ + if (ARM_2D_CMP_SMALLER == tCompare) { + + return ARM_2D_ERR_INVALID_PARAM; + } + } + + if (NULL != ptDesMask) { + //! valid target mask tile + if (0 == ptDesMask->bHasEnforcedColour) { + return ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptDesMask->tColourInfo.u3ColourSZ) + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + && (ARM_2D_CHANNEL_8in32 != ptDesMask->tColourInfo.chScheme) + #endif + ) { + return ARM_2D_ERR_INVALID_PARAM; + } + + /*! \note the target mask tile should be bigger than or equals to the + *! target tile in width + */ + if (ARM_2D_CMP_SMALLER == arm_2d_tile_width_compare(ptDesMask, ptTarget)) { + return ARM_2D_ERR_INVALID_PARAM; + } + + if (ARM_2D_CMP_SMALLER == arm_2d_tile_height_compare(ptDesMask, ptTarget)) { + if (1 != ptDesMask->tRegion.tSize.iHeight) { + return ARM_2D_ERR_INVALID_PARAM; + } else if (ARM_2D_CHANNEL_8in32 == ptDesMask->tColourInfo.chScheme) { + /*! does NOT support a target mask consists of 1 horizontal line + *! in the special colour 'ARM_2D_CHANNEL_8in32'. + */ + return ARM_2D_ERR_INVALID_PARAM; + } + } + + } + + return ARM_2D_ERR_NONE; +} + /*----------------------------------------------------------------------------* * Low Level IO Interfaces * @@ -1497,15 +2079,6 @@ const __arm_2d_op_info_t ARM_2D_OP_BARRIER = { }; - -#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 diff --git a/package/Arm2D/__arm_2d_draw_pattern.inc b/package/Arm2D/Library/Source/__arm_2d_draw_pattern.inc similarity index 100% rename from package/Arm2D/__arm_2d_draw_pattern.inc rename to package/Arm2D/Library/Source/__arm_2d_draw_pattern.inc diff --git a/package/Arm2D/__arm_2d_draw_pattern_helium.inc b/package/Arm2D/Library/Source/__arm_2d_draw_pattern_helium.inc similarity index 96% rename from package/Arm2D/__arm_2d_draw_pattern_helium.inc rename to package/Arm2D/Library/Source/__arm_2d_draw_pattern_helium.inc index 986181759..84e644c2c 100644 --- a/package/Arm2D/__arm_2d_draw_pattern_helium.inc +++ b/package/Arm2D/Library/Source/__arm_2d_draw_pattern_helium.inc @@ -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) diff --git a/package/Arm2D/__arm_2d_fill_colour.inc b/package/Arm2D/Library/Source/__arm_2d_fill_colour.inc similarity index 100% rename from package/Arm2D/__arm_2d_fill_colour.inc rename to package/Arm2D/Library/Source/__arm_2d_fill_colour.inc diff --git a/package/Arm2D/__arm_2d_fill_colour_helium.inc b/package/Arm2D/Library/Source/__arm_2d_fill_colour_helium.inc similarity index 97% rename from package/Arm2D/__arm_2d_fill_colour_helium.inc rename to package/Arm2D/Library/Source/__arm_2d_fill_colour_helium.inc index f8437d355..a9e0ac9a0 100644 --- a/package/Arm2D/__arm_2d_fill_colour_helium.inc +++ b/package/Arm2D/Library/Source/__arm_2d_fill_colour_helium.inc @@ -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" diff --git a/package/Arm2D/__arm_2d_meta_copy_and_fill.inc b/package/Arm2D/Library/Source/__arm_2d_meta_copy_and_fill.inc similarity index 100% rename from package/Arm2D/__arm_2d_meta_copy_and_fill.inc rename to package/Arm2D/Library/Source/__arm_2d_meta_copy_and_fill.inc diff --git a/package/Arm2D/__arm_2d_meta_copy_with_masks.inc b/package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks.inc similarity index 90% rename from package/Arm2D/__arm_2d_meta_copy_with_masks.inc rename to package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks.inc index 233429bd6..0ad73aba9 100644 --- a/package/Arm2D/__arm_2d_meta_copy_with_masks.inc +++ b/package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks.inc @@ -25,7 +25,7 @@ * $Revision: V.1.0.0 * * -------------------------------------------------------------------- */ - + #ifndef __API_MCWM_COLOUR # error You have to define __API_MCWM_COLOUR before using this c template #endif @@ -70,7 +70,7 @@ #ifndef __API_MCWM_OP_NAME # define ____MCWM_FUNC(__NAME, __COLOUR) \ __arm_2d_impl_##__COLOUR##_##__NAME -# define ___MCWM_FUNC(__NAME, __COLOUR) ____MCWM_FUNC(__NAME, __COLOUR) +# define ___MCWM_FUNC(__NAME, __COLOUR) ____MCWM_FUNC(__NAME, __COLOUR) #else # define _____MCWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ __arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME @@ -89,14 +89,14 @@ #ifndef __API_MCWM_OP_NAME # define ____MCWM_TYPE(__NAME, __COLOUR) arm_2d_##__COLOUR##_##__NAME -# define ___MCWM_TYPE(__NAME, __COLOUR) ____MCWM_TYPE(__NAME, __COLOUR) +# define ___MCWM_TYPE(__NAME, __COLOUR) ____MCWM_TYPE(__NAME, __COLOUR) #else # define _____MCWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ arm_2d_##__COLOUR##_##__OP_NAME##_##__NAME # define ____MCWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ _____MCWM_TYPE(__OP_NAME, __NAME, __COLOUR) # define ___MCWM_TYPE(__NAME, __COLOUR) \ - ____MCWM_TYPE(__API_MCWM_OP_NAME, __NAME, __COLOUR) + ____MCWM_TYPE(__API_MCWM_OP_NAME, __NAME, __COLOUR) #endif @@ -112,7 +112,7 @@ void __MCWM_FUNC(masks_fill)( __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -120,7 +120,7 @@ void __MCWM_FUNC(masks_fill)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, @@ -135,31 +135,31 @@ void __MCWM_FUNC(masks_fill)( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #endif for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - + //! reset source - __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else uint8_t *ptSourceMask = ptSourceMaskBase; #endif - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; #endif - + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #endif - + /*---------------- Height Loop Begin----------------*/ uint_fast32_t wLengthLeft = ptTargetSize->iWidth; @@ -168,44 +168,49 @@ void __MCWM_FUNC(masks_fill)( /*---------------- Width Loop Begin----------------*/ __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; #else uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; #endif - + for (int_fast16_t x = 0; x < wLength; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(ptSrcMsk++) #else - (*ptSrcMsk++) + (*ptSrcMsk++) #endif - - * + + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif + __API_MCWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); } /*---------------- Width Loop End----------------*/ wLengthLeft -= wLength; } while (wLengthLeft); - + /*---------------- Height Loop End----------------*/ ptSource += iSourceStride; ptTargetBase += iTargetStride; - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING iSourceMaskY++; - //! handle source mask + //! handle source mask if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= ptSourceSize->iHeight)) { ptSourceMask = ptSourceMaskBase; @@ -216,13 +221,13 @@ void __MCWM_FUNC(masks_fill)( #else ptSourceMask += iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMaskLineBase = ptTargetMaskBase; #else ptTargetMaskLineBase += iTargetMaskStride; #endif - + iTargetY++; if (iTargetY >= ptTargetSize->iHeight) { break; @@ -236,7 +241,7 @@ void __MCWM_FUNC(masks_fill_x_mirror)( __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -244,11 +249,11 @@ void __MCWM_FUNC(masks_fill_x_mirror)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskBase, #else @@ -258,34 +263,34 @@ void __MCWM_FUNC(masks_fill_x_mirror)( arm_2d_size_t *__RESTRICT ptTargetMaskSize) { #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #endif for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - + //! reset source __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else - uint8_t *ptSourceMask = ptSourceMaskBase; + uint8_t *ptSourceMask = ptSourceMaskBase; #endif - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; #endif - + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #endif - + /*---------------- Height Loop Begin----------------*/ uint_fast32_t wLengthLeft = ptTargetSize->iWidth; @@ -299,41 +304,46 @@ void __MCWM_FUNC(masks_fill_x_mirror)( #else uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; #endif - + ptSrc += ptSourceSize->iWidth - 1; ptSrcMsk += ptSourceSize->iWidth - 1; - + for (int_fast16_t x = 0; x < wLength; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(ptSrcMsk--) #else - (*ptSrcMsk--) + (*ptSrcMsk--) #endif - - * + + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif + __API_MCWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); } /*---------------- Width Loop End----------------*/ wLengthLeft -= wLength; } while (wLengthLeft); - + /*---------------- Height Loop End----------------*/ ptSource += iSourceStride; ptTargetBase += iTargetStride; - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING iSourceMaskY++; - //! handle source mask + //! handle source mask if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= ptSourceSize->iHeight)) { ptSourceMask = ptSourceMaskBase; @@ -344,13 +354,13 @@ void __MCWM_FUNC(masks_fill_x_mirror)( #else ptSourceMask += iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMaskLineBase = ptTargetMaskBase; #else ptTargetMaskLineBase += iTargetMaskStride; #endif - + iTargetY++; if (iTargetY >= ptTargetSize->iHeight) { break; @@ -366,7 +376,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -374,11 +384,11 @@ void __MCWM_FUNC(masks_fill_y_mirror)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskBase, #else @@ -389,37 +399,37 @@ void __MCWM_FUNC(masks_fill_y_mirror)( { assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #endif for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - + //! reset source - __API_MCWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + __API_MCWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else - uint8_t *ptSourceMask = ptSourceMaskBase; + uint8_t *ptSourceMask = ptSourceMaskBase; #endif - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; #endif - + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #endif - + /*---------------- Height Loop Begin----------------*/ uint_fast32_t wLengthLeft = ptTargetSize->iWidth; @@ -434,36 +444,40 @@ void __MCWM_FUNC(masks_fill_y_mirror)( uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; #endif for (int_fast16_t x = 0; x < wLength; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(ptSrcMsk++) #else - (*ptSrcMsk++) + (*ptSrcMsk++) #endif - - * + + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif __API_MCWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); } /*---------------- Width Loop End----------------*/ wLengthLeft -= wLength; } while (wLengthLeft); - + /*---------------- Height Loop End----------------*/ ptSource -= iSourceStride; ptTargetBase += iTargetStride; - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING iSourceMaskY++; - //! handle source mask + //! handle source mask if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= ptSourceSize->iHeight)) { ptSourceMask = ptSourceMaskBase; @@ -474,13 +488,13 @@ void __MCWM_FUNC(masks_fill_y_mirror)( #else ptSourceMask -= iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMaskLineBase = ptTargetMaskBase; #else ptTargetMaskLineBase += iTargetMaskStride; #endif - + iTargetY++; if (iTargetY >= ptTargetSize->iHeight) { break; @@ -495,7 +509,7 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -503,11 +517,11 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskBase, #else @@ -518,37 +532,37 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( { assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #endif for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - + //! reset source - __API_MCWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); + __API_MCWM_INT_TYPE *__RESTRICT ptSource + = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint32_t *ptSourceMask = ptSourceMaskBase; + uint32_t *ptSourceMask = ptSourceMaskBase; #else - uint8_t *ptSourceMask = ptSourceMaskBase; + uint8_t *ptSourceMask = ptSourceMaskBase; #endif - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; #endif - + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #endif - + /*---------------- Height Loop Begin----------------*/ uint_fast32_t wLengthLeft = ptTargetSize->iWidth; @@ -562,42 +576,46 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( #else uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; #endif - + ptSrc += ptSourceSize->iWidth - 1; ptSrcMsk += ptSourceSize->iWidth - 1; - - + + for (int_fast16_t x = 0; x < wLength; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(ptSrcMsk--) #else - (*ptSrcMsk--) + (*ptSrcMsk--) #endif - - * + + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif __API_MCWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); } /*---------------- Width Loop End----------------*/ wLengthLeft -= wLength; } while (wLengthLeft); - + /*---------------- Height Loop End----------------*/ ptSource -= iSourceStride; ptTargetBase += iTargetStride; - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING iSourceMaskY++; - //! handle source mask + //! handle source mask if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= ptSourceSize->iHeight)) { ptSourceMask = ptSourceMaskBase; @@ -608,13 +626,13 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( #else ptSourceMask -= iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMaskLineBase = ptTargetMaskBase; #else ptTargetMaskLineBase += iTargetMaskStride; #endif - + iTargetY++; if (iTargetY >= ptTargetSize->iHeight) { break; @@ -630,7 +648,7 @@ void __MCWM_FUNC(masks_fill_mirror)( __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -638,11 +656,11 @@ void __MCWM_FUNC(masks_fill_mirror)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskBase, #else @@ -685,10 +703,10 @@ void __MCWM_FUNC(masks_fill_mirror)( * Copy with Mirroring (both masks) * *----------------------------------------------------------------------------*/ __WEAK -void __MCWM_FUNC(masks_copy)( +void __MCWM_FUNC(masks_copy)( __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t * __RESTRICT ptSourceMaskBase, #else @@ -696,7 +714,7 @@ void __MCWM_FUNC(masks_copy)( #endif int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - + __API_MCWM_INT_TYPE * __RESTRICT pTargetBase, int16_t iTargetStride, @@ -727,37 +745,40 @@ void __MCWM_FUNC(masks_copy)( #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; -#endif - - for ( int_fast16_t y = 0; - y < iHeight; +#endif + + for ( int_fast16_t y = 0; + y < iHeight; y++) { - + for (int_fast16_t x = 0; x < iWidth; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(ptSourceMask++) #else - (*ptSourceMask++) + (*ptSourceMask++) #endif - * + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif __API_MCWM_PIXEL_BLENDING( pSourceBase++, pTargetBase++, hwOpacity); - + } pSourceBase += (iSourceStride - iWidth); pTargetBase += (iTargetStride - iWidth); - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask + //! handle source mask iSourceMaskY++; if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= iHeight)) { @@ -769,7 +790,7 @@ void __MCWM_FUNC(masks_copy)( #else ptSourceMask += (iSourceMaskStride - iWidth); #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMask = ptTargetMaskBase; #else @@ -780,7 +801,7 @@ void __MCWM_FUNC(masks_copy)( __WEAK -void __MCWM_FUNC(masks_copy_x_mirror)( +void __MCWM_FUNC(masks_copy_x_mirror)( __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, @@ -820,12 +841,12 @@ void __MCWM_FUNC(masks_copy_x_mirror)( #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; -#endif +#endif - for ( int_fast16_t y = 0; - y < iHeight; + for ( int_fast16_t y = 0; + y < iHeight; y++) { - + __API_MCWM_INT_TYPE *ptTargetCur = pTargetBase; __API_MCWM_INT_TYPE *ptSourceCur = pSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -833,35 +854,40 @@ void __MCWM_FUNC(masks_copy_x_mirror)( #else uint8_t *pchSourceMaskCur = ptSourceMask; #endif - + ptSourceCur += ptCopySize->iWidth - 1; //! \note do not use ptSourceMaskSize->iWidth - pchSourceMaskCur += ptCopySize->iWidth - 1; - + pchSourceMaskCur += ptCopySize->iWidth - 1; + for (int_fast16_t x = 0; x < iWidth; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(pchSourceMaskCur--) #else - (*pchSourceMaskCur--) + (*pchSourceMaskCur--) #endif - * + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif + __API_MCWM_PIXEL_BLENDING( ptSourceCur--, ptTargetCur++, hwOpacity); - + } pSourceBase += iSourceStride; pTargetBase += iTargetStride; - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask + //! handle source mask iSourceMaskY++; if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= iHeight)) { @@ -873,7 +899,7 @@ void __MCWM_FUNC(masks_copy_x_mirror)( #else ptSourceMask += iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMask = ptTargetMaskBase; #else @@ -885,7 +911,7 @@ void __MCWM_FUNC(masks_copy_x_mirror)( __WEAK -void __MCWM_FUNC(masks_copy_y_mirror)( +void __MCWM_FUNC(masks_copy_y_mirror)( __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, @@ -915,10 +941,10 @@ void __MCWM_FUNC(masks_copy_y_mirror)( //uint16_t hwRatioCompl = 256 - chRatio; pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); - + assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else @@ -932,45 +958,48 @@ void __MCWM_FUNC(masks_copy_y_mirror)( #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; -#endif +#endif - for ( int_fast16_t y = 0; - y < iHeight; + for ( int_fast16_t y = 0; + y < iHeight; y++) { - + __API_MCWM_INT_TYPE *ptSourceCur = pSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *pchSourceMaskCur = ptSourceMask; #else uint8_t *pchSourceMaskCur = ptSourceMask; #endif - + for (int_fast16_t x = 0; x < iWidth; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(pchSourceMaskCur++) #else - (*pchSourceMaskCur++) + (*pchSourceMaskCur++) #endif - * + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); - + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif __API_MCWM_PIXEL_BLENDING( ptSourceCur++, pTargetBase++, hwOpacity); - + } pSourceBase -= iSourceStride; pTargetBase += (iTargetStride - iWidth); - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask + //! handle source mask iSourceMaskY++; if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= iHeight)) { @@ -982,7 +1011,7 @@ void __MCWM_FUNC(masks_copy_y_mirror)( #else ptSourceMask -= iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMask = ptTargetMaskBase; #else @@ -994,7 +1023,7 @@ void __MCWM_FUNC(masks_copy_y_mirror)( __WEAK -void __MCWM_FUNC(masks_copy_xy_mirror)( +void __MCWM_FUNC(masks_copy_xy_mirror)( __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, @@ -1024,11 +1053,11 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( //uint16_t hwRatioCompl = 256 - chRatio; pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); - + assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); - - + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else @@ -1043,49 +1072,53 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING int_fast16_t iSourceMaskY = 0; -#endif +#endif - for ( int_fast16_t y = 0; - y < iHeight; + for ( int_fast16_t y = 0; + y < iHeight; y++) { - + __API_MCWM_INT_TYPE *ptSourceCur = pSourceBase; - + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *pchSourceMaskCur = ptSourceMask; #else uint8_t *pchSourceMaskCur = ptSourceMask; #endif - + ptSourceCur += ptCopySize->iWidth - 1; //! \note do not use ptSourceMaskSize->iWidth - pchSourceMaskCur += ptCopySize->iWidth - 1; - + pchSourceMaskCur += ptCopySize->iWidth - 1; + for (int_fast16_t x = 0; x < iWidth; x++) { - uint16_t hwOpacity = + uint16_t hwOpacity = 256 - ( #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE *(uint8_t *)(pchSourceMaskCur--) #else - (*pchSourceMaskCur--) + (*pchSourceMaskCur--) #endif - * + * #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE *(uint8_t *)(ptTargetMask++) #else - (*ptTargetMask++) + (*ptTargetMask++) #endif - + >> 8); + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwOpacity -= (hwOpacity == 2) * 2; + #endif + __API_MCWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity); - + } pSourceBase -= iSourceStride; pTargetBase += (iTargetStride - iWidth); - + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask + //! handle source mask iSourceMaskY++; if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) || (iSourceMaskY >= iHeight)) { @@ -1097,7 +1130,7 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( #else ptSourceMask -= iSourceMaskStride; #endif - + #if __API_MCWM_CFG_1_HORIZONTAL_LINE ptTargetMask = ptTargetMaskBase; #else @@ -1108,7 +1141,7 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( } __WEAK -void __MCWM_FUNC(masks_copy_mirror)( +void __MCWM_FUNC(masks_copy_mirror)( __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, @@ -1139,7 +1172,7 @@ void __MCWM_FUNC(masks_copy_mirror)( __MCWM_FUNC(masks_copy_x_mirror)(pSourceBase, iSourceStride, ptSourceMaskBase, iSourceMaskStride, ptSourceMaskSize, - pTargetBase, iTargetStride, + pTargetBase, iTargetStride, ptTargetMaskBase, iTargetMaskStride, ptTargetMaskSize, ptCopySize); @@ -1148,7 +1181,7 @@ void __MCWM_FUNC(masks_copy_mirror)( __MCWM_FUNC(masks_copy_y_mirror)(pSourceBase, iSourceStride, ptSourceMaskBase, iSourceMaskStride, ptSourceMaskSize, - pTargetBase, iTargetStride, + pTargetBase, iTargetStride, ptTargetMaskBase, iTargetMaskStride, ptTargetMaskSize, ptCopySize); @@ -1157,7 +1190,7 @@ void __MCWM_FUNC(masks_copy_mirror)( __MCWM_FUNC(masks_copy_xy_mirror)(pSourceBase, iSourceStride, ptSourceMaskBase, iSourceMaskStride, ptSourceMaskSize, - pTargetBase, iTargetStride, + pTargetBase, iTargetStride, ptTargetMaskBase, iTargetMaskStride, ptTargetMaskSize, ptCopySize); @@ -1169,19 +1202,19 @@ void __MCWM_FUNC(masks_copy_mirror)( } -#undef masks_fill -#undef masks_fill_x_mirror -#undef masks_fill_y_mirror -#undef masks_fill_xy_mirror -#undef masks_fill_mirror - +#undef masks_fill +#undef masks_fill_x_mirror +#undef masks_fill_y_mirror +#undef masks_fill_xy_mirror +#undef masks_fill_mirror + + +#undef masks_copy +#undef masks_copy_x_mirror +#undef masks_copy_y_mirror +#undef masks_copy_xy_mirror +#undef masks_copy_mirror -#undef masks_copy -#undef masks_copy_x_mirror -#undef masks_copy_y_mirror -#undef masks_copy_xy_mirror -#undef masks_copy_mirror - #undef __API_MCWM_COPY_LIKE_OP_NAME #undef __API_MCWM_OP_NAME diff --git a/package/Arm2D/__arm_2d_meta_copy_with_masks_helium.inc b/package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks_helium.inc similarity index 51% rename from package/Arm2D/__arm_2d_meta_copy_with_masks_helium.inc rename to package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks_helium.inc index 68da24c05..a93c179d7 100644 --- a/package/Arm2D/__arm_2d_meta_copy_with_masks_helium.inc +++ b/package/Arm2D/Library/Source/__arm_2d_meta_copy_with_masks_helium.inc @@ -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_meta_copy_with_masks_helium.inc * Description: c code template for copy and fill like operations * - * $Date: 06. Oct 2021 - * $Revision: V.1.0.0 + * $Date: 12. July 2022 + * $Revision: v1.0.1 * * -------------------------------------------------------------------- */ @@ -30,10 +30,44 @@ # error You have to define __API_MCWM_COLOUR before using this c template #endif -#if __API_MCWM_COLOUR != rgb565 +#include "__arm_2d_math_helium.h" + + +#if CHECKPIXTYP(__API_MCWM_COLOUR, rgb565) +#define __API_MCWM_PIXEL_BIT_NUM 16 +#define __API_MCWM_PIXEL_VECLOAD vld1q +#define __API_MCWM_PIXEL_GATHVECLOAD vldrhq_gather_shifted_offset +#define __API_MCWM_PIXEL_PVECSTORE vst1q_p +#define __API_MCWM_PIXEL_BLENDING __arm_2d_rgb565_blending_opacity_single_vec + +#elif CHECKPIXTYP(__API_MCWM_COLOUR, gray8) +#define __API_MCWM_PIXEL_BIT_NUM 16 /* widening involved */ +#define __API_MCWM_PIXEL_VECLOAD vldrbq_u16 +#define __API_MCWM_PIXEL_GATHVECLOAD vldrbq_gather_offset_u16 +#define __API_MCWM_PIXEL_PVECSTORE vstrbq_p_u16 +#define __API_MCWM_PIXEL_BLENDING __arm_2d_gray8_blending_opacity_single_vec + +#elif CHECKPIXTYP(__API_MCWM_COLOUR, cccn888) +#if !ENABLE_ALT_MASK_FILL +#define __API_MCWM_PIXEL_BIT_NUM 32 +#define __API_MCWM_PIXEL_VECLOAD vld1q +#define __API_MCWM_PIXEL_GATHVECLOAD vldrwq_gather_shifted_offset +#define __API_MCWM_PIXEL_PVECSTORE vst1q_p +#define __API_MCWM_PIXEL_BLENDING __arm_2d_cccn888_blending_opacity_single_vec +#else +#define __API_MCWM_PIXEL_BIT_NUM 16 /* widening involved */ +#define __API_MCWM_PIXEL_VECLOAD vldrbq_u16 +#define __API_MCWM_PIXEL_GATHVECLOAD vldrbq_gather_offset_u16 +#define __API_MCWM_PIXEL_PVECSTORE vstrbq_p_u16 +#define __API_MCWM_PIXEL_BLENDING __arm_2d_gray8_blending_opacity_single_vec +#endif + +#else #error Unknown colour #endif +#define __API_MCWM_PIXEL_VECTYP ARM_PIX_VECTYP(__API_MCWM_PIXEL_BIT_NUM) +#define __API_MCWM_VEC_INCR ARM_PIX_VECELT(__API_MCWM_PIXEL_BIT_NUM) /*! disable this feature by default */ #ifndef __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING @@ -65,11 +99,11 @@ #ifndef __API_MCWM_OP_NAME # define ____MCWM_FUNC(__NAME, __COLOUR) \ - __arm_2d_impl_##__COLOUR##_##__NAME + __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME) # define ___MCWM_FUNC(__NAME, __COLOUR) ____MCWM_FUNC(__NAME, __COLOUR) #else # define _____MCWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ - __arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME + __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME) # define ____MCWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ _____MCWM_FUNC(__OP_NAME, __NAME, __COLOUR) # define ___MCWM_FUNC(__NAME, __COLOUR) \ @@ -104,8 +138,9 @@ *----------------------------------------------------------------------------*/ +__OVERRIDE_WEAK void __MCWM_FUNC(masks_fill)( - uint16_t * __RESTRICT ptSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, @@ -117,7 +152,7 @@ void __MCWM_FUNC(masks_fill)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t *__RESTRICT ptTargetBase, + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE @@ -128,7 +163,7 @@ void __MCWM_FUNC(masks_fill)( int16_t iTargetMaskStride, arm_2d_size_t *__RESTRICT ptTargetMaskSize) { - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; @@ -139,7 +174,7 @@ void __MCWM_FUNC(masks_fill)( for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { //! reset source - uint16_t *__RESTRICT ptSource = ptSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else @@ -152,7 +187,7 @@ void __MCWM_FUNC(masks_fill)( for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - uint16_t *__RESTRICT ptTarget = ptTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else @@ -166,13 +201,14 @@ void __MCWM_FUNC(masks_fill)( uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); /*---------------- Width Loop Begin----------------*/ - uint16_t *__RESTRICT ptSrc = ptSource; - uint16_t *__RESTRICT ptTargetCur = ptTarget; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -188,47 +224,57 @@ void __MCWM_FUNC(masks_fill)( int32_t blkCnt = wLength; do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = vld1q(ptSrc); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = __API_MCWM_PIXEL_VECLOAD(ptSrc); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptSrcMsk, vIncStride4Offs); #else - uint16x8_t vecSrcMsk = vldrbq_u16(ptSrcMsk); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, + __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16(ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, + __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); - vecTarget = __arm_2d_rgb565_blending_opacity_single_vec( + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __API_MCWM_PIXEL_BLENDING( vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - ptSrcMsk += 8; + ptSrcMsk += __API_MCWM_VEC_INCR; #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; - ptSrc += 8; + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -274,9 +320,17 @@ void __MCWM_FUNC(masks_fill)( +#if CHECKPIXTYP(__API_MCWM_COLOUR, cccn888) && ENABLE_ALT_MASK_FILL + +/* Alternative 32-bit fill with mask */ +/* Operates on individual cccn888 pixel channel */ +/* requires slower scat/gather for channel extraction */ +/* but allows faster processing with vector of 8 elements */ +/* slightly faster than version above but deviates from 8 & 16-bit template versions */ + __OVERRIDE_WEAK -void __MCWM_FUNC(masks_fill_x_mirror)( - uint16_t * __RESTRICT ptSourceBase, +void __MCWM_FUNC(masks_fill_alt)( + __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, @@ -288,10 +342,9 @@ void __MCWM_FUNC(masks_fill_x_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t *__RESTRICT ptTargetBase, + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, - #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskBase, #else @@ -300,8 +353,8 @@ void __MCWM_FUNC(masks_fill_x_mirror)( int16_t iTargetMaskStride, arm_2d_size_t *__RESTRICT ptTargetMaskSize) { - uint16x8_t v256 = vdupq_n_u16(256); - uint16_t srcWidth = ptSourceSize->iWidth; + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else @@ -311,7 +364,7 @@ void __MCWM_FUNC(masks_fill_x_mirror)( for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { //! reset source - uint16_t *__RESTRICT ptSource = ptSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; #else @@ -323,7 +376,330 @@ void __MCWM_FUNC(masks_fill_x_mirror)( #endif for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - uint16_t *__RESTRICT ptTarget = ptTargetBase; + + __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #else + uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; + #endif + + /*---------------- Height Loop Begin----------------*/ + uint_fast32_t wLengthLeft = ptTargetSize->iWidth; + + do { + uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); + /*---------------- Width Loop Begin----------------*/ + + + /* + * chan 0 (scat / gath with 8x16 elements ) + */ + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; + + uint32_t curIncStride4Idx = 0; + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; + #else + uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; + #endif + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + uint32_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #else + uint8_t *__RESTRICT ptTargetMaskCur = ptTargetMask; + #endif + int32_t blkCnt = wLength; + + do { + __API_MCWM_PIXEL_VECTYP vecTarget = vldrbq_gather_offset_u16((uint8_t*)ptTargetCur, vIncStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSource = vldrbq_gather_offset_u16((uint8_t*)ptSrc, vIncStride4Offs); + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + __API_MCWM_PIXEL_VECTYP vecSrcMsk = vldrbq_gather_offset_u16( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + __API_MCWM_PIXEL_VECTYP vecTargetMask = vldrbq_gather_offset_u16( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __arm_2d_gray8_blending_opacity_single_vec( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + vstrbq_scatter_offset_p_u16((uint8_t*)ptTargetCur, vIncStride4Offs, + vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + ptSrcMsk += __API_MCWM_VEC_INCR; + #endif + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + ptTargetMaskCur += __API_MCWM_VEC_INCR; + #endif + + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; + + blkCnt -= __API_MCWM_VEC_INCR; + } + while (blkCnt > 0); + + + /* + * chan 1 (scat / gath with 8x16 elements ) + */ + ptSrc = ptSource; + ptTargetCur = ptTarget; + + curIncStride4Idx = 0; + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + ptSrcMsk = ptSourceMask; + #else + ptSrcMsk = ptSourceMask; + #endif + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + ptTargetMaskCur = ptTargetMask; + #else + ptTargetMaskCur = ptTargetMask; + #endif + blkCnt = wLength; + + do { + __API_MCWM_PIXEL_VECTYP vecTarget = vldrbq_gather_offset_u16(((uint8_t*)ptTargetCur)+1, vIncStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSource = vldrbq_gather_offset_u16(((uint8_t*)ptSrc)+1, vIncStride4Offs); + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + __API_MCWM_PIXEL_VECTYP vecSrcMsk = vldrbq_gather_offset_u16( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + __API_MCWM_PIXEL_VECTYP vecTargetMask = vldrbq_gather_offset_u16( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __arm_2d_gray8_blending_opacity_single_vec( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + vstrbq_scatter_offset_p_u16(((uint8_t*)ptTargetCur)+1, vIncStride4Offs, + vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + ptSrcMsk += __API_MCWM_VEC_INCR; + #endif + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + ptTargetMaskCur += __API_MCWM_VEC_INCR; + #endif + + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; + + blkCnt -= __API_MCWM_VEC_INCR; + } + while (blkCnt > 0); + + + /* + * chan 2 (scat / gath with 8x16 elements ) + */ + ptSrc = ptSource; + ptTargetCur = ptTarget; + + curIncStride4Idx = 0; + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + ptSrcMsk = ptSourceMask; + #else + ptSrcMsk = ptSourceMask; + #endif + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + ptTargetMaskCur = ptTargetMask; + #else + ptTargetMaskCur = ptTargetMask; + #endif + blkCnt = wLength; + + do { + __API_MCWM_PIXEL_VECTYP vecTarget = vldrbq_gather_offset_u16(((uint8_t*)ptTargetCur)+2, vIncStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSource = vldrbq_gather_offset_u16(((uint8_t*)ptSrc)+2, vIncStride4Offs); + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + __API_MCWM_PIXEL_VECTYP vecSrcMsk = vldrbq_gather_offset_u16( + (uint8_t const *)ptSrcMsk, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); + #endif + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + __API_MCWM_PIXEL_VECTYP vecTargetMask = vldrbq_gather_offset_u16( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + #else + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); + #endif + + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __arm_2d_gray8_blending_opacity_single_vec( + vecTarget, vecSource, vecHwOpacity); + /* tail predication */ + vstrbq_scatter_offset_p_u16(((uint8_t*)ptTargetCur)+2, vIncStride4Offs, + vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); + + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + ptSrcMsk += __API_MCWM_VEC_INCR; + #endif + + #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + ptTargetMaskCur += __API_MCWM_VEC_INCR; + #endif + + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; + + blkCnt -= __API_MCWM_VEC_INCR; + } + while (blkCnt > 0); + + + ptTarget += wLength; + ptTargetMask += wLength; + + /*---------------- Width Loop End----------------*/ + wLengthLeft -= wLength; + } while (wLengthLeft); + + /*---------------- Height Loop End----------------*/ + ptSource += iSourceStride; + ptTargetBase += iTargetStride; + + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING + iSourceMaskY++; + //! handle source mask + if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) + || (iSourceMaskY >= ptSourceSize->iHeight)) { + ptSourceMask = ptSourceMaskBase; + iSourceMaskY = 0; + } else { + ptSourceMask += iSourceMaskStride; + } + #else + ptSourceMask += iSourceMaskStride; + #endif + + #if __API_MCWM_CFG_1_HORIZONTAL_LINE + ptTargetMaskLineBase = ptTargetMaskBase; + #else + ptTargetMaskLineBase += iTargetMaskStride; + #endif + + iTargetY++; + if (iTargetY >= ptTargetSize->iHeight) { + break; + } + } + } +} + +#endif + + + +__OVERRIDE_WEAK +void __MCWM_FUNC(masks_fill_x_mirror)( + __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t *__RESTRICT ptSourceSize, + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + uint32_t * __RESTRICT ptSourceMaskBase, + #else + uint8_t * __RESTRICT ptSourceMaskBase, + #endif + int16_t iSourceMaskStride, + arm_2d_size_t *__RESTRICT ptSourceMaskSize, + + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t *__RESTRICT ptTargetSize, + + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + uint32_t *__RESTRICT ptTargetMaskBase, + #else + uint8_t *__RESTRICT ptTargetMaskBase, + #endif + int16_t iTargetMaskStride, + arm_2d_size_t *__RESTRICT ptTargetMaskSize) +{ + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); + uint16_t srcWidth = ptSourceSize->iWidth; +#if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE + uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#else + uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; +#endif + + for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { + + //! reset source + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; + #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + uint32_t *ptSourceMask = ptSourceMaskBase; + #else + uint8_t *ptSourceMask = ptSourceMaskBase; + #endif + + #if __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING + int_fast16_t iSourceMaskY = 0; + #endif + + for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { + __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; @@ -338,12 +714,13 @@ void __MCWM_FUNC(masks_fill_x_mirror)( uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); /*---------------- Width Loop Begin----------------*/ - uint16_t *__RESTRICT ptSrc = ptSource; - uint16_t *__RESTRICT ptTargetCur = ptTarget; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -361,52 +738,64 @@ void __MCWM_FUNC(masks_fill_x_mirror)( int32_t blkCnt = wLength; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t curDecrStride4Idx = 4*(srcWidth - 1); - uint16x8_t vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - uint16x8_t vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + __API_MCWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = - vldrhq_gather_shifted_offset(ptSrc, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = + __API_MCWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16((uint8_t *)ptSrcMsk, vDecrStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM) + ((uint8_t *)ptSrcMsk, vDecrStride4Offs); #else - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16(ptSrcMsk, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM) + (ptSrcMsk, vDecrStride1Offs); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16((uint8_t *)ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); vecTarget = - __arm_2d_rgb565_blending_opacity_single_vec(vecTarget, vecSource, + __API_MCWM_PIXEL_BLENDING(vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #else - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; + ptTargetCur += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -453,7 +842,7 @@ void __MCWM_FUNC(masks_fill_x_mirror)( __OVERRIDE_WEAK void __MCWM_FUNC(masks_fill_y_mirror)( - uint16_t * __RESTRICT ptSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, @@ -465,7 +854,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t *__RESTRICT ptTargetBase, + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, @@ -477,7 +866,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( int16_t iTargetMaskStride, arm_2d_size_t *__RESTRICT ptTargetMaskSize) { - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); @@ -491,7 +880,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { //! reset source - uint16_t *__RESTRICT ptSource + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -506,7 +895,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - uint16_t *__RESTRICT ptTarget = ptTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; #else @@ -520,13 +909,14 @@ void __MCWM_FUNC(masks_fill_y_mirror)( uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); /*---------------- Width Loop Begin----------------*/ - uint16_t *__RESTRICT ptSrc = ptSource; - uint16_t *__RESTRICT ptTargetCur = ptTarget; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -542,47 +932,53 @@ void __MCWM_FUNC(masks_fill_y_mirror)( int32_t blkCnt = wLength; do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = vld1q(ptSrc); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = __API_MCWM_PIXEL_VECLOAD(ptSrc); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptSrcMsk, vIncStride4Offs); #else - uint16x8_t vecSrcMsk = vldrbq_u16(ptSrcMsk); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( - (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( + (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16(ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); - vecTarget = __arm_2d_rgb565_blending_opacity_single_vec( + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __API_MCWM_PIXEL_BLENDING( vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - ptSrcMsk += 8; + ptSrcMsk += __API_MCWM_VEC_INCR; #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; - ptSrc += 8; + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -629,7 +1025,7 @@ void __MCWM_FUNC(masks_fill_y_mirror)( __OVERRIDE_WEAK void __MCWM_FUNC(masks_fill_xy_mirror)( - uint16_t * __RESTRICT ptSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT ptSourceBase, int16_t iSourceStride, arm_2d_size_t *__RESTRICT ptSourceSize, @@ -641,7 +1037,7 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t *__RESTRICT ptTargetBase, + __API_MCWM_INT_TYPE *__RESTRICT ptTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptTargetSize, @@ -656,8 +1052,8 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); - uint16x8_t v256 = vdupq_n_u16(256); - uint16_t srcWidth = ptSourceSize->iWidth; + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); + __API_MCWM_INT_TYPE srcWidth = ptSourceSize->iWidth; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; #else @@ -667,7 +1063,7 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { //! reset source - uint16_t *__RESTRICT ptSource + __API_MCWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -681,7 +1077,7 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( #endif for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - uint16_t *__RESTRICT ptTarget = ptTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; @@ -696,12 +1092,13 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); /*---------------- Width Loop Begin----------------*/ - uint16_t *__RESTRICT ptSrc = ptSource; - uint16_t *__RESTRICT ptTargetCur = ptTarget; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = ptSource; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = ptTarget; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -719,52 +1116,62 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( int32_t blkCnt = wLength; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t curDecrStride4Idx = 4*(srcWidth - 1); - uint16x8_t vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - uint16x8_t vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + __API_MCWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = - vldrhq_gather_shifted_offset(ptSrc, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = + __API_MCWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16((uint8_t *)ptSrcMsk, vDecrStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); + #else - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16(ptSrcMsk, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16((uint8_t *)ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif vecTarget = - __arm_2d_rgb565_blending_opacity_single_vec(vecTarget, vecSource, + __API_MCWM_PIXEL_BLENDING(vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #else - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; + ptTargetCur += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -817,7 +1224,7 @@ void __MCWM_FUNC(masks_fill_xy_mirror)( __OVERRIDE_WEAK void __MCWM_FUNC(masks_copy)( - uint16_t * __RESTRICT pSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -828,7 +1235,7 @@ void __MCWM_FUNC(masks_copy)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT pTargetBase, + __API_MCWM_INT_TYPE * __RESTRICT pTargetBase, int16_t iTargetStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE @@ -843,7 +1250,7 @@ void __MCWM_FUNC(masks_copy)( { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; @@ -863,13 +1270,13 @@ void __MCWM_FUNC(masks_copy)( for ( int_fast16_t y = 0; y < iHeight; y++) { - uint16_t *__RESTRICT ptSrc = pSourceBase; - uint16_t *__RESTRICT ptTargetCur = pTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -885,46 +1292,51 @@ void __MCWM_FUNC(masks_copy)( int32_t blkCnt = iWidth; do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = vld1q(ptSrc); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = __API_MCWM_PIXEL_VECLOAD(ptSrc); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptSrcMsk, vIncStride4Offs); #else - uint16x8_t vecSrcMsk = vldrbq_u16(ptSrcMsk); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16(ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); - vecTarget = __arm_2d_rgb565_blending_opacity_single_vec( + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __API_MCWM_PIXEL_BLENDING( vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - ptSrcMsk += 8; + ptSrcMsk += __API_MCWM_VEC_INCR; #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; - ptSrc += 8; - blkCnt -= 8; + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -954,10 +1366,9 @@ void __MCWM_FUNC(masks_copy)( } - __OVERRIDE_WEAK void __MCWM_FUNC(masks_copy_x_mirror)( - uint16_t * __RESTRICT pSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -968,7 +1379,7 @@ void __MCWM_FUNC(masks_copy_x_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT pTargetBase, + __API_MCWM_INT_TYPE * __RESTRICT pTargetBase, int16_t iTargetStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE @@ -983,7 +1394,7 @@ void __MCWM_FUNC(masks_copy_x_mirror)( { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t *ptSourceMask = ptSourceMaskBase; @@ -1004,12 +1415,12 @@ void __MCWM_FUNC(masks_copy_x_mirror)( y < iHeight; y++) { - uint16_t *__RESTRICT ptSrc = pSourceBase; - uint16_t *__RESTRICT ptTargetCur = pTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -1027,52 +1438,61 @@ void __MCWM_FUNC(masks_copy_x_mirror)( int32_t blkCnt = iWidth; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t curDecrStride4Idx = 4*(iWidth - 1); - uint16x8_t vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - uint16x8_t vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + __API_MCWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = - vldrhq_gather_shifted_offset(ptSrc, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = + __API_MCWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16((uint8_t *)ptSrcMsk, vDecrStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); #else - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16(ptSrcMsk, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16((uint8_t *)ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); + #endif + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); vecTarget = - __arm_2d_rgb565_blending_opacity_single_vec(vecTarget, vecSource, + __API_MCWM_PIXEL_BLENDING(vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #else - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; + ptTargetCur += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -1103,9 +1523,10 @@ void __MCWM_FUNC(masks_copy_x_mirror)( } } + __OVERRIDE_WEAK void __MCWM_FUNC(masks_copy_y_mirror)( - uint16_t * __RESTRICT pSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -1116,7 +1537,7 @@ void __MCWM_FUNC(masks_copy_y_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT pTargetBase, + __API_MCWM_INT_TYPE * __RESTRICT pTargetBase, int16_t iTargetStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE @@ -1131,7 +1552,7 @@ void __MCWM_FUNC(masks_copy_y_mirror)( { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); @@ -1156,13 +1577,14 @@ void __MCWM_FUNC(masks_copy_y_mirror)( for ( int_fast16_t y = 0; y < iHeight; y++) { - uint16_t *__RESTRICT ptSrc = pSourceBase; - uint16_t *__RESTRICT ptTargetCur = pTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -1178,47 +1600,57 @@ void __MCWM_FUNC(masks_copy_y_mirror)( int32_t blkCnt = iWidth; do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = vld1q(ptSrc); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = __API_MCWM_PIXEL_VECLOAD(ptSrc); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptSrcMsk, vIncStride4Offs); #else - uint16x8_t vecSrcMsk = vldrbq_u16(ptSrcMsk); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16(ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)(ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); - vecTarget = __arm_2d_rgb565_blending_opacity_single_vec( + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif + + vecTarget = __API_MCWM_PIXEL_BLENDING( vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, + ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE || \ __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - ptSrcMsk += 8; + ptSrcMsk += __API_MCWM_VEC_INCR; #endif #if !__API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; - ptSrc += 8; + ptTargetCur += __API_MCWM_VEC_INCR; + ptSrc += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -1251,7 +1683,7 @@ void __MCWM_FUNC(masks_copy_y_mirror)( __OVERRIDE_WEAK void __MCWM_FUNC(masks_copy_xy_mirror)( - uint16_t * __RESTRICT pSourceBase, + __API_MCWM_INT_TYPE * __RESTRICT pSourceBase, int16_t iSourceStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -1262,7 +1694,7 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( int16_t iSourceMaskStride, arm_2d_size_t *__RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT pTargetBase, + __API_MCWM_INT_TYPE * __RESTRICT pTargetBase, int16_t iTargetStride, #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE @@ -1277,7 +1709,7 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint16x8_t v256 = vdupq_n_u16(256); + __API_MCWM_PIXEL_VECTYP v256 = ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(256); pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); @@ -1304,12 +1736,13 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( for ( int_fast16_t y = 0; y < iHeight; y++) { - uint16_t *__RESTRICT ptSrc = pSourceBase; - uint16_t *__RESTRICT ptTargetCur = pTargetBase; + __API_MCWM_INT_TYPE *__RESTRICT ptSrc = pSourceBase; + __API_MCWM_INT_TYPE *__RESTRICT ptTargetCur = pTargetBase; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE uint32_t curIncStride4Idx = 0; - uint16x8_t vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vIncStride4Offs = + ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE @@ -1327,52 +1760,61 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( int32_t blkCnt = iWidth; #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE uint32_t curDecrStride4Idx = 4*(iWidth - 1); - uint16x8_t vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + __API_MCWM_PIXEL_VECTYP vDecrStride4Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - uint16x8_t vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + __API_MCWM_PIXEL_VECTYP vDecrStride1Offs = + ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); do { - uint16x8_t vecTarget = vld1q(ptTargetCur); - uint16x8_t vecSource = - vldrhq_gather_shifted_offset(ptSrc, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecTarget = __API_MCWM_PIXEL_VECLOAD(ptTargetCur); + __API_MCWM_PIXEL_VECTYP vecSource = + __API_MCWM_PIXEL_GATHVECLOAD(ptSrc, vDecrStride1Offs); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16((uint8_t *)ptSrcMsk, vDecrStride4Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptSrcMsk, vDecrStride4Offs); #else - uint16x8_t vecSrcMsk = - vldrbq_gather_offset_u16(ptSrcMsk, vDecrStride1Offs); + __API_MCWM_PIXEL_VECTYP vecSrcMsk = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)(ptSrcMsk, vDecrStride1Offs); #endif #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - uint16x8_t vecTargetMask = vldrbq_gather_offset_u16( + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_gather_offset_u, __API_MCWM_PIXEL_BIT_NUM)( (uint8_t const *)ptTargetMaskCur, vIncStride4Offs); #else - uint16x8_t vecTargetMask = vldrbq_u16((uint8_t *)ptTargetMaskCur); + __API_MCWM_PIXEL_VECTYP vecTargetMask = + ARM_CONNECT2(vldrbq_u, __API_MCWM_PIXEL_BIT_NUM)((uint8_t *)ptTargetMaskCur); #endif - uint16x8_t vecHwOpacity = - vsubq_u16(v256, (vecSrcMsk * vecTargetMask) >> 8); + __API_MCWM_PIXEL_VECTYP vecHwOpacity = + vsubq(v256, (vecSrcMsk * vecTargetMask) >> 8); + + #if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + vecHwOpacity = vpselq(ARM_CONNECT2(vdupq_n_u, __API_MCWM_PIXEL_BIT_NUM)(0),vecHwOpacity, + ARM_CONNECT2(vcmpeqq_n_u, __API_MCWM_PIXEL_BIT_NUM)(vecHwOpacity, 2)); + #endif vecTarget = - __arm_2d_rgb565_blending_opacity_single_vec(vecTarget, vecSource, + __API_MCWM_PIXEL_BLENDING(vecTarget, vecSource, vecHwOpacity); /* tail predication */ - vst1q_p_u16(ptTargetCur, vecTarget, vctp16q(blkCnt)); + __API_MCWM_PIXEL_PVECSTORE(ptTargetCur, vecTarget, ARM_CONNECT3(vctp, __API_MCWM_PIXEL_BIT_NUM, q)(blkCnt)); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE - vDecrStride4Offs = vddupq_wb_u16(&curDecrStride4Idx, 4); + vDecrStride4Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride4Idx, 4); #endif - vDecrStride1Offs = vddupq_wb_u16(&curDecrStride1Idx, 1); + vDecrStride1Offs = ARM_CONNECT2(vddupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curDecrStride1Idx, 1); #if __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE - vIncStride4Offs = vidupq_wb_u16(&curIncStride4Idx, 4); + vIncStride4Offs = ARM_CONNECT2(vidupq_wb_u, __API_MCWM_PIXEL_BIT_NUM)(&curIncStride4Idx, 4); #else - ptTargetMaskCur += 8; + ptTargetMaskCur += __API_MCWM_VEC_INCR; #endif - ptTargetCur += 8; + ptTargetCur += __API_MCWM_VEC_INCR; - blkCnt -= 8; + blkCnt -= __API_MCWM_VEC_INCR; } while (blkCnt > 0); @@ -1426,6 +1868,12 @@ void __MCWM_FUNC(masks_copy_xy_mirror)( #undef ____MCWM_TYPE #undef ___MCWM_TYPE #undef __MCWM_TYPE +#undef __API_MCWM_PIXEL_BIT_NUM +#undef __API_MCWM_PIXEL_VECLOAD +#undef __API_MCWM_PIXEL_PVECSTORE +#undef __API_MCWM_PIXEL_BLENDING +#undef __API_MCWM_PIXEL_GATHVECLOAD +#undef __API_MCWM_VEC_INCR #undef __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING #undef __API_MCWM_CFG_1_HORIZONTAL_LINE #undef __API_MCWM_CFG_CHANNEL_8in32_SUPPORT diff --git a/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks.inc b/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks.inc new file mode 100644 index 000000000..2c25638da --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks.inc @@ -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 diff --git a/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks_helium.inc b/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks_helium.inc new file mode 100644 index 000000000..c01cdc8b5 --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_meta_trans_with_masks_helium.inc @@ -0,0 +1,1232 @@ +/* + * 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_helium.inc + * Description: c code template for : + * - transform_with_src_chn_mask_and_opacity + * - transform_with_src_mask_and_opacity + * - transform_with_src_chn_mask + * - transform_with_src_mask + * + * $Date: 12. July 2022 + * $Revision: V.1.0.4 + * + * -------------------------------------------------------------------- */ + +#ifndef __API_MTWM_COLOUR +# error You have to define __API_MTWM_COLOUR before using this c template +#endif +#ifndef __API_MTWM_COLOUR_NAME +# error You have to define __API_MTWM_COLOUR_NAME 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 + + +/*! 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 + + +#if __API_MTWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE + #define MASK_STRIDE_SCALE 4 +#else + #define MASK_STRIDE_SCALE 1 +#endif + +#if __API_MTWM_CFG_SUPPORT_OPACITY + #define SCALE_BY_OPACITY(pixelAlpha, opa) vPixelAlpha = (vPixelAlpha * opa) >> 8; +#else + #define SCALE_BY_OPACITY(pixelAlpha, opa) +#endif + + +#ifndef __API_MTWM_OP_NAME +# define ____MTWM_FUNC(__NAME, __COLOUR) \ + __MVE_WRAPPER(__arm_2d_impl_##__COLOUR##_##__NAME) +# define ___MTWM_FUNC(__NAME, __COLOUR) ____MTWM_FUNC(__NAME, __COLOUR) +#else +# define _____MTWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ + __MVE_WRAPPER(__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_NAME) + + +#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) + +/*============================ 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__ + +/** + Scale Gray8 pixel vector with Area & Alpha + */ +#define __ARM_2D_SCALE_MASK_GRAY8VEC(/* outputs */ \ + vAvgPix, vTransp, \ + /* inputs */ \ + vPtVal, vAreaScal, vAlphaSc) \ + float16x8_t vAlpha = vAreaScal * vcvtq_f16_u16(vAlphaSc) ; \ + vTransp = 256.0f16 * vAreaScal - vAlpha; \ + vAvgPix = vAlpha * vcvtq_f16_u16(vPtVal); + +/** + Scale Gray8 pixel vector with Area & Alpha. Accumulated version + */ +#define __ARM_2D_SCALE_MASK_GRAY8VEC_ACC(/* input / outputs */ \ + vAvgPix, vTransp, \ + /* inputs */ \ + vPtVal, vAreaScal, vAlphaSc) \ + float16x8_t vAlpha = vAreaScal * vcvtq_f16_u16(vAlphaSc); \ + vTransp += 256.0f16 * vAreaScal - vAlpha; \ + vAvgPix += vAlpha * vcvtq_f16_u16(vPtVal); + + +/** + Scale R/G/B pixel vectors with Area & Alpha + */ +#define __ARM_2D_SCALE_MASK_RGBVEC(/* outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, \ + /* inputs */ \ + R, G, B, vScal, vAlphaSc) \ + float16x8_t vAlpha = vScal * vcvtq_f16_u16(vAlphaSc) ; \ + vAvgTransparency = 256.0f16 * vScal - vAlpha; \ + vAvgPixelR = vAlpha * vcvtq_f16_u16(R); \ + vAvgPixelG = vAlpha * vcvtq_f16_u16(G); \ + vAvgPixelB = vAlpha * vcvtq_f16_u16(B); + + +/** + Scale R/G/B pixel vectors with Area & Alpha. Accumulated version + */ +#define __ARM_2D_SCALE_MASK_RGBVEC_ACC(/* input / outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB,vAvgTransparency, \ + /* inputs */ \ + R, G, B, vScal, vAlphaSc) \ + float16x8_t vAlpha = vScal * vcvtq_f16_u16(vAlphaSc) ; \ + vAvgTransparency += 256.0f16 * vScal - vAlpha; \ + vAvgPixelR += vAlpha * vcvtq_f16_u16(R); \ + vAvgPixelG += vAlpha * vcvtq_f16_u16(G); \ + vAvgPixelB += vAlpha * vcvtq_f16_u16(B); + + +/** + Mix Gray8 averaged pixel vector with transparency-scaled target vector + */ +#define __ARM_2D_BLEND_AVG_TARGET_GRAY8(vAvgPixel, vTarget, vAvgTransparency) \ + vqaddq(vcvtq_u16_f16(vAvgPixel), \ + vcvtq_u16_f16(vAvgTransparency) * vTarget) >> 8; + +/** + Mix R, G, B averaged pixel vectors with transparency-scaled target vector + */ +#define __ARM_2D_BLEND_AVG_TARGET_RGB(/* input / outputs */ \ + vAvgR, vAvgG, vAvgB, \ + /* inputs */ \ + vTargetR, vTargetG, vTargetB, vAvgTrans) \ + vAvgR = vqaddq(vAvgR, vTargetR * vAvgTrans); \ + vAvgR = vAvgR >> 8; \ + \ + vAvgG = vqaddq(vAvgG, vTargetG * vAvgTrans); \ + vAvgG = vAvgG >> 8; \ + \ + vAvgB = vqaddq(vAvgB, vTargetB * vAvgTrans); \ + vAvgB = vAvgB >> 8; + + +#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */ + + +/** + Scale Gray8 pixel vector with Area & Alpha + */ +#define __ARM_2D_SCALE_MASK_GRAY8VEC(/* outputs */ \ + vAvgPix, vTransp, \ + /* inputs */ \ + vPtVal, vAreaScal, vAlphaSc) \ + uint16x8_t vAlpha = vmulq_u16((vAreaScal >> 8), vAlphaSc); \ + vTransp = vAreaScal - vAlpha; \ + vAvgPix = vrmulhq(vAlpha, vPtVal); + +/** + Scale Gray8 pixel vector with Area & Alpha. Accumulated version + */ +#define __ARM_2D_SCALE_MASK_GRAY8VEC_ACC(/* input / outputs */ \ + vAvgPix, vTransp, \ + /* inputs */ \ + vPtVal, vAreaScal, vAlphaSc) \ + uint16x8_t vAlpha = vmulq_u16((vAreaScal >> 8), vAlphaSc); \ + vTransp = vqaddq(vTransp, vAreaScal - vAlpha); \ + vAvgPix = vqaddq(vAvgPix, vrmulhq(vAlpha, vPtVal)); + +/** + Scale R/G/B pixel vectors with Area & Alpha + */ +#define __ARM_2D_SCALE_MASK_RGBVEC(/* outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, \ + /* inputs */ \ + R, G, B, vScal, vAlphaSc) \ + uint16x8_t vAlpha = vmulq_u16((vScal >> 8), vAlphaSc); \ + vAvgTransparency = vScal - vAlpha; \ + vAvgPixelR = vrmulhq_u16(vAlpha, R ); \ + vAvgPixelG = vrmulhq_u16(vAlpha, G ); \ + vAvgPixelB = vrmulhq_u16(vAlpha, B ); + + +/** + Scale R/G/B pixel vectors with Area & Alpha. Accumulated version + */ +#define __ARM_2D_SCALE_MASK_RGBVEC_ACC(/* input / outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB,vAvgTransparency, \ + /* inputs */ \ + R, G, B, vScal, vAlphaSc) \ + uint16x8_t vAlpha = vmulq_u16((vScal >> 8), vAlphaSc); \ + vAvgTransparency = vqaddq(vAvgTransparency, vScal - vAlpha); \ + vAvgPixelR = vqaddq(vAvgPixelR, vrmulhq_u16(vAlpha, R)); \ + vAvgPixelG = vqaddq(vAvgPixelG, vrmulhq_u16(vAlpha, G)); \ + vAvgPixelB = vqaddq(vAvgPixelB, vrmulhq_u16(vAlpha, B)); + + +/** + Mix Gray8 averaged pixel vector with transparency-scaled target vector + */ +#define __ARM_2D_BLEND_AVG_TARGET_GRAY8(vAvgPixel, vTarget, vAvgTransparency) \ + vminq(vAvgPixel + vrmulhq(vTarget, vAvgTransparency), vdupq_n_u16(255)); + + +/** + Mix R, G, B averaged pixel vectors with transparency-scaled target vector + */ +#define __ARM_2D_BLEND_AVG_TARGET_RGB(/* inputs / outputs */ \ + vAvgR, vAvgG, vAvgB, \ + /* inputs */ \ + vTargetR, vTargetG, vTargetB, vAvgTrans) \ + vAvgR = vqaddq(vAvgR, vrmulhq(vTargetR, vAvgTrans)); \ + vAvgR = vminq(vAvgR, vdupq_n_u16(255)); \ + \ + vAvgG = vqaddq(vAvgG, vrmulhq(vTargetG, vAvgTrans)); \ + vAvgG = vminq(vAvgG, vdupq_n_u16(255)); \ + \ + vAvgB = vqaddq(vAvgB, vrmulhq(vTargetB, vAvgTrans)); \ + vAvgB = vminq(vAvgB, vdupq_n_u16(255)); + +#endif + +#if __API_MTWM_COLOUR == ARM_2D_M_COLOUR_GRAY8 + +/** + Unpack vectors of 8-bit widened pixels read from a input 2D coordinates if fits inside the region of + interest + Unpack vectors of 8-bit widened masks (alpha) read from a input 2D coordinates if fits inside the region of + interest. Masks indexes are scaled based on input stride and exta scale for src chan. mask operarations + Vector mask content is further scaled using input opacity + Update global predictor tracking region fit & color mask comparison. + */ + +#define __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(/* inputs */ \ + vecX, vecY, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStrd, maskScal, \ + opacity, predTail, \ + /* outputs */ \ + vPixVal, vPixelAlpha, \ + predGlb) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = \ + arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ + predGlb |= p; \ + /* prepare vector of point offsets */ \ + int16_t correctionOffset = vminvq_s16(INT16_MAX, vPoint.Y) - 1; \ + uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ + \ + /* base pointer update to compensate offset */ \ + uint8_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ + /* retrieve all point values */ \ + vPixVal = \ + vldrbq_gather_offset_z_u16(pOriginCorrected, ptOffs, predTail & p); \ + \ + uint16x8_t maskOffs = maskScal * vPoint.X + (vPoint.Y - correctionOffset) * maskStrd; \ + uint8_t *pMaskCorrected = pMaskArr + (correctionOffset * maskStrd); \ + /* retrieve all mask values */ \ + vPixelAlpha = \ + vldrbq_gather_offset_z_u16(pMaskCorrected, maskOffs, predTail & p); \ + \ + SCALE_BY_OPACITY(vPixelAlpha, opacity); \ + \ + ALPHA_255_COMP_VEC16(vPixelAlpha, 255); + + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + +/* Compute averaged gray8 pixel 8-bit widenedvector and tranparency using 4 neighbouring pixel / masks */ +/* Return predictors if vectors fit region of interest */ +#define __ARM2D_AVG_NEIGHBR_GRAY8_PIX_MASK_ARR(/* inputs */ \ + ptPoint, vXi, vYi, \ + Origin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, \ + vTarget, opacity, predTail, \ + /* outputs */ \ + predGlb, vAvgPixel, vAvgTransparency) \ + \ + uint16x8_t ptVal8, vPixelAlpha; \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + __typeof__ (vAvgPixel) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + /* \ + * accumulate / average over the 4 neigbouring pixels \ + */ \ + \ + /* Bottom Left averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, \ + ptVal8, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_GRAY8VEC(vAvgPixel, vAvgTransparency, ptVal8, vAreaBL, vPixelAlpha); \ + } \ + \ + /* Bottom Right averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(vaddq_n_s16(vXi, 1), vYi, pOrigin, \ + ptOrigValidRegion, iOrigStride, pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, ptVal8, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_GRAY8VEC_ACC(vAvgPixel, vAvgTransparency, ptVal8, vAreaBR, vPixelAlpha); \ + } \ + \ + /* Top Left averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(vXi, vaddq_n_s16(vYi, 1), pOrigin, \ + ptOrigValidRegion, iOrigStride, pMaskArr,maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, \ + ptVal8, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_GRAY8VEC_ACC(vAvgPixel, vAvgTransparency, ptVal8, vAreaTL, vPixelAlpha); \ + } \ + \ + /* Top Right averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail,ptVal8, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_GRAY8VEC_ACC(vAvgPixel, vAvgTransparency, ptVal8, vAreaTR, vPixelAlpha); \ + } + +#endif + + +#elif __API_MTWM_COLOUR == ARM_2D_M_COLOUR_RGB565 + +/** + Unpack vectors of 8-bit widened R, G and B pixels read from a input 2D coordinates if fits inside the region of + interest + Unpack vectors of 8-bit widened masks (alpha) read from a input 2D coordinates if fits inside the region of + interest. Masks indexes are scaled based on input stride and exta scale for src chan. mask operarations + Vector mask content is further scaled using input opacity + Update global predictor tracking region fit & color mask comparison. + */ +#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(/* inputs */ \ + vecX, vecY, pOrigin, \ + ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStrd, maskScal, \ + opacity, predTail, \ + /* outputs */ \ + R, G, B, \ + vPixelAlpha, pGlb) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = \ + arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ + pGlb |= p; \ + /* prepare vector of point offsets */ \ + int16_t correctionOffset = vminvq_s16(INT16_MAX, vPoint.Y) - 1; \ + uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ + \ + /* base pointer update to compensate offset */ \ + uint16_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ + /* retrieve all point values */ \ + uint16x8_t ptVal = \ + vldrhq_gather_shifted_offset_z_u16(pOriginCorrected, ptOffs, predTail & p); \ + \ + /* expand channels */ \ + __arm_2d_rgb565_unpack_single_vec(ptVal, &R, &G, &B); \ + uint16x8_t maskOffs = maskScal * vPoint.X + (vPoint.Y - correctionOffset) * maskStrd; \ + uint8_t *pMaskCorrected = pMaskArr + (correctionOffset * maskStrd); \ + /* retrieve all mask values */ \ + vPixelAlpha = \ + vldrbq_gather_offset_z_u16(pMaskCorrected, maskOffs, predTail & p); \ + \ + SCALE_BY_OPACITY(vPixelAlpha, opacity); \ + \ + ALPHA_255_COMP_VEC16(vPixelAlpha, 255); + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + +/* Computes averaged R, G, B 8-bit widened pixels vector and tranparency using 4 neighbouring pixel / masks */ +/* Returns predictor if vectors fit region of interest */ +#define __ARM2D_AVG_NEIGHBR_RGB565_PIX_MASK_ARR(ptPoint, vXi, vYi, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, vTarget, \ + opacity, predTail, \ + /* outputs */ \ + predGlb, \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency) \ + \ + uint16x8_t R, G, B, vPixelAlpha; \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + __typeof__ (vAvgPixelR) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + \ + /* Bottom Left averaging */ \ + { \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, \ + R, G, B, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, R, \ + G, B, vAreaBL, vPixelAlpha); \ + } \ + \ + \ + /* Bottom Right averaging */ \ + { \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(vaddq_n_s16(vXi, 1), vYi, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr,maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, \ + R, G, B, vPixelAlpha, \ + predGlb); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaBR, vPixelAlpha); \ + } \ + \ + /* Top Left averaging */ \ + { \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(vXi, vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTail, \ + R, G, B, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaTL, vPixelAlpha); \ + } \ + \ + /* Top Right averaging */ \ + { \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity,predTail, \ + R, G, B, vPixelAlpha, predGlb); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaTR, vPixelAlpha); \ + } +#endif + + +#elif __API_MTWM_COLOUR == ARM_2D_M_COLOUR_CCCN888 + +/** + Unpack vectors of 8-bit widened R, G and B pixels read from a input 2D coordinates if fits inside the region of + interest. These are read from 2 adjacent 32-bit packed vectors hence 2 tail prediction masks are needed + Unpack vectors of 8-bit widened masks (alpha) read from a input 2D coordinates if fits inside the region of + interest. Masks indexes are scaled based on input stride and exta scale for src chan. mask operarations + Vector mask content is further scaled using input opacity + Update 2 global predictors tracking region fit for 1st and 2nd 32-bit vector. + */ + +#define __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(/* inputs */ \ + vecX, vecY, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStrd, maskScal, opacity, \ + predTailLow, predTailHigh, \ + /* outputs */ \ + R, G, B, vPixelAlpha, pGlbLo, pGlbHi) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + arm_2d_point_s32x4_t tPointLo, tPointHi; \ + \ + /* split 16-bit point vector into 2 x 32-bit vectors */ \ + vst1q(pscratch16, vPoint.X); \ + tPointLo.X = vldrhq_s32(pscratch16); \ + tPointHi.X = vldrhq_s32(pscratch16 + 4); \ + \ + vst1q(pscratch16, vPoint.Y); \ + tPointLo.Y = vldrhq_s32(pscratch16); \ + tPointHi.Y = vldrhq_s32(pscratch16 + 4); \ + \ + /* 1st half */ \ + \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); \ + pGlbLo |= p; \ + /* prepare vector of point offsets */ \ + uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; \ + \ + /* retrieve all point values */ \ + uint32x4_t ptVal = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailLow & p); \ + \ + vst1q(scratch32, ptVal); \ + \ + uint32x4_t maskOffs = maskScal * tPointLo.X + tPointLo.Y * maskStrd; \ + uint32x4_t maskVal = \ + vldrbq_gather_offset_z_u32(pMaskArr, maskOffs, predTailLow & p); \ + \ + vst1q(scratch32+8, maskVal); \ + \ + /* 2nd half */ \ + \ + /* set vector predicate if point is inside the region */ \ + p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); \ + pGlbHi |= p; \ + /* prepare vector of point offsets */ \ + ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; \ + \ + /* retrieve all point values */ \ + ptVal = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailHigh & p); \ + \ + vst1q(scratch32 + 4, ptVal); \ + \ + maskOffs = maskScal * tPointHi.X + tPointHi.Y * maskStrd; \ + maskVal = \ + vldrbq_gather_offset_z_u32(pMaskArr, maskOffs, predTailHigh & p); \ + \ + vst1q(scratch32+12, maskVal); \ + \ + /* expand channels */ \ + __arm_2d_unpack_rgb888_from_mem((uint8_t *) scratch32, &R, &G, &B); \ + \ + vPixelAlpha = vldrbq_gather_offset_u16((uint8_t *) &scratch32[8], vidupq_n_u16(0, 4)); \ + \ + SCALE_BY_OPACITY(vPixelAlpha, opacity); \ + \ + ALPHA_255_COMP_VEC16(vPixelAlpha, 255); + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + +/* compute averaged R, G, B 8-bit widened pixels vector and tranparency using 4 neighbouring pixel / masks */ +/* Returns 2 predictors for top / bottom 32-bit vectors fitting region of interest */ +#define __ARM2D_AVG_NEIGHBR_RGB888_PIX_MASK_ARR(ptPoint, vXi, vYi, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, vTarget, opacity, \ + predTail, \ + /* outputs */ \ + predGlbLo, predGlbHi, \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency)\ + \ + uint16x8_t R, G, B, vPixelAlpha; \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + __typeof__ (vAvgPixelR) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + /* \ + * accumulate / average over the 4 neigbouring pixels \ + */ \ + \ + \ + /* Bottom Left averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(vXi, vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, pMaskArr, \ + maskStride, MASK_STRIDE_SCALE, opacity, \ + predTailLow, predTailHigh, \ + R, G, B, vPixelAlpha, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, R, \ + G, B, vAreaBL, vPixelAlpha); \ + } \ + \ + /* Bottom Right averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(vaddq_n_s16(vXi, 1), vYi, \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTailLow, predTailHigh, \ + R, G, B, vPixelAlpha, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaBR, vPixelAlpha); \ + } \ + \ + /* Top Left averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(vXi, vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTailLow, predTailHigh, \ + R, G, B, vPixelAlpha, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaTL, vPixelAlpha) \ + } \ + \ + /* Top Right averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, \ + pMaskArr, maskStride, MASK_STRIDE_SCALE, \ + opacity, predTailLow, predTailHigh, \ + R, G, B, vPixelAlpha, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_MASK_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + vAvgTransparency, R, G, B, vAreaTR, vPixelAlpha) \ + } + +#endif + +#endif + + +#if __API_MTWM_COLOUR == ARM_2D_M_COLOUR_GRAY8 + +static +void __MVE_WRAPPER(ARM_CONNECT2(__arm_2d_impl_gray8_, get_pixel_colour_mask)) ( + ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint8_t * pOrigin, int16_t iOrigStride, + uint8_t * pTarget, + #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 + uint32_t elts) +{ + iOrigmaskStride *= MASK_STRIDE_SCALE; + + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vldrbq_u16(pTarget); + + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixel; + + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + PIX_VEC_TYP vAvgTransparency; + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + __ARM2D_AVG_NEIGHBR_GRAY8_PIX_MASK_ARR(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, pchOrigMask, iOrigmaskStride, vTarget, + hwOpacity, predTail, + predGlb, vAvgPixel, vAvgTransparency); + } +#else + { + uint16x8_t ptVal8, vPixelAlpha; + + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, pchOrigMask, iOrigmaskStride, + MASK_STRIDE_SCALE, hwOpacity, predTail, + ptVal8, vPixelAlpha, predGlb); + + __ARM_2D_SCALE_MASK_GRAY8VEC(vAvgPixel, vAvgTransparency, ptVal8, AREA_UNITY, vPixelAlpha); + + } +#endif + + /* blending */ + uint16x8_t vBlended = __ARM_2D_BLEND_AVG_TARGET_GRAY8(vAvgPixel, vTarget, vAvgTransparency); + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vBlended, vTarget, predGlb); + + vstrbq_p_u16(pTarget, vTarget, predTail); +} + +#elif __API_MTWM_COLOUR == ARM_2D_M_COLOUR_RGB565 + +static +void __MVE_WRAPPER(ARM_CONNECT2(__arm_2d_impl_rgb565_, get_pixel_colour_mask))(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint16_t * pOrigin, + int16_t iOrigStride, + uint16_t * pTarget, + #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 + uint32_t elts) +{ + iOrigmaskStride *= MASK_STRIDE_SCALE; + + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vld1q(pTarget); + PIX_VEC_TYP vAvgTransparency; + + + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + uint16x8_t vAvgR, vAvgG, vAvgB, vAvgTrans; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + + __ARM2D_AVG_NEIGHBR_RGB565_PIX_MASK_ARR(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, pchOrigMask, iOrigmaskStride, vTarget, + hwOpacity, predTail, predGlb, vAvgPixelR, + vAvgPixelG, vAvgPixelB, vAvgTransparency); + +#else + { + uint16x8_t R, G, B, vPixelAlpha; + + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + pchOrigMask, + iOrigmaskStride, MASK_STRIDE_SCALE, + hwOpacity, predTail, R, G, B, + vPixelAlpha, predGlb); + + __ARM_2D_SCALE_MASK_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, R, + G, B, AREA_UNITY, vPixelAlpha); + } +#endif + + vAvgR = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR); + vAvgG = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG); + vAvgB = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB); + vAvgTrans = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgTransparency); + + /* blending */ + uint16x8_t vBlended; + uint16x8_t vTargetR, vTargetG, vTargetB; + + __arm_2d_rgb565_unpack_single_vec(vTarget, &vTargetR, &vTargetG, &vTargetB); + + /* merge */ + __ARM_2D_BLEND_AVG_TARGET_RGB(vAvgR, vAvgG, vAvgB, vTargetR, vTargetG, vTargetB, vAvgTrans); + + vBlended = __arm_2d_rgb565_pack_single_vec(vAvgR, vAvgG, vAvgB); + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vBlended, vTarget, predGlb); + + vst1q_p(pTarget, vTarget, predTail); +} + + +#elif __API_MTWM_COLOUR == ARM_2D_M_COLOUR_CCCN888 + + +static +void __MVE_WRAPPER(ARM_CONNECT2(__arm_2d_impl_cccn888_, get_pixel_colour_mask))(ARM_2D_POINT_VEC *ptPoint, + arm_2d_region_t *ptOrigValidRegion, + uint32_t *pOrigin, + int16_t iOrigStride, + uint32_t *pTarget, + #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 + uint32_t elts + ) +{ + iOrigmaskStride *= MASK_STRIDE_SCALE; + + ARM_ALIGN(8) uint32_t scratch32[32]; + int16_t *pscratch16 = (int16_t *) scratch32; + uint32x4_t vTargetLo = vld1q(pTarget); + uint32x4_t vTargetHi = vld1q(pTarget + 4); + mve_pred16_t predTailLow = vctp32q(elts); + mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + /* predicate accumulators */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlbLo = 0, predGlbHi = 0; + PIX_VEC_TYP vAvgTransparency; + uint16x8_t vAvgR, vAvgG, vAvgB, vAvgTrans; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + /* + * accumulate / average over the 4 neigbouring pixels + */ + __ARM2D_AVG_NEIGHBR_RGB888_PIX_MASK_ARR(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, pchOrigMask, iOrigmaskStride, vTarget, + hwOpacity, predTail, predGlbLo, predGlbHi, + vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency); +#else + { + uint16x8_t R, G, B, vPixelAlpha; + + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR(vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, pchOrigMask, + iOrigmaskStride, MASK_STRIDE_SCALE, + hwOpacity, predTailLow, predTailHigh, + R, G, B, vPixelAlpha, predGlbLo, predGlbHi); + + __ARM_2D_SCALE_MASK_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, vAvgTransparency, R, + G, B, AREA_UNITY, vPixelAlpha); + } +#endif + + vAvgR = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR); + vAvgG = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG); + vAvgB = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB); + vAvgTrans = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgTransparency); + + /* alpha blending */ + uint16x8_t vTargetR, vTargetG, vTargetB; + + __arm_2d_unpack_rgb888_from_mem((const uint8_t *) pTarget, &vTargetR, &vTargetG, &vTargetB); + + + /* merge */ + __ARM_2D_BLEND_AVG_TARGET_RGB(vAvgR, vAvgG, vAvgB, vTargetR, vTargetG, vTargetB, vAvgTrans); + + /* pack */ + __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vAvgR, vAvgG, vAvgB); + + uint32x4_t TempPixel = vld1q(scratch32); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); + + vst1q_p(pTarget, TempPixel, predTailLow); + + TempPixel = vld1q(scratch32 + 4); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); + + vst1q_p(pTarget + 4, TempPixel, predTailHigh); +} + + + +#endif + + + +#if !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ + + + +__OVERRIDE_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 = ptInfo->Mask.hwColour; +#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), + iOrigStride, + 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; + + int32_t nbVecElts = iWidth; + float16x8_t vX = vcvtq_f16_s16((int16x8_t) vidupq_n_u16(0, 1)); + __API_INT_TYPE *pTargetBaseCur = pTargetBase; + + while (nbVecElts > 0) { + arm_2d_point_f16x8_t tPointV; + + /* linear interpolation thru first & last columns */ + tPointV.X = + vfmaq_n_f16(vdupq_n_f16(colFirstX), vX, slopeX); + tPointV.Y = + vfmaq_n_f16(vdupq_n_f16(colFirstY), vX, slopeY); + +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__) + tPointV.X = vaddq_m_n_f16(tPointV.X, tPointV.X, __CALIB, vcmpgtq(tPointV.X, 0)); + tPointV.X = vsubq_m_n_f16(tPointV.X, tPointV.X, __CALIB, vcmpleq(tPointV.X, 0)); + + 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_FUNC(get_pixel_colour_mask)( + &tPointV, + &ptParam->tOrigin.tValidRegion, + ptParam->tOrigin.pBuffer, + iOrigStride, + pTargetBaseCur, + #if __API_MTWM_CFG_SUPPORT_SOURCE_MASK + pOriginMask, + iOrigMaskStride, + #else + MaskColour, + #endif + #if __API_MTWM_CFG_SUPPORT_OPACITY + hwOpacity, + #endif + nbVecElts + ); + + pTargetBaseCur += 8; + vX += 8.0f16; + nbVecElts -= 8; + } + pTargetBase += (iTargetStride); + } +} + + +#else /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */ + + +__OVERRIDE_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 = ptInfo->Mask.hwColour; +#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), + iOrigStride, + 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); + + int32_t nrmSlopeX = 17 - __CLZ(ABS(slopeX)); + int32_t nrmSlopeY = 17 - __CLZ(ABS(slopeY)); + + slopeX = ARSHIFT(slopeX, nrmSlopeX); + slopeY = ARSHIFT(slopeY, nrmSlopeY); + + 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); + + /* Q6 conversion */ + colFirstX = colFirstX >> 10; + colFirstY = colFirstY >> 10; + + int32_t nbVecElts = iWidth; + int16x8_t vX = (int16x8_t) vidupq_n_u16(0, 1); + __API_INT_TYPE *pTargetBaseCur = pTargetBase; + + /* Q9.6 coversion */ + vX = SET_Q6INT(vX); + + while (nbVecElts > 0) { + arm_2d_point_s16x8_t tPointV; + + tPointV.X = vqdmulhq_n_s16(vX, slopeX); + tPointV.X = vaddq_n_s16(vqrshlq_n_s16(tPointV.X, nrmSlopeX), colFirstX); + + tPointV.Y = vqdmulhq_n_s16(vX, slopeY); + tPointV.Y = vaddq_n_s16(vqrshlq_n_s16(tPointV.Y, nrmSlopeY), colFirstY); + + + + __ARM_2D_FUNC(get_pixel_colour_mask)( + &tPointV, + &ptParam->tOrigin.tValidRegion, + ptParam->tOrigin.pBuffer, + iOrigStride, + pTargetBaseCur, + #if __API_MTWM_CFG_SUPPORT_SOURCE_MASK + pOriginMask, + iOrigMaskStride, + #else + MaskColour, + #endif + #if __API_MTWM_CFG_SUPPORT_OPACITY + hwOpacity, + #endif + nbVecElts + ); + + pTargetBaseCur += 8; + vX += SET_Q6INT(8); + nbVecElts -= 8; + } + pTargetBase += iTargetStride; + } +} + + + +#endif /* __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */ + + + + +#undef get_pixel_colour_mask +#undef transform_with_mask +#undef MASK_STRIDE_SCALE +#undef SCALE_BY_OPACITY + +#undef __ARM2D_AVG_NEIGHBR_GRAY8_PIX_MASK_ARR +#undef __ARM2D_AVG_NEIGHBR_RGB565_PIX_MASK_ARR +#undef __ARM2D_AVG_NEIGHBR_RGB888_PIX_MASK_ARR + + +#undef __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_ARR_FAR +#undef __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_MASK_ARRR_FAR +#undef __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_MASK_ARR + +#undef __ARM_2D_SCALE_MASK_GRAY8VEC +#undef __ARM_2D_SCALE_MASK_GRAY8VEC_ACC +#undef __ARM_2D_SCALE_MASK_RGBVEC +#undef __ARM_2D_SCALE_MASK_RGBVEC_ACC + +#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_COLOUR_NAME +#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_CFG_SUPPORT_SOURCE_MASK +#undef __API_MTWM_CFG_SUPPORT_TARGET_MASK +#undef __API_MTWM_CFG_SUPPORT_OPACITY diff --git a/package/Arm2D/Library/Source/__arm_2d_tile.c b/package/Arm2D/Library/Source/__arm_2d_tile.c new file mode 100644 index 000000000..b1852cf79 --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_tile.c @@ -0,0 +1,2899 @@ +/* + * 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_tile.c + * Description: Basic Tile operations + * + * $Date: 11. Aug 2022 + * $Revision: V.1.2.1 + * + * Target Processor: Cortex-M cores + * + * -------------------------------------------------------------------- */ + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wempty-translation-unit" +#endif + + +#ifdef __ARM_2D_COMPILATION_UNIT +#undef __ARM_2D_COMPILATION_UNIT + +#define __ARM_2D_IMPL__ + +#include "arm_2d.h" +#include "__arm_2d_impl.h" +#include "__arm_2d_paving.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 "-Wmissing-prototypes" +# 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_GCC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" +#endif + +/*----------------------------------------------------------------------------* + * Code Template * + *----------------------------------------------------------------------------*/ + +#define __API_COLOUR c8bit +#define __API_INT_TYPE uint8_t +#define __API_INT_TYPE_BIT_NUM 8 + +#include "__arm_2d_copy.inc" + + +#define __API_COLOUR rgb16 +#define __API_INT_TYPE uint16_t +#define __API_INT_TYPE_BIT_NUM 16 + +#include "__arm_2d_copy.inc" + + +#define __API_COLOUR rgb32 +#define __API_INT_TYPE uint32_t +#define __API_INT_TYPE_BIT_NUM 32 + +#include "__arm_2d_copy.inc" + +/*----------------------------------------------------------------------------* + * Tile Operations * + *----------------------------------------------------------------------------*/ + +/* + HOW IT WORKS: + + Input Region 0 + +------------------------------------------------------+ + | | + | | + | | + | +------------------------------+---------+ + | | |/////////| + | | Output Region |/////////| + | | |/////////| + +-----------------------+------------------------------+/////////| + |////////////////////////////////////////| + |////////////////////////////////////////| + +----------------------------------------+ + Input Region 1 + */ +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) +{ + assert(ptRegionIn0 != NULL); + assert(ptRegionIn1 != NULL); + + do { + arm_2d_location_t tLocationIn0End = { + .iX = ptRegionIn0->tLocation.iX + + ptRegionIn0->tSize.iWidth + - 1, + .iY = ptRegionIn0->tLocation.iY + + ptRegionIn0->tSize.iHeight + - 1, + }; + + arm_2d_location_t tLocationIn1End = { + .iX = ptRegionIn1->tLocation.iX + + ptRegionIn1->tSize.iWidth + - 1, + .iY = ptRegionIn1->tLocation.iY + + ptRegionIn1->tSize.iHeight + - 1, + }; + + arm_2d_location_t tLocationOutStart = { + .iX = MAX( ptRegionIn0->tLocation.iX, + ptRegionIn1->tLocation.iX), + + .iY = MAX( ptRegionIn0->tLocation.iY, + ptRegionIn1->tLocation.iY), + }; + + arm_2d_location_t tLocationOutEnd = { + .iX = MIN( tLocationIn0End.iX, + tLocationIn1End.iX), + .iY = MIN( tLocationIn0End.iY, + tLocationIn1End.iY), + }; + + if ( (tLocationOutStart.iX > tLocationOutEnd.iX) + || (tLocationOutStart.iY > tLocationOutEnd.iY)) { + return false; + } + + if (NULL != ptRegionOut) { + ptRegionOut->tLocation = tLocationOutStart; + ptRegionOut->tSize.iWidth = tLocationOutEnd.iX + - tLocationOutStart.iX + + 1; + + ptRegionOut->tSize.iHeight = tLocationOutEnd.iY + - tLocationOutStart.iY + + 1; + } + } while(0); + + return true; +} + +ARM_NONNULL(1,2) +bool arm_2d_is_point_inside_region( const arm_2d_region_t *ptRegion, + const arm_2d_location_t *ptPoint) +{ + assert(ptRegion != NULL); + assert(ptPoint != NULL); + + do { + if (ptPoint->iX < ptRegion->tLocation.iX) { + break; + } else if (ptPoint->iY < ptRegion->tLocation.iY) { + break; + } else if (ptPoint->iX >= ptRegion->tLocation.iX + ptRegion->tSize.iWidth) { + break; + } else if (ptPoint->iY >= ptRegion->tLocation.iY + ptRegion->tSize.iHeight) { + break; + } + + return true; + } while(0); + + return false; +} + +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) +{ + assert(NULL != ptTile); + assert(NULL != ptValidRegion); + + *ptValidRegion = ptTile->tRegion; + + if (NULL != ppFirstDerivedChild) { + *ppFirstDerivedChild = NULL; /* initialise */ + } + + if (NULL != ptOffset) { + ptOffset->iX = 0; + ptOffset->iY = 0; + } + + if (arm_2d_is_root_tile(ptTile)) { + return ptTile; + } + + do { + if (ptTile->tInfo.bDerivedResource) { + if (NULL != ppFirstDerivedChild) { + if (NULL == *ppFirstDerivedChild) { + *ppFirstDerivedChild = ptTile; + } + } + } + + //! get parent + ptTile = (const arm_2d_tile_t *)ptTile->ptParent; + if (NULL == ptTile) { + break; + } + + + + /*! \note Calculate the relative position between valid region and + *! the tile's original region. Usually, the tile's region + *! is inside the parent tile, but when the tile's location is + *! out of the parent's region with one or more negative axies, + *! the offset will be non-zero. + *! The offset is used to indicate the tile's view, and the + *! valid region is seen as inside the tile's region. + *! + *! Figure: What's the meaning of offset location + *! + *! The special case, where the child tile has a negative coordinates, + *! hence, the offset is (a,b) **as if** the valid region is inside + *! the child tile. + *! + *! (-a,-b) Child Tile + *! +------------------------------------+ + *! |///(0,0) Parent Tile ///////////////| + *! |/////+------------------------------+---------+ + *! |/////| | | + *! |/////| Valid Region | | + *! |/////| | | + *! +-----+------------------------------+ | + *! | | + *! | | + *! +----------------------------------------+ + *! + */ + if (NULL != ptOffset) { + arm_2d_location_t tOffset = ptValidRegion->tLocation; + tOffset.iX = MAX(0, -tOffset.iX); + tOffset.iY = MAX(0, -tOffset.iY); + + ptOffset->iX += tOffset.iX; + ptOffset->iY += tOffset.iY; + } + + /*! calculate the valid range in parent tile + *! + *! \note the location of the parent tile is used to indicate its + *! relative location between the it and its parent. + *! when calculate the valid range in parent, we have to assume + *! that the location is always (0,0) + *! + */ + arm_2d_region_t tParentRegion = { + .tSize = ptTile->tRegion.tSize, + }; + + if (arm_2d_is_root_tile(ptTile)) { + /* root tile can has offset */ + tParentRegion.tLocation = ptTile->tRegion.tLocation; + } + + /*! make sure the output region is valid */ + if (!arm_2d_region_intersect( &tParentRegion, + ptValidRegion, + ptValidRegion)) { + /* out of range */ + return NULL; + } + + if (arm_2d_is_root_tile(ptTile)) { + break; + } + + ptValidRegion->tLocation.iX += ptTile->tRegion.tLocation.iX; + ptValidRegion->tLocation.iY += ptTile->tRegion.tLocation.iY; + + } while(true); + + return ptTile; +} + +/* + HOW IT WORKS: + + Root Tile (Output Tile) + +------------------------------------------------------------------------+ + | ... ... | + | | + | Parent Tile | + | +------------------------------------+ | + | | Child Tile | | + | | +------------------------------+---------+ | + | | | |/////////| | + | | | Valid Region |/////////| | + | | | |/////////| | + | +-----+------------------------------+/////////| | + | |////////////////////////////////////////| | + | |////////////////////////////////////////| | + | +----------------------------------------+ | + | | + +------------------------------------------------------------------------+ + */ +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) +{ + return __arm_2d_tile_get_root(ptTile, ptValidRegion, ptOffset, NULL); +} + +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) +{ + assert(ptTarget != NULL); + assert(ptReference != NULL); + arm_2d_region_t tTargetRegion; + arm_2d_region_t tReferenceRegion; + + ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); + ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); + + if (NULL == ptTarget) { + if (NULL != ptReference) { + return ARM_2D_CMP_SMALLER; + } + return ARM_2D_CMP_EQUALS; + } else if (NULL == ptReference) { + return ARM_2D_CMP_LARGER; + } + + if (tTargetRegion.tSize.iWidth > tReferenceRegion.tSize.iWidth) { + return ARM_2D_CMP_LARGER; + } else if (tTargetRegion.tSize.iWidth < tReferenceRegion.tSize.iWidth) { + return ARM_2D_CMP_SMALLER; + } + + return ARM_2D_CMP_EQUALS; +} + + +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) +{ + assert(ptTarget != NULL); + assert(ptReference != NULL); + arm_2d_region_t tTargetRegion; + arm_2d_region_t tReferenceRegion; + + ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); + ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); + + if (NULL == ptTarget) { + if (NULL != ptReference) { + return ARM_2D_CMP_SMALLER; + } + return ARM_2D_CMP_EQUALS; + } else if (NULL == ptReference) { + return ARM_2D_CMP_LARGER; + } + + if (tTargetRegion.tSize.iHeight > tReferenceRegion.tSize.iHeight) { + return ARM_2D_CMP_LARGER; + } else if (tTargetRegion.tSize.iHeight < tReferenceRegion.tSize.iHeight) { + return ARM_2D_CMP_SMALLER; + } + + return ARM_2D_CMP_EQUALS; +} + +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) +{ + assert(ptTarget != NULL); + assert(ptReference != NULL); + arm_2d_region_t tTargetRegion; + arm_2d_region_t tReferenceRegion; + + ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); + ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); + + if (NULL == ptTarget) { + if (NULL != ptReference) { + return ARM_2D_CMP_SMALLER; + } + return ARM_2D_CMP_EQUALS; + } else if (NULL == ptReference) { + return ARM_2D_CMP_LARGER; + } + + if (tTargetRegion.tSize.iWidth < tReferenceRegion.tSize.iWidth) { + return ARM_2D_CMP_SMALLER; + } + + if (tTargetRegion.tSize.iHeight < tReferenceRegion.tSize.iHeight) { + return ARM_2D_CMP_SMALLER; + } + + if ( (tTargetRegion.tSize.iWidth == tReferenceRegion.tSize.iWidth) + && (tTargetRegion.tSize.iHeight == tReferenceRegion.tSize.iHeight)) { + return ARM_2D_CMP_EQUALS; + } + + return ARM_2D_CMP_LARGER; +} + + +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) +{ + + assert(NULL != ptTile); + assert(NULL != ptLocation); + + ptLocation->iX = 0; + ptLocation->iY = 0; + + while( !ptTile->tInfo.bIsRoot ) { + ptLocation->iX += ptTile->tRegion.tLocation.iX; + ptLocation->iY += ptTile->tRegion.tLocation.iY; + + ptTile = ptTile->ptParent; + } + + return ptTile; +} + +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) +{ + assert(NULL != ptTarget); + assert(NULL != ptReference); + assert(NULL != ptBuffer); + + //! get the absolute location + arm_2d_location_t tTargetAbsoluteLocaton, tReferenceAbsoluteLocation; + + ptBuffer->tSize.iWidth = ptTarget->tRegion.tSize.iWidth + - ptReference->tRegion.tSize.iWidth; + ptBuffer->tSize.iHeight = ptTarget->tRegion.tSize.iHeight + - ptReference->tRegion.tSize.iHeight; + + ptTarget = arm_2d_get_absolute_location(ptTarget, &tTargetAbsoluteLocaton); + ptReference = arm_2d_get_absolute_location(ptReference, &tReferenceAbsoluteLocation); + + if (ptTarget != ptReference) { + //! they don't have the same root + return NULL; + } + + ptBuffer->tLocation.iX = tTargetAbsoluteLocaton.iX + - tReferenceAbsoluteLocation.iX; + ptBuffer->tLocation.iY = tTargetAbsoluteLocaton.iY + - tReferenceAbsoluteLocation.iY; + + return ptBuffer; +} + +/* + HOW IT WORKS: + + Parent Tile (Are NOT necessarily a ROOT tile ) + +------------------------------------------------------+ + | | + | | + | Target Region | + | +------------------------------+---------+ + | | |/////////| + | | New Child Tile (Output) |/////////| + | | |/////////| + +-----------------------+------------------------------+/////////| + |////////////////////////////////////////| + |////////////////////////////////////////| + +----------------------------------------+ + */ +ARM_NONNULL(1,2,3) +arm_2d_tile_t *arm_2d_tile_generate_child( + const arm_2d_tile_t *ptParentTile, + const arm_2d_region_t *ptRegion, + arm_2d_tile_t *ptOutput, + bool bClipRegion) +{ + assert(NULL != ptParentTile); + assert(NULL != ptRegion); + assert(NULL != ptOutput); + + memset(ptOutput, 0, sizeof(arm_2d_tile_t)); + ptOutput->tRegion = *ptRegion; + + arm_2d_region_t tParentRegion = { + .tSize = ptParentTile->tRegion.tSize, + }; + + if (bClipRegion) { + if (!arm_2d_region_intersect( &tParentRegion, + &(ptOutput->tRegion), + &(ptOutput->tRegion) + )) { + /* out of range */ + return NULL; + } + } else { + /*! \note since you are allowed to generate a child tile whose region is + *! bigger than its parent, so we don't have to clip it, see **note** + *! below. + */ + if (!arm_2d_region_intersect( &tParentRegion, + &(ptOutput->tRegion), + NULL //&(ptOutput->tRegion) //!< **note** + )) { + /* out of range */ + return NULL; + } + } + + ptOutput->tInfo = ptParentTile->tInfo; + ptOutput->tInfo.bIsRoot = false; + + /* user has to manually set this flag to true to indicate a derived resource */ + ptOutput->tInfo.bDerivedResource = false; + + ptOutput->ptParent = (arm_2d_tile_t *)ptParentTile; + + return ptOutput; +} + + +/*----------------------------------------------------------------------------* + * Copy/Fill tile to destination with Mirroring * + *----------------------------------------------------------------------------*/ + +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) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +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) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +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) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + __arm_2d_impl_c8bit_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode); + } else { + __arm_2d_impl_c8bit_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + __arm_2d_impl_rgb16_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode); + } else { + __arm_2d_impl_rgb16_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + __arm_2d_impl_rgb32_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode); + } else { + __arm_2d_impl_rgb32_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_c8bit_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode); + + + } else { + __arm_2d_impl_c8bit_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_rgb16_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode); + + + } else { + __arm_2d_impl_rgb16_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + } + + return arm_fsm_rt_cpl; +} + + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_rgb32_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode); + + } else { + __arm_2d_impl_rgb32_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + } + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Copy Only * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_ONLY_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = 0; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_ONLY_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = 0; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_ONLY_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = 0; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Copy with X mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_X_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_X_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_X_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_copy_x_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_copy_x_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_copy_x_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Copy with Y mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_Y_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_copy_y_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_copy_y_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_copy_y_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Copy with XY mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_XY_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_copy_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_copy_xy_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_copy_xy_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_copy_xy_mirror( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + + return arm_fsm_rt_cpl; +} + + +/*----------------------------------------------------------------------------* + * Fill Only * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_ONLY_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_ONLY_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_only( arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_ONLY_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_fill( ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_fill( ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_only( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_fill( ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Fill with X mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_X_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_X_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_x_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_X_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_X_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_fill_x_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_fill_x_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_x_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_fill_x_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Fill with Y mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_Y_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_y_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_Y_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_fill_y_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_fill_y_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_y_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_fill_y_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +/*----------------------------------------------------------------------------* + * Fill with XY mirroring * + *----------------------------------------------------------------------------*/ + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_c8bit_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_XY_MIRROR_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb16_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +ARM_NONNULL(2,3) +arm_fsm_rt_t arm_2dp_rgb32_tile_fill_with_xy_mirror( + arm_2d_op_cp_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion) +{ + + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = ARM_2D_CP_MODE_FILL | ARM_2D_CP_MODE_XY_MIRROR; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_c8bit_fill_xy_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb16_fill_xy_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_xy_mirror( __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + __arm_2d_impl_rgb32_fill_xy_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize); + + return arm_fsm_rt_cpl; +} + + + +/*----------------------------------------------------------------------------* + * Copy/Fill with colour-keying and Mirroring * + *----------------------------------------------------------------------------*/ + +/*! \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. + *! + */ + +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) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + OP_CORE.ptOp = + &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + this.chColour = chMaskColour; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +/*! \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 + */ + +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) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + OP_CORE.ptOp = + &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + this.hwColour = hwMaskColour; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + +/*! \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. + */ +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) +{ + assert(NULL != ptSource); + assert(NULL != ptTarget); + + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + OP_CORE.ptOp = + &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Source.ptTile = ptSource; + this.wMode = wMode; + this.wColour = wMaskColour; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) + + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_c8bit_cl_key_copy_mirror( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode, + this.hwColour); + + } else { + __arm_2d_impl_c8bit_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.hwColour); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) + + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_rgb16_cl_key_copy_mirror( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode, + this.hwColour); + + } else { + __arm_2d_impl_rgb16_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.hwColour); + } + + return arm_fsm_rt_cpl; +} + + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) + + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_rgb32_cl_key_copy_mirror( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + wMode, + this.wColour); + } else { + __arm_2d_impl_rgb32_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.wColour); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + __arm_2d_impl_c8bit_cl_key_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode, + this.hwColour); + } else { + __arm_2d_impl_c8bit_cl_key_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + this.hwColour); + } + + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + __arm_2d_impl_rgb16_cl_key_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode, + this.hwColour); + } else { + __arm_2d_impl_rgb16_cl_key_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + this.hwColour); + } + + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_with_colour_keying( + __arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + uint32_t wMode = this.wMode; + + if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { + + __arm_2d_impl_rgb32_cl_key_fill_mirror( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + wMode, + this.wColour); + + } else { + + __arm_2d_impl_rgb32_cl_key_fill( + ptTask->Param.tFill.tSource.pBuffer, + ptTask->Param.tFill.tSource.iStride, + &ptTask->Param.tFill.tSource.tValidRegion.tSize, + ptTask->Param.tFill.tTarget.pBuffer, + ptTask->Param.tFill.tTarget.iStride, + &ptTask->Param.tFill.tTarget.tValidRegion.tSize, + this.wColour); + + } + + + return arm_fsm_rt_cpl; +} + + +/*----------------------------------------------------------------------------* + * Low Level IO Interfaces * + *----------------------------------------------------------------------------*/ +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_C8BIT, __arm_2d_c8bit_sw_tile_copy); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_RGB16, __arm_2d_rgb16_sw_tile_copy); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_RGB32, __arm_2d_rgb32_sw_tile_copy); + +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_ONLY_C8BIT, __arm_2d_c8bit_sw_tile_copy_only); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB16, __arm_2d_rgb16_sw_tile_copy_only); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB32, __arm_2d_rgb32_sw_tile_copy_only); + +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_copy_x_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_copy_x_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_copy_x_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_copy_y_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_copy_y_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_copy_y_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_copy_xy_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_copy_xy_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_copy_xy_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_ONLY_C8BIT, __arm_2d_c8bit_sw_tile_fill_only); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_ONLY_RGB16, __arm_2d_rgb16_sw_tile_fill_only); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_ONLY_RGB32, __arm_2d_rgb32_sw_tile_fill_only); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_fill_x_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_fill_x_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_fill_x_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_fill_y_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_fill_y_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_fill_y_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_C8BIT, __arm_2d_c8bit_sw_tile_fill_xy_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_RGB16, __arm_2d_rgb16_sw_tile_fill_xy_mirror); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_RGB32, __arm_2d_rgb32_sw_tile_fill_xy_mirror); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_C8BIT, __arm_2d_c8bit_sw_tile_fill); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_RGB16, __arm_2d_rgb16_sw_tile_fill); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_RGB32, __arm_2d_rgb32_sw_tile_fill); + +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_C8BIT, + __arm_2d_c8bit_sw_tile_copy_with_colour_keying); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB16, + __arm_2d_rgb16_sw_tile_copy_with_colour_keying); +__WEAK +def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB32, + __arm_2d_rgb32_sw_tile_copy_with_colour_keying); + +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_C8BIT, + __arm_2d_c8bit_sw_tile_fill_with_colour_keying); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB16, + __arm_2d_rgb16_sw_tile_fill_with_colour_keying); +__WEAK +def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB32, + __arm_2d_rgb32_sw_tile_fill_with_colour_keying); + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_C8BIT), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_RGB16), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_RGB32), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_RGB32), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_ONLY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_C8BIT), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_ONLY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB16), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_ONLY_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_ONLY, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB32), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_X_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_C8BIT), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_X_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB16), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_X_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_X_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB32), + .ptFillLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_C8BIT), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB16), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_Y_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB32), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_C8BIT), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB16), + .ptFillLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_XY_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB32), + .ptFillLike = NULL, + }, + }, +}; + + + + + + + + + + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_ONLY, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_ONLY_C8BIT), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_ONLY, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_ONLY_RGB16), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_ONLY_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_ONLY, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_ONLY_RGB32), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_ONLY_RGB32), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_X_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_C8BIT), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_X_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_RGB16), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_X_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_X_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_X_MIRROR_RGB32), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_X_MIRROR_RGB32), + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_C8BIT), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_RGB16), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_Y_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_Y_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_Y_MIRROR_RGB32), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_Y_MIRROR_RGB32), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_C8BIT), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_RGB16), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_FILL_XY_MIRROR_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_FILL_WITH_XY_MIRROR, + + .LowLevelIO = { + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_XY_MIRROR_RGB32), + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_XY_MIRROR_RGB32), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_C8BIT), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_C8BIT), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB16, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB16), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB16), + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB32, + }, + .Param = { + .bHasSource = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, + + .LowLevelIO = { + .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB32), + .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB32), + }, + }, +}; + + + +#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 + +#endif + diff --git a/package/Arm2D/__arm_2d_rotate.inc b/package/Arm2D/Library/Source/__arm_2d_transform.inc similarity index 61% rename from package/Arm2D/__arm_2d_rotate.inc rename to package/Arm2D/Library/Source/__arm_2d_transform.inc index 651149d9f..6a2878c28 100644 --- a/package/Arm2D/__arm_2d_rotate.inc +++ b/package/Arm2D/Library/Source/__arm_2d_transform.inc @@ -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 diff --git a/package/Arm2D/Library/Source/__arm_2d_transform_helium.c b/package/Arm2D/Library/Source/__arm_2d_transform_helium.c new file mode 100644 index 000000000..78b3d1122 --- /dev/null +++ b/package/Arm2D/Library/Source/__arm_2d_transform_helium.c @@ -0,0 +1,1440 @@ +/* + * 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_transform_helium.c + * Description: Acceleration extensions using Helium. + * + * $Date: 12. July 2022 + * $Revision: V.0.1.5 + * + * 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 + + + + +#include "__arm_2d_math_helium.h" +#include "__arm_2d_utils_helium.h" +#ifdef __cplusplus +extern "C" { +#endif + + + + +static +mve_pred16_t arm_2d_is_point_vec_inside_region_s16(const arm_2d_region_t * ptRegion, + const arm_2d_point_s16x8_t * ptPoint) +{ + mve_pred16_t p0 = vcmpgeq(ptPoint->X, ptRegion->tLocation.iX); + p0 = vcmpgeq_m(ptPoint->Y, ptRegion->tLocation.iY, p0); + p0 = vcmpltq_m(ptPoint->X, ptRegion->tLocation.iX + ptRegion->tSize.iWidth, p0); + p0 = vcmpltq_m(ptPoint->Y, ptRegion->tLocation.iY + ptRegion->tSize.iHeight, p0); + + return p0; +} + +static +mve_pred16_t arm_2d_is_point_vec_inside_region_s32(const arm_2d_region_t * ptRegion, + const arm_2d_point_s32x4_t * ptPoint) +{ + mve_pred16_t p0 = vcmpgeq_n_s32(ptPoint->X, ptRegion->tLocation.iX); + p0 = vcmpgeq_m_n_s32(ptPoint->Y, ptRegion->tLocation.iY, p0); + p0 = vcmpltq_m_n_s32(ptPoint->X, ptRegion->tLocation.iX + ptRegion->tSize.iWidth, p0); + p0 = vcmpltq_m_n_s32(ptPoint->Y, ptRegion->tLocation.iY + ptRegion->tSize.iHeight, p0); + + return p0; +} + + +/** + @brief return 3 vector of 16-bit channels (8-bit widened) taken from a memory reference + @param[in] pMem pointer to packed 8-bit channel + @param[out] R vector of 16-bit widened R channel + @param[out] G vector of 16-bit widened G channel + @param[out] B vector of 16-bit widened B channel + */ +void __arm_2d_unpack_rgb888_from_mem(const uint8_t * pMem, uint16x8_t * R, uint16x8_t * G, + uint16x8_t * B) +{ + uint16x8_t sg = vidupq_n_u16(0, 4); + + *R = vldrbq_gather_offset_u16(pMem, sg); + *G = vldrbq_gather_offset_u16(pMem + 1, sg); + *B = vldrbq_gather_offset_u16(pMem + 2, sg); +} + +/** + @brief interleave 3 x 16-bit widened vectors into 8-bit memory reference + (4th channel untouched) + @param[in] pMem pointer to packed 8-bit channel + @param[in] R vector of 16-bit widened R channel + @param[in] G vector of 16-bit widened G channel + @param[in] B vector of 16-bit widened B channel + */ +void __arm_2d_pack_rgb888_to_mem(uint8_t * pMem, uint16x8_t R, uint16x8_t G, uint16x8_t B) +{ + uint16x8_t sg = vidupq_n_u16(0, 4); + + vstrbq_scatter_offset_u16(pMem, sg, vminq(R, vdupq_n_u16(255))); + vstrbq_scatter_offset_u16(pMem + 1, sg, vminq(G, vdupq_n_u16(255))); + vstrbq_scatter_offset_u16(pMem + 2, sg, vminq(B, vdupq_n_u16(255))); + //vstrbq_scatter_offset_u16(pMem + 3, sg, vdupq_n_u16(0)); +} + + + +/* selector for 16-bit vector gather load */ +/* FAR version is been used when offsets involved are above 65535 16-bit words */ +#define FAR_OFFSET _FAR +#define NEAR_OFFSET + + +/** + unpack vectors of 8-bit widened pixels read from a input 2D coordinates if fits inside the region of + interest or alternative target pixel if content matches color mask + (vector of packed pixels & region of interest name implicit and fixed to respectively + vTarget and ptOrigValidRegion) + Update global predictor tracking region fit & color mask comparison. + */ +#define __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour, vTarget, predTail, \ + /* outputs */ \ + vPixVal, predGlb) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = \ + arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ + predGlb |= p; \ + /* prepare vector of point offsets */ \ + int16_t correctionOffset = vminvq_s16(INT16_MAX, vPoint.Y) - 1; \ + uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ + \ + /* base pointer update to compensate offset */ \ + uint8_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ + /* retrieve all point values */ \ + vPixVal = \ + vldrbq_gather_offset_z_u16(pOriginCorrected, ptOffs, predTail & p); \ + \ + /* combine 2 predicates set to true if point is in the region & values */ \ + /* different from color mask */ \ + p = vcmpneq_m_n_u16(vPixVal, MaskColour, p); \ + predGlb |= p; \ + vPixVal = vpselq_u16(vPixVal, vTarget, p); + + + + +/** + unpack vectors of pixels read from a input 2D coordinates if fits inside the region of + interest or alternative target pixel if content matches color mask + (vector of packed pixels & region of interest name implicit and fixed to respectively + vTarget and ptOrigValidRegion) + Update global predictor tracking region fit & color mask comparison. + */ + +#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + ptVal, predGlb) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = \ + arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ + \ + /* prepare vector of point offsets */ \ + uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; \ + /* retrieve all point values */ \ + ptVal = \ + vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail & p); \ + \ + /* combine 2 predicates set to true if point is in the region & values different from color mask */\ + p = vcmpneq_m_n_u16(ptVal, MaskColour, p); \ + predGlb |= p; \ + ptVal = vpselq_u16(ptVal, vTarget, p); + + + +#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + vPixValR, vPixValG, vPixValB, predGlb) \ + uint16x8_t ptVal; \ + \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK(vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, ptVal, predGlb) \ + /* expand channels */ \ + __arm_2d_rgb565_unpack_single_vec(ptVal, &vPixValR, &vPixValG, &vPixValB); + + + + + +/** + Same as above but use offset compensation during gather load. + unpack vectors of pixels read from a input 2D coordinates if fits inside the region of + interest or alternative target pixel if content matches color mask + (vector of packed pixels & region of interest name implicit and fixed to respectively + vTarget and ptOrigValidRegion) + Update global predictor tracking region fit & color mask comparison. + */ + +#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK_FAR( \ + /* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + ptVal, predGlb) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = \ + arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ + /* prepare vector of point offsets */ \ + int16_t correctionOffset = vminvq_s16(INT16_MAX, vPoint.Y) - 1; \ + uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ + \ + /* base pointer update to compensate offset */ \ + uint16_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ + /* retrieve all point values */ \ + ptVal = \ + vldrhq_gather_shifted_offset_z_u16(pOriginCorrected, ptOffs, predTail & p); \ + \ + /* combine 2 predicates set to true if point is in the region & values different from color mask */\ + p = vcmpneq_m_n_u16(ptVal, MaskColour, p); \ + predGlb |= p; \ + ptVal = vpselq_u16(ptVal, vTarget, p); + + +#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + vPixValR, vPixValG, vPixValB, predGlb) \ + uint16x8_t ptVal; \ + \ + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK_FAR(vecX, vecY, pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour, vTarget, predTail, ptVal, predGlb); \ + \ + /* expand channels */ \ + __arm_2d_rgb565_unpack_single_vec(ptVal, &vPixValR, &vPixValG, &vPixValB); + + +/** + unpack vectors of 32-bit pixels read from a input 2D coordinates if fits inside the region of + interest or alternative target pixel if content matches color mask + 16-bit vector processed in 2 parts because of 32-bit requirements, so handles 8 x 32-bit vectors + (vectors of packed pixels & region of interest name implicit and fixed to respectively + vTargetLo, vectorHi and ptOrigValidRegion) + Update 2 global predictors tracking region fit & color mask comparison for 1st and 2nd half. + */ + +#define __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_NOUNPK(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTargetLo, vTargetHi, \ + predTailLo, predTailHi, \ + /* outputs */ \ + pointLo, pointHi, predGlbLo, predGlbHi) \ + arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ + arm_2d_point_s32x4_t tPointLo, tPointHi; \ + ARM_ALIGN(8) uint32_t scratch32[32]; \ + int16_t *pscratch16 = (int16_t *) scratch32; \ + \ + /* split 16-bit point vector into 2 x 32-bit vectors */ \ + vst1q(pscratch16, vPoint.X); \ + tPointLo.X = vldrhq_s32(pscratch16); \ + tPointHi.X = vldrhq_s32(pscratch16 + 4); \ + \ + vst1q(pscratch16, vPoint.Y); \ + tPointLo.Y = vldrhq_s32(pscratch16); \ + tPointHi.Y = vldrhq_s32(pscratch16 + 4); \ + \ + /* 1st half */ \ + \ + /* set vector predicate if point is inside the region */ \ + mve_pred16_t p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); \ + /* prepare vector of point offsets */ \ + uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; \ + \ + /* retrieve all point values */ \ + pointLo = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailLo & p); \ + \ + /* combine 2 predicates set to true if point is in the region & values different from color mask */\ + p = vcmpneq_m_n_u32(pointLo, MaskColour, p); \ + predGlbLo |= p; \ + pointLo = vpselq_u32(pointLo, vTargetLo, p); \ + \ + \ + /* 2nd half */ \ + \ + /* set vector predicate if point is inside the region */ \ + p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); \ + /* prepare vector of point offsets */ \ + ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; \ + \ + /* retrieve all point values */ \ + pointHi = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailHi & p); \ + \ + /* combine 2 predicates set to true if point is in the region & values different from color mask */\ + p = vcmpneq_m_n_u32(pointHi, MaskColour, p); \ + predGlbHi |= p; \ + pointHi = vpselq_u32(pointHi, vTargetHi, p); + + +#define __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(/* inputs */ \ + vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTargetLo, vTargetHi, predTailLo, predTailHi, \ + /* outputs */ \ + vPixValR, vPixValG, vPixValB, predGlbLo, predGlbHi ) \ + \ + uint32x4_t pointLo, pointHi; \ + \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_NOUNPK(vecX, vecY, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTargetLo, vTargetHi, predTailLo, predTailHi, \ + pointLo, pointHi, predGlbLo, predGlbHi) \ + \ + /* expand channels */ \ + vst1q(scratch32, pointLo); \ + vst1q(scratch32 + 4, pointHi); \ + \ + __arm_2d_unpack_rgb888_from_mem((uint8_t *) scratch32, &vPixValR, &vPixValG, &vPixValB); + + + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + +#define __ARM2D_AVG_NEIGHBR_GRAY8_PIX(/* inputs */ \ + ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + predGlb, vAvgPixel) \ + \ + uint16x8_t ptVal8; \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + __typeof__ (vAvgPixel) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + /* \ + * accumulate / average over the 4 neigbouring pixels \ + */ \ + \ + /* Bottom Left averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour, vTarget, predTail, ptVal8, predGlb); \ + \ + __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vAreaBL); \ + } \ + \ + /* Bottom Right averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vaddq_n_s16(vXi, 1), vYi, pOrigin, \ + ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, ptVal8, predGlb); \ + \ + __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaBR); \ + } \ + \ + /* Top Left averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vXi, vaddq_n_s16(vYi, 1), pOrigin, \ + ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, ptVal8, predGlb); \ + \ + __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTL); \ + } \ + \ + /* Top Right averaging */ \ + { \ + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, ptVal8, predGlb); \ + \ + __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTR); \ + } + + + +#define __ARM2D_AVG_NEIGHBR_RGB565_PIX(/* inputs */ \ + far, ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTarget, predTail, \ + /* outputs */ \ + predGlb, vAvgPixelR, vAvgPixelG, vAvgPixelB) \ + \ + uint16x8_t R, G, B; \ + __typeof__ (vAvgPixelR) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + \ + /* \ + * accumulate / average over the 4 neigbouring pixels \ + */ \ + \ + /* Bottom Left averaging */ \ + { \ + ARM_CONNECT2(__ARM_2D_RGB565_GET_RGBVEC_FROM_POINT, far)(vXi, vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour,vTarget, predTail, R, G, B, predGlb); \ + \ + __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); \ + } \ + \ + /* Bottom Right averaging */ \ + { \ + ARM_CONNECT2(__ARM_2D_RGB565_GET_RGBVEC_FROM_POINT, far)(vaddq_n_s16(vXi, 1), vYi, \ + pOrigin, ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, R, G, B, predGlb); \ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); \ + } \ + \ + /* Top Left averaging */ \ + { \ + ARM_CONNECT2(__ARM_2D_RGB565_GET_RGBVEC_FROM_POINT, far)(vXi, vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, R, G, B, predGlb);\ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); \ + } \ + \ + /* Top Right averaging */ \ + { \ + ARM_CONNECT2(__ARM_2D_RGB565_GET_RGBVEC_FROM_POINT, far)(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), \ + pOrigin, ptOrigValidRegion, iOrigStride, MaskColour, vTarget, predTail, R, G, B, predGlb);\ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); \ + } + + +#define __ARM2D_AVG_NEIGHBR_CCCN888_PIX(/* inputs */ \ + ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, \ + /* outputs */ \ + predGlbLo, predGlbHi, \ + vAvgPixelR, vAvgPixelG, vAvgPixelB) \ + \ + uint16x8_t R, G, B; \ + __typeof__ (vAvgPixelR) vAreaTR, vAreaTL, vAreaBR, vAreaBL; \ + \ + __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, vAreaTR, vAreaTL, vAreaBR, vAreaBL); \ + \ + /* \ + * accumulate / average over the 4 neigbouring pixels \ + */ \ + \ + /* Bottom Left averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, \ + MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, R, G, B, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); \ + } \ + \ + /* Bottom Right averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, \ + R, G, B, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); \ + } \ + \ + /* Top Left averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), pOrigin, ptOrigValidRegion, \ + iOrigStride, MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, \ + R, G, B, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); \ + } \ + \ + /* Top Right averaging */ \ + { \ + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), pOrigin, \ + ptOrigValidRegion, iOrigStride, MaskColour, vTargetLo, vTargetHi, \ + predTailLow, predTailHigh, R, G, B, predGlbLo, predGlbHi); \ + \ + __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); \ + } + + +#endif + +#define __ARM_2D_8BIT_RGB_MIX(/* inputs / outputs */ \ + vR_InOut, vG_InOut, vB_InOut, \ + /* inputs */ \ + C1, \ + vR2, vG2, vB2, C2) \ + vR_InOut = vqaddq(vR_InOut * C1, vR2 * C2); \ + vR_InOut = vR_InOut >> 8; \ + \ + vG_InOut = vqaddq(vG_InOut * C1, vG2 * C2); \ + vG_InOut = vG_InOut >> 8; \ + \ + vB_InOut = vqaddq(vB_InOut * C1, vB2 * C2); \ + vB_InOut = vB_InOut >> 8; + + +/** + Alpha blending of a packed vector with 3 vectors of single R, G & B channels + */ + + +#define __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(/* inputs */ \ + hwOpacity, vPackedTarget, vAvgR, vAvgG, vAvgB, \ + /* output */ \ + vBlended) \ + uint16x8_t vTargetR, vTargetG, vTargetB; \ + \ + __arm_2d_rgb565_unpack_single_vec(vTarget, &vTargetR, &vTargetG, &vTargetB); \ + \ + uint16_t transp = 256 - hwOpacity; \ + /* merge */ \ + __ARM_2D_8BIT_RGB_MIX(vAvgR, vAvgG, vAvgB, hwOpacity, \ + vTargetR, vTargetG, vTargetB, transp); \ + \ + vBlended = __arm_2d_rgb565_pack_single_vec(vAvgR, vAvgG, vAvgB); + + + + +#if __ARM_2D_HAS_HELIUM_FLOAT__ \ + && !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ + +#define __CALIB 0.009f16 + +/** + Scale Gray8 channel + */ +#define __ARM_2D_SCALE_GRAY8VEC(/* output */ \ + vAvgPix, \ + /* inputs */ \ + vPtVal, vAreaScal) \ + vAvgPix = vAreaScal * vcvtq_f16_u16(vPtVal); + +/** + Scale Gray8 channel with accumulation + */ +#define __ARM_2D_SCALE_GRAY8VEC_ACC(/* input / output */ \ + vAvgPix, \ + /* inputs */ \ + vPtVal, vAreaScal) \ + vAvgPix += vAreaScal * vcvtq_f16_u16(vPtVal); + + +/** + Scale R, G & B channels + */ +#define __ARM_2D_SCALE_RGBVEC(/* outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + /* inputs */ \ + R, G, B, vScal) \ + vAvgPixelR = vScal * vcvtq_f16_u16(R); \ + vAvgPixelG = vScal * vcvtq_f16_u16(G); \ + vAvgPixelB = vScal * vcvtq_f16_u16(B); + + +/** + Scale R, G & B channels with accumulation + */ + +#define __ARM_2D_SCALE_RGBVEC_ACC(/* inputs / outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + /* inputs */ \ + R, G, B, vScal) \ + vAvgPixelR += vScal * vcvtq_f16_u16(R); \ + vAvgPixelG += vScal * vcvtq_f16_u16(G); \ + vAvgPixelB += vScal * vcvtq_f16_u16(B); + + + +#define __ARM_2D_GET_POINT_COORD(point) vcvtq_s16_f16(point) +#define __ARM_2D_CONVERT_TO_PIX_TYP(x) vcvtq_u16_f16(x) + +#define PIX_VEC_TYP float16x8_t +#define ARM_2D_POINT_VEC arm_2d_point_f16x8_t +#define AREA_UNITY 1.0f16 + + +static +bool __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 * center, + int32_t iOrigStride, + arm_2d_rot_linear_regr_t regrCoefs[] + ) +{ + int32_t iHeight = ptCopySize->iHeight; + int32_t iWidth = ptCopySize->iWidth; + float invHeight = iHeight > 1 ? 1.0f / (float) (iHeight - 1) : __LARGEINVF32; + arm_2d_point_s32x4_t vPointCornerI; + int32x4_t vCornerX = { 0, 1, 0, 1 }; + int32x4_t vCornerY = { 0, 0, 1, 1 }; + float cosAngle = arm_cos_f32(fAngle) * fScale; + float sinAngle = arm_sin_f32(fAngle) * fScale; + arm_2d_point_float_t centerf; + float slopeX, slopeY; + bool gatherLoadIdxOverflow = 0; + + + centerf.fX = (float) center->iX; + centerf.fY = (float) center->iY; + + vPointCornerI.X = vdupq_n_s32(pSrcPoint->iX + tOffset->iX); + vPointCornerI.X = vPointCornerI.X + vmulq_n_s32(vCornerX, (iWidth - 1)); + + vPointCornerI.Y = vdupq_n_s32(pSrcPoint->iY + tOffset->iY); + vPointCornerI.Y = vPointCornerI.Y + vmulq_n_s32(vCornerY, (iHeight - 1)); + + /* + Vector version of: + + int16_t iX = ptLocation->iX - ptCenter->iX; + int16_t iY = ptLocation->iY - ptCenter->iY; + + float cosAngle = arm_cos_f32(fAngle); + float sinAngle = arm_sin_f32(fAngle); + + ptOutBuffer->fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY); + ptOutBuffer->fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX); + */ + + arm_2d_point_f32x4_t vTmp, vPointCornerF; + + vTmp.X = vsubq_n_f32(vcvtq_f32_s32(vPointCornerI.X), centerf.fX); + vTmp.Y = vsubq_n_f32(vcvtq_f32_s32(vPointCornerI.Y), centerf.fY); + + vPointCornerF.X = vmulq_n_f32(vTmp.X, cosAngle) - vmulq_n_f32(vTmp.Y, sinAngle); + vPointCornerF.X = vaddq_n_f32(vPointCornerF.X, centerf.fX); + + vPointCornerF.Y = vmulq_n_f32(vTmp.X, sinAngle) + vmulq_n_f32(vTmp.Y, cosAngle); + vPointCornerF.Y = vaddq_n_f32(vPointCornerF.Y, centerf.fY); + + /* + Check whether rotated index offsets could exceed 16-bit limits + used in subsequent gather loads + This will occur for parts of large images (e.g. 320*200) + To avoid unconditional penalties for small/medium images, + returns a speculative overflow allowing to handle large offsets. + */ + float32_t maxY = vmaxnmvq(0.0f, vPointCornerF.Y); + + if((iOrigStride * maxY) > (float)(UINT16_MAX)) + gatherLoadIdxOverflow = true; + + + /* interpolation in Y direction for 1st elements column */ + slopeX = (vPointCornerF.X[2] - vPointCornerF.X[0]) * invHeight; + slopeY = (vPointCornerF.Y[2] - vPointCornerF.Y[0]) * invHeight; + + regrCoefs[0].slopeY = slopeY; + regrCoefs[0].slopeX = slopeX; + regrCoefs[0].interceptY = vPointCornerF.Y[0]; + regrCoefs[0].interceptX = vPointCornerF.X[0]; + + + /* interpolation in Y direction for the last elements column */ + slopeX = (vPointCornerF.X[3] - vPointCornerF.X[1]) * invHeight; + slopeY = (vPointCornerF.Y[3] - vPointCornerF.Y[1]) * invHeight; + + regrCoefs[1].slopeY = slopeY; + regrCoefs[1].slopeX = slopeX; + regrCoefs[1].interceptY = vPointCornerF.Y[1]; + regrCoefs[1].interceptX = vPointCornerF.X[1]; + + return gatherLoadIdxOverflow; +} + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + +#define __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, \ + vAreaTR, vAreaTL, vAreaBR, vAreaBL) \ + float16x8_t vOne = vdupq_n_f16(1.0f); \ + \ + vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); \ + vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); \ + \ + float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); \ + float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); \ + \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + vAreaTR = vWX * vWY; \ + vAreaTL = (vOne - vWX) * vWY; \ + vAreaBR = vWX * (vOne - vWY); \ + vAreaBL = (vOne - vWX) * (vOne - vWY); + +#endif + + +#else /* __ARM_2D_HAS_HELIUM_FLOAT__ && ! __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ */ + +/* extra calibration removed in fixed-point code since offset is lower than Q9.6 representation */ + +#define ONE_BY_2PI_Q31 341782637.0f +#define ONE_Q16 UINT16_MAX +#define ARSHIFT(x, shift) (shift > 0 ? x >> shift : x << (-shift)) +#define TO_Q16(x) ((x) << 16) +#define GET_Q6INT(x) ((x) >> 6) +#define SET_Q6INT(x) ((x) << 6) + +/** + Scale Gray8 channel + */ +#define __ARM_2D_SCALE_GRAY8VEC(/* output */ \ + vAvgPix, \ + /* inputs */ \ + vPtVal, vAreaScal) \ + vAvgPix = vrmulhq_u16(vAreaScal, vPtVal); + +/** + Scale Gray8 channel with accumulation + */ +#define __ARM_2D_SCALE_GRAY8VEC_ACC(/* input / output */ \ + vAvgPix, \ + /* inputs */ \ + vPtVal, vAreaScal) \ + vAvgPix = vqaddq(vAvgPix, vrmulhq_u16(vAreaScal, vPtVal)); + + +/** + Scale R, G & B channels + */ +#define __ARM_2D_SCALE_RGBVEC(/* outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + /* inputs */ \ + R, G, B, vScal) \ + vAvgPixelR = vrmulhq_u16(vScal, R); \ + vAvgPixelG = vrmulhq_u16(vScal, G); \ + vAvgPixelB = vrmulhq_u16(vScal, B); + +/** + Scale R, G & B channels with accumulation + */ +#define __ARM_2D_SCALE_RGBVEC_ACC(/* inputs / outputs */ \ + vAvgPixelR, vAvgPixelG, vAvgPixelB, \ + /* inputs */ \ + R, G, B, vScal) \ + vAvgPixelR = vqaddq(vAvgPixelR, vrmulhq_u16(vScal, R)); \ + vAvgPixelG = vqaddq(vAvgPixelG, vrmulhq_u16(vScal, G)); \ + vAvgPixelB = vqaddq(vAvgPixelB, vrmulhq_u16(vScal, B)); + + + +#define __ARM_2D_GET_POINT_COORD(point) GET_Q6INT(point) +#define __ARM_2D_CONVERT_TO_PIX_TYP(x) (x) + +#define PIX_VEC_TYP uint16x8_t +#define ARM_2D_POINT_VEC arm_2d_point_s16x8_t +#define AREA_UNITY vdupq_n_u16(ONE_Q16) + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + + +#define __ARM2D_GET_NEIGHBR_PIX_AREAS(vXi, vYi, ptPoint, \ + vAreaTR, vAreaTL, vAreaBR, vAreaBL) \ + int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); \ + \ + /*vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); */ \ + /*vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); */ \ + \ + int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); \ + int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); \ + \ + /* combination of Bottom / Top & Left / Right areas contributions */ \ + vAreaTR = vmulq_u16(vWX, vWY); \ + vAreaTL = vmulq_u16((vOne - vWX), vWY); \ + vAreaBR = vmulq_u16(vWX, (vOne - vWY)); \ + vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); \ + \ + /* Q16 conversion */ \ + vAreaTR = vqshlq_n_u16(vAreaTR, 4); \ + vAreaTL = vqshlq_n_u16(vAreaTL, 4); \ + vAreaBR = vqshlq_n_u16(vAreaBR, 4); \ + vAreaBL = vqshlq_n_u16(vAreaBL, 4); + + +#endif + +static +bool __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 * center, + int32_t iOrigStride, + arm_2d_rot_linear_regr_t regrCoefs[] + ) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + q31_t invHeightFx = iHeight > 1 ? INT32_MAX / (iHeight - 1) : INT32_MAX; + int32_t AngleFx = lroundf(fAngle * ONE_BY_2PI_Q31); + int32_t ScaleFx = (int32_t)((float)fScale * (float)TO_Q16(1)); + q31_t cosAngleFx = MULTFX(arm_cos_q31(AngleFx), ScaleFx); + q31_t sinAngleFx = MULTFX(arm_sin_q31(AngleFx), ScaleFx); + 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; + bool gatherLoadIdxOverflow = 0; + + /* 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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[0][0].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[1][0].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[1][1].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[0][1].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(iYQ16, sinAngleFx)); + + /* + Check whether rotated index offsets could exceed 16-bit limits + used in subsequent gather loads + This will occur for parts of large images (e.g. 320*200) + To avoid unconditional penalties for small/medium images, + returns a speculative overflow allowing to handle large offsets. + */ + int32_t maxY = MAX(MAX + (MAX(tPointCornerFx[0][0].Y, tPointCornerFx[0][1].Y), + tPointCornerFx[1][0].Y), + tPointCornerFx[1][1].Y); + + if(MULTFX(TO_Q16(iOrigStride), maxY) > UINT16_MAX) + gatherLoadIdxOverflow = true; + + + /* 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; + + return gatherLoadIdxOverflow; +} +#endif // __ARM_2D_HAS_HELIUM_FLOAT__ + + + +static +void __MVE_WRAPPER( __arm_2d_impl_gray8_get_pixel_colour)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint8_t * pOrigin, + int16_t iOrigStride, + uint8_t * pTarget, uint8_t MaskColour, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vldrbq_u16(pTarget); + + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + /* accumulated pixel vectors */ + uint16x8_t vDstPixel; + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixel; + + __ARM2D_AVG_NEIGHBR_GRAY8_PIX(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, predGlb, vAvgPixel); + + vDstPixel = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixel); + + /* saturate to 8-bit */ + vDstPixel = vminq(vDstPixel, vdupq_n_u16(255)); + } +#else + { + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, + vDstPixel, predGlb); + } +#endif + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vDstPixel, vTarget, predGlb); + + vstrbq_p_u16(pTarget, vTarget, predTail); +} + + + + +static +void __MVE_WRAPPER( __arm_2d_impl_gray8_get_pixel_colour_with_alpha)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint8_t * pOrigin, + int16_t iOrigStride, + uint8_t * pTarget, + uint8_t MaskColour, + uint_fast16_t hwOpacity, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vldrbq_u16(pTarget); + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + uint16x8_t vDstPixel; + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixel; + + __ARM2D_AVG_NEIGHBR_GRAY8_PIX(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, predGlb, vAvgPixel); + + vDstPixel = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixel); + } +#else + { + __ARM_2D_GRAY8_GET_PIXVEC_FROM_POINT_MASK_CLR_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, + vDstPixel, predGlb); + } +#endif + + /* blending */ + uint16_t hwTransparency = 256 - hwOpacity; + uint16x8_t vBlended = + vqaddq(vDstPixel * (uint16_t) hwOpacity, vTarget * hwTransparency) >> 8; + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vBlended, vTarget, predGlb); + + vstrbq_p_u16(pTarget, vTarget, predTail); +} + + +static +void __MVE_WRAPPER( __arm_2d_impl_rgb565_get_pixel_colour)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint16_t * pOrigin, + int16_t iOrigStride, + uint16_t * pTarget, uint16_t MaskColour, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vld1q(pTarget); + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + uint16x8_t vDstPixel; + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + __ARM2D_AVG_NEIGHBR_RGB565_PIX(NEAR_OFFSET, ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, predGlb, vAvgPixelR, + vAvgPixelG, vAvgPixelB); + + /* pack */ + vDstPixel = __arm_2d_rgb565_pack_single_vec(__ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR), + __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG), + __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB)); + } +#else + { + + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, vDstPixel, predGlb ); + } +#endif + + vTarget = vpselq_u16(vDstPixel, vTarget, predGlb); + + /* update target pixels */ + vst1q_p(pTarget, vTarget, predTail); +} + + + + +static +void __MVE_WRAPPER( __arm_2d_impl_rgb565_get_pixel_colour_offs_compensated)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint16_t * pOrigin, + int16_t iOrigStride, + uint16_t * pTarget, uint16_t MaskColour, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vld1q(pTarget); + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + uint16x8_t vDstPixel; + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + __ARM2D_AVG_NEIGHBR_RGB565_PIX(FAR_OFFSET, ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, predGlb, vAvgPixelR, + vAvgPixelG, vAvgPixelB); + + /* pack */ + vDstPixel = __arm_2d_rgb565_pack_single_vec(__ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR), + __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG), + __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB)); + } +#else + { + + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_NOUNPK_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, vDstPixel, predGlb); + } +#endif + + vTarget = vpselq_u16(vDstPixel, vTarget, predGlb); + + /* update target pixels */ + vst1q_p(pTarget, vTarget, predTail); +} + + + +static +void __MVE_WRAPPER( __arm_2d_impl_rgb565_get_pixel_colour_with_alpha)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint16_t * pOrigin, + int16_t iOrigStride, + uint16_t * pTarget, + uint16_t MaskColour, + uint_fast16_t hwOpacity, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vld1q(pTarget); + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + uint16x8_t vAvgR, vAvgG, vAvgB; + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + __ARM2D_AVG_NEIGHBR_RGB565_PIX(NEAR_OFFSET, ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, predGlb, vAvgPixelR, + vAvgPixelG, vAvgPixelB); + + vAvgR = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR); + vAvgG = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG); + vAvgB = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB); + } +#else + { + + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, vAvgR, vAvgG, vAvgB, predGlb ); + } +#endif + /* blending */ + + uint16x8_t vBlended; + + __ARM_2D_BLEND_RGB565_TARGET_RGBVEC((uint16_t) hwOpacity, vTarget, vAvgR, vAvgG, vAvgB, + vBlended); + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vBlended, vTarget, predGlb); + + vst1q_p(pTarget, vTarget, predTail); +} + + +static +void __MVE_WRAPPER( __arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint16_t * pOrigin, + int16_t iOrigStride, + uint16_t * pTarget, + uint16_t MaskColour, + uint_fast16_t hwOpacity, uint32_t elts) +{ + mve_pred16_t predTail = vctp16q(elts); + uint16x8_t vTarget = vld1q(pTarget); + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + uint16x8_t vAvgR, vAvgG, vAvgB; + /* predicate accumulator */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlb = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + __ARM2D_AVG_NEIGHBR_RGB565_PIX(FAR_OFFSET, ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, + iOrigStride, MaskColour, vTarget, predTail, predGlb, vAvgPixelR, + vAvgPixelG, vAvgPixelB); + + vAvgR = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR); + vAvgG = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG); + vAvgB = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB); + } +#else + { + __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTarget, predTail, vAvgR, vAvgG, vAvgB, predGlb ); + } +#endif + /* blending */ + + uint16x8_t vBlended; + + __ARM_2D_BLEND_RGB565_TARGET_RGBVEC((uint16_t) hwOpacity, vTarget, vAvgR, vAvgG, vAvgB, + vBlended); + + /* select between target pixel, averaged pixed */ + vTarget = vpselq_u16(vBlended, vTarget, predGlb); + + vst1q_p(pTarget, vTarget, predTail); +} + + + + +static +void __MVE_WRAPPER( __arm_2d_impl_cccn888_get_pixel_colour)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint32_t * pOrigin, + int16_t iOrigStride, + uint32_t * pTarget, uint32_t MaskColour, int16_t elts) +{ + + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + uint32x4_t vTargetLo = vld1q(pTarget); + uint32x4_t vTargetHi = vld1q(pTarget + 4); + mve_pred16_t predTailLow = vctp32q(elts); + mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; + + /* predicate accumulators */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlbLo = 0, predGlbHi = 0; + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + + __ARM2D_AVG_NEIGHBR_CCCN888_PIX(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, + predGlbLo, predGlbHi, + vAvgPixelR, vAvgPixelG, vAvgPixelB); + + { + ARM_ALIGN(8) uint32_t scratch32[32]; + /* pack */ + __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR), + __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG), __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB)); + + uint32x4_t TempPixel = vld1q(scratch32); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); + + vst1q_p(pTarget, TempPixel, predTailLow); + + TempPixel = vld1q(scratch32 + 4); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); + + vst1q_p(pTarget + 4, TempPixel, predTailHigh); + } + } +#else + { + uint32x4_t pointLo, pointHi; + + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT_NOUNPK(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, pointLo, pointHi, predGlbLo, predGlbHi); + + uint32x4_t vPixel = vpselq_u32(pointLo, vTargetLo, predGlbLo); + + vst1q_p(pTarget, vPixel, predTailLow); + + vPixel = vpselq_u32(pointHi, vTargetHi, predGlbHi); + + vst1q_p(pTarget + 4, vPixel, predTailHigh); + } +#endif +} + + + +static +void __MVE_WRAPPER( __arm_2d_impl_cccn888_get_pixel_colour_with_alpha)(ARM_2D_POINT_VEC * ptPoint, + arm_2d_region_t * ptOrigValidRegion, + uint32_t * pOrigin, + int16_t iOrigStride, + uint32_t * pTarget, + uint32_t MaskColour, + uint_fast16_t hwOpacity, int16_t elts) +{ + int16x8_t vXi = __ARM_2D_GET_POINT_COORD(ptPoint->X); + int16x8_t vYi = __ARM_2D_GET_POINT_COORD(ptPoint->Y); + + uint32x4_t vTargetLo = vld1q(pTarget); + uint32x4_t vTargetHi = vld1q(pTarget + 4); + mve_pred16_t predTailLow = vctp32q(elts); + mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; + uint16x8_t vAvgR, vAvgG, vAvgB; + + + /* predicate accumulators */ + /* tracks all predications conditions for selecting final */ + /* averaged pixed / target pixel */ + mve_pred16_t predGlbLo = 0, predGlbHi = 0; + + +#if defined(__ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__) && __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + { + /* accumulated pixel vectors */ + PIX_VEC_TYP vAvgPixelR, vAvgPixelG, vAvgPixelB; + + __ARM2D_AVG_NEIGHBR_CCCN888_PIX(ptPoint, vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, + MaskColour, vTargetLo, vTargetHi, predTailLow, predTailHigh, + predGlbLo, predGlbHi, + vAvgPixelR, vAvgPixelG, + vAvgPixelB); + vAvgR = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelR); + vAvgG = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelG); + vAvgB = __ARM_2D_CONVERT_TO_PIX_TYP(vAvgPixelB); + } +#else + { + uint16x8_t R, G, B; + + __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, pOrigin, ptOrigValidRegion, iOrigStride, MaskColour, vTargetLo, + vTargetHi, predTailLow, predTailHigh, R, G, B, predGlbLo, predGlbHi); + + vAvgR = R; + vAvgG = G; + vAvgB = B; + } +#endif + + + /* alpha blending */ + uint16x8_t vTargetR, vTargetG, vTargetB; + uint16_t transp = 256 - hwOpacity; + ARM_ALIGN(8) uint32_t scratch32[32]; + + __arm_2d_unpack_rgb888_from_mem((const uint8_t *) pTarget, &vTargetR, &vTargetG, &vTargetB); + + /* merge */ + __ARM_2D_8BIT_RGB_MIX(vAvgR, vAvgG, vAvgB, (uint16_t) hwOpacity, + vTargetR, vTargetG, vTargetB, transp); + + /* pack */ + __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vAvgR, vAvgG, vAvgB); + + uint32x4_t TempPixel = vld1q(scratch32); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); + + vst1q_p(pTarget, TempPixel, predTailLow); + + TempPixel = vld1q(scratch32 + 4); + + /* select between target pixel, averaged pixed */ + TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); + + vst1q_p(pTarget + 4, TempPixel, predTailHigh); +} + + +/* + * Src mask variants expansion + * + * - transform_with_src_chn_mask_and_opacity + * - transform_with_src_mask_and_opacity + * - transform_with_src_chn_mask + * - transform_with_src_mask + */ + + +#define __API_INT_TYPE_BIT_NUM 8 +#define __API_COLOUR ARM_2D_M_COLOUR_GRAY8 +#define __API_COLOUR_NAME gray8 + + +#include "__arm_2d_transform_helium.inc" + +#define __API_INT_TYPE_BIT_NUM 16 +#define __API_COLOUR ARM_2D_M_COLOUR_RGB565 +#define __API_COLOUR_NAME rgb565 + +#include "__arm_2d_transform_helium.inc" + +#define __API_INT_TYPE_BIT_NUM 32 +#define __API_COLOUR ARM_2D_M_COLOUR_CCCN888 +#define __API_COLOUR_NAME cccn888 + +#include "__arm_2d_transform_helium.inc" + + +#ifdef __cplusplus +} +#endif + +#endif // __ARM_2D_HAS_HELIUM__ + +#endif // __ARM_2D_COMPILATION_UNIT diff --git a/package/Arm2D/__arm_2d_rotate_helium.inc b/package/Arm2D/Library/Source/__arm_2d_transform_helium.inc similarity index 79% rename from package/Arm2D/__arm_2d_rotate_helium.inc rename to package/Arm2D/Library/Source/__arm_2d_transform_helium.inc index 019ca6863..ed4094f20 100644 --- a/package/Arm2D/__arm_2d_rotate_helium.inc +++ b/package/Arm2D/Library/Source/__arm_2d_transform_helium.inc @@ -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 diff --git a/package/Arm2D/Library/Source/arm_2d.c b/package/Arm2D/Library/Source/arm_2d.c new file mode 100644 index 000000000..c239faceb --- /dev/null +++ b/package/Arm2D/Library/Source/arm_2d.c @@ -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 diff --git a/package/Arm2D/arm_2d_alpha_blending.c b/package/Arm2D/Library/Source/arm_2d_alpha_blending.c similarity index 73% rename from package/Arm2D/arm_2d_alpha_blending.c rename to package/Arm2D/Library/Source/arm_2d_alpha_blending.c index 4268df828..a32bd8931 100644 --- a/package/Arm2D/arm_2d_alpha_blending.c +++ b/package/Arm2D/Library/Source/arm_2d_alpha_blending.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2020 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.c * Description: APIs for various alpha related operations * - * $Date: 03. Oct 2021 - * $Revision: V.0.9.1 + * $Date: 25. May 2022 + * $Revision: V.1.0.3 * * 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" @@ -59,7 +58,7 @@ extern "C" { # pragma clang diagnostic ignored "-Wmissing-prototypes" # pragma clang diagnostic ignored "-Wreserved-identifier" # pragma clang diagnostic ignored "-Wsign-compare" - +# pragma clang diagnostic ignored "-Wdeclaration-after-statement" #elif defined(__IS_COMPILER_ARM_COMPILER_5__) # pragma diag_suppress 174,177,188,68,513,144 #endif @@ -207,7 +206,7 @@ void __arm_2d_impl_rgb565_alpha_blending_direct( const uint16_t *phwBackground, uint16_t *phwDestination, uint32_t wPixelCount, - uint_fast8_t chRatio); + uint_fast16_t hwRatio); extern void __arm_2d_impl_cccn888_alpha_blending_direct( @@ -215,72 +214,12 @@ void __arm_2d_impl_cccn888_alpha_blending_direct( const uint32_t *__RESTRICT pwBackground, uint32_t *pwDestination, uint32_t wPixelCount, - uint_fast8_t chRatio); + uint_fast16_t hwRatio); /*----------------------------------------------------------------------------* * Copy tile to destination with specified masks * *----------------------------------------------------------------------------*/ - -static -arm_2d_err_t __arm_2dp_tile_copy_with_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) -{ - if (NULL != ptSrcMask) { - //! valid source mask tile - if (0 == ptSrcMask->bHasEnforcedColour) { - return ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptSrcMask->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptSrcMask->tColourInfo.chScheme)) { - return ARM_2D_ERR_INVALID_PARAM; - } - - arm_2d_cmp_t tCompare = arm_2d_tile_shape_compare(ptSrcMask, ptSource); - - /*! \note the source mask tile should be bigger than or equals to the - *! source tile - */ - if (ARM_2D_CMP_SMALLER == tCompare) { - - return ARM_2D_ERR_INVALID_PARAM; - } - } - - if (NULL != ptDesMask) { - //! valid target mask tile - if (0 == ptDesMask->bHasEnforcedColour) { - return ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptDesMask->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptDesMask->tColourInfo.chScheme)) { - return ARM_2D_ERR_INVALID_PARAM; - } - - /*! \note the target mask tile should be bigger than or equals to the - *! target tile in width - */ - if (ARM_2D_CMP_SMALLER == arm_2d_tile_width_compare(ptDesMask, ptTarget)) { - return ARM_2D_ERR_INVALID_PARAM; - } - - if (ARM_2D_CMP_SMALLER == arm_2d_tile_height_compare(ptDesMask, ptTarget)) { - if (1 != ptDesMask->tRegion.tSize.iHeight) { - return ARM_2D_ERR_INVALID_PARAM; - } else if (ARM_2D_CHANNEL_8in32 == ptDesMask->tColourInfo.chScheme) { - /*! does NOT support a target mask consists of 1 horizontal line - *! in the special colour 'ARM_2D_CHANNEL_8in32'. - */ - return ARM_2D_ERR_INVALID_PARAM; - } - } - - } - - return ARM_2D_ERR_NONE; -} ARM_NONNULL(2,3,4,5) arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_masks( @@ -299,7 +238,7 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_masks( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -342,7 +281,7 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_masks( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -386,7 +325,7 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_masks( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -432,7 +371,7 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_src_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, NULL, wMode); if (tErr < 0) { @@ -473,7 +412,7 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_src_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, NULL, wMode); if (tErr < 0) { @@ -515,7 +454,7 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_src_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, ptSrcMask, ptTarget, NULL, wMode); if (tErr < 0) { @@ -560,7 +499,7 @@ arm_fsm_rt_t arm_2dp_gray8_tile_copy_with_des_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, NULL, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -601,7 +540,7 @@ arm_fsm_rt_t arm_2dp_rgb565_tile_copy_with_des_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, NULL, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -643,7 +582,7 @@ arm_fsm_rt_t arm_2dp_cccn888_tile_copy_with_des_mask( ARM_2D_IMPL(arm_2d_op_cp_msk_t, ptOP); - arm_2d_err_t tErr = __arm_2dp_tile_copy_with_mask_validate( + arm_2d_err_t tErr = __arm_mask_validate( ptSource, NULL, ptTarget, ptDesMask, wMode); if (tErr < 0) { @@ -766,25 +705,14 @@ arm_fsm_rt_t __arm_2d_gray8_sw_alpha_blending(__arm_2d_sub_task_t *ptTask) ARM_2D_IMPL(arm_2d_op_alpha_t, ptTask->ptOP) assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); - -#if 0 // todo: might implement this in the future - if ( (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tTarget.iStride) - && (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tCopySize.iWidth)) { - - //! direct blending - __arm_2d_impl_gray8_alpha_blending_direct( - ptTask->Param.tCopy.tSource.pBuffer, + if (255 == this.chRatio) { + __arm_2d_impl_c8bit_copy( ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tCopySize.iHeight - * ptTask->Param.tCopy.tCopySize.iWidth, - this.chRatio); - } else -#endif - { - __arm_2d_impl_gray8_alpha_blending( + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize); + } else { + __arm_2d_impl_gray8_alpha_blending( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, @@ -792,7 +720,7 @@ arm_fsm_rt_t __arm_2d_gray8_sw_alpha_blending(__arm_2d_sub_task_t *ptTask) &(ptTask->Param.tCopy.tCopySize), this.chRatio); } - + return arm_fsm_rt_cpl; } @@ -800,31 +728,23 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_alpha_blending(__arm_2d_sub_task_t *ptTask) { ARM_2D_IMPL(arm_2d_op_alpha_t, ptTask->ptOP) assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); - - if ( (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tTarget.iStride) - && (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tCopySize.iWidth)) { - - //! direct blending - __arm_2d_impl_rgb565_alpha_blending_direct( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tCopySize.iHeight - * ptTask->Param.tCopy.tCopySize.iWidth, - this.chRatio); - } else { - __arm_2d_impl_rgb565_alpha_blending( - ptTask->Param.tCopy.tSource.pBuffer, + if (255 == this.chRatio) { + __arm_2d_impl_rgb16_copy( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, ptTask->Param.tCopy.tTarget.iStride, - &(ptTask->Param.tCopy.tCopySize), - this.chRatio); + &ptTask->Param.tCopy.tCopySize); + } else { + __arm_2d_impl_rgb565_alpha_blending( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &(ptTask->Param.tCopy.tCopySize), + this.chRatio); } - + return arm_fsm_rt_cpl; } @@ -833,28 +753,21 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_alpha_blending(__arm_2d_sub_task_t *ptTask) { ARM_2D_IMPL(arm_2d_op_alpha_t, ptTask->ptOP) assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - if ( (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tTarget.iStride) - && (ptTask->Param.tCopy.tSource.iStride - == ptTask->Param.tCopy.tCopySize.iWidth)) { - - //! direct blending - __arm_2d_impl_cccn888_alpha_blending_direct( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tCopySize.iHeight - * ptTask->Param.tCopy.tCopySize.iWidth, - this.chRatio); - } else { - __arm_2d_impl_cccn888_alpha_blending( - ptTask->Param.tCopy.tSource.pBuffer, + + if (255 == this.chRatio) { + __arm_2d_impl_rgb32_copy( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, ptTask->Param.tCopy.tTarget.iStride, - &(ptTask->Param.tCopy.tCopySize), - this.chRatio); + &ptTask->Param.tCopy.tCopySize); + } else { + __arm_2d_impl_cccn888_alpha_blending( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &(ptTask->Param.tCopy.tCopySize), + this.chRatio); } return arm_fsm_rt_cpl; @@ -869,7 +782,7 @@ arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_opacity( arm_2d_op_fill_cl_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, - uint8_t chColour, + arm_2d_color_gray8_t tColour, uint_fast8_t chRatio) { assert(NULL != ptTarget); @@ -886,7 +799,7 @@ arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_opacity( this.Target.ptTile = ptTarget; this.Target.ptRegion = ptRegion; - this.chColour = chColour; + this.chColour = tColour.tValue; this.chRatio = chRatio; return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); @@ -925,7 +838,7 @@ arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_opacity( arm_2d_op_fill_cl_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, - arm_2d_color_rgb888_t tColour, + arm_2d_color_cccn888_t tColour, uint_fast8_t chRatio) { assert(NULL != ptTarget); @@ -953,14 +866,21 @@ arm_fsm_rt_t __arm_2d_gray8_sw_colour_filling_with_opacity( { ARM_2D_IMPL(arm_2d_op_fill_cl_opc_t, ptTask->ptOP) assert(ARM_2D_COLOUR_GRAY8 == OP_CORE.ptOp->Info.Colour.chScheme); - - __arm_2d_impl_gray8_colour_filling_with_opacity( - ptTask->Param.tTileProcess.pBuffer, - ptTask->Param.tTileProcess.iStride, - &(ptTask->Param.tTileProcess.tValidRegion.tSize), - this.chColour, - this.chRatio); + if (255 == this.chRatio) { + __arm_2d_impl_c8bit_colour_filling( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.chColour ); + } else { + __arm_2d_impl_gray8_colour_filling_with_opacity( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.chColour, + this.chRatio); + } return arm_fsm_rt_cpl; } @@ -969,14 +889,22 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_colour_filling_with_opacity( { ARM_2D_IMPL(arm_2d_op_fill_cl_opc_t, ptTask->ptOP) assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); - - __arm_2d_impl_rgb565_colour_filling_with_opacity( - ptTask->Param.tTileProcess.pBuffer, - ptTask->Param.tTileProcess.iStride, - &(ptTask->Param.tTileProcess.tValidRegion.tSize), - this.hwColour, - this.chRatio); + if (255 == this.chRatio) { + __arm_2d_impl_rgb16_colour_filling( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.hwColour ); + } else { + __arm_2d_impl_rgb565_colour_filling_with_opacity( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.hwColour, + this.chRatio); + } + return arm_fsm_rt_cpl; } @@ -985,14 +913,22 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_opacity( { ARM_2D_IMPL(arm_2d_op_fill_cl_opc_t, ptTask->ptOP) assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - __arm_2d_impl_cccn888_colour_filling_with_opacity( - ptTask->Param.tTileProcess.pBuffer, - ptTask->Param.tTileProcess.iStride, - &(ptTask->Param.tTileProcess.tValidRegion.tSize), - this.wColour, - this.chRatio); + if (255 == this.chRatio) { + __arm_2d_impl_rgb32_colour_filling( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.wColour ); + } else { + __arm_2d_impl_cccn888_colour_filling_with_opacity( + ptTask->Param.tTileProcess.pBuffer, + ptTask->Param.tTileProcess.iStride, + &(ptTask->Param.tTileProcess.tValidRegion.tSize), + this.wColour, + this.chRatio); + } + return arm_fsm_rt_cpl; } @@ -1001,51 +937,46 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_opacity( * Fill tile with a specified colour and an alpha mask * *----------------------------------------------------------------------------*/ -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_mask( arm_2d_op_fill_cl_msk_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - uint8_t chColour) + arm_2d_color_gray8_t tColour) { assert(NULL != ptTarget); + assert(NULL != ptAlpha); + + ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); - if (NULL == ptAlpha) { - return arm_2dp_c8bit_fill_colour( (arm_2d_op_fill_cl_t *)ptOP, - ptTarget, - ptRegion, - chColour); - } else{ - ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); - - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_GRAY8; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.chColour = chColour; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_GRAY8; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.chColour = tColour.tValue; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask( arm_2d_op_fill_cl_msk_t *ptOP, const arm_2d_tile_t *ptTarget, @@ -1054,38 +985,34 @@ arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask( arm_2d_color_rgb565_t tColour) { assert(NULL != ptTarget); - if (NULL == ptAlpha) { - return arm_2dp_rgb16_fill_colour( (arm_2d_op_fill_cl_t *)ptOP, - ptTarget, - ptRegion, - tColour.tValue); - } else{ - ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); + assert(NULL != ptAlpha); - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } + ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_RGB565; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.hwColour = tColour.tValue; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_RGB565; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.hwColour = tColour.tValue; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } ARM_NONNULL(2,4) @@ -1099,39 +1026,32 @@ arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask( assert(NULL != ptTarget); assert(NULL != ptAlpha); - if (NULL == ptAlpha) { - return arm_2dp_rgb32_fill_colour( (arm_2d_op_fill_cl_t *)ptOP, - ptTarget, - ptRegion, - tColour.tValue); - } else{ - - ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); + ARM_2D_IMPL(arm_2d_op_fill_cl_msk_t, ptOP); - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_CCCN888; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.wColour = tColour.tValue; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_CCCN888; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.wColour = tColour.tValue; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } @@ -1213,7 +1133,7 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_mask( ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile ptTask->Param.tCopy.tSource.iStride, //!< alpha tile &(ptTask->Param.tCopy.tCopySize), - this.hwColour); + this.wColour); #endif } else { __arm_2d_impl_cccn888_colour_filling_mask( @@ -1222,7 +1142,7 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_mask( ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile ptTask->Param.tCopy.tSource.iStride, //!< alpha tile &(ptTask->Param.tCopy.tCopySize), - this.hwColour); + this.wColour); } return arm_fsm_rt_cpl; @@ -1234,55 +1154,49 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_mask( * Fill tile with a specified colour, an alpha mask and a specified opacity * *----------------------------------------------------------------------------*/ -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_gray8_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - uint8_t chColour, + arm_2d_color_gray8_t tColour, uint8_t chOpacity) { assert(NULL != ptTarget); - if (NULL == ptAlpha) { - return arm_2dp_gray8_fill_colour_with_opacity( - (arm_2d_op_fill_cl_opc_t *)ptOP, - ptTarget, - ptRegion, - chColour, - chOpacity); - } else{ + assert(NULL != ptAlpha); + - ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); + ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_GRAY8; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.chColour = chColour; - this.chOpacity = chOpacity; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_GRAY8; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.chColour = tColour.tValue; + this.chRatio = chOpacity; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, @@ -1292,90 +1206,77 @@ arm_fsm_rt_t arm_2dp_rgb565_fill_colour_with_mask_and_opacity( uint8_t chOpacity) { assert(NULL != ptTarget); - if (NULL == ptAlpha) { - return arm_2dp_rgb565_fill_colour_with_opacity( - (arm_2d_op_fill_cl_opc_t *)ptOP, - ptTarget, - ptRegion, - tColour, - chOpacity); - } else{ + assert(NULL != ptAlpha); + - ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); + ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_RGB565; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.hwColour = tColour.tValue; - this.chOpacity = chOpacity; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_RGB565; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.hwColour = tColour.tValue; + this.chRatio = chOpacity; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } -ARM_NONNULL(2) +ARM_NONNULL(2,4) arm_fsm_rt_t arm_2dp_cccn888_fill_colour_with_mask_and_opacity( arm_2d_op_alpha_fill_cl_msk_opc_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, const arm_2d_tile_t *ptAlpha, - arm_2d_color_rgb888_t tColour, + arm_2d_color_cccn888_t tColour, uint8_t chOpacity) { assert(NULL != ptTarget); + assert(NULL != ptAlpha); - if (NULL == ptAlpha) { - return arm_2dp_cccn888_fill_colour_with_opacity( - (arm_2d_op_fill_cl_opc_t *)ptOP, - ptTarget, - ptRegion, - tColour, - chOpacity); - } else{ - ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); + ARM_2D_IMPL(arm_2d_op_alpha_fill_cl_msk_opc_t, ptOP); - //! valid alpha mask tile - if (0 == ptAlpha->bHasEnforcedColour) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) - && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { - return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; - } - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_CCCN888; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Mask.ptTile = ptAlpha; - this.wMode = 0; - this.wColour = tColour.tValue; - this.chOpacity = chOpacity; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + //! valid alpha mask tile + if (0 == ptAlpha->bHasEnforcedColour) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; + } else if ( (ARM_2D_COLOUR_SZ_8BIT != ptAlpha->tColourInfo.u3ColourSZ) + && (ARM_2D_CHANNEL_8in32 != ptAlpha->tColourInfo.chScheme)) { + return (arm_fsm_rt_t)ARM_2D_ERR_INVALID_PARAM; } + + if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { + return arm_fsm_rt_on_going; + } + + //memset(ptThis, 0, sizeof(*ptThis)); + + OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_CCCN888; + + this.Target.ptTile = ptTarget; + this.Target.ptRegion = ptRegion; + this.Mask.ptTile = ptAlpha; + this.wMode = 0; + this.wColour = tColour.tValue; + this.chRatio = chOpacity; + + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); + } @@ -1389,24 +1290,45 @@ arm_fsm_rt_t __arm_2d_gray8_sw_colour_filling_with_mask_and_opacity( #if !__ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ return (arm_fsm_rt_t)ARM_2D_ERR_UNSUPPORTED_COLOUR; #else - __arm_2d_impl_gray8_colour_filling_channel_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.chColour, - this.chOpacity); + + if (255 == this.chRatio) { + __arm_2d_impl_gray8_colour_filling_channel_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.chColour); + } else { + __arm_2d_impl_gray8_colour_filling_channel_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.chColour, + this.chRatio); + } #endif } else { - __arm_2d_impl_gray8_colour_filling_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.chColour, - this.chOpacity); + if (255 == this.chRatio) { + __arm_2d_impl_gray8_colour_filling_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.chColour); + } else { + __arm_2d_impl_gray8_colour_filling_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.chColour, + this.chRatio); + } } return arm_fsm_rt_cpl; } @@ -1421,24 +1343,44 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_colour_filling_with_mask_and_opacity( #if !__ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ return (arm_fsm_rt_t)ARM_2D_ERR_UNSUPPORTED_COLOUR; #else - __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.hwColour, - this.chOpacity); + if (255 == this.chRatio) { + __arm_2d_impl_rgb565_colour_filling_channel_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.hwColour); + } else { + __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.hwColour, + this.chRatio); + } #endif } else { - __arm_2d_impl_rgb565_colour_filling_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.hwColour, - this.chOpacity); + if (255 == this.chRatio) { + __arm_2d_impl_rgb565_colour_filling_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.hwColour); + } else { + __arm_2d_impl_rgb565_colour_filling_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.hwColour, + this.chRatio); + } } return arm_fsm_rt_cpl; } @@ -1453,24 +1395,44 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_colour_filling_with_mask_and_opacity( #if !__ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ return (arm_fsm_rt_t)ARM_2D_ERR_UNSUPPORTED_COLOUR; #else - __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.hwColour, - this.chOpacity); + if (255 == this.chRatio) { + __arm_2d_impl_cccn888_colour_filling_channel_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.wColour); + } else { + __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.wColour, + this.chRatio); + } #endif } else { - __arm_2d_impl_cccn888_colour_filling_mask_opacity( - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile - ptTask->Param.tCopy.tSource.iStride, //!< alpha tile - &(ptTask->Param.tCopy.tCopySize), - this.hwColour, - this.chOpacity); + if (255 == this.chRatio) { + __arm_2d_impl_cccn888_colour_filling_mask( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.wColour); + } else { + __arm_2d_impl_cccn888_colour_filling_mask_opacity( + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + ptTask->Param.tCopy.tSource.pBuffer, //!< alpha tile + ptTask->Param.tCopy.tSource.iStride, //!< alpha tile + &(ptTask->Param.tCopy.tCopySize), + this.wColour, + this.chRatio); + } } return arm_fsm_rt_cpl; @@ -1491,7 +1453,7 @@ arm_fsm_rt_t arm_2dp_gray8_alpha_blending_with_colour_keying( const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio, - uint8_t chColour) + arm_2d_color_gray8_t tColour) { assert(NULL != ptSource); assert(NULL != ptTarget); @@ -1511,7 +1473,7 @@ arm_fsm_rt_t arm_2dp_gray8_alpha_blending_with_colour_keying( this.Source.ptTile = ptSource; this.wMode = 0; this.chRatio = chRatio; - this.chColour = chColour; + this.chColour = tColour.tValue; return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); } @@ -1557,7 +1519,7 @@ arm_fsm_rt_t arm_2dp_cccn888_alpha_blending_with_colour_keying( const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast8_t chRatio, - arm_2d_color_rgb888_t tColour) + arm_2d_color_cccn888_t tColour) { assert(NULL != ptSource); assert(NULL != ptTarget); @@ -1586,9 +1548,18 @@ arm_fsm_rt_t __arm_2d_gray8_sw_alpha_blending_with_colour_keying( __arm_2d_sub_task_t *ptTask) { ARM_2D_IMPL(arm_2d_op_alpha_cl_key_t, ptTask->ptOP) - //assert(ARM_2D_COLOUR_GRAY8 == OP_CORE.ptOp->Info.Colour.chScheme); + assert(ARM_2D_COLOUR_GRAY8 == OP_CORE.ptOp->Info.Colour.chScheme); - __arm_2d_impl_gray8_alpha_blending_colour_keying( + if (255 == this.chRatio) { + __arm_2d_impl_c8bit_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.chColour); + } else { + __arm_2d_impl_gray8_alpha_blending_colour_keying( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, @@ -1596,8 +1567,7 @@ arm_fsm_rt_t __arm_2d_gray8_sw_alpha_blending_with_colour_keying( &ptTask->Param.tCopy.tCopySize, this.chRatio, this.chColour); - - + } return arm_fsm_rt_cpl; } @@ -1606,10 +1576,18 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_alpha_blending_with_colour_keying( __arm_2d_sub_task_t *ptTask) { ARM_2D_IMPL(arm_2d_op_alpha_cl_key_t, ptTask->ptOP) - //assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); + assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); - - __arm_2d_impl_rgb565_alpha_blending_colour_keying( + if (255 == this.chRatio) { + __arm_2d_impl_rgb16_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.hwColour); + } else { + __arm_2d_impl_rgb565_alpha_blending_colour_keying( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, ptTask->Param.tCopy.tTarget.pBuffer, @@ -1617,8 +1595,7 @@ arm_fsm_rt_t __arm_2d_rgb565_sw_alpha_blending_with_colour_keying( &ptTask->Param.tCopy.tCopySize, this.chRatio, this.hwColour); - - + } return arm_fsm_rt_cpl; } @@ -1627,8 +1604,17 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_alpha_blending_with_colour_keying( __arm_2d_sub_task_t *ptTask) { ARM_2D_IMPL(arm_2d_op_alpha_cl_key_t, ptTask->ptOP) - //assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + if (255 == this.chRatio) { + __arm_2d_impl_rgb32_cl_key_copy( + ptTask->Param.tCopy.tSource.pBuffer, + ptTask->Param.tCopy.tSource.iStride, + ptTask->Param.tCopy.tTarget.pBuffer, + ptTask->Param.tCopy.tTarget.iStride, + &ptTask->Param.tCopy.tCopySize, + this.wColour); + } else { __arm_2d_impl_cccn888_alpha_blending_colour_keying( ptTask->Param.tCopy.tSource.pBuffer, ptTask->Param.tCopy.tSource.iStride, @@ -1637,7 +1623,8 @@ arm_fsm_rt_t __arm_2d_cccn888_sw_alpha_blending_with_colour_keying( &ptTask->Param.tCopy.tCopySize, this.chRatio, this.wColour); - + } + return arm_fsm_rt_cpl; } @@ -1652,12 +1639,13 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *__RESTRICT phwSourceBase, uint16_t *__RESTRICT phwTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptCopySize, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { uint32_t iHeight = ptCopySize->iHeight; uint32_t iWidth = ptCopySize->iWidth; - uint16_t ratioCompl = 256 - chRatio; + uint16_t ratioCompl = 256 - hwRatio; + ARM_2D_UNUSED(ratioCompl); for (uint32_t y = 0; y < iHeight; y++) { @@ -1713,8 +1701,8 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *__RESTRICT phwSourceBase, : [src] "+r" (phwSourceBase), [pTarget] "+r" (phwTargetBase), [cnt] "+r" (loopCnt) - : [ratio1] "r" ((256 - (uint_fast16_t)chRatio) ), - [ratio0] "r" (chRatio), [cst] "r" (0x7e0 /* mask G */) + : [ratio1] "r" ((256 - (uint_fast16_t)hwRatio) ), + [ratio0] "r" (hwRatio), [cst] "r" (0x7e0 /* mask G */) : "r0", "r1", "r2", "r3", "r4", "r5", "memory" ); @@ -1728,9 +1716,9 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *__RESTRICT phwSourceBase, for (int i = 0; i < 3; i++) { uint16_t tmp = - (uint16_t) (srcPix.RGB[i] * chRatio) + - (targetPix.RGB[i] * ratioCompl); - targetPix.RGB[i] = (uint16_t) (tmp >> 8); + (uint16_t) (srcPix.BGRA[i] * hwRatio) + + (targetPix.BGRA[i] * ratioCompl); + targetPix.BGRA[i] = (uint16_t) (tmp >> 8); } /* pack merged stream */ *phwTargetBase++ = __arm_2d_rgb565_pack(&targetPix); @@ -1741,119 +1729,6 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *__RESTRICT phwSourceBase, } } - -__WEAK -void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, - const uint16_t *phwBackground, - uint16_t *phwDestination, - uint32_t wPixelCount, - uint_fast8_t chRatio) -{ - uint16_t ratioCompl = 256 - chRatio; - - ARM_2D_UNUSED(ratioCompl); - -#if (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) - /* M55 NOMVE optimization */ - register unsigned loopCnt __asm("lr"); - loopCnt = wPixelCount; - - __asm volatile( - " dls lr, lr \n" - ".p2align 2 \n" - "1: \n" - /* read source / target pixel */ - " ldrh r4, [%[src]], #2 \n" - " ldrh r5, [%[backgrd]], #2 \n" - - /* unpack R */ - " and r0, r4, #31 \n" - " and r1, r5, #31 \n" - - /* unpack B */ - " lsr r2, r4, #11 \n" - " lsr r3, r5, #11 \n" - - /* unpack G */ - " ubfx r4, r4, #5, #6 \n" - " ubfx r5, r5, #5, #6 \n" - - /* mix */ - " mul r0, r0, %[ratio0] \n" - " mul r4, r4, %[ratio0] \n" - " mul r2, r2, %[ratio0] \n" - - " mla r0, %[ratio1], r1, r0 \n" - " mla r1, %[ratio1], r5, r4 \n" - - /* pack R */ - " ubfx r0, r0, #8, #5 \n" - /* shift & mask G */ - " and r1, %[cst], r1, lsr #3 \n" - /* MLA moved here to fill stall */ - " mla r5, %[ratio1], r3, r2 \n" - - /* pack G */ - " add r0, r0, r1 \n" - /* pack R */ - " bic r1, r5, #255 \n" - " orr r0, r0, r1, lsl #3 \n" - - " strh r0, [%[pTarget]], #2 \n" - " le lr, 1b \n" - - : [src] "+r" (phwSource), [backgrd] "+r" (phwBackground), - [pTarget] "+r" (phwDestination), [cnt] "+r" (loopCnt) - : [ratio1] "r" ((256 - (uint_fast16_t)chRatio) ), - [ratio0] "r" (chRatio), [cst] "r" (0x7e0 /* mask G */) - : "r0", "r1", "r2", "r3", - "r4", "r5", "memory" - ); -#else - do { - __arm_2d_color_fast_rgb_t wSourcePixel, wBackgroundPixel, wTargetPixel; - - - __arm_2d_rgb565_unpack(*phwSource++, &wSourcePixel); - __arm_2d_rgb565_unpack(*phwBackground++, &wBackgroundPixel); - - for (int i = 0; i < 3; i++) { - uint16_t tmp = - (uint16_t) (wSourcePixel.RGB[i] * chRatio) + - (wBackgroundPixel.RGB[i] * ratioCompl); - wTargetPixel.RGB[i] = (uint16_t) (tmp >> 8); - } - - *phwDestination++ = __arm_2d_rgb565_pack(&wTargetPixel); - } while (--wPixelCount); - -#endif -} - - -__WEAK -void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, - const uint32_t *pwBackground, - uint32_t *pwDestination, - uint32_t wPixelCount, - uint_fast8_t chRatio) -{ - do { - uint_fast8_t n = sizeof(uint32_t) - 1; - const uint8_t *pchSrc = (uint8_t *)(pwSource++); - const uint8_t *pchBG = (uint8_t *)(pwBackground++); - uint8_t *pchDes = (uint8_t *)(pwDestination++); - - do { - *pchDes++ = ( ((uint_fast16_t)(*pchSrc++) * chRatio) - + ( (uint_fast16_t)(*pchBG++) - * (256 - (uint_fast16_t)chRatio))) >> 8; - } while(--n); - - } while(--wPixelCount); -} - - /*----------------------------------------------------------------------------* * Low Level IO Interfaces * *----------------------------------------------------------------------------*/ @@ -1969,7 +1844,7 @@ def_low_lv_io(__ARM_2D_IO_ALPHA_FILL_COLOUR_RGB888, __arm_2d_cccn888_sw_colour_filling_with_opacity); -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_GRAY8 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_GRAY8 = { .Info = { .Colour = { .chScheme = ARM_2D_COLOUR_GRAY8, @@ -1988,7 +1863,7 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_GRAY8 = { }, }; -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_RGB565 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_RGB565 = { .Info = { .Colour = { .chScheme = ARM_2D_COLOUR_RGB565, @@ -2007,10 +1882,10 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_RGB565 = { }, }; -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_CCCN888 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_CCCN888 = { .Info = { .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, + .chScheme = ARM_2D_COLOUR_CCCN888, }, .Param = { .bHasSource = true, @@ -2028,7 +1903,7 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_CCCN888 = { -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_GRAY8 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_GRAY8 = { .Info = { .Colour = { .chScheme = ARM_2D_COLOUR_GRAY8, @@ -2047,7 +1922,7 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_GRAY8 }, }; -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_RGB565 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_RGB565 = { .Info = { .Colour = { .chScheme = ARM_2D_COLOUR_RGB565, @@ -2066,10 +1941,10 @@ const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_RGB56 }, }; -const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_ALPHA_MASK_AND_OPACITY_CCCN888 = { +const __arm_2d_op_info_t ARM_2D_OP_FILL_COLOUR_WITH_MASK_AND_OPACITY_CCCN888 = { .Info = { .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, + .chScheme = ARM_2D_COLOUR_CCCN888, }, .Param = { .bHasSource = true, @@ -2124,7 +1999,7 @@ const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB565 = { const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_RGB888 = { .Info = { .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, + .chScheme = ARM_2D_COLOUR_CCCN888, }, .Param = { .bHasSource = true, @@ -2178,7 +2053,7 @@ const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB565 = { const __arm_2d_op_info_t ARM_2D_OP_ALPHA_BLENDING_WITH_COLOUR_KEYING_RGB888 = { .Info = { .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, + .chScheme = ARM_2D_COLOUR_CCCN888, }, .Param = { .bHasSource = true, @@ -2230,7 +2105,7 @@ const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB565 = { const __arm_2d_op_info_t ARM_2D_OP_ALPHA_COLOUR_FILL_RGB888 = { .Info = { .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, + .chScheme = ARM_2D_COLOUR_CCCN888, }, .Param = { .bHasSource = false, @@ -2255,7 +2130,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_GRAY8 = { .bHasSrcMask = true, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASKS, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_MASKS_GRAY8), @@ -2276,7 +2151,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_RGB565 = { .bHasSrcMask = true, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASKS, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_MASKS_RGB565), @@ -2297,7 +2172,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_MASK_CCCN888 = { .bHasSrcMask = true, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_MASKS, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_MASKS_CCCN888), @@ -2317,7 +2192,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_GRAY8 = { .bHasSrcMask = true, .bHasDesMask = false, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SRC_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SOURCE_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_SRC_MASK_GRAY8), @@ -2338,7 +2213,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_RGB565 = { .bHasSrcMask = true, .bHasDesMask = false, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SRC_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SOURCE_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_SRC_MASK_RGB565), @@ -2359,7 +2234,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_SRC_MASK_CCCN888 = { .bHasSrcMask = true, .bHasDesMask = false, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SRC_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_SOURCE_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_SRC_MASK_CCCN888), @@ -2379,7 +2254,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_GRAY8 = { .bHasSrcMask = false, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_DES_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_TARGET_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_DES_MASK_GRAY8), @@ -2400,7 +2275,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_RGB565 = { .bHasSrcMask = false, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_DES_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_TARGET_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_DES_MASK_RGB565), @@ -2421,7 +2296,7 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_CCCN888 = { .bHasSrcMask = false, .bHasDesMask = true, }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_DES_MASK, + .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_TARGET_MASK, .LowLevelIO = { .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_DES_MASK_CCCN888), @@ -2431,14 +2306,6 @@ const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_DES_MASK_CCCN888 = { }; - - -#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 diff --git a/package/Arm2D/arm_2d_async.c b/package/Arm2D/Library/Source/arm_2d_async.c similarity index 90% rename from package/Arm2D/arm_2d_async.c rename to package/Arm2D/Library/Source/arm_2d_async.c index 16c5c298a..1b1ab65e4 100644 --- a/package/Arm2D/arm_2d_async.c +++ b/package/Arm2D/Library/Source/arm_2d_async.c @@ -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 diff --git a/package/Arm2D/arm_2d_conversion.c b/package/Arm2D/Library/Source/arm_2d_conversion.c similarity index 51% rename from package/Arm2D/arm_2d_conversion.c rename to package/Arm2D/Library/Source/arm_2d_conversion.c index a04f8bec3..aaad5a491 100644 --- a/package/Arm2D/arm_2d_conversion.c +++ b/package/Arm2D/Library/Source/arm_2d_conversion.c @@ -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 diff --git a/package/Arm2D/arm_2d_draw.c b/package/Arm2D/Library/Source/arm_2d_draw.c similarity index 84% rename from package/Arm2D/arm_2d_draw.c rename to package/Arm2D/Library/Source/arm_2d_draw.c index b20794090..c6377137a 100644 --- a/package/Arm2D/arm_2d_draw.c +++ b/package/Arm2D/Library/Source/arm_2d_draw.c @@ -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 diff --git a/package/Arm2D/arm_2d_helium.c b/package/Arm2D/Library/Source/arm_2d_helium.c similarity index 52% rename from package/Arm2D/arm_2d_helium.c rename to package/Arm2D/Library/Source/arm_2d_helium.c index 3b8314c15..afe03698b 100644 --- a/package/Arm2D/arm_2d_helium.c +++ b/package/Arm2D/Library/Source/arm_2d_helium.c @@ -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_helium.c * Description: Acceleration extensions using Helium. * - * $Date: 22. Sep 2021 - * $Revision: V.0.12.0 + * $Date: 03. Aug 2022 + * $Revision: V.0.13.6 * * Target Processor: Cortex-M cores with Helium * @@ -36,7 +36,6 @@ #if defined(__ARM_2D_HAS_HELIUM__) && __ARM_2D_HAS_HELIUM__ #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" @@ -57,9 +56,11 @@ # 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_paving_helium.h" #include "__arm_2d_math_helium.h" @@ -68,12 +69,16 @@ extern "C" { #endif +/*============================ MACROS ========================================*/ +/*============================ MACROFIED FUNCTIONS ===========================*/ +/*============================ TYPES =========================================*/ +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ +/*============================ LOCAL VARIABLES ===============================*/ +/*============================ IMPLEMENTATION ================================*/ - - -/*! \brief initialise the helium service service - *! \param none - *! \return none +/*! + * \brief initialise the helium acceleration */ void __arm_2d_helium_init(void) { @@ -105,6 +110,68 @@ void __arm_2d_helium_init(void) #include "__arm_2d_copy_helium.inc" +#define __ARM_2D_COMPILATION_UNIT +#include "__arm_2d_transform_helium.c" + +#define __ARM_2D_COMPILATION_UNIT +#include "__arm_2d_conversion_helium.c" + +/*----------------------------------------------------------------------------* + * Helper + *----------------------------------------------------------------------------*/ + +__OVERRIDE_WEAK +void __MVE_WRAPPER(arm_2d_helper_swap_rgb16)(uint16_t *phwBuffer, uint32_t wCount) +{ + if (0 == wCount) { + return ; + } + + // aligned (2) + assert((((uintptr_t) phwBuffer) & 0x01) == 0); + + // src not aligned to 32-bit + // (helium supports unaligned vector load & store but with extra cycle penalty) + if ((((uintptr_t) phwBuffer) & 0x03) == 0x02) { + // handle the leading pixel + uint32_t wTemp = *phwBuffer; + *phwBuffer++ = (uint16_t)__REV16(wTemp); + wCount--; + } + +#ifdef USE_MVE_INTRINSICS + do { + mve_pred16_t tailPred = vctp16q(wCount); + uint16x8_t rgb16vec = vld1q_z(phwBuffer, tailPred); + + rgb16vec = (uint16x8_t)vrev16q_m_u8(rgb16vec, rgb16vec, tailPred); + + vst1q_p(phwBuffer , rgb16vec , tailPred); + + phwBuffer += 8; + wCount -= 8; + } + while ((int32_t)wCount > 0); + +#else + __asm volatile( + ".p2align 2 \n" + " wlstp.16 lr, %[wCount], 1f \n" + "2: \n" + + " vldrh.u16 q0, [%[phwBuffer]] \n" + " vrev16.8 q0, q0 \n" + " vstrh.u16 q0, [%[phwBuffer]], #16 \n" + " letp lr, 2b \n" + "1: \n" + + : [phwBuffer] "+r"(phwBuffer) + : [wCount] "r" (wCount) + :"q0", "lr", "memory"); +#endif +} + + /*----------------------------------------------------------------------------* * Specialized Copy Routines * @@ -244,7 +311,7 @@ void __arm_copy_32_mve_narrow( uint32_t *pwSource, __OVERRIDE_WEAK -void __arm_2d_impl_rgb16_copy( uint16_t *phwSource, +void __MVE_WRAPPER( __arm_2d_impl_rgb16_copy)( uint16_t *phwSource, int16_t iSourceStride, uint16_t *phwTarget, int16_t iTargetStride, @@ -339,11 +406,11 @@ void __arm_2d_impl_rgb16_copy( uint16_t *phwSource, } __OVERRIDE_WEAK - void __arm_2d_impl_rgb32_copy( uint32_t *pwSource, - int16_t iSourceStride, - uint32_t *pwTarget, - int16_t iTargetStride, - arm_2d_size_t *ptCopySize) + void __MVE_WRAPPER( __arm_2d_impl_rgb32_copy)( uint32_t *pwSource, + int16_t iSourceStride, + uint32_t *pwTarget, + int16_t iTargetStride, + arm_2d_size_t *ptCopySize) { if(ptCopySize->iWidth <= 2) { /* @@ -433,17 +500,20 @@ __OVERRIDE_WEAK *----------------------------------------------------------------------------*/ __OVERRIDE_WEAK -void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, +void __MVE_WRAPPER( __arm_2d_impl_gray8_alpha_blending)(uint8_t * __RESTRICT pSourceBase, int16_t iSourceStride, uint8_t * __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++) { @@ -458,7 +528,7 @@ void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, uint16x8_t vecSrc = vldrbq_z_u16(pSource, tailPred); vecTgt = vmulq_x(vecTgt, hwRatioCompl, tailPred); - vecTgt = vmlaq_m(vecTgt, vecSrc, chRatio, tailPred); + vecTgt = vmlaq_m(vecTgt, vecSrc, hwRatio, tailPred); vecTgt = vecTgt >> 8; vstrbq_p_u16(pTarget , vecTgt , tailPred); @@ -477,13 +547,13 @@ void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, "2: \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q0, q1, %[chRatio] \n" + " vmla.s16 q0, q1, %[hwRatio] \n" " vldrb.u16 q2, [%[pTarget], #8] \n" " vshr.u16 q0, q0, #8 \n" " vstrb.u16 q0, [%[pTarget]], #8 \n" " vmul.u16 q2, q2, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q2, q1, %[chRatio] \n" + " vmla.s16 q2, q1, %[hwRatio] \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vshr.u16 q2, q2, #8 \n" " vstrb.u16 q2, [%[pTarget]], #8 \n" @@ -494,7 +564,7 @@ void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, "2: \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q0, q1, %[chRatio] \n" + " vmla.s16 q0, q1, %[hwRatio] \n" " vshr.u16 q1, q0, #8 \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vstrb.u16 q1, [%[pTarget]], #8 \n" @@ -502,7 +572,7 @@ void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, "1: \n" : [pTarget] "+r"(pTarget), [pSource] "+r" (pSource) - : [chRatio] "r" (chRatio), [hwRatioCompl] "r" (hwRatioCompl), + : [hwRatio] "r" (hwRatio), [hwRatioCompl] "r" (hwRatioCompl), [loopCnt] "r"(blkCnt/16), [tail] "r"(blkCnt & 0xf) :"q0", "q1", "q2", "memory", "r14"); #endif @@ -512,19 +582,22 @@ void __arm_2d_impl_gray8_alpha_blending(uint8_t * __RESTRICT pSourceBase, } __OVERRIDE_WEAK -void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSourceBase, +void __MVE_WRAPPER( __arm_2d_impl_gray8_alpha_blending_colour_keying)(uint8_t * __RESTRICT pSourceBase, int16_t iSourceStride, uint8_t * __RESTRICT pTargetBase, int16_t iTargetStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint_fast8_t chRatio, + uint_fast16_t hwRatio, uint8_t 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++) { @@ -539,7 +612,7 @@ void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSour uint16x8_t vecSrc = vldrbq_z_u16(pSource, tailPred); vecTgt = vmulq_x(vecTgt, hwRatioCompl, tailPred); - vecTgt = vmlaq_m(vecTgt, vecSrc, chRatio, tailPred); + vecTgt = vmlaq_m(vecTgt, vecSrc, hwRatio, tailPred); vecTgt = vecTgt >> 8; vstrbq_p_u16(pTarget , vecTgt , @@ -559,14 +632,14 @@ void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSour "2: \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q0, q1, %[chRatio] \n" + " vmla.s16 q0, q1, %[hwRatio] \n" " vldrb.u16 q2, [%[pTarget], #8] \n" " vshr.u16 q0, q0, #8 \n" " vpt.u16 ne, q1, %[Colour] \n" " vstrbt.u16 q0, [%[pTarget]], #8 \n" " vmul.u16 q2, q2, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q2, q1, %[chRatio] \n" + " vmla.s16 q2, q1, %[hwRatio] \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vshr.u16 q2, q2, #8 \n" " vpt.u16 ne, q1, %[Colour] \n" @@ -578,7 +651,7 @@ void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSour "2: \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pSource]], #8 \n" - " vmla.u16 q0, q1, %[chRatio] \n" + " vmla.s16 q0, q1, %[hwRatio] \n" " vshr.u16 q2, q0, #8 \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vpt.u16 ne, q1, %[Colour] \n" @@ -587,7 +660,7 @@ void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSour "1: \n" : [pTarget] "+r"(pTarget), [pSource] "+r" (pSource) - : [chRatio] "r" (chRatio), [hwRatioCompl] "r" (hwRatioCompl), + : [hwRatio] "r" (hwRatio), [hwRatioCompl] "r" (hwRatioCompl), [loopCnt] "r"(blkCnt/16), [tail] "r"(blkCnt & 0xf), [Colour] "r" (Colour) :"q0", "q1", "q2", "memory", "r14"); @@ -599,15 +672,22 @@ void __arm_2d_impl_gray8_alpha_blending_colour_keying(uint8_t * __RESTRICT pSour __OVERRIDE_WEAK -void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTargetBase, +void __MVE_WRAPPER( __arm_2d_impl_gray8_colour_filling_with_opacity)(uint8_t * __restrict pTargetBase, int16_t iTargetStride, arm_2d_size_t * __restrict ptCopySize, - uint8_t Colour, uint_fast8_t chRatio) + uint8_t Colour, + 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; + uint16x8_t vecSrc = vdupq_n_u16(Colour); for (int_fast16_t y = 0; y < iHeight; y++) { @@ -621,7 +701,7 @@ void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTarge uint16x8_t vecTgt = vldrbq_z_u16(pTarget, tailPred); vecTgt = vmulq_x(vecTgt, hwRatioCompl, tailPred); - vecTgt = vmlaq_m(vecTgt, vecSrc, chRatio, tailPred); + vecTgt = vmlaq_m(vecTgt, vecSrc, hwRatio, tailPred); vecTgt = vecTgt >> 8; vstrbq_p_u16(pTarget , vecTgt , tailPred); @@ -639,12 +719,12 @@ void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTarge " wls lr, %[loopCnt], 1f \n" "2: \n" - " vmla.u16 q0, %[vecSrc], %[chRatio] \n" + " vmla.s16 q0, %[vecSrc], %[hwRatio] \n" " vldrb.u16 q2, [%[pTarget], #8] \n" " vshr.u16 q0, q0, #8 \n" " vmul.u16 q2, q2, %[hwRatioCompl] \n" " vstrb.u16 q0, [%[pTarget]], #8 \n" - " vmla.u16 q2, %[vecSrc], %[chRatio] \n" + " vmla.s16 q2, %[vecSrc], %[hwRatio] \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vshr.u16 q2, q2, #8 \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" @@ -655,7 +735,7 @@ void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTarge " wlstp.16 lr, %[tail], 1f \n" "2: \n" - " vmla.u16 q0, %[vecSrc], %[chRatio] \n" + " vmla.s16 q0, %[vecSrc], %[hwRatio] \n" " vshr.u16 q2, q0, #8 \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vmul.u16 q0, q0, %[hwRatioCompl] \n" @@ -664,7 +744,7 @@ void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTarge "1: \n" : [pTarget] "+r"(pTarget) - : [chRatio] "r" (chRatio), [hwRatioCompl] "r" (hwRatioCompl), + : [hwRatio] "r" (hwRatio), [hwRatioCompl] "r" (hwRatioCompl), [loopCnt] "r"(blkCnt/16), [tail] "r"(blkCnt & 0xf), [vecSrc] "t" (vecSrc) :"q0", "q2", "memory", "r14"); @@ -678,19 +758,23 @@ void __arm_2d_impl_gray8_colour_filling_with_opacity(uint8_t * __restrict pTarge __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_alpha_blending)( uint16_t *phwSourceBase, int16_t iSourceStride, uint16_t *phwTargetBase, int16_t iTargetStride, arm_2d_size_t *ptCopySize, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + #ifdef USE_MVE_INTRINSICS int32_t blkCnt; - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); @@ -760,10 +844,10 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, #else /* USE_MVE_INTRINSICS */ - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8); @@ -796,7 +880,7 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, // B source extraction " vand q7, q5, %[vecMaskR] \n" // B mix - " vmla.u16 q6, q7, %[ratio1x8] \n" + " vmla.s16 q6, q7, %[ratio1x8] \n" // G extraction " vand q2, q2, %[vecMaskG] \n" " vshr.u16 q7, q5, #5 \n" @@ -804,14 +888,14 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, // G extraction " vand q7, q7, %[vecMaskG] \n" // G mix - " vmla.u16 q2, q7, %[ratio1x4] \n" + " vmla.s16 q2, q7, %[ratio1x4] \n" // R extraction " vshr.u16 q4, q4, #11 \n" " vmul.i16 q7, q4, %[ratio2x8] \n" // R extraction " vshr.u16 q5, q5, #11 \n" // R mix - " vmla.u16 q7, q5, %[ratio1x8] \n" + " vmla.s16 q7, q5, %[ratio1x8] \n" " vshr.u16 q2, q2, #8 \n" " vldrh.16 q5, [%[scratch]] \n" @@ -825,7 +909,7 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, " vand q7, q4, %[vecMaskBpck] \n" // pack R & G // vmulq((vecG0 & vecMaskGpck), 8) + vmulq((vecR0 & vecMaskRpck), 256) - " vmla.u16 q2, q7, %[twofiftysix] \n" + " vmla.s16 q2, q7, %[twofiftysix] \n" // downshift B ((vecB0 >> 8) >> 3) " vshr.u16 q7, q6, #11 \n" // schedule next target load (pre offset as target not imcrementred so far) @@ -854,20 +938,27 @@ void __arm_2d_impl_rgb565_alpha_blending( uint16_t *phwSourceBase, + + __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_colour_filling_with_opacity( +void __MVE_WRAPPER( __arm_2d_impl_rgb565_colour_filling_with_opacity)( uint16_t *__RESTRICT pTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptCopySize, uint16_t Colour, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { + +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + #ifdef USE_MVE_INTRINSICS int32_t blkCnt; - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); @@ -929,10 +1020,10 @@ void __arm_2d_impl_rgb565_colour_filling_with_opacity( #else /* USE_MVE_INTRINSICS */ - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8); @@ -969,21 +1060,21 @@ void __arm_2d_impl_rgb565_colour_filling_with_opacity( " vshr.u16 q2, q4, #5 \n" // B mix - " vmla.u16 q6, q7, %[ratio2x8] \n" + " vmla.s16 q6, q7, %[ratio2x8] \n" // G extraction " vand q7, q2, %[vecMaskG] \n" // G extraction " vldrh.u16 q2, [%[scratch], #32] \n" // G mix - " vmla.u16 q2, q7, %[ratio2x4] \n" + " vmla.s16 q2, q7, %[ratio2x4] \n" " vshr.u16 q4, q4, #11 \n" // R extraction " vldrh.u16 q7, [%[scratch], #16] \n" " vshr.u16 q2, q2, #8 \n" // R mix - " vmla.u16 q7, q4, %[ratio2x8] \n" + " vmla.s16 q7, q4, %[ratio2x8] \n" " vshr.u16 q4, q7, #8 \n" // load duplicated 0xfc mask @@ -994,7 +1085,7 @@ void __arm_2d_impl_rgb565_colour_filling_with_opacity( " vand q7, q4, %[vecMaskBpck] \n" // pack R & G - " vmla.u16 q2, q7, %[twofiftysix] \n" + " vmla.s16 q2, q7, %[twofiftysix] \n" // downshift B ((vecB0 >> 8) >> 3) " vshr.u16 q7, q6, #11 \n" // schedule next target load @@ -1020,24 +1111,28 @@ void __arm_2d_impl_rgb565_colour_filling_with_opacity( __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_alpha_blending_colour_keying( +void __MVE_WRAPPER( __arm_2d_impl_rgb565_alpha_blending_colour_keying)( uint16_t * __RESTRICT phwSource, int16_t iSourceStride, uint16_t * __RESTRICT phwTarget, int16_t iTargetStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint_fast8_t chRatio, - uint32_t hwColour) + uint_fast16_t hwRatio, + uint16_t hwColour) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + #ifdef USE_MVE_INTRINSICS uint32_t iHeight = ptCopySize->iHeight; uint32_t iWidth = ptCopySize->iWidth; int32_t blkCnt; - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); @@ -1138,10 +1233,10 @@ void __arm_2d_impl_rgb565_alpha_blending_colour_keying( uint32_t iHeight = ptCopySize->iHeight; uint32_t iWidth = ptCopySize->iWidth; - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); @@ -1170,7 +1265,7 @@ void __arm_2d_impl_rgb565_alpha_blending_colour_keying( // B source extraction " vand q7, q5, %[vecMaskR] \n" // B mix - " vmla.u16 q6, q7, %[ratio1x8] \n" + " vmla.s16 q6, q7, %[ratio1x8] \n" // G extraction " vand q2, q2, %[vecMaskG] \n" " vshr.u16 q7, q5, #5 \n" @@ -1178,14 +1273,14 @@ void __arm_2d_impl_rgb565_alpha_blending_colour_keying( // G extraction " vand q7, q7, %[vecMaskG] \n" // G mix - " vmla.u16 q2, q7, %[ratio1x4] \n" + " vmla.s16 q2, q7, %[ratio1x4] \n" // R extraction " vshr.u16 q4, q4, #11 \n" " vmul.i16 q7, q4, %[ratio2x8] \n" // R extraction " vshr.u16 q5, q5, #11 \n" // R mix - " vmla.u16 q7, q5, %[ratio1x8] \n" + " vmla.s16 q7, q5, %[ratio1x8] \n" " vshr.u16 q2, q2, #8 \n" " vldrh.16 q5, [%[scratch]] \n" @@ -1199,7 +1294,7 @@ void __arm_2d_impl_rgb565_alpha_blending_colour_keying( " vand q7, q4, %[vecMaskBpck] \n" // pack R & G // vmulq((vecG0 & vecMaskGpck), 8) + vmulq((vecR0 & vecMaskRpck), 256) - " vmla.u16 q2, q7, %[twofiftysix] \n" + " vmla.s16 q2, q7, %[twofiftysix] \n" // downshift B ((vecB0 >> 8) >> 3) " vshr.u16 q7, q6, #11 \n" // schedule next target load (pre offset as target not imcrementred so far) @@ -1231,15 +1326,21 @@ void __arm_2d_impl_rgb565_alpha_blending_colour_keying( __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_alpha_blending)( uint32_t *pwSourceBase, int16_t iSourceStride, uint32_t *pwTargetBase, int16_t iTargetStride, arm_2d_size_t *ptCopySize, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + uint16_t hwRatioCompl = 256 - (uint16_t) hwRatio; + #ifdef USE_MVE_INTRINSICS - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; + + int32_t blkCnt; int32_t row = ptCopySize->iHeight; @@ -1256,7 +1357,7 @@ void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, while (blkCnt > 0) { vstrbq_u16((const uint8_t *)pwTarget, - vmlaq(vmulq(vecSrc, chRatio), vecTrg, chRatioCompl) >> 8); + vmlaq(vmulq(vecSrc, hwRatio), vecTrg, hwRatioCompl) >> 8); pwTarget += 2; @@ -1271,7 +1372,7 @@ void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, row--; } #else - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; + register unsigned blkCnt __asm("lr"); int32_t row = ptCopySize->iHeight; @@ -1287,9 +1388,9 @@ void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vmul.u16 q2, q0, %[chRatio] \n" + " vmul.u16 q2, q0, %[hwRatio] \n" " vldrb.u16 q0, [%[pwSource]], #8 \n" - " vmla.u16 q2, q1, %[chRatioCompl] \n" + " vmla.s16 q2, q1, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pwTarget], #8] \n" " vshr.u16 q2, q2, #8 \n" " vstrb.16 q2, [%[pwTarget]], #8 \n" @@ -1298,7 +1399,7 @@ void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, : [pwSource] "+l"(pwSource), [pwTarget] "+l"(pwTarget), [loopCnt] "+r"(blkCnt) - : [chRatio] "r" (chRatio), [chRatioCompl] "r" (chRatioCompl) + : [hwRatio] "r" (hwRatio), [hwRatioCompl] "r" (hwRatioCompl) : "q0", "q1", "q2", "memory" ); pwSourceBase += iSourceStride; @@ -1312,15 +1413,19 @@ void __arm_2d_impl_cccn888_alpha_blending( uint32_t *pwSourceBase, __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_colour_filling_with_opacity( +void __MVE_WRAPPER( __arm_2d_impl_cccn888_colour_filling_with_opacity)( uint32_t *__RESTRICT pTargetBase, int16_t iTargetStride, arm_2d_size_t *__RESTRICT ptCopySize, uint32_t Colour, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + uint16_t hwRatioCompl = 256 - (uint16_t) hwRatio; + #ifdef USE_MVE_INTRINSICS - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; int32_t blkCnt; int32_t row = ptCopySize->iHeight; uint32_t scratch[2]; @@ -1328,7 +1433,7 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( scratch[0] = scratch[1] = Colour; vColor = vldrbq_u16((uint8_t *) scratch); - vColor = vColor * (uint16_t)chRatio; + vColor = vColor * (uint16_t)hwRatio; while (row > 0) { uint32_t *pTarget = pTargetBase; @@ -1338,7 +1443,7 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( /* byte extraction into 16-bit vector */ uint16x8_t vecTrg = vldrbq_u16((uint8_t *)pTarget); - vstrbq_u16((uint8_t *)pTarget, vmlaq(vColor, vecTrg, chRatioCompl) >> 8); + vstrbq_u16((uint8_t *)pTarget, vmlaq(vColor, vecTrg, hwRatioCompl) >> 8); pTarget += 2; blkCnt -= 2; @@ -1348,7 +1453,6 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( } #else /* USE_MVE_INTRINSICS */ - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; int32_t blkCnt; int32_t row = ptCopySize->iHeight; uint32_t scratch[2]; @@ -1356,7 +1460,7 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( scratch[0] = scratch[1] = Colour; vColor = vldrbq_u16((uint8_t *) scratch); - vColor = vColor * (uint16_t)chRatio; + vColor = vColor * (uint16_t)hwRatio; while (row > 0) { uint32_t *pTarget = pTargetBase; @@ -1370,14 +1474,14 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( ".p2align 2 \n" "2: \n" " vmov q2, %[vColor] \n" - " vmla.u16 q2, q1, %[chRatioCompl] \n" + " vmla.s16 q2, q1, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pTarget], #8] \n" " vshr.u16 q2, q2, #8 \n" " vstrb.16 q2, [%[pTarget]], #8 \n" " letp lr, 2b \n" "1: \n" : [pTarget] "+l"(pTarget) - : [loopCnt] "r"(blkCnt), [chRatioCompl] "r" (chRatioCompl), [vColor] "t" (vColor) + : [loopCnt] "r"(blkCnt), [hwRatioCompl] "r" (hwRatioCompl), [vColor] "t" (vColor) : "q0", "q1", "q2", "memory" ); pTargetBase += iTargetStride; @@ -1388,19 +1492,22 @@ void __arm_2d_impl_cccn888_colour_filling_with_opacity( } __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * __RESTRICT pSourceBase, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_alpha_blending_colour_keying)(uint32_t * __RESTRICT pSourceBase, int16_t iSourceStride, uint32_t * __RESTRICT pTargetBase, int16_t iTargetStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint_fast8_t chRatio, + uint_fast16_t hwRatio, uint32_t Colour) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint16_t chRatioCompl = 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++) { const uint32_t *pSource = pSourceBase; @@ -1426,9 +1533,9 @@ void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * __RESTRICT pS uint16x8_t vTrg16t = vmovltq_x(vTrg8, p); /* A/G blending */ - int16x8_t vecOutb = vmlaq_m(vmulq_x(vSrc16b, chRatio, p), vTrg16b, chRatioCompl, p); + int16x8_t vecOutb = vmlaq_m(vmulq_x(vSrc16b, hwRatio, p), vTrg16b, hwRatioCompl, p); /* R/B blending */ - int16x8_t vecOutt = vmlaq_m(vmulq_x(vSrc16t, chRatio, p), vTrg16t, chRatioCompl, p); + int16x8_t vecOutt = vmlaq_m(vmulq_x(vSrc16t, hwRatio, p), vTrg16t, hwRatioCompl, p); /* merge into 8-bit vector */ int8x16_t vecOut8 = vuninitializedq_s8(); @@ -1464,14 +1571,14 @@ void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * __RESTRICT pS /* 16-bit expansion R/B target pixels */ " vmovlt.u8 q2, q2 \n" /* A/G blending */ - " vmla.u16 q1, q3, %[ratioCmp] \n" + " vmla.s16 q1, q3, %[ratioCmp] \n" /* 16-bit expansion R/B source pixels */ " vmovlt.u8 q3, q0 \n" " vmul.i16 q3, q3, %[ratio] \n" /* merge A/G into 8-bit vector */ " vqshrnb.s16 q1, q1, #8 \n" /* R/B blending */ - " vmla.u16 q3, q2, %[ratioCmp] \n" + " vmla.s16 q3, q2, %[ratioCmp] \n" /* preload next target */ " vldrw.u32 q2, [%[targ], #16] \n" /* merge R/B into 8-bit vector */ @@ -1482,8 +1589,8 @@ void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * __RESTRICT pS " letp lr, 2b \n" "1: \n" :[targ] "+r" (pTarget), [src] "+r" (pSource) - :[loopCnt] "r" (iWidth), [ratio] "r" (chRatio), - [ratioCmp] "r" (chRatioCompl), [color] "r" (Colour) + :[loopCnt] "r" (iWidth), [ratio] "r" (hwRatio), + [ratioCmp] "r" (hwRatioCompl), [color] "r" (Colour) :"r14", "q0", "q1", "q2", "q3", "memory"); #endif pSourceBase += (iSourceStride); @@ -1494,18 +1601,22 @@ void __arm_2d_impl_cccn888_alpha_blending_colour_keying(uint32_t * __RESTRICT pS __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_alpha_blending_direct)(const uint16_t *phwSource, const uint16_t *phwBackground, uint16_t *phwDestination, uint32_t wPixelCount, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + #ifdef USE_MVE_INTRINSICS int32_t blkCnt; - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); @@ -1568,10 +1679,10 @@ void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, #else /* USE_MVE_INTRINSICS */ - uint16_t ratio1x8 = chRatio * 8; - uint16_t ratio1x4 = chRatio * 4; - uint16_t ratio2x8 = (256 - chRatio) * 8; - uint16_t ratio2x4 = (256 - chRatio) * 4; + uint16_t ratio1x8 = hwRatio * 8; + uint16_t ratio1x4 = hwRatio * 4; + uint16_t ratio2x8 = (256 - hwRatio) * 8; + uint16_t ratio2x4 = (256 - hwRatio) * 4; uint16x8_t vecMaskR = vdupq_n_u16(0x001f); uint16x8_t vecMaskG = vdupq_n_u16(0x003f); uint16x8_t vecMaskBpck = vdupq_n_u16(0x00f8); @@ -1591,17 +1702,17 @@ void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, " vmul.i16 q6, q6, %[ratio2x8] \n" " vshr.u16 q2, q4, #5 \n" " vand q7, q5, %[vecMaskR] \n" - " vmla.u16 q6, q7, %[ratio1x8] \n" + " vmla.s16 q6, q7, %[ratio1x8] \n" " vand q2, q2, %[vecMaskG] \n" " vshr.u16 q7, q5, #5 \n" " vmul.i16 q2, q2, %[ratio2x4] \n" " vand q7, q7, %[vecMaskG] \n" - " vmla.u16 q2, q7, %[ratio1x4] \n" + " vmla.s16 q2, q7, %[ratio1x4] \n" " vshr.u16 q4, q4, #11 \n" " vmul.i16 q7, q4, %[ratio2x8] \n" " vshr.u16 q5, q5, #11 \n" " vshr.u16 q2, q2, #8 \n" - " vmla.u16 q7, q5, %[ratio1x8] \n" + " vmla.s16 q7, q5, %[ratio1x8] \n" // " vmov.i16 q6, #0x00fc \n" " vshr.u16 q7, q7, #8 \n" @@ -1612,7 +1723,7 @@ void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, " vmul.i16 q2, q2, %[eight] \n" " vand q4, q7, %[vecMaskBpck] \n" // Q7 = vecB0 " vldrh.u16 q5, [%[in1]], #16 \n" - " vmla.u16 q2, q4, %[twofiftysix] \n" + " vmla.s16 q2, q4, %[twofiftysix] \n" // (vecR0 >> 3) >> 8 " vshr.u16 q6, q6, #11 \n" " vldrh.u16 q4, [%[in2]], #16 \n" @@ -1634,15 +1745,20 @@ void __arm_2d_impl_rgb565_alpha_blending_direct(const uint16_t *phwSource, } __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_alpha_blending_direct)(const uint32_t *pwSource, const uint32_t *pwBackground, uint32_t *pwDestination, uint32_t wPixelCount, - uint_fast8_t chRatio) + uint_fast16_t hwRatio) { +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + hwRatio += (hwRatio == 255); +#endif + uint16_t hwRatioCompl = 256 - hwRatio; + #ifdef USE_MVE_INTRINSICS int32_t blkCnt; - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; + uint16x8_t vecSrc, vecBckg; @@ -1656,11 +1772,11 @@ void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, do { uint16x8_t vecOut; - vecOut = vmulq_n_u16(vecSrc, (uint16_t) chRatio); + vecOut = vmulq_n_u16(vecSrc, (uint16_t) hwRatio); vecSrc = vldrbq_u16((uint8_t const *) pwSource); pwSource += 2; - vecOut = vmlaq_n_u16(vecOut, vecBckg, chRatioCompl); + vecOut = vmlaq_n_u16(vecOut, vecBckg, hwRatioCompl); vecBckg = vldrbq_u16((uint8_t const *) pwBackground); pwBackground += 2; @@ -1674,7 +1790,6 @@ void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, while (blkCnt > 0); #else /* USE_MVE_INTRINSICS */ - uint16_t chRatioCompl = 256 - (uint16_t) chRatio; register unsigned blkCnt __asm("lr") = (wPixelCount * 4); __asm volatile( @@ -1683,9 +1798,9 @@ void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vmul.u16 q2, q0, %[chRatio] \n" + " vmul.u16 q2, q0, %[hwRatio] \n" " vldrb.u16 q0, [%[pwSource]], #8 \n" - " vmla.u16 q2, q1, %[chRatioCompl] \n" + " vmla.s16 q2, q1, %[hwRatioCompl] \n" " vldrb.u16 q1, [%[pwBackg]], #8 \n" " vshr.u16 q2, q2, #8 \n" " vstrb.16 q2, [%[pwDest]], #8 \n" @@ -1694,2755 +1809,13 @@ void __arm_2d_impl_cccn888_alpha_blending_direct(const uint32_t *pwSource, : [pwSource] "+l"(pwSource), [pwBackg] "+l"(pwBackground), [pwDest] "+l" (pwDestination), [loopCnt] "+r"(blkCnt) - : [chRatio] "r" (chRatio), [chRatioCompl] "r" (chRatioCompl) + : [hwRatio] "r" (hwRatio), [hwRatioCompl] "r" (hwRatioCompl) : "q0", "q1", "q2", "memory" ); #endif } -static -mve_pred16_t arm_2d_is_point_vec_inside_region_s16(const arm_2d_region_t * ptRegion, - const arm_2d_point_s16x8_t * ptPoint) -{ - mve_pred16_t p0 = vcmpgeq(ptPoint->X, ptRegion->tLocation.iX); - p0 = vcmpgeq_m(ptPoint->Y, ptRegion->tLocation.iY, p0); - p0 = vcmpltq_m(ptPoint->X, ptRegion->tLocation.iX + ptRegion->tSize.iWidth, p0); - p0 = vcmpltq_m(ptPoint->Y, ptRegion->tLocation.iY + ptRegion->tSize.iHeight, p0); - - return p0; -} - -static -mve_pred16_t arm_2d_is_point_vec_inside_region_s32(const arm_2d_region_t * ptRegion, - const arm_2d_point_s32x4_t * ptPoint) -{ - mve_pred16_t p0 = vcmpgeq_n_s32(ptPoint->X, ptRegion->tLocation.iX); - p0 = vcmpgeq_m_n_s32(ptPoint->Y, ptRegion->tLocation.iY, p0); - p0 = vcmpltq_m_n_s32(ptPoint->X, ptRegion->tLocation.iX + ptRegion->tSize.iWidth, p0); - p0 = vcmpltq_m_n_s32(ptPoint->Y, ptRegion->tLocation.iY + ptRegion->tSize.iHeight, p0); - - return p0; -} - - -/** - @brief return 3 vector of 16-bit channels (8-bit widened) taken from a memory reference - @param[in] pMem pointer to packed 8-bit channel - @param[out] R vector of 16-bit widened R channel - @param[out] G vector of 16-bit widened G channel - @param[out] B vector of 16-bit widened B channel - */ -void __arm_2d_unpack_rgb888_from_mem(const uint8_t * pMem, uint16x8_t * R, uint16x8_t * G, - uint16x8_t * B) -{ - uint16x8_t sg = vidupq_n_u16(0, 4); - - *R = vldrbq_gather_offset_u16(pMem, sg); - *G = vldrbq_gather_offset_u16(pMem + 1, sg); - *B = vldrbq_gather_offset_u16(pMem + 2, sg); -} - -/** - @brief interleave 3 x 16-bit widened vectors into 8-bit memory reference - (4th channel untouched) - @param[in] pMem pointer to packed 8-bit channel - @param[in] R vector of 16-bit widened R channel - @param[in] G vector of 16-bit widened G channel - @param[in] B vector of 16-bit widened B channel - */ -void __arm_2d_pack_rgb888_to_mem(uint8_t * pMem, uint16x8_t R, uint16x8_t G, uint16x8_t B) -{ - uint16x8_t sg = vidupq_n_u16(0, 4); - - vstrbq_scatter_offset_u16(pMem, sg, R); - vstrbq_scatter_offset_u16(pMem + 1, sg, G); - vstrbq_scatter_offset_u16(pMem + 2, sg, B); - //vstrbq_scatter_offset_u16(pMem + 3, sg, vdupq_n_u16(0)); -} - - - - - -/** - unpack vectors of 8-bit widened pixels read from a input 2D coordinates if fits inside the region of - interest or alternative target pixel if content matches color mask - (vector of packed pixels & region of interest name implicit and fixed to respectively - vTarget and ptOrigValidRegion) - Update global predictor tracking region fit & color mask comparison. - */ -#define __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vecX, vecY, ptVal8, MaskColour, pGlb) \ - arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ - /* set vector predicate if point is inside the region */ \ - mve_pred16_t p = \ - arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ - pGlb |= p; \ - /* prepare vector of point offsets */ \ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; \ - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ - \ - /* base pointer update to compensate offset */ \ - uint8_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ - /* retrieve all point values */ \ - ptVal8 = \ - vldrbq_gather_offset_z_u16(pOriginCorrected, ptOffs, predTail); \ - \ - /* combine 2 predicates set to true if point is in the region & values */ \ - /* different from color mask */ \ - p = vcmpneq_m_n_u16(ptVal8, MaskColour, p); \ - pGlb |= p; \ - ptVal8 = vpselq_u16(ptVal8, vTarget, p); - -/** - unpack vectors of pixels read from a input 2D coordinates if fits inside the region of - interest or alternative target pixel if content matches color mask - (vector of packed pixels & region of interest name implicit and fixed to respectively - vTarget and ptOrigValidRegion) - Update global predictor tracking region fit & color mask comparison. - */ - -#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vecX, vecY, R, G, B, MaskColour, pGlb) \ - arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ - /* set vector predicate if point is inside the region */ \ - mve_pred16_t p = \ - arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ - pGlb |= p; \ - \ - /* prepare vector of point offsets */ \ - uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; \ - /* retrieve all point values */ \ - uint16x8_t ptVal = \ - vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); \ - \ - /* combine 2 predicates set to true if point is in the region & values different from color mask */\ - p = vcmpneq_m_n_u16(ptVal, MaskColour, p); \ - pGlb |= p; \ - ptVal = vpselq_u16(ptVal, vTarget, p); \ - \ - /* expand channels */ \ - __arm_2d_rgb565_unpack_single_vec(ptVal, &R, &G, &B); - - -/** - Same as above but use offset compensation during gather load. - unpack vectors of pixels read from a input 2D coordinates if fits inside the region of - interest or alternative target pixel if content matches color mask - (vector of packed pixels & region of interest name implicit and fixed to respectively - vTarget and ptOrigValidRegion) - Update global predictor tracking region fit & color mask comparison. - */ - -#define __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vecX, vecY, R, G, B, MaskColour, pGlb) \ - arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ - /* set vector predicate if point is inside the region */ \ - mve_pred16_t p = \ - arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); \ - pGlb |= p; \ - /* prepare vector of point offsets */ \ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; \ - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; \ - \ - /* base pointer update to compensate offset */ \ - uint16_t *pOriginCorrected = pOrigin + (correctionOffset * iOrigStride); \ - /* retrieve all point values */ \ - uint16x8_t ptVal = \ - vldrhq_gather_shifted_offset_z_u16(pOriginCorrected, ptOffs, predTail); \ - \ - /* combine 2 predicates set to true if point is in the region & values different from color mask */\ - p = vcmpneq_m_n_u16(ptVal, MaskColour, p); \ - pGlb |= p; \ - ptVal = vpselq_u16(ptVal, vTarget, p); \ - \ - /* expand channels */ \ - __arm_2d_rgb565_unpack_single_vec(ptVal, &R, &G, &B); - - -/** - unpack vectors of 32-bit pixels read from a input 2D coordinates if fits inside the region of - interest or alternative target pixel if content matches color mask - 16-bit vector processed in 2 parts because of 32-bit requirements, so handles 8 x 32-bit vectors - (vectors of packed pixels & region of interest name implicit and fixed to respectively - vTargetLo, vectorHi and ptOrigValidRegion) - Update 2 global predictors tracking region fit & color mask comparison for 1st and 2nd half. - */ - -#define __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vecX, vecY, R, G, B, MaskColour, pGlbLo, pGlbHi) \ - arm_2d_point_s16x8_t vPoint = {.X = vecX,.Y = vecY }; \ - arm_2d_point_s32x4_t tPointLo, tPointHi; \ - \ - /* split 16-bit point vector into 2 x 32-bit vectors */ \ - vst1q(pscratch16, vPoint.X); \ - tPointLo.X = vldrhq_s32(pscratch16); \ - tPointHi.X = vldrhq_s32(pscratch16 + 4); \ - \ - vst1q(pscratch16, vPoint.Y); \ - tPointLo.Y = vldrhq_s32(pscratch16); \ - tPointHi.Y = vldrhq_s32(pscratch16 + 4); \ - \ - /* 1st half */ \ - \ - /* set vector predicate if point is inside the region */ \ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); \ - /* prepare vector of point offsets */ \ - uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; \ - \ - /* retrieve all point values */ \ - uint32x4_t ptVal = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailLow); \ - \ - /* combine 2 predicates set to true if point is in the region & values different from color mask */\ - p = vcmpneq_m_n_u32(ptVal, MaskColour, p); \ - pGlbLo |= p; \ - ptVal = vpselq_u32(ptVal, vTargetLo, p); \ - \ - vst1q(scratch32, ptVal); \ - \ - /* 2nd half */ \ - \ - /* set vector predicate if point is inside the region */ \ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); \ - /* prepare vector of point offsets */ \ - ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; \ - \ - /* retrieve all point values */ \ - ptVal = vldrwq_gather_shifted_offset_z_u32(pOrigin, ptOffs, predTailHigh); \ - \ - /* combine 2 predicates set to true if point is in the region & values different from color mask */\ - p = vcmpneq_m_n_u32(ptVal, MaskColour, p); \ - pGlbHi |= p; \ - ptVal = vpselq_u32(ptVal, vTargetHi, p); \ - \ - vst1q(scratch32 + 4, ptVal); \ - \ - /* expand channels */ \ - __arm_2d_unpack_rgb888_from_mem((uint8_t *) scratch32, &R, &G, &B); - - -/** - Alpha blending of a packed vector with 3 vectors of single R, G & B channels - */ - -#define __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(chOpacity, vPackedTarget, vAvgR, vAvgG, vAvgB, vBlended) \ - uint16x8_t vTargetR, vTargetG, vTargetB; \ - \ - __arm_2d_rgb565_unpack_single_vec(vTarget, &vTargetR, &vTargetG, &vTargetB); \ - \ - uint16_t chOpacityCompl = (256 - chOpacity); \ - \ - /* merge */ \ - vAvgR = vAvgR * chOpacityCompl + vTargetR * chOpacity; \ - vAvgR = vAvgR >> 8; \ - \ - vAvgG = vAvgG * chOpacityCompl + vTargetG * chOpacity; \ - vAvgG = vAvgG >> 8; \ - \ - vAvgB = vAvgB * chOpacityCompl + vTargetB * chOpacity; \ - vAvgB = vAvgB >> 8; \ - \ - vBlended = __arm_2d_rgb565_pack_single_vec(vAvgR, vAvgG, vAvgB); - - -#if __ARM_2D_HAS_HELIUM_FLOAT__ \ - && !__ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ - -#define __CALIB 0.009f16 - -/** - Scale Gray8 channel - */ -#define __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vScal) \ - vAvgPixel = vScal * vcvtq_f16_s16(ptVal8); - -/** - Scale Gray8 channel with accumulation - */ -#define __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vScal) \ - vAvgPixel += vScal * vcvtq_f16_s16(ptVal8); - -/** - Scale R, G & B channels - */ -#define __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vScal) \ - vAvgPixelR = vScal * vcvtq_f16_s16(R); \ - vAvgPixelG = vScal * vcvtq_f16_s16(G); \ - vAvgPixelB = vScal * vcvtq_f16_s16(B); - -/** - Scale R, G & B channels with accumulation - */ - -#define __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vScal) \ - vAvgPixelR += vScal * vcvtq_f16_s16(R); \ - vAvgPixelG += vScal * vcvtq_f16_s16(G); \ - vAvgPixelB += vScal * vcvtq_f16_s16(B); - - -static -bool __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, - int32_t iOrigStride, - arm_2d_rot_linear_regr_t regrCoefs[] - ) -{ - int32_t iHeight = ptCopySize->iHeight; - int32_t iWidth = ptCopySize->iWidth; - float invHeight = iHeight > 1 ? 1.0f / (float) (iHeight - 1) : __LARGEINVF32; - arm_2d_point_s32x4_t vPointCornerI; - int32x4_t vCornerX = { 0, 1, 0, 1 }; - int32x4_t vCornerY = { 0, 0, 1, 1 }; - float cosAngle = arm_cos_f32(fAngle); - float sinAngle = arm_sin_f32(fAngle); - arm_2d_point_float_t centerf; - float slopeX, slopeY; - bool gatherLoadIdxOverflow = 0; - - //printf("invHeight %f\n",invHeight); - - - centerf.fX = (float) center->iX; - centerf.fY = (float) center->iY; - - vPointCornerI.X = vdupq_n_s32(pSrcPoint->iX + tOffset->iX); - vPointCornerI.X = vPointCornerI.X + vmulq_n_s32(vCornerX, (iWidth - 1)); - - vPointCornerI.Y = vdupq_n_s32(pSrcPoint->iY + tOffset->iY); - vPointCornerI.Y = vPointCornerI.Y + vmulq_n_s32(vCornerY, (iHeight - 1)); - - /* - Vector version of: - - int16_t iX = ptLocation->iX - ptCenter->iX; - int16_t iY = ptLocation->iY - ptCenter->iY; - - float cosAngle = arm_cos_f32(fAngle); - float sinAngle = arm_sin_f32(fAngle); - - ptOutBuffer->fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY); - ptOutBuffer->fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX); - */ - - arm_2d_point_f32x4_t vTmp, vPointCornerF; - - vTmp.X = vsubq_n_f32(vcvtq_f32_s32(vPointCornerI.X), centerf.fX); - vTmp.Y = vsubq_n_f32(vcvtq_f32_s32(vPointCornerI.Y), centerf.fY); - - vPointCornerF.X = vmulq_n_f32(vTmp.X, cosAngle) - vmulq_n_f32(vTmp.Y, sinAngle); - vPointCornerF.X = vaddq_n_f32(vPointCornerF.X, centerf.fX); - - vPointCornerF.Y = vmulq_n_f32(vTmp.X, sinAngle) + vmulq_n_f32(vTmp.Y, cosAngle); - vPointCornerF.Y = vaddq_n_f32(vPointCornerF.Y, centerf.fY); - - /* - Check whether rotated index offsets could exceed 16-bit limits - used in subsequent gather loads - This will occur for parts of large images (e.g. 320*200) - To avoid unconditional penalties for small/medium images, - returns a speculative overflow allowing to handle large offsets. - */ - float32_t maxY = vmaxnmvq(0.0f, vPointCornerF.Y); - - if((iOrigStride * maxY) > (float)(UINT16_MAX)) - gatherLoadIdxOverflow = true; - - - /* interpolation in Y direction for 1st elements column */ - slopeX = (vPointCornerF.X[2] - vPointCornerF.X[0]) * invHeight; - slopeY = (vPointCornerF.Y[2] - vPointCornerF.Y[0]) * invHeight; - - regrCoefs[0].slopeY = slopeY; - regrCoefs[0].slopeX = slopeX; - regrCoefs[0].interceptY = vPointCornerF.Y[0]; - regrCoefs[0].interceptX = vPointCornerF.X[0]; - - - /* interpolation in Y direction for the last elements column */ - slopeX = (vPointCornerF.X[3] - vPointCornerF.X[1]) * invHeight; - slopeY = (vPointCornerF.Y[3] - vPointCornerF.Y[1]) * invHeight; - - regrCoefs[1].slopeY = slopeY; - regrCoefs[1].slopeX = slopeX; - regrCoefs[1].interceptY = vPointCornerF.Y[1]; - regrCoefs[1].interceptX = vPointCornerF.X[1]; - - return gatherLoadIdxOverflow; -} - - - - -static -void __arm_2d_impl_gray8_get_pixel_colour(arm_2d_point_f16x8_t - * ptPoint, - arm_2d_region_t * - ptOrigValidRegion, - uint8_t * pOrigin, - int16_t iOrigStride, - uint8_t * pTarget, - uint8_t MaskColour, uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vldrbq_u16(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixel; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t ptVal8; - /* Bottom Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTR); - } - - - /* pack */ - uint16x8_t TempPixel = vcvtq_s16_f16(vAvgPixel); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(TempPixel, vTarget, predGlb); - -#else - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) - }; - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - /* retrieve all point values */ - uint16x8_t ptVal = vldrbq_gather_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vstrbq_p_u16(pTarget, vTarget, predTail); -} - - - -static -void __arm_2d_impl_gray8_get_pixel_colour_with_alpha(arm_2d_point_f16x8_t * ptPoint, - arm_2d_region_t * ptOrigValidRegion, - uint8_t * pOrigin, - int16_t iOrigStride, - uint8_t * pTarget, - uint8_t MaskColour, - uint8_t chOpacity, uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vldrbq_u16(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixel; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t ptVal8; - /* Bottom Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTR); - } - - - - /* blending */ - uint16x8_t vAvg = vcvtq_s16_f16(vAvgPixel); - - uint16_t chTransparency = 256 - (chOpacity); - uint16x8_t vBlended = (vAvg * chTransparency + vTarget * chOpacity) >> 8; - - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); -#else - /* set vector predicate if point is inside the region */ - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) - }; - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* retrieve all point values */ - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - uint16x8_t ptVal = vldrbq_gather_offset_z_u16(pOrigin, ptOffs, predTail); - - /* alpha blending */ - uint16_t chTransparency = 256 - (chOpacity); - uint16x8_t vBlended = (ptVal * chTransparency + vTarget * chOpacity) >> 8; - - - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vstrbq_p_u16(pTarget, vTarget, predTail); -} - - -static -void __arm_2d_impl_rgb565_get_pixel_colour(arm_2d_point_f16x8_t * ptPoint, - arm_2d_region_t * ptOrigValidRegion, - uint16_t * pOrigin, - int16_t iOrigStride, - uint16_t * pTarget, - uint16_t MaskColour, uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* pack */ - uint16x8_t TempPixel = __arm_2d_rgb565_pack_single_vec(vcvtq_s16_f16(vAvgPixelR), - vcvtq_s16_f16(vAvgPixelG), - vcvtq_s16_f16(vAvgPixelB)); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(TempPixel, vTarget, predGlb); - -#else - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) }; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - /* update target pixels */ - vst1q_p(pTarget, vTarget, predTail); -} - - -static -void __arm_2d_impl_rgb565_get_pixel_colour_offs_compensated(arm_2d_point_f16x8_t * - ptPoint, - arm_2d_region_t * - ptOrigValidRegion, - uint16_t * pOrigin, - int16_t iOrigStride, - uint16_t * pTarget, - uint16_t MaskColour, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* pack */ - uint16x8_t TempPixel = __arm_2d_rgb565_pack_single_vec(vcvtq_s16_f16(vAvgPixelR), - vcvtq_s16_f16(vAvgPixelG), - vcvtq_s16_f16(vAvgPixelB)); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(TempPixel, vTarget, predGlb); - -#else - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) }; - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - -static -void __arm_2d_impl_rgb565_get_pixel_colour_with_alpha( - arm_2d_point_f16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint8_t chOpacity, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* blending */ - uint16x8_t vAvgR, vAvgG, vAvgB; - - vAvgR = vcvtq_s16_f16(vAvgPixelR); - vAvgG = vcvtq_s16_f16(vAvgPixelG); - vAvgB = vcvtq_s16_f16(vAvgPixelB); - - uint16x8_t vBlended; - - __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(chOpacity, vTarget, vAvgR, vAvgG, vAvgB, vBlended); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); - -#else - /* set vector predicate if point is inside the region */ - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) }; - - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* alpha blending */ - uint16x8_t vBlended = - __arm_2d_rgb565_alpha_blending_single_vec(ptVal, vTarget, chOpacity); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - - -static -void __arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated( - arm_2d_point_f16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint8_t chOpacity, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - - float16x8_t vOne = vdupq_n_f16(1.0f); - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* blending */ - uint16x8_t vAvgR, vAvgG, vAvgB; - - vAvgR = vcvtq_s16_f16(vAvgPixelR); - vAvgG = vcvtq_s16_f16(vAvgPixelG); - vAvgB = vcvtq_s16_f16(vAvgPixelB); - - uint16x8_t vBlended; - - __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(chOpacity, vTarget, vAvgR, vAvgG, vAvgB, vBlended); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); -#else - /* set vector predicate if point is inside the region */ - arm_2d_point_s16x8_t vPoint = { - .X = vcvtq_s16_f16(ptPoint->X), - .Y = vcvtq_s16_f16(ptPoint->Y) }; - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - - uint16x8_t ptOffs = - vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* retrieve all point values */ - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - - /* alpha blending */ - uint16x8_t vBlended = - __arm_2d_rgb565_alpha_blending_single_vec(ptVal, vTarget, chOpacity); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - - - - -static -void __arm_2d_impl_cccn888_get_pixel_colour( arm_2d_point_f16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint32_t *pOrigin, - int16_t iOrigStride, - uint32_t *pTarget, - uint32_t MaskColour, - int16_t elts) -{ -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - ARM_ALIGN(8) uint32_t scratch32[32]; - int16_t *pscratch16 = (int16_t *) scratch32; - uint32x4_t vTargetLo = vld1q(pTarget); - uint32x4_t vTargetHi = vld1q(pTarget + 4); - mve_pred16_t predTailLow = vctp32q(elts); - mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; - float16x8_t vOne = vdupq_n_f16(1.0f); - - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulators */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlbLo = 0, predGlbHi = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - - /* Bottom Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - /* pack */ - __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vcvtq_s16_f16(vAvgPixelR), - vcvtq_s16_f16(vAvgPixelG), vcvtq_s16_f16(vAvgPixelB)); - - uint32x4_t TempPixel = vld1q(scratch32); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); - - vst1q_p(pTarget, TempPixel, predTailLow); - - TempPixel = vld1q(scratch32 + 4); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); - - vst1q_p(pTarget + 4, TempPixel, predTailHigh); -#else - - arm_2d_point_s32x4_t tPointLo, tPointHi; - ARM_ALIGN(8) int16_t scratch[8]; - mve_pred16_t p; - - /* split 16-bit point vector into 2 x 32-bit vectors */ - vst1q(scratch, vcvtq_s16_f16(ptPoint->X)); - tPointLo.X = vldrhq_s32(scratch); - tPointHi.X = vldrhq_s32(scratch + 4); - - vst1q(scratch, vcvtq_s16_f16(ptPoint->Y)); - tPointLo.Y = vldrhq_s32(scratch); - tPointHi.Y = vldrhq_s32(scratch + 4); - - /* 1st half */ - - /* set vector predicate if point is inside the region */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); - /* prepare vector of point offsets */ - uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; - uint32x4_t vPixel = vld1q(pTarget); - /* retrieve all point values */ - uint32x4_t ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vPixel = vpselq_u32(ptVal, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget, vPixel, vctp32q(elts)); - - elts -= 4; - if (elts > 0) { - - /* second half */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); - ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; - vPixel = vld1q(pTarget + 4); - - ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - vPixel = vpselq_u32(ptVal, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - vst1q_p(pTarget + 4, vPixel, vctp32q(elts)); - } -#endif -} - - - -static -void __arm_2d_impl_cccn888_get_pixel_colour_with_alpha( - arm_2d_point_f16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint32_t *pOrigin, - int16_t iOrigStride, - uint32_t *pTarget, - uint32_t MaskColour, - uint8_t chOpacity, - int16_t elts) -{ -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - ARM_ALIGN(8) uint32_t scratch32[32]; - int16_t *pscratch16 = (int16_t *) scratch32; - uint32x4_t vTargetLo = vld1q(pTarget); - uint32x4_t vTargetHi = vld1q(pTarget + 4); - mve_pred16_t predTailLow = vctp32q(elts); - mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; - float16x8_t vOne = vdupq_n_f16(1.0f); - - int16x8_t vXi = vcvtq_s16_f16(ptPoint->X); - int16x8_t vYi = vcvtq_s16_f16(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_f16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_f16(ptPoint->Y, 0)); - - float16x8_t vWX = ptPoint->X - vcvtq_f16_s16(vXi); - float16x8_t vWY = ptPoint->Y - vcvtq_f16_s16(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - float16x8_t vAreaTR = vWX * vWY; - float16x8_t vAreaTL = (vOne - vWX) * vWY; - float16x8_t vAreaBR = vWX * (vOne - vWY); - float16x8_t vAreaBL = (vOne - vWX) * (vOne - vWY); - - /* accumulated pixel vectors */ - float16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - - /* predicate accumulators */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlbLo = 0, predGlbHi = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - uint16x8_t R, G, B; - - /* Bottom Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* alpha blending */ - uint16x8_t vTargetR, vTargetG, vTargetB; - - __arm_2d_unpack_rgb888_from_mem((const uint8_t *) pTarget, &vTargetR, &vTargetG, &vTargetB); - - uint16_t chOpacityCompl = (256 - chOpacity); - - uint16x8_t vAvgR, vAvgG, vAvgB; - - vAvgR = vcvtq_s16_f16(vAvgPixelR); - vAvgG = vcvtq_s16_f16(vAvgPixelG); - vAvgB = vcvtq_s16_f16(vAvgPixelB); - - /* merge */ - vAvgR = vAvgR * chOpacityCompl + vTargetR * chOpacity; - vAvgR = vAvgR >> 8; - - vAvgG = vAvgG * chOpacityCompl + vTargetG * chOpacity; - vAvgG = vAvgG >> 8; - - vAvgB = vAvgB * chOpacityCompl + vTargetB * chOpacity; - vAvgB = vAvgB >> 8; - - - /* pack */ - __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vAvgR, vAvgG, vAvgB); - - uint32x4_t TempPixel = vld1q(scratch32); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); - - vst1q_p(pTarget, TempPixel, predTailLow); - - TempPixel = vld1q(scratch32 + 4); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); - - vst1q_p(pTarget + 4, TempPixel, predTailHigh); -#else - arm_2d_point_s32x4_t tPointLo, tPointHi; - ARM_ALIGN(8) int16_t scratch[8]; - ARM_ALIGN(8) uint32_t blendled[4]; - mve_pred16_t p; - - /* split 16-bit point vector into 2 x 32-bit vectors */ - vst1q(scratch, vcvtq_s16_f16(ptPoint->X)); - tPointLo.X = vldrhq_s32(scratch); - tPointHi.X = vldrhq_s32(scratch + 4); - - vst1q(scratch, vcvtq_s16_f16(ptPoint->Y)); - tPointLo.Y = vldrhq_s32(scratch); - tPointHi.Y = vldrhq_s32(scratch + 4); - - - /* 1st half */ - - /* set vector predicate if point is inside the region */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); - /* prepare vector of point offsets */ - uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; - uint32x4_t vPixel = vld1q(pTarget); - /* retrieve all point values */ - uint32x4_t ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - vstrwq_u32((uint32_t *) scratch, ptVal); - - /* alpha-blending (requires widened inputs) */ - vstrbq_u16((uint8_t *) blendled, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *) scratch), - vldrbq_u16((uint8_t const *) pTarget), chOpacity)); - - vstrbq_u16((uint8_t *) blendled + 2, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *)scratch + 4), - vldrbq_u16((uint8_t const *)pTarget + 2), chOpacity)); - - uint32x4_t vBlended = vld1q(blendled); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vPixel = vpselq_u32(vBlended, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget, vPixel, vctp32q(elts)); - - elts -= 4; - if(elts > 0) { - /* second half */ - - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); - ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; - vPixel = vld1q(pTarget); - ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - vstrwq_u32((uint32_t *) scratch, ptVal); - - /* alpha-blending (requires widened inputs) */ - vstrbq_u16((uint8_t *) blendled, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *) scratch), - vldrbq_u16((uint8_t const *) pTarget), chOpacity)); - vstrbq_u16((uint8_t *) blendled + 2, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *)scratch + 4), - vldrbq_u16((uint8_t const *)pTarget + 2), chOpacity)); - - vBlended = vld1q(blendled); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vPixel = vpselq_u32(vBlended, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget + 4, vPixel, vctp32q(elts)); - } -#endif -} - -#else /* __ARM_2D_HAS_HELIUM_FLOAT__ && ! __ARM_2D_CFG_FORCED_FIXED_POINT_ROTATION__ */ - - -/* extra calibration removed in fixed-point code since offset is lower than Q9.6 representation */ - -#define ONE_BY_2PI_Q31 341782637.0f -#define ARSHIFT(x, shift) (shift > 0 ? x >> shift : x << (-shift)) -#define TO_Q16(x) ((x) << 16) -#define GET_Q6INT(x) ((x) >> 6) -#define SET_Q6INT(x) ((x) << 6) - -/** - Scale Gray8 channel - */ -#define __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vScal) \ - vAvgPixel = vmulhq_u16(vScal, ptVal8); - -/** - Scale Gray8 channel with accumulation - */ -#define __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vScal) \ - vAvgPixel += vmulhq_u16(vScal, ptVal8); - -/** - Scale R, G & B channels - */ -#define __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vScal) \ - vAvgPixelR = vmulhq_u16(vScal, R); \ - vAvgPixelG = vmulhq_u16(vScal, G); \ - vAvgPixelB = vmulhq_u16(vScal, B); -/** - Scale R, G & B channels with accumulation - */ -#define __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vScal) \ - vAvgPixelR += vmulhq_u16(vScal, R); \ - vAvgPixelG += vmulhq_u16(vScal, G); \ - vAvgPixelB += vmulhq_u16(vScal, B); - - -#ifdef VECTORIZED_ROTATION_REGR -/* disabled as slower than scalar */ -static -bool __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, - int32_t iOrigStride, - arm_2d_rot_linear_regr_t regrCoefs[] - ) -{ - int32_t iHeight = ptCopySize->iHeight; - int32_t iWidth = ptCopySize->iWidth; - q31_t invHeightFx = 0x7fffffff / (iHeight - 1); - arm_2d_point_s32x4_t vPointCornerI; - int32_t AngleFx = (int32_t) roundf(fAngle * ONE_BY_2PI_Q31); - q31_t cosAngleFx = arm_cos_q31(AngleFx); - q31_t sinAngleFx = arm_sin_q31(AngleFx); - int32x4_t vCornerX = { 0, 1, 0, 1 }; - int32x4_t vCornerY = { 0, 0, 1, 1 }; - bool gatherLoadIdxOverflow = 0; - - vPointCornerI.X = vdupq_n_s32(pSrcPoint->iX + tOffset->iX); - vPointCornerI.X = vPointCornerI.X + vmulq_n_s32(vCornerX, (iWidth - 1)); - - vPointCornerI.Y = vdupq_n_s32(pSrcPoint->iY + tOffset->iY); - vPointCornerI.Y = vPointCornerI.Y + vmulq_n_s32(vCornerY, (iHeight - 1)); - - /* - Vector version of: - - int16_t iX = ptLocation->iX - ptCenter->iX; - int16_t iY = ptLocation->iY - ptCenter->iY; - - q31_t cosAngleFx = arm_cos_q31(fAngle); - q31_t sinAngleFx = arm_sin_q31(fAngle); - 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)); - - */ - - arm_2d_point_s32x4_t vTmp1; - - vTmp1.X = vsubq_n_s16(vPointCornerI.X, center->iX); - vTmp1.Y = vsubq_n_s16(vPointCornerI.Y, center->iY); - vTmp1.X <<= 16; - vTmp1.Y <<= 16; - - - vPointCornerI.X = - vqsubq(vqdmulhq_n_s32(vTmp1.X, cosAngleFx), vqdmulhq_n_s32(vTmp1.Y, sinAngleFx)); - vPointCornerI.X = vqaddq_n_s32(vPointCornerI.X, (center->iX << 16)); - - vPointCornerI.Y = vqdmlahq(vqdmulhq_n_s32(vTmp1.X, sinAngleFx), vTmp1.Y, cosAngleFx); - vPointCornerI.Y = vqaddq_n_s32(vPointCornerI.Y, (center->iY << 16)); - - /* - Check whether rotated index offsets could exceed 16-bit limits - used in subsequent gather loads - This will occur for parts of large images (e.g. 320*200) - To avoid unconditional penalties for small/medium images, - returns a speculative overflow allowing to handle large offsets. - */ - int32_t maxY = vmaxvq(0.0f, vPointCornerI.Y); - - if(MULTFX(TO_Q16(iOrigStride), maxY) > UINT16_MAX) - gatherLoadIdxOverflow = true; - - - /* regression parameters */ - - vTmp1.X[0] = vPointCornerI.X[0]; - vTmp1.X[1] = vPointCornerI.X[1]; - vTmp1.X[2] = vPointCornerI.Y[0]; - vTmp1.X[3] = vPointCornerI.Y[1]; - - vTmp1.Y[0] = vPointCornerI.X[2]; - vTmp1.Y[1] = vPointCornerI.X[3]; - vTmp1.Y[2] = vPointCornerI.Y[2]; - vTmp1.Y[3] = vPointCornerI.Y[3]; - - /* slopes */ - vTmp1.X = vqdmulhq_n_s32(vTmp1.Y - vTmp1.X, invHeightFx); - - regrCoefs[0].slopeY = vTmp1.X[2]; - regrCoefs[0].slopeX = vTmp1.X[0]; - regrCoefs[0].interceptY = vPointCornerI.Y[0]; - regrCoefs[0].interceptX = vPointCornerI.X[0]; - - regrCoefs[1].slopeY = vTmp1.X[3]; - regrCoefs[1].slopeX = vTmp1.X[1]; - regrCoefs[1].interceptY = vPointCornerI.Y[1]; - regrCoefs[1].interceptX = vPointCornerI.X[1]; - - return gatherLoadIdxOverflow; -} - -#else - -static -bool __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, - int32_t iOrigStride, - arm_2d_rot_linear_regr_t regrCoefs[] - ) -{ - 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; - bool gatherLoadIdxOverflow = 0; - - /* 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)); - /* - Check whether rotated index offsets could exceed 16-bit limits - used in subsequent gather loads - This will occur for parts of large images (e.g. 320*200) - To avoid unconditional penalties for small/medium images, - returns a speculative overflow allowing to handle large offsets. - */ - int32_t maxY = MAX(MAX - (MAX(tPointCornerFx[0][0].Y, tPointCornerFx[0][1].Y), - tPointCornerFx[1][0].Y), - tPointCornerFx[1][1].Y); - - if(MULTFX(TO_Q16(iOrigStride), maxY) > UINT16_MAX) - gatherLoadIdxOverflow = true; - - - /* 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; - - return gatherLoadIdxOverflow; -} - -#endif - - -static -void __arm_2d_impl_gray8_get_pixel_colour(arm_2d_point_s16x8_t * ptPoint, - arm_2d_region_t * ptOrigValidRegion, - uint8_t * pOrigin, - int16_t iOrigStride, - uint8_t * pTarget, - uint8_t MaskColour, uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vldrbq_u16(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixel; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t ptVal8; - /* Bottom Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, ptVal8, MaskColour, - predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), ptVal8, MaskColour, - predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTR); - } - - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vAvgPixel, vTarget, predGlb); - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y) - }; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - /* retrieve all point values */ - uint16x8_t ptVal = vldrbq_gather_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); -#endif - - vstrbq_p_u16(pTarget, vTarget, predTail); -} - - - - - - -static -void __arm_2d_impl_gray8_get_pixel_colour_with_alpha(arm_2d_point_s16x8_t * ptPoint, - arm_2d_region_t * - ptOrigValidRegion, - uint8_t * pOrigin, - int16_t iOrigStride, - uint8_t * pTarget, - uint8_t MaskColour, - uint8_t chOpacity, uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vldrbq_u16(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixel; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t ptVal8; - /* Bottom Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC(vAvgPixel, ptVal8, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, ptVal8, MaskColour, - predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), ptVal8, MaskColour, - predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_GRAY8_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - ptVal8, MaskColour, predGlb); - - __ARM_2D_SCALE_GRAY8VEC_ACC(vAvgPixel, ptVal8, vAreaTR); - } - - - - /* alpha blending */ - uint16_t chTransparency = 256 - (chOpacity); - uint16x8_t vBlended = (vAvgPixel * chTransparency + vTarget * chOpacity) >> 8; - - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y) - }; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* retrieve all point values */ - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - uint16x8_t ptVal = vldrbq_gather_offset_z_u16(pOrigin, ptOffs, predTail); - - /* alpha blending */ - uint16_t chTransparency = 256 - (chOpacity); - uint16x8_t vBlended = (ptVal * chTransparency + vTarget * chOpacity) >> 8; - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vstrbq_p_u16(pTarget, vTarget, predTail); -} - - -static -void __arm_2d_impl_rgb565_get_pixel_colour( arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - /* pack */ - uint16x8_t TempPixel = __arm_2d_rgb565_pack_single_vec(vAvgPixelR, - vAvgPixelG, - vAvgPixelB); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(TempPixel, vTarget, predGlb); - - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y)}; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - vst1q_p(pTarget, vTarget, predTail); -} - -static -void __arm_2d_impl_rgb565_get_pixel_colour_offs_compensated( arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - /* pack */ - uint16x8_t TempPixel = __arm_2d_rgb565_pack_single_vec(vAvgPixelR, - vAvgPixelG, - vAvgPixelB); - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(TempPixel, vTarget, predGlb); - - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y)}; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = - vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vTarget = vpselq_u16(ptVal, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - - - -static -void __arm_2d_impl_rgb565_get_pixel_colour_with_alpha( - arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint8_t chOpacity, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* alpha blending */ - uint16x8_t vBlended; - - __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(chOpacity, vTarget, vAvgPixelR, vAvgPixelG, vAvgPixelB, vBlended); - - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y)}; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - uint16x8_t ptOffs = vPoint.X + vPoint.Y * iOrigStride; - /* retrieve all point values */ - uint16x8_t ptVal = vldrhq_gather_shifted_offset_u16(pOrigin, ptOffs); - - /* alpha blending */ - uint16x8_t vBlended = - __arm_2d_rgb565_alpha_blending_single_vec(ptVal, vTarget, chOpacity); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - - -static -void __arm_2d_impl_rgb565_get_pixel_colour_with_alpha_offs_compensated( - arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint16_t *pOrigin, - int16_t iOrigStride, - uint16_t *pTarget, - uint16_t MaskColour, - uint8_t chOpacity, - uint32_t elts) -{ - mve_pred16_t predTail = vctp16q(elts); - uint16x8_t vTarget = vld1q(pTarget); - -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - SET_Q6INT(vXi); - int16x8_t vWY = ptPoint->Y - SET_Q6INT(vYi); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulator */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlb = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - /* Bottom Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - - /* Bottom Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vYi, R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vXi, vaddq_n_s16(vYi, 1), R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB565_GET_RGBVEC_FROM_POINT_FAR(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlb); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - /* alpha blending */ - uint16x8_t vBlended; - - __ARM_2D_BLEND_RGB565_TARGET_RGBVEC(chOpacity, vTarget, vAvgPixelR, vAvgPixelG, vAvgPixelB, vBlended); - - - - /* select between target pixel, averaged pixed */ - vTarget = vpselq_u16(vBlended, vTarget, predGlb); - -#else - /* extract integer part */ - arm_2d_point_s16x8_t vPoint = { - .X = GET_Q6INT(ptPoint->X), - .Y = GET_Q6INT(ptPoint->Y)}; - - /* set vector predicate if point is inside the region */ - mve_pred16_t p = arm_2d_is_point_vec_inside_region_s16(ptOrigValidRegion, &vPoint); - /* prepare vector of point offsets */ - /* correctionOffset avoid 16-bit overflow */ - int16_t correctionOffset = vminvq_s16(0x7fff, vPoint.Y) - 1; - uint16x8_t ptOffs = - vPoint.X + (vPoint.Y - correctionOffset) * iOrigStride; - - /* retrieve all point values */ - /* base pointer update to compensate offset */ - pOrigin += (correctionOffset * iOrigStride); - - uint16x8_t ptVal = vldrhq_gather_shifted_offset_z_u16(pOrigin, ptOffs, predTail); - - /* alpha blending */ - uint16x8_t vBlended = - __arm_2d_rgb565_alpha_blending_single_vec(ptVal, vTarget, chOpacity); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vTarget = vpselq_u16(vBlended, vTarget, vcmpneq_m_n_u16(ptVal, MaskColour, p)); - -#endif - - vst1q_p(pTarget, vTarget, predTail); -} - -static -void __arm_2d_impl_cccn888_get_pixel_colour( arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint32_t *pOrigin, - int16_t iOrigStride, - uint32_t *pTarget, - uint32_t MaskColour, - int16_t elts) -{ -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - ARM_ALIGN(8) uint32_t scratch32[32]; - int16_t *pscratch16 = (int16_t *) scratch32; - uint32x4_t vTargetLo = vld1q(pTarget); - uint32x4_t vTargetHi = vld1q(pTarget + 4); - mve_pred16_t predTailLow = vctp32q(elts); - mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - (SET_Q6INT(vXi)); - int16x8_t vWY = ptPoint->Y - (SET_Q6INT(vYi)); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulators */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlbLo = 0, predGlbHi = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - - /* Bottom Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - - /* pack */ - __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vAvgPixelR, vAvgPixelG, vAvgPixelB); - - uint32x4_t TempPixel = vld1q(scratch32); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); - - vst1q_p(pTarget, TempPixel, predTailLow); - - TempPixel = vld1q(scratch32 + 4); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); - - vst1q_p(pTarget + 4, TempPixel, predTailHigh); -#else - - arm_2d_point_s32x4_t tPointLo, tPointHi; - ARM_ALIGN(8) int16_t scratch[8]; - mve_pred16_t p; - - /* split 16-bit point vector into 2 x 32-bit vectors */ - vst1q(scratch, GET_Q6INT(ptPoint->X)); - tPointLo.X = vldrhq_s32(scratch); - tPointHi.X = vldrhq_s32(scratch + 4); - - vst1q(scratch, GET_Q6INT(ptPoint->Y)); - tPointLo.Y = vldrhq_s32(scratch); - tPointHi.Y = vldrhq_s32(scratch + 4); - - /* 1st half */ - - /* set vector predicate if point is inside the region */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); - /* prepare vector of point offsets */ - uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; - uint32x4_t vPixel = vld1q(pTarget); - /* retrieve all point values */ - uint32x4_t ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - /* combine 2 predicates set to true if point is in the region & values different from color mask */ - vPixel = vpselq_u32(ptVal, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget, vPixel, vctp32q(elts)); - - elts -= 4; - if (elts > 0) { - - /* second half */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); - ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; - vPixel = vld1q(pTarget + 4); - - ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - vPixel = vpselq_u32(ptVal, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - vst1q_p(pTarget + 4, vPixel, vctp32q(elts)); - } -#endif -} - -static -void __arm_2d_impl_cccn888_get_pixel_colour_with_alpha( - arm_2d_point_s16x8_t *ptPoint, - arm_2d_region_t *ptOrigValidRegion, - uint32_t *pOrigin, - int16_t iOrigStride, - uint32_t *pTarget, - uint32_t MaskColour, - uint8_t chOpacity, - int16_t elts) -{ -#if defined(__ARM_2D_HAS_INTERPOLATION_ROTATION__) && __ARM_2D_HAS_INTERPOLATION_ROTATION__ - ARM_ALIGN(8) uint32_t scratch32[32]; - int16_t *pscratch16 = (int16_t *) scratch32; - uint32x4_t vTargetLo = vld1q(pTarget); - uint32x4_t vTargetHi = vld1q(pTarget + 4); - mve_pred16_t predTailLow = vctp32q(elts); - mve_pred16_t predTailHigh = elts - 4 > 0 ? vctp32q(elts - 4) : 0; - int16x8_t vOne = vdupq_n_s16(SET_Q6INT(1)); - - int16x8_t vXi = GET_Q6INT(ptPoint->X); - int16x8_t vYi = GET_Q6INT(ptPoint->Y); - - vXi = vsubq_m_n_s16(vXi, vXi, 1, vcmpltq_n_s16(ptPoint->X, 0)); - vYi = vsubq_m_n_s16(vYi, vYi, 1, vcmpltq_n_s16(ptPoint->Y, 0)); - - int16x8_t vWX = ptPoint->X - (SET_Q6INT(vXi)); - int16x8_t vWY = ptPoint->Y - (SET_Q6INT(vYi)); - - /* combination of Bottom / Top & Left / Right areas contributions */ - uint16x8_t vAreaTR = vmulq_u16(vWX, vWY); - uint16x8_t vAreaTL = vmulq_u16((vOne - vWX), vWY); - uint16x8_t vAreaBR = vmulq_u16(vWX, (vOne - vWY)); - uint16x8_t vAreaBL = vmulq_u16((vOne - vWX), (vOne - vWY)); - - /* Q16 conversion */ - vAreaTR = vqshlq_n_u16(vAreaTR, 4); - vAreaTL = vqshlq_n_u16(vAreaTL, 4); - vAreaBR = vqshlq_n_u16(vAreaBR, 4); - vAreaBL = vqshlq_n_u16(vAreaBL, 4); - - - /* accumulated pixel vectors */ - uint16x8_t vAvgPixelR, vAvgPixelG, vAvgPixelB; - - /* predicate accumulators */ - /* tracks all predications conditions for selecting final */ - /* averaged pixed / target pixel */ - /* can probably optimized away since averaged target pixel is */ - /* equivalent to original pixel, but precision limitations would introduce small errors */ - mve_pred16_t predGlbLo = 0, predGlbHi = 0; - - /* - * accumulate / average over the 4 neigbouring pixels - */ - - uint16x8_t R, G, B; - - /* Bottom Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vYi, R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBL); - } - - /* Bottom Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vYi, - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaBR); - } - - /* Top Left averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vXi, vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTL); - } - - /* Top Right averaging */ - { - __ARM_2D_RGB888_GET_RGBVEC_FROM_POINT(vaddq_n_s16(vXi, 1), vaddq_n_s16(vYi, 1), - R, G, B, MaskColour, predGlbLo, predGlbHi); - - __ARM_2D_SCALE_RGBVEC_ACC(vAvgPixelR, vAvgPixelG, vAvgPixelB, R, G, B, vAreaTR); - } - - /* alpha blending */ - uint16x8_t vTargetR, vTargetG, vTargetB; - - __arm_2d_unpack_rgb888_from_mem((const uint8_t *) pTarget, &vTargetR, &vTargetG, &vTargetB); - - uint16_t chOpacityCompl = (256 - chOpacity); - - /* merge */ - vAvgPixelR = vmlaq_n_u16(vmulq_n_u16(vAvgPixelR, chOpacityCompl), vTargetR, chOpacity); - vAvgPixelR = vAvgPixelR >> 8; - - vAvgPixelG = vmlaq_n_u16(vmulq_n_u16(vAvgPixelG, chOpacityCompl), vTargetG, chOpacity); - vAvgPixelG = vAvgPixelG >> 8; - - vAvgPixelB = vmlaq_n_u16(vmulq_n_u16(vAvgPixelB, chOpacityCompl), vTargetB, chOpacity); - vAvgPixelB = vAvgPixelB >> 8; - - /* pack */ - __arm_2d_pack_rgb888_to_mem((uint8_t *) scratch32, vAvgPixelR, vAvgPixelG, vAvgPixelB); - - uint32x4_t TempPixel = vld1q(scratch32); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetLo, predGlbLo); - - vst1q_p(pTarget, TempPixel, predTailLow); - - TempPixel = vld1q(scratch32 + 4); - - /* select between target pixel, averaged pixed */ - TempPixel = vpselq_u32(TempPixel, vTargetHi, predGlbHi); - - vst1q_p(pTarget + 4, TempPixel, predTailHigh); -#else - arm_2d_point_s32x4_t tPointLo, tPointHi; - ARM_ALIGN(8) int16_t scratch[8]; - ARM_ALIGN(8) uint32_t blendled[4]; - mve_pred16_t p; - - /* split 16-bit point vector into 2 x 32-bit vectors */ - vst1q(scratch, GET_Q6INT(ptPoint->X)); - tPointLo.X = vldrhq_s32(scratch); - tPointHi.X = vldrhq_s32(scratch + 4); - - vst1q(scratch, GET_Q6INT(ptPoint->Y)); - tPointLo.Y = vldrhq_s32(scratch); - tPointHi.Y = vldrhq_s32(scratch + 4); - - /* 1st half */ - - /* set vector predicate if point is inside the region */ - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointLo); - /* prepare vector of point offsets */ - uint32x4_t ptOffs = tPointLo.X + tPointLo.Y * iOrigStride; - uint32x4_t vPixel = vld1q(pTarget); - /* retrieve all point values */ - uint32x4_t ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - vstrwq_u32((uint32_t *) scratch, ptVal); - - /* alpha-blending (requires widened inputs) */ - vstrbq_u16((uint8_t *) blendled, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *) scratch), - vldrbq_u16((uint8_t const *) pTarget), chOpacity)); - - vstrbq_u16((uint8_t *) blendled + 2, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *)scratch + 4), - vldrbq_u16((uint8_t const *)pTarget + 2), chOpacity)); - - uint32x4_t vBlended = vld1q(blendled); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vPixel = vpselq_u32(vBlended, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget, vPixel, vctp32q(elts)); - - elts -= 4; - if(elts > 0) { - /* second half */ - - p = arm_2d_is_point_vec_inside_region_s32(ptOrigValidRegion, &tPointHi); - ptOffs = tPointHi.X + tPointHi.Y * iOrigStride; - vPixel = vld1q(pTarget); - ptVal = vldrwq_gather_shifted_offset_u32(pOrigin, ptOffs); - - vstrwq_u32((uint32_t *) scratch, ptVal); - - /* alpha-blending (requires widened inputs) */ - vstrbq_u16((uint8_t *) blendled, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *) scratch), - vldrbq_u16((uint8_t const *) pTarget), chOpacity)); - vstrbq_u16((uint8_t *) blendled + 2, - __rgb888_alpha_blending_direct_single_vec(vldrbq_u16((uint8_t const *)scratch + 4), - vldrbq_u16((uint8_t const *)pTarget + 2), chOpacity)); - - vBlended = vld1q(blendled); - - /* combine 2 predicates, set to true, if point is in the region & values different from color mask */ - vPixel = vpselq_u32(vBlended, vPixel, vcmpneq_m_n_u32(ptVal, MaskColour, p)); - - vst1q_p(pTarget + 4, vPixel, vctp32q(elts)); - } -#endif -} - -#endif - - -#define __API_INT_TYPE_BIT_NUM 8 -#define __API_COLOUR gray8 -#include "__arm_2d_rotate_helium.inc" - -#define __API_INT_TYPE_BIT_NUM 16 -#define __API_COLOUR rgb565 -#include "__arm_2d_rotate_helium.inc" - -#define __API_INT_TYPE_BIT_NUM 32 -#define __API_COLOUR cccn888 -#include "__arm_2d_rotate_helium.inc" - /* rgb8_draw_pattern helpers */ @@ -4557,8 +1930,11 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { Macro assumes pTarget8/ pAlpha are already setup */ + + + #define C8BIT_COLOUR_FILLING_MASK_INNER_MVE(TRGT_LOAD, STRIDE, SCAL_OPACITY, \ - OPACITY, ALPHA_SZ) \ + OPACITY, ALPHA_SZ, COMPVAL) \ int32_t blkCnt = iWidth; \ do { \ mve_pred16_t tailPred = vctp16q(blkCnt); \ @@ -4567,6 +1943,9 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { uint16x8_t vecTransp = TRGT_LOAD(pAlpha, STRIDE, tailPred); \ \ vecTransp = SCAL_OPACITY(vecTransp, OPACITY, tailPred); \ + \ + ALPHA_255_COMP_VEC16(vecTransp, COMPVAL); \ + \ uint16x8_t vecAlpha = vsubq_x_u16(v256, vecTransp, tailPred); \ \ vecTarget = vmulq_x(vecTarget, vecAlpha, tailPred); \ @@ -4599,7 +1978,7 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { */ #define RGB565_COLOUR_FILLING_MASK_MVE(TRGT_LOAD, STRIDE, SCAL_OPACITY, OPACITY, \ - P_ALPHA, ALPHA_SZ) \ + P_ALPHA, ALPHA_SZ, COMPVAL) \ uint16x8_t v256 = vdupq_n_u16(256); \ \ for (int_fast16_t y = 0; y < iHeight; y++) { \ @@ -4611,6 +1990,9 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { uint16x8_t vecTarget = vld1q(pCurTarget); \ uint16x8_t vecTransp = TRGT_LOAD(pAlpha, STRIDE); \ vecTransp = SCAL_OPACITY(vecTransp, OPACITY); \ + \ + ALPHA_255_COMP_VEC16(vecTransp, COMPVAL); \ + \ uint16x8_t vecAlpha = vsubq_u16(v256, vecTransp); \ uint16x8_t vecR, vecG, vecB; \ \ @@ -4660,7 +2042,7 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { */ #define CCCN888_COLOUR_FILLING_MASK_INNER_MVE(TRGT_LOAD, STRIDE, SCAL_OPACITY, \ - OPACITY, ALPHA_SZ) \ + OPACITY, ALPHA_SZ, COMPVAL) \ int32_t blkCnt = iWidth; \ \ do { \ @@ -4677,8 +2059,11 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { \ vecTransp = SCAL_OPACITY(vecTransp, OPACITY, tailPred); \ \ + ALPHA_255_COMP_VEC16(vecTransp, COMPVAL); \ + \ uint16x8_t vecAlpha = vsubq_x_u16(v256, vecTransp, tailPred); \ \ + \ /* scale ch0 vector with alpha vector */ \ vecTargetC0 = vmulq_x(vecTargetC0, vecAlpha, tailPred); \ /* blend ch0 vector with input ch0 color*/ \ @@ -4727,7 +2112,7 @@ static uint32_t __draw_pattern_src_bitmask_rgb32[16] = { __OVERRIDE_WEAK -void __arm_2d_impl_gray8_colour_filling_mask(uint8_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_gray8_colour_filling_mask)(uint8_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, @@ -4744,19 +2129,27 @@ void __arm_2d_impl_gray8_colour_filling_mask(uint8_t * __RESTRICT pTarget, #ifdef USE_MVE_INTRINSICS C8BIT_COLOUR_FILLING_MASK_INNER_MVE(C8BIT_TRGT_LOAD, _, - C8BIT_SCAL_OPACITY_NONE, _, 1); + C8BIT_SCAL_OPACITY_NONE, _, 1, 255); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" " vldrb.u16 q0, [%[pTarget]] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" - " vmul.u16 q3, q0, q2 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif + + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vmla.u16 q3, q1, %[Colour] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" @@ -4765,10 +2158,13 @@ void __arm_2d_impl_gray8_colour_filling_mask(uint8_t * __RESTRICT pTarget, " letp lr, 2b \n" "1: \n" - : [pTarget] "+r"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + " .unreq vecAlphaCompl \n" + : [pTarget] "+l"(pTarget8), [pAlpha] "+l" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[Colour] "r"(Colour) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif :"q0", "q1", "q2", "q3", "memory"); - #endif pchAlpha += (iAlphaStride); pTarget += (iTargetStride); @@ -4776,17 +2172,18 @@ void __arm_2d_impl_gray8_colour_filling_mask(uint8_t * __RESTRICT pTarget, } __OVERRIDE_WEAK -void __arm_2d_impl_gray8_colour_filling_mask_opacity(uint8_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_gray8_colour_filling_mask_opacity)(uint8_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint8_t Colour, uint8_t chOpacity) + uint8_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); uint16x8_t v256 = vdupq_n_u16(256); for (int_fast16_t y = 0; y < iHeight; y++) { @@ -4795,20 +2192,29 @@ void __arm_2d_impl_gray8_colour_filling_mask_opacity(uint8_t * __RESTRICT pTarge #ifdef USE_MVE_INTRINSICS C8BIT_COLOUR_FILLING_MASK_INNER_MVE(C8BIT_TRGT_LOAD, _, - C8BIT_SCAL_OPACITY, vOpacity, 1); + C8BIT_SCAL_OPACITY, vOpacity, 1, 254); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" " vldrb.u16 q0, [%[pTarget]] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" " vmulh.u8 q1, q1, %[vOpacity] \n" " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" - " vmul.u16 q3, q0, q2 \n" + +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif + + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTarget], #8] \n" " vmla.u16 q3, q1, %[Colour] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" @@ -4818,8 +2224,12 @@ void __arm_2d_impl_gray8_colour_filling_mask_opacity(uint8_t * __RESTRICT pTarge " letp lr, 2b \n" "1: \n" - : [pTarget] "+r"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + " .unreq vecAlphaCompl \n" + : [pTarget] "+l"(pTarget8), [pAlpha] "+l" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[Colour] "r"(Colour),[vOpacity] "t"(vOpacity) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif :"q0", "q1", "q2", "q3", "memory"); #endif @@ -4830,7 +2240,7 @@ void __arm_2d_impl_gray8_colour_filling_mask_opacity(uint8_t * __RESTRICT pTarge __OVERRIDE_WEAK -void __arm_2d_impl_gray8_colour_filling_channel_mask(uint8_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_gray8_colour_filling_channel_mask)(uint8_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, @@ -4848,30 +2258,42 @@ void __arm_2d_impl_gray8_colour_filling_channel_mask(uint8_t * __RESTRICT pTarge #ifdef USE_MVE_INTRINSICS C8BIT_COLOUR_FILLING_MASK_INNER_MVE(C8BIT_TRGT_LOAD_STRIDE, vStride4Offs, - C8BIT_SCAL_OPACITY_NONE, _, 4); + C8BIT_SCAL_OPACITY_NONE, _, 4, 255); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" " vldrb.u16 q0, [%[pTarget]] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" - " vmul.u16 q3, q0, q2 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif + " add %[pAlpha], %[pAlpha], #(8*4) \n" + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTarget], #8] \n" - " vmla.u16 q3, q1, %[Colour] \n" + " vmla.s16 q3, q1, %[Colour] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTarget]], #8 \n" " letp lr, 2b \n" "1: \n" - : [pTarget] "+r"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + " .unreq vecAlphaCompl \n" + : [pTarget] "+l"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[Colour] "r"(Colour),[str4Offs] "t"(vStride4Offs) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif :"q0", "q1", "q2", "q3", "memory"); #endif @@ -4884,17 +2306,18 @@ void __arm_2d_impl_gray8_colour_filling_channel_mask(uint8_t * __RESTRICT pTarge __OVERRIDE_WEAK -void __arm_2d_impl_gray8_colour_filling_channel_mask_opacity(uint8_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_gray8_colour_filling_channel_mask_opacity)(uint8_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint8_t Colour, uint8_t chOpacity) + uint8_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); uint16x8_t v256 = vdupq_n_u16(256); uint16x8_t vStride4Offs = vidupq_n_u16(0, 4); @@ -4904,23 +2327,33 @@ void __arm_2d_impl_gray8_colour_filling_channel_mask_opacity(uint8_t * __RESTRIC #ifdef USE_MVE_INTRINSICS C8BIT_COLOUR_FILLING_MASK_INNER_MVE(C8BIT_TRGT_LOAD_STRIDE, vStride4Offs, - C8BIT_SCAL_OPACITY, vOpacity, 4); + C8BIT_SCAL_OPACITY, vOpacity, 4, 254); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" " vldrb.u16 q0, [%[pTarget]] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " vmulh.u8 q1, q1, %[vOpacity] \n" " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" - " vmul.u16 q3, q0, q2 \n" - " vldrb.u16 q0, [%[pTarget], #8] \n" + +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif + " add %[pAlpha], %[pAlpha], #(8*4) \n" - " vmla.u16 q3, q1, %[Colour] \n" + + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" + " vldrb.u16 q0, [%[pTarget], #8] \n" + " vmla.s16 q3, q1, %[Colour] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " vmulh.u8 q1, q1, %[vOpacity] \n" " vshr.u16 q3, q3, #8 \n" @@ -4928,9 +2361,13 @@ void __arm_2d_impl_gray8_colour_filling_channel_mask_opacity(uint8_t * __RESTRIC " letp lr, 2b \n" "1: \n" - : [pTarget] "+r"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + " .unreq vecAlphaCompl \n" + : [pTarget] "+l"(pTarget8), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[Colour] "r"(Colour),[vOpacity] "t"(vOpacity), [str4Offs] "t"(vStride4Offs) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif :"q0", "q1", "q2", "q3", "memory"); #endif @@ -4941,7 +2378,7 @@ void __arm_2d_impl_gray8_colour_filling_channel_mask_opacity(uint8_t * __RESTRIC __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_colour_filling_mask)(uint16_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, @@ -4955,12 +2392,12 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, __arm_2d_rgb565_unpack(*(&Colour), &tSrcPix); #ifdef USE_MVE_INTRINSICS - RGB565_COLOUR_FILLING_MASK_MVE(RGB565_TRGT_LOAD, _, - RGB565_SCAL_OPACITY_NONE, _, pchAlpha, 1); + RGB565_COLOUR_FILLING_MASK_MVE( RGB565_TRGT_LOAD, _, + RGB565_SCAL_OPACITY_NONE, _, pchAlpha, 1, 255); #else /* RGB565 pack/unpack Masks */ /* use memory rather than vmov to optimize Helium operations interleaving */ - uint16x8_t scratch[4]; + uint16x8_t scratch[5]; // Unpacking Mask Red vst1q((uint16_t*)&scratch[0], vdupq_n_u16(0x1f)); @@ -4987,6 +2424,12 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif + // vecAlpha " vsub.i16 q2, q7, q1 \n" @@ -5011,7 +2454,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " vshr.u16 q6, q0, #11 \n" /* blend G vector with input G color*/ - " vmla.u16 q5, q1, %[G] \n" + " vmla.s16 q5, q1, %[G] \n" /* vecAlpha * 8 for R & B upscale */ " vshl.i16 q2, q2, #1 \n" @@ -5022,7 +2465,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " vshr.u16 q5, q5, #8 \n" /* blend R vector with input R color*/ - " vmla.u16 q4, q1, %[R] \n" + " vmla.s16 q4, q1, %[B] \n" /* load packing Mask for G channel */ " vldrh.u16 q7, [%[scratch], #(2*16)] \n" @@ -5032,7 +2475,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " vand q5, q5, q7 \n" /* blend B vector with input B color*/ - " vmla.u16 q6, q1, %[B] \n" + " vmla.s16 q6, q1, %[R] \n" /* load packing Mask for B channel */ " vldrh.u16 q7, [%[scratch], #(3*16)] \n" @@ -5052,7 +2495,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " vmov.i16 q7, #0x0100 \n" /* pack G & B */ - " vmla.u16 q5, q6, %[twofiftysix] \n" + " vmla.s16 q5, q6, %[twofiftysix] \n" /* combined (R >> 8) >> 3 */ " vshr.u16 q4, q4, #11 \n" @@ -5064,10 +2507,13 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, " vstrh.16 q4, [%[pTarget]], #16 \n" " letp lr, 2b \n" "1: \n" - :[pTarget]"+r"(pCurTarget),[pAlpha] "+r"(pAlpha),[loopCnt] "+r"(blkCnt) + :[pTarget]"+l"(pCurTarget),[pAlpha] "+l"(pAlpha),[loopCnt] "+r"(blkCnt) :[Colour] "r"(Colour), [eight] "r" (8), [four] "r" (4), [R] "r" (tSrcPix.R), [G] "r" (tSrcPix.G), [B] "r" (tSrcPix.B), [twofiftysix] "r" (256), [scratch] "r" (scratch) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif :"q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"); pchAlpha += (iAlphaStride); @@ -5079,28 +2525,29 @@ void __arm_2d_impl_rgb565_colour_filling_mask(uint16_t * __RESTRICT pTarget, __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_colour_filling_mask_opacity)(uint16_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint16_t Colour, uint8_t chOpacity) + uint16_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); __arm_2d_color_fast_rgb_t tSrcPix; __arm_2d_rgb565_unpack(*(&Colour), &tSrcPix); #ifdef USE_MVE_INTRINSICS - RGB565_COLOUR_FILLING_MASK_MVE(RGB565_TRGT_LOAD, _, - RGB565_SCAL_OPACITY, vOpacity, pchAlpha, 1); + RGB565_COLOUR_FILLING_MASK_MVE( RGB565_TRGT_LOAD, _, + RGB565_SCAL_OPACITY, vOpacity, pchAlpha, 1, 254); #else /* RGB565 pack/unpack Masks + opacity */ /* use memory rather than vmov to optimize Helium operations interleaving */ - uint16x8_t scratch[5]; + uint16x8_t scratch[6]; // Unpacking Mask Red vst1q((uint16_t*)&scratch[0], vdupq_n_u16(0x1f)); @@ -5113,7 +2560,6 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar // opacity vst1q((uint16_t*)&scratch[4], (uint16x8_t)vOpacity); - for (int_fast16_t y = 0; y < iHeight; y++) { const uint8_t *pAlpha = pchAlpha; uint16_t *pCurTarget = pTarget; @@ -5133,6 +2579,11 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif // vecAlpha " vsub.i16 q2, q7, q1 \n" @@ -5157,7 +2608,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " vshr.u16 q6, q0, #11 \n" /* blend G vector with input G color*/ - " vmla.u16 q5, q1, %[G] \n" + " vmla.s16 q5, q1, %[G] \n" /* vecAlpha * 8 for R & B upscale */ " vshl.i16 q2, q2, #1 \n" @@ -5168,7 +2619,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " vshr.u16 q5, q5, #8 \n" /* blend R vector with input R color*/ - " vmla.u16 q4, q1, %[R] \n" + " vmla.s16 q4, q1, %[B] \n" /* load packing Mask for G channel */ " vldrh.u16 q7, [%[scratch], #(2*16)] \n" @@ -5178,7 +2629,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " vand q5, q5, q7 \n" /* blend B vector with input B color*/ - " vmla.u16 q6, q1, %[B] \n" + " vmla.s16 q6, q1, %[R] \n" /* load packing Mask for B channel */ " vldrh.u16 q7, [%[scratch], #(3*16)] \n" @@ -5198,7 +2649,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " vmov.i16 q7, #0x0100 \n" /* pack G & B */ - " vmla.u16 q5, q6, %[twofiftysix] \n" + " vmla.s16 q5, q6, %[twofiftysix] \n" /* reload opacity and scale alpha */ " vldrh.u16 q6, [%[scratch], #(4*16)] \n" " vmulh.u8 q1, q1, q6 \n" @@ -5214,10 +2665,13 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar " vstrh.16 q4, [%[pTarget]], #16 \n" " letp lr, 2b \n" "1: \n" - :[pTarget]"+r"(pCurTarget),[pAlpha] "+r"(pAlpha),[loopCnt] "+r"(blkCnt) + :[pTarget]"+r"(pCurTarget),[pAlpha] "+l"(pAlpha),[loopCnt] "+r"(blkCnt) :[Colour] "r"(Colour), [eight] "r" (8), [four] "r" (4), [R] "r" (tSrcPix.R), [G] "r" (tSrcPix.G), [B] "r" (tSrcPix.B), [twofiftysix] "r" (256), [scratch] "r" (scratch) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif :"q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"); pchAlpha += (iAlphaStride); @@ -5228,7 +2682,7 @@ void __arm_2d_impl_rgb565_colour_filling_mask_opacity(uint16_t * __RESTRICT pTar __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_colour_filling_channel_mask)(uint16_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, @@ -5244,7 +2698,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar #ifdef USE_MVE_INTRINSICS RGB565_COLOUR_FILLING_MASK_MVE(RGB565_TRGT_LOAD_STRIDE, vStride4Offs, - RGB565_SCAL_OPACITY_NONE, _, pwAlpha, 4); + RGB565_SCAL_OPACITY_NONE, _, pwAlpha, 4, 1); #else /* RGB565 pack/unpack Masks */ /* use memory rather than vmov to optimize Helium operations interleaving */ @@ -5276,6 +2730,11 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" " add %[pAlpha], %[pAlpha],#(8*4)\n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif // vecAlpha " vsub.i16 q2, q7, q1 \n" @@ -5300,7 +2759,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar " vshr.u16 q6, q0, #11 \n" /* blend G vector with input G color*/ - " vmla.u16 q5, q1, %[G] \n" + " vmla.s16 q5, q1, %[G] \n" /* vecAlpha * 8 for R & B upscale */ " vshl.i16 q2, q2, #1 \n" @@ -5311,7 +2770,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar " vshr.u16 q5, q5, #8 \n" /* blend R vector with input R color*/ - " vmla.u16 q4, q1, %[R] \n" + " vmla.s16 q4, q1, %[B] \n" /* load packing Mask for G channel */ " vldrh.u16 q7, [%[scratch], #(2*16)] \n" @@ -5321,7 +2780,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar " vand q5, q5, q7 \n" /* blend B vector with input B color*/ - " vmla.u16 q6, q1, %[B] \n" + " vmla.s16 q6, q1, %[R] \n" /* load packing Mask for B channel */ " vldrh.u16 q7, [%[scratch], #(3*16)] \n" @@ -5342,7 +2801,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar " vmov.i16 q7, #0x0100 \n" /* pack G & B */ - " vmla.u16 q5, q6, %[twofiftysix] \n" + " vmla.s16 q5, q6, %[twofiftysix] \n" /* combined (R >> 8) >> 3 */ " vshr.u16 q4, q4, #11 \n" @@ -5358,6 +2817,9 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar :[Colour] "r"(Colour), [eight] "r" (8), [four] "r" (4), [R] "r" (tSrcPix.R), [G] "r" (tSrcPix.G), [B] "r" (tSrcPix.B), [twofiftysix] "r" (256), [scratch] "r" (scratch), [str4Offs] "t"(vStride4Offs) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif :"q0", "q1", "q2", "q4", "q5", "q6", "q7", "memory"); pwAlpha += (iAlphaStride); @@ -5368,17 +2830,18 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask(uint16_t * __RESTRICT pTar __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity)(uint16_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint16_t Colour, uint8_t chOpacity) + uint16_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; uint16x8_t vStride4Offs = vidupq_n_u16(0, 4); - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); __arm_2d_color_fast_rgb_t tSrcPix; __arm_2d_rgb565_unpack(*(&Colour), &tSrcPix); @@ -5386,7 +2849,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR #ifdef USE_MVE_INTRINSICS RGB565_COLOUR_FILLING_MASK_MVE(RGB565_TRGT_LOAD_STRIDE, vStride4Offs, - RGB565_SCAL_OPACITY, vOpacity, pwAlpha, 4); + RGB565_SCAL_OPACITY, vOpacity, pwAlpha, 4, 2); #else /* RGB565 pack/unpack Masks + opacity */ /* use memory rather than vmov to optimize Helium operations interleaving */ @@ -5423,6 +2886,11 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" " add %[pAlpha], %[pAlpha],#(8*4)\n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif // vecAlpha " vsub.i16 q2, q7, q1 \n" @@ -5447,7 +2915,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR " vshr.u16 q6, q0, #11 \n" /* blend G vector with input G color*/ - " vmla.u16 q5, q1, %[G] \n" + " vmla.s16 q5, q1, %[G] \n" /* vecAlpha * 8 for R & B upscale */ " vshl.i16 q2, q2, #1 \n" @@ -5458,7 +2926,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR " vshr.u16 q5, q5, #8 \n" /* blend R vector with input R color*/ - " vmla.u16 q4, q1, %[R] \n" + " vmla.s16 q4, q1, %[B] \n" /* load packing Mask for G channel */ " vldrh.u16 q7, [%[scratch], #(2*16)] \n" @@ -5468,7 +2936,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR " vand q5, q5, q7 \n" /* blend B vector with input B color*/ - " vmla.u16 q6, q1, %[B] \n" + " vmla.s16 q6, q1, %[R] \n" /* load packing Mask for B channel */ " vldrh.u16 q7, [%[scratch], #(3*16)] \n" @@ -5489,7 +2957,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR " vmov.i16 q7, #0x0100 \n" /* pack G & B */ - " vmla.u16 q5, q6, %[twofiftysix] \n" + " vmla.s16 q5, q6, %[twofiftysix] \n" /* combined (R >> 8) >> 3 */ " vldrh.u16 q6, [%[scratch], #(4*16)] \n" " vmulh.u8 q1, q1, q6 \n" @@ -5507,6 +2975,9 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR :[Colour] "r"(Colour), [eight] "r" (8), [four] "r" (4), [R] "r" (tSrcPix.R), [G] "r" (tSrcPix.G), [B] "r" (tSrcPix.B), [twofiftysix] "r" (256), [scratch] "r" (scratch), [str4Offs] "t"(vStride4Offs) +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif :"q0", "q1", "q2", "q4", "q5", "q6", "q7", "memory"); pwAlpha += (iAlphaStride); @@ -5518,7 +2989,7 @@ void __arm_2d_impl_rgb565_colour_filling_channel_mask_opacity(uint16_t * __RESTR __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_colour_filling_mask)(uint32_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, @@ -5544,13 +3015,15 @@ void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, #ifdef USE_MVE_INTRINSICS CCCN888_COLOUR_FILLING_MASK_INNER_MVE(CCCN888_TRGT_LOAD, _, - CCCN888_SCAL_OPACITY_NONE, _, 1); + CCCN888_SCAL_OPACITY_NONE, _, 1, 255); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" /* expand chan0 */ " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" @@ -5559,26 +3032,31 @@ void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" /* scale ch0 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan1 */ " vldrb.u16 q0, [%[pTargetCh1], %[str4Offs]] \n" /* blend ch0 vector with input ch0 color*/ - " vmla.u16 q3, q1, %[c0] \n" + " vmla.s16 q3, q1, %[c0] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh0], %[str4Offs]] \n" /* scale ch1 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan2 */ " vldrb.u16 q0, [%[pTargetCh2], %[str4Offs]] \n" /* blend ch1 vector with input ch1 color*/ - " vmla.u16 q3, q1, %[c1] \n" + " vmla.s16 q3, q1, %[c1] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh1], %[str4Offs]] \n" @@ -5586,11 +3064,11 @@ void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, " adds %[pTargetCh1], #32 \n" /* scale ch2 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" /* blend ch2 vector with input ch2 color*/ - " vmla.u16 q3, q1, %[c2] \n" + " vmla.s16 q3, q1, %[c2] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" " vshr.u16 q3, q3, #8 \n" @@ -5601,11 +3079,16 @@ void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, " letp lr, 2b \n" "1: \n" + " .unreq vecAlphaCompl \n" + :[pTargetCh0] "+r"(pTargetCh0), [pTargetCh1] "+r"(pTargetCh1), - [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+l" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[str4Offs] "t" (vStride4Offs), [c0] "r"(c0), [c1] "r"(c1), [c2] "r"(c2) - :"q0", "q1", "q2", "q3", "memory"); +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif + :"q0", "q1", "q2", "q3", "memory", "cc"); #endif pchAlpha += (iAlphaStride); @@ -5616,18 +3099,19 @@ void __arm_2d_impl_cccn888_colour_filling_mask(uint32_t * __RESTRICT pTarget, __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_colour_filling_mask_opacity)(uint32_t * __RESTRICT pTarget, int16_t iTargetStride, uint8_t * __RESTRICT pchAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint32_t Colour, uint8_t chOpacity) + uint32_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; uint16x8_t v256 = vdupq_n_u16(256); uint16x8_t vStride4Offs = vidupq_n_u16(0, 4); - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); uint16_t c0, c1, c2; c0 = Colour & 0xff; @@ -5643,13 +3127,15 @@ void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTa #ifdef USE_MVE_INTRINSICS CCCN888_COLOUR_FILLING_MASK_INNER_MVE(CCCN888_TRGT_LOAD, _, - CCCN888_SCAL_OPACITY, vOpacity, 1); + CCCN888_SCAL_OPACITY, vOpacity, 1, 254); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" /* expand chan0 */ " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" @@ -5659,26 +3145,31 @@ void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTa " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" /* scale ch0 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan1 */ " vldrb.u16 q0, [%[pTargetCh1], %[str4Offs]] \n" /* blend ch0 vector with input ch0 color*/ - " vmla.u16 q3, q1, %[c0] \n" + " vmla.s16 q3, q1, %[c0] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh0], %[str4Offs]] \n" /* scale ch1 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan2 */ " vldrb.u16 q0, [%[pTargetCh2], %[str4Offs]] \n" /* blend ch1 vector with input ch1 color*/ - " vmla.u16 q3, q1, %[c1] \n" + " vmla.s16 q3, q1, %[c1] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh1], %[str4Offs]] \n" @@ -5686,11 +3177,11 @@ void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTa " adds %[pTargetCh1], #32 \n" /* scale ch2 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" /* blend ch2 vector with input ch2 color*/ - " vmla.u16 q3, q1, %[c2] \n" + " vmla.s16 q3, q1, %[c2] \n" " vldrb.u16 q1, [%[pAlpha]], #8 \n" " vmulh.u8 q1, q1, %[vOpacity] \n" @@ -5703,11 +3194,14 @@ void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTa "1: \n" :[pTargetCh0] "+r"(pTargetCh0), [pTargetCh1] "+r"(pTargetCh1), - [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) + [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+l" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[str4Offs] "t" (vStride4Offs), [vOpacity] "t"(vOpacity), [c0] "r"(c0), [c1] "r"(c1), [c2] "r"(c2) - :"q0", "q1", "q2", "q3", "memory"); +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif + :"q0", "q1", "q2", "q3", "memory", "cc"); #endif pchAlpha += (iAlphaStride); @@ -5717,7 +3211,7 @@ void __arm_2d_impl_cccn888_colour_filling_mask_opacity(uint32_t * __RESTRICT pTa __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_colour_filling_channel_mask)(uint32_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, @@ -5743,13 +3237,15 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTa #ifdef USE_MVE_INTRINSICS CCCN888_COLOUR_FILLING_MASK_INNER_MVE(CCCN888_TRGT_LOAD_STRIDE, vStride4Offs, - CCCN888_SCAL_OPACITY_NONE, _, 4); + CCCN888_SCAL_OPACITY_NONE, _, 4, 255); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" /* expand chan0 */ " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" @@ -5758,26 +3254,31 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTa " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if alpha == 255, boost to 256 */ + " vpt.i16 eq, q1, %[alph255] \n" + " vmovt.i16 q1, #256 \n" +#endif + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" /* scale ch0 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan1 */ " vldrb.u16 q0, [%[pTargetCh1], %[str4Offs]] \n" /* blend ch0 vector with input ch0 color*/ - " vmla.u16 q3, q1, %[c0] \n" + " vmla.s16 q3, q1, %[c0] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh0], %[str4Offs]] \n" /* scale ch1 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan2 */ " vldrb.u16 q0, [%[pTargetCh2], %[str4Offs]] \n" /* blend ch1 vector with input ch1 color*/ - " vmla.u16 q3, q1, %[c1] \n" + " vmla.s16 q3, q1, %[c1] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh1], %[str4Offs]] \n" @@ -5786,11 +3287,11 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTa /* scale ch2 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" /* blend ch2 vector with input ch2 color*/ - " vmla.u16 q3, q1, %[c2] \n" + " vmla.s16 q3, q1, %[c2] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " vshr.u16 q3, q3, #8 \n" @@ -5806,7 +3307,10 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTa [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[str4Offs] "t" (vStride4Offs), [c0] "r"(c0), [c1] "r"(c1), [c2] "r"(c2) - :"q0", "q1", "q2", "q3", "memory"); +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[alph255] "r" (255) +#endif + :"q0", "q1", "q2", "q3", "memory", "cc"); #endif pwAlpha += (iAlphaStride); @@ -5817,19 +3321,20 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask(uint32_t * __RESTRICT pTa __OVERRIDE_WEAK -void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __RESTRICT pTarget, +void __MVE_WRAPPER( __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity)(uint32_t * __RESTRICT pTarget, int16_t iTargetStride, uint32_t * __RESTRICT pwAlpha, int16_t iAlphaStride, arm_2d_size_t * __RESTRICT ptCopySize, - uint32_t Colour, uint8_t chOpacity) + uint32_t Colour, + uint_fast16_t hwOpacity) { int_fast16_t iHeight = ptCopySize->iHeight; int_fast16_t iWidth = ptCopySize->iWidth; uint16x8_t v256 = vdupq_n_u16(256); uint16x8_t vStride4Offs = vidupq_n_u16(0, 4); - uint8x16_t vOpacity = vdupq_n_u8(chOpacity); + uint8x16_t vOpacity = vdupq_n_u8(hwOpacity); uint16_t c0, c1, c2; c0 = Colour & 0xff; @@ -5845,13 +3350,15 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __REST #ifdef USE_MVE_INTRINSICS CCCN888_COLOUR_FILLING_MASK_INNER_MVE(CCCN888_TRGT_LOAD_STRIDE, vStride4Offs, - CCCN888_SCAL_OPACITY, vOpacity, 4); + CCCN888_SCAL_OPACITY, vOpacity, 4, 254); #else register unsigned blkCnt __asm("lr"); blkCnt = iWidth; __asm volatile( + "vecAlphaCompl .req q2 \n" + ".p2align 2 \n" /* expand chan0 */ " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" @@ -5861,26 +3368,31 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __REST " wlstp.16 lr, %[loopCnt], 1f \n" "2: \n" - " vsub.i16 q2, %[vec256], q1 \n" +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + /* if vOpacity == 254, boost to 256 */ + " vpt.i16 eq, q1, %[opa254] \n" + " vmovt.i16 q1, #256 \n" +#endif + " vsub.i16 vecAlphaCompl, %[vec256], q1 \n" /* scale ch0 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan1 */ " vldrb.u16 q0, [%[pTargetCh1], %[str4Offs]] \n" /* blend ch0 vector with input ch0 color*/ - " vmla.u16 q3, q1, %[c0] \n" + " vmla.s16 q3, q1, %[c0] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh0], %[str4Offs]] \n" /* scale ch1 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" /* expand chan2 */ " vldrb.u16 q0, [%[pTargetCh2], %[str4Offs]] \n" /* blend ch1 vector with input ch1 color*/ - " vmla.u16 q3, q1, %[c1] \n" + " vmla.s16 q3, q1, %[c1] \n" " vshr.u16 q3, q3, #8 \n" " vstrb.u16 q3, [%[pTargetCh1], %[str4Offs]] \n" @@ -5889,11 +3401,11 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __REST /* scale ch2 vector with alpha vector */ - " vmul.u16 q3, q0, q2 \n" + " vmul.u16 q3, q0, vecAlphaCompl \n" " vldrb.u16 q0, [%[pTargetCh0], %[str4Offs]] \n" /* blend ch2 vector with input ch2 color*/ - " vmla.u16 q3, q1, %[c2] \n" + " vmla.s16 q3, q1, %[c2] \n" " vldrb.u16 q1, [%[pAlpha], %[str4Offs]] \n" " vmulh.u8 q1, q1, %[vOpacity] \n" @@ -5910,7 +3422,10 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __REST [pTargetCh2] "+r"(pTargetCh2), [pAlpha] "+r" (pAlpha), [loopCnt] "+r"(blkCnt) :[vec256] "t" (v256),[str4Offs] "t" (vStride4Offs), [vOpacity] "t"(vOpacity), [c0] "r"(c0), [c1] "r"(c1), [c2] "r"(c2) - :"q0", "q1", "q2", "q3", "memory"); +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__) + ,[opa254] "r" (254) +#endif + :"q0", "q1", "q2", "q3", "memory", "cc"); #endif pwAlpha += (iAlphaStride); @@ -5919,204 +3434,77 @@ void __arm_2d_impl_cccn888_colour_filling_channel_mask_opacity(uint32_t * __REST } +/* use macro expansion of fill/copy with masking */ + +#define __API_CAFWM_COLOUR gray8 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_1_HORIZONTAL_LINE 1 +#define __API_CAFWM_COLOUR gray8 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT 1 +#define __API_CAFWM_COLOUR gray8 + +#include "__arm_2d_alpha_mask_helium.inc" + + + +#define __API_CAFWM_COLOUR rgb565 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_1_HORIZONTAL_LINE 1 +#define __API_CAFWM_COLOUR rgb565 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT 1 +#define __API_CAFWM_COLOUR rgb565 + +#include "__arm_2d_alpha_mask_helium.inc" + + + + +#define __API_CAFWM_COLOUR cccn888 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_1_HORIZONTAL_LINE 1 +#define __API_CAFWM_COLOUR cccn888 + +#include "__arm_2d_alpha_mask_helium.inc" + +#define __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT 1 +#define __API_CAFWM_COLOUR cccn888 + +#include "__arm_2d_alpha_mask_helium.inc" + + + /*----------------------------------------------------------------------------* - * Convert Colour format * + * Assembly Patches * *----------------------------------------------------------------------------*/ +#if defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__ __OVERRIDE_WEAK -void __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 bit position */ - 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 - 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 __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" - /* 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; - } -} - - - - - - -void __arm_2d_impl_rgb565_masks_fill(uint16_t * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t * __RESTRICT ptSourceSize, - uint8_t * __RESTRICT pchSourceMaskBase, - int16_t iSourceMaskStride, - arm_2d_size_t * __RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t * __RESTRICT ptTargetSize, - uint8_t * __RESTRICT pchTargetMaskBase, - int16_t iTargetMaskStride, - arm_2d_size_t * __RESTRICT ptTargetMaskSize) +void ARM_2D_WRAP_FUNC( __MVE_WRAPPER( __arm_2d_impl_rgb565_masks_fill))( + uint16_t * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __RESTRICT ptSourceSize, + uint8_t * __RESTRICT pchSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * __RESTRICT ptSourceMaskSize, + uint16_t * __RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __RESTRICT ptTargetSize, + uint8_t * __RESTRICT pchTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * __RESTRICT ptTargetMaskSize) { uint8_t *__RESTRICT pchTargetMaskLineBase = pchTargetMaskBase; uint16x8_t v256 = vdupq_n_u16(256); @@ -6238,7 +3626,7 @@ void __arm_2d_impl_rgb565_masks_fill(uint16_t * __RESTRICT ptSourceBase, /* blended G */ /* vadd.i16 q2, q4, q2 addition using vmla for more efficient overlap */ - " vmla.u16 q2, q4, %[one] \n" + " vmla.s16 q2, q4, %[one] \n" /* vecB extract and scale */ " vshr.u16 q4, q6, #8 \n" " vand q4, q4, vecRBUnpackMask \n" @@ -6256,7 +3644,7 @@ void __arm_2d_impl_rgb565_masks_fill(uint16_t * __RESTRICT ptSourceBase, /* blended B vadd.i16 q0, q4, q0 addition using vmla for more efficient overlap */ - " vmla.u16 q0, q4, %[one] \n" + " vmla.s16 q0, q4, %[one] \n" /* pack R */ " vshr.u16 q3, q1, #11 \n" /* B channel packing mask 0xf800 */ @@ -6321,19 +3709,19 @@ void __arm_2d_impl_rgb565_masks_fill(uint16_t * __RESTRICT ptSourceBase, __OVERRIDE_WEAK -void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill( - uint16_t * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t * __RESTRICT ptSourceSize, - uint8_t * __RESTRICT pchSourceMaskBase, - int16_t iSourceMaskStride, - arm_2d_size_t * __RESTRICT ptSourceMaskSize, - uint16_t * __RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t * __RESTRICT ptTargetSize, - uint8_t * __RESTRICT pchTargetMaskBase, - int16_t iTargetMaskStride, - arm_2d_size_t * __RESTRICT ptTargetMaskSize) +void ARM_2D_WRAP_FUNC( __MVE_WRAPPER( __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill))( + uint16_t * __RESTRICT ptSourceBase, + int16_t iSourceStride, + arm_2d_size_t * __RESTRICT ptSourceSize, + uint8_t * __RESTRICT pchSourceMaskBase, + int16_t iSourceMaskStride, + arm_2d_size_t * __RESTRICT ptSourceMaskSize, + uint16_t * __RESTRICT ptTargetBase, + int16_t iTargetStride, + arm_2d_size_t * __RESTRICT ptTargetSize, + uint8_t * __RESTRICT pchTargetMaskBase, + int16_t iTargetMaskStride, + arm_2d_size_t * __RESTRICT ptTargetMaskSize) { uint8_t *__RESTRICT pchTargetMaskLineBase = pchTargetMaskBase; uint16x8_t v256 = vdupq_n_u16(256); @@ -6455,7 +3843,7 @@ void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill( /* blended G */ /* vadd.i16 q2, q4, q2 addition using vmla for more efficient overlap */ - " vmla.u16 q2, q4, %[one] \n" + " vmla.s16 q2, q4, %[one] \n" /* vecB extract and scale */ " vshr.u16 q4, q6, #8 \n" " vand q4, q4, vecRBUnpackMask \n" @@ -6473,7 +3861,7 @@ void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill( /* blended B vadd.i16 q0, q4, q0 addition using vmla for more efficient overlap */ - " vmla.u16 q0, q4, %[one] \n" + " vmla.s16 q0, q4, %[one] \n" /* pack R */ " vshr.u16 q3, q1, #11 \n" /* B channel packing mask 0xf800 */ @@ -6535,9 +3923,6 @@ void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill( } } - -#if defined(__clang__) -# pragma clang diagnostic pop #endif #ifdef __cplusplus @@ -6545,4 +3930,3 @@ void __arm_2d_impl_rgb565_src_msk_1h_des_msk_fill( #endif #endif // __ARM_2D_HAS_HELIUM__ - diff --git a/package/Arm2D/Library/Source/arm_2d_transform.c b/package/Arm2D/Library/Source/arm_2d_transform.c new file mode 100644 index 000000000..021708faf --- /dev/null +++ b/package/Arm2D/Library/Source/arm_2d_transform.c @@ -0,0 +1,1847 @@ +/* + * 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_transform.c + * Description: APIs for tile transform + * + * $Date: 20 May 2022 + * $Revision: V.1.0.3 + * + * 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 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" +# pragma clang diagnostic ignored "-Wdeclaration-after-statement" +#elif defined(__IS_COMPILER_ARM_COMPILER_5__) +# pragma diag_suppress 174,177,188,68,513,144,1296 +#elif defined(__IS_COMPILER_IAR__) +# pragma diag_suppress=Pa093 +#elif defined(__IS_COMPILER_GCC__) +# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" +#endif + +#include + +/*============================ 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 + + +#define TO_Q16(x) ((int32_t)(x) << 16) + +/*----------------------------------------------------------------------------* + * 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_CCCN888() \ + ( tPixel.R >>= 8, \ + tPixel.G >>= 8, \ + tPixel.B >>= 8, \ + tPixel.A = *((uint8_t *)pTarget + 3), \ + __arm_2d_cccn888_pack(&tPixel)) + + +#define __API_COLOUR gray8 +#define __API_INT_TYPE uint8_t +#define __API_INT_TYPE_BIT_NUM 16 +#define __API_PIXEL_AVERAGE_INIT() uint16_t tPixel = 0; +#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_OPA_GRAY8 +#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_GRAY8 +#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_GRAY8 +#include "__arm_2d_transform.inc" + +#define __API_COLOUR rgb565 +#define __API_INT_TYPE uint16_t +#define __API_INT_TYPE_BIT_NUM 16 +#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_OPA_RGB565 +#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_RGB565 +#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_RGB565 +#include "__arm_2d_transform.inc" + +#define __API_COLOUR cccn888 +#define __API_INT_TYPE uint32_t +#define __API_INT_TYPE_BIT_NUM 32 +#define __API_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_OPA_CCCN888 +#define __API_PIXEL_AVERAGE __ARM_2D_PIXEL_AVERAGE_CCCN888 +#define __API_PIXEL_AVERAGE_RESULT __API_PIXEL_AVERAGE_RESULT_CCCN888 + +#include "__arm_2d_transform.inc" + +/*============================ MACROFIED FUNCTIONS ===========================*/ +/*============================ TYPES =========================================*/ +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ PROTOTYPES ====================================*/ +/*============================ LOCAL VARIABLES ===============================*/ +/*============================ IMPLEMENTATION ================================*/ + +/*----------------------------------------------------------------------------* + * 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 ; + int16_t iYSign = y < 0 ; + + __arm_2d_point_adj_alpha_t tResult = { + .tMatrix = { + [0] = { + .tOffset = { + .iX = -iXSign, + .iY = -iYSign, + }, + #if 0 + .chAlpha = (uint8_t)( + ((float)(1-iXSign) - (float)x) //!< x + * ((float)(1-iYSign) - (float)y) //!< y + * 256.0f + ), + #endif + }, + [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 + ), + }, + }, + }; +#if 1 + tResult.tMatrix[0].chAlpha = 256 + - tResult.tMatrix[1].chAlpha + - tResult.tMatrix[2].chAlpha + - tResult.tMatrix[3].chAlpha; +#endif + 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, + }, + #if 0 + .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), + #endif + }, + [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), + }, + }, + }; +#if 1 + tResult.tMatrix[0].chAlpha = 256 + - tResult.tMatrix[1].chAlpha + - tResult.tMatrix[2].chAlpha + - tResult.tMatrix[3].chAlpha; +#endif + + return tResult; +} + + + +#if __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ + +static +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 * 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; + + if (1 == iHeight) { + invHeightFx = 0x7fffffff; + } else { + invHeightFx = 0x7fffffff / (iHeight - 1); + } + + int32_t AngleFx = lroundf(fAngle * ONE_BY_2PI_Q31); + int32_t ScaleFx = (int32_t)((float)fScale * (float)TO_Q16(1)); + q31_t cosAngleFx = MULTFX(arm_cos_q31(AngleFx), ScaleFx); + q31_t sinAngleFx = MULTFX(arm_sin_q31(AngleFx), ScaleFx); + 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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[0][0].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[1][0].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[1][1].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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, MUL_Q16(iYQ16, cosAngleFx)), + MUL_Q16(iXQ16, sinAngleFx)); + tPointCornerFx[0][1].X = + __QDSUB(__QDADD(centerQ16.X, MUL_Q16(iXQ16, cosAngleFx)), + MUL_Q16(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_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[]) +{ + int_fast16_t iHeight = ptCopySize->iHeight; + int_fast16_t iWidth = ptCopySize->iWidth; + float invHeight; + + if (1 == iHeight ) { + invHeight = __LARGEINVF32; + } else { + invHeight = 1.0f / (float) (iHeight - 1); + } + + float cosAngle = arm_cos_f32(fAngle) * fScale; + float sinAngle = arm_sin_f32(fAngle) * fScale; + 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,5) +static +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) +{ + int16_t iX = ptLocation->iX - ptCenter->iX; + int16_t iY = ptLocation->iY - ptCenter->iY; + + float fX,fY; + + float cosAngle = arm_cos_f32(fAngle) * fScale; + float sinAngle = arm_sin_f32(fAngle) * fScale; + + fY = (iY * cosAngle + iX * sinAngle + ptCenter->iY); + fX = (-iY * sinAngle + iX * cosAngle + ptCenter->iX); + + +#if !defined(__ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__) + 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_transform_preprocess_source( + arm_2d_op_trans_t *ptThis, + __arm_2d_transform_info_t *ptTransform) +{ + arm_2d_tile_t *ptSource = (arm_2d_tile_t *)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 + ptTransform->fAngle = fmodf(ptTransform->fAngle, ARM_2D_ANGLE(360)); + if (0.0f == ptTransform->fScale) { + ptTransform->fScale = 1.0f; + } + + //! 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_transform_point( &tCornerPoint, + &ptTransform->tCenter, + ptTransform->fAngle, + ptTransform->fScale, + &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_transform_point( &tCornerPoint, + &ptTransform->tCenter, + ptTransform->fAngle, + ptTransform->fScale, + &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_transform_point( &tCornerPoint, + &ptTransform->tCenter, + ptTransform->fAngle, + ptTransform->fScale, + &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_transform_point( &tCornerPoint, + &ptTransform->tCenter, + ptTransform->fAngle, + ptTransform->fScale, + &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 + ptTransform->tDummySourceOffset = tTopLeft; + + ptSource->tRegion.tSize.iHeight = tBottomRight.iY - tTopLeft.iY + 1; + ptSource->tRegion.tSize.iWidth = tBottomRight.iX - tTopLeft.iX + 1; + + ptTransform->fScale = 1.0f / ptTransform->fScale; + + //ptTransform->tTargetRegion.tSize = ptSource->tRegion.tSize; + } while(0); + + return ARM_2D_ERR_NONE; +} + + +static void __arm_2d_transform_preprocess_target( + arm_2d_op_trans_t *ptThis, + const arm_2d_location_t *ptTargetCentre) +{ + __arm_2d_transform_info_t *ptTransform + = (__arm_2d_transform_info_t *) + ( (uintptr_t)ptThis + + this.use_as__arm_2d_op_core_t.ptOp->Info.chInClassOffset); + + //! the following code is correct. DO NOT modify it unless you 100% sure. + ptTransform->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 = &ptTransform->Target.tRegion; + + ptTransform->Target.tRegion.tLocation = tTargetRegion.tLocation; + + //! align with the specified center point + do { + + arm_2d_location_t tOffset = { + .iX = ptTransform->tCenter.iX - ptTransform->tDummySourceOffset.iX, + .iY = ptTransform->tCenter.iY - ptTransform->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; + } + ptTransform->Target.tRegion.tLocation.iX += tOffset.iX; + ptTransform->Target.tRegion.tLocation.iY += tOffset.iY; + + } while(0); +} + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_gray8_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chFillColour) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_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_TRANSFORM_GRAY8; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.hwColour = chFillColour; + + return __arm_2d_transform_preprocess_source(ptThis, &this.tTransform); +} + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_rgb565_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast16_t hwFillColour) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_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_TRANSFORM_RGB565; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.hwColour = hwFillColour; + + return __arm_2d_transform_preprocess_source(ptThis, &this.tTransform); +} + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_cccn888_tile_transform_prepare( + arm_2d_op_trans_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint32_t wFillColour) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_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_TRANSFORM_CCCN888; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.wColour = wFillColour; + + return __arm_2d_transform_preprocess_source(ptThis, &this.tTransform); +} + +arm_fsm_rt_t __arm_2d_gray8_sw_transform(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_8BIT == OP_CORE.ptOp->Info.Colour.chScheme); + + __arm_2d_impl_gray8_transform( &(ptTask->Param.tCopyOrig), + &this.tTransform); + + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb565_sw_transform(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); + + __arm_2d_impl_rgb565_transform( &(ptTask->Param.tCopyOrig), + &this.tTransform); + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_cccn888_sw_transform(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + + __arm_2d_impl_cccn888_transform(&(ptTask->Param.tCopyOrig), + &this.tTransform); + + return arm_fsm_rt_cpl; +} + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chFillColour, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_opa_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_TRANSFORM_WITH_OPACITY_GRAY8; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.chColour = chFillColour; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast16_t hwFillColour, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_opa_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_TRANSFORM_WITH_OPACITY_RGB565; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.hwColour = hwFillColour; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +ARM_NONNULL(2) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_opacity_prepare( + arm_2d_op_trans_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint32_t wFillColour, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_opa_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_TRANSFORM_WITH_OPACITY_CCCN888; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + this.tTransform.Mask.wColour = wFillColour; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +arm_fsm_rt_t __arm_2d_gray8_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_GRAY8 == OP_CORE.ptOp->Info.Colour.chScheme); + + if (255 == this.chOpacity) { + __arm_2d_impl_gray8_transform( &(ptTask->Param.tCopyOrig), + &this.tTransform); + } else { + __arm_2d_impl_gray8_transform_with_opacity( &(ptTask->Param.tCopyOrig), + &this.tTransform, + this.chOpacity); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_rgb565_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); + + if (255 == this.chOpacity) { + __arm_2d_impl_rgb565_transform( &(ptTask->Param.tCopyOrig), + &this.tTransform); + } else { + __arm_2d_impl_rgb565_transform_with_opacity( &(ptTask->Param.tCopyOrig), + &this.tTransform, + this.chOpacity); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t __arm_2d_cccn888_sw_transform_with_alpha(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + + if (255 == this.chOpacity) { + __arm_2d_impl_cccn888_transform(&(ptTask->Param.tCopyOrig), + &this.tTransform); + } else { + __arm_2d_impl_cccn888_transform_with_opacity( &(ptTask->Param.tCopyOrig), + &this.tTransform, + this.chOpacity); + } + return arm_fsm_rt_cpl; +} + +ARM_NONNULL(2) +arm_fsm_rt_t arm_2dp_tile_transform(arm_2d_op_trans_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_trans_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) { + __arm_2d_transform_info_t *ptTransform + = (__arm_2d_transform_info_t *) + ( (uintptr_t)ptThis + + this.use_as__arm_2d_op_core_t.ptOp->Info.chInClassOffset); + + + this.Target.ptTile = arm_2d_tile_generate_child( + ptTarget, + ptRegion, + &ptTransform->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_transform_preprocess_target( ptThis, ptTargetCentre); + return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); +} + + + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_GRAY8; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = chFillColour; + this.Mask.ptOriginSide = ptSourceMask; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_RGB565; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = hwFillColour; + this.Mask.ptOriginSide = ptSourceMask; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_src_mask_prepare( + arm_2d_op_trans_msk_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_CCCN888; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = wFillColour; + this.Mask.ptOriginSide = ptSourceMask; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +arm_fsm_rt_t +__arm_2d_gray8_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_8BIT == OP_CORE.ptOp->Info.Colour.chScheme); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); + + if (bIsMaskChannel8In32) { + __arm_2d_impl_gray8_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else +#endif + { + __arm_2d_impl_gray8_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t +__arm_2d_rgb565_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); + + if (bIsMaskChannel8In32) { + __arm_2d_impl_rgb565_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else +#endif + { + __arm_2d_impl_rgb565_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t +__arm_2d_cccn888_sw_transform_with_src_mask(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); + + if (bIsMaskChannel8In32) { + __arm_2d_impl_cccn888_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else +#endif + { + __arm_2d_impl_cccn888_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + + return arm_fsm_rt_cpl; +} + + + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_gray8_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_GRAY8; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = chFillColour; + this.Mask.ptOriginSide = ptSourceMask; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_rgb565_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_RGB565; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = hwFillColour; + this.Mask.ptOriginSide = ptSourceMask; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +ARM_NONNULL(2,3) +arm_2d_err_t arm_2dp_cccn888_tile_transform_with_src_mask_and_opacity_prepare( + arm_2d_op_trans_msk_opa_t *ptOP, + const arm_2d_tile_t *ptSource, + const arm_2d_tile_t *ptSourceMask, + const arm_2d_location_t tCentre, + float fAngle, + float fScale, + uint_fast8_t chOpacity) +{ + assert(NULL != ptSource); + + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptOP); + + arm_2d_err_t tErr = __arm_mask_validate(ptSource, + ptSourceMask, + NULL, + NULL, + 0); + if (tErr < 0) { + return tErr; + } + + if (!arm_2d_op_wait_async((arm_2d_op_core_t *)ptThis)) { + return ARM_2D_ERR_BUSY; + } + + OP_CORE.ptOp = &ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_CCCN888; + + this.Source.ptTile = &this.Origin.tDummySource; + this.Origin.ptTile = ptSource; + this.wMode = 0; + this.tTransform.fAngle = fAngle; + this.tTransform.fScale = fScale; + this.tTransform.tCenter = tCentre; + //this.tTransform.Mask.hwColour = wFillColour; + this.Mask.ptOriginSide = ptSourceMask; + this.chOpacity = chOpacity; + + return __arm_2d_transform_preprocess_source((arm_2d_op_trans_t *)ptThis, + &this.tTransform); +} + +arm_fsm_rt_t +__arm_2d_gray8_sw_transform_with_src_mask_and_opacity(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_8BIT == OP_CORE.ptOp->Info.Colour.chScheme); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); +#endif + + if (255 == this.chOpacity) { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_gray8_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else + #endif + { + __arm_2d_impl_gray8_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + } else { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_gray8_transform_with_src_chn_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } else + #endif + { + __arm_2d_impl_gray8_transform_with_src_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } + } + + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t +__arm_2d_rgb565_sw_transform_with_src_mask_and_opacity(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_RGB565 == OP_CORE.ptOp->Info.Colour.chScheme); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); +#endif + + if (255 == this.chOpacity) { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_rgb565_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else + #endif + { + __arm_2d_impl_rgb565_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + } else { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_rgb565_transform_with_src_chn_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } else + #endif + { + __arm_2d_impl_rgb565_transform_with_src_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } + } + + return arm_fsm_rt_cpl; +} + +arm_fsm_rt_t +__arm_2d_cccn888_sw_transform_with_src_mask_and_opacity(__arm_2d_sub_task_t *ptTask) +{ + ARM_2D_IMPL(arm_2d_op_trans_msk_opa_t, ptTask->ptOP); + assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); + +#if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + bool bIsMaskChannel8In32 = (ARM_2D_CHANNEL_8in32 + == ptTask->Param.tCopyOrigMask.tOrigMask.tColour.chScheme); +#endif + + if (255 == this.chOpacity) { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_cccn888_transform_with_src_chn_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } else + #endif + { + __arm_2d_impl_cccn888_transform_with_src_mask( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform); + } + } else { + #if __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + if (bIsMaskChannel8In32) { + __arm_2d_impl_cccn888_transform_with_src_chn_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } else + #endif + { + __arm_2d_impl_cccn888_transform_with_src_mask_and_opacity( + &(ptTask->Param.tCopyOrigMask), + &this.tTransform, + this.chOpacity); + } + } + return arm_fsm_rt_cpl; +} + + + +/*----------------------------------------------------------------------------* + * 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_TRANSFORM_GRAY8, + __arm_2d_gray8_sw_transform); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_RGB565, + __arm_2d_rgb565_sw_transform); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_CCCN888, + __arm_2d_cccn888_sw_transform); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_GRAY8, + __arm_2d_gray8_sw_transform_with_alpha); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_RGB565, + __arm_2d_rgb565_sw_transform_with_alpha); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_CCCN888, + __arm_2d_cccn888_sw_transform_with_alpha); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_GRAY8, + __arm_2d_gray8_sw_transform_with_src_mask); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_RGB565, + __arm_2d_rgb565_sw_transform_with_src_mask); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_CCCN888, + __arm_2d_cccn888_sw_transform_with_src_mask); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_GRAY8, + __arm_2d_gray8_sw_transform_with_src_mask_and_opacity); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_RGB565, + __arm_2d_rgb565_sw_transform_with_src_mask_and_opacity); + +__WEAK +def_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_CCCN888, + __arm_2d_cccn888_sw_transform_with_src_mask_and_opacity); + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_GRAY8 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM, + .chInClassOffset = offsetof(arm_2d_op_trans_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_GRAY8), + .ptFillOrigLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_RGB565 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM, + .chInClassOffset = offsetof(arm_2d_op_trans_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_RGB565), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_CCCN888 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM, + .chInClassOffset = offsetof(arm_2d_op_trans_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_CCCN888), + .ptFillOrigLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_GRAY8 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_GRAY8, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_GRAY8), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_RGB565 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_RGB565), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_OPACITY_CCCN888 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_ALPHA_CCCN888), + .ptFillOrigLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_GRAY8 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_GRAY8), + .ptFillOrigLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_RGB565 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_RGB565), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_CCCN888 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_CCCN888), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_GRAY8 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_8BIT, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK_AND_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_GRAY8), + .ptFillOrigLike = NULL, + }, + }, +}; + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_RGB565 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_RGB565, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK_AND_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_RGB565), + .ptFillOrigLike = NULL, + }, + }, +}; + + +const __arm_2d_op_info_t ARM_2D_OP_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_CCCN888 = { + .Info = { + .Colour = { + .chScheme = ARM_2D_COLOUR_CCCN888, + }, + .Param = { + .bHasSource = true, + .bHasOrigin = true, + .bHasTarget = true, + .bHasSrcMask = true, + }, + .chOpIndex = __ARM_2D_OP_IDX_TRANSFORM_WITH_SOURCE_MASK_AND_OPACITY, + .chInClassOffset = offsetof(arm_2d_op_trans_msk_opa_t, tTransform), + + .LowLevelIO = { + .ptCopyOrigLike = ref_low_lv_io(__ARM_2D_IO_TRANSFORM_WITH_SRC_MSK_AND_OPACITY_CCCN888), + .ptFillOrigLike = NULL, + }, + }, +}; + + +#ifdef __cplusplus +} +#endif diff --git a/package/Arm2D/__arm_2d_alpha_mask_helium.inc b/package/Arm2D/__arm_2d_alpha_mask_helium.inc deleted file mode 100644 index d66dedea8..000000000 --- a/package/Arm2D/__arm_2d_alpha_mask_helium.inc +++ /dev/null @@ -1,1606 +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_alpha_mask_helium.inc - * Description: c code template for copy and fill like operations - * - * $Date: 30. Sept 2021 - * $Revision: V.1.0.0 - * - * -------------------------------------------------------------------- */ - -#ifndef __API_CAFWM_COLOUR -# error You have to define __API_CAFWM_COLOUR before using this c template -#endif - -#if __API_CAFWM_COLOUR == rgb565 -#define __API_CAFWM_INT_TYPE uint16_t -#define __API_CAFWM_INT_TYPE_BIT_NUM 16 -#define __API_CAFWM_PIXEL_BLENDING __ARM_2D_PIXEL_BLENDING_RGB565 -#else -#error Unknown colour -#endif - -/*! disable this feature by default */ -#ifndef __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -# define __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING 0 -#endif - -#ifndef __API_CAFWM_CFG_1_HORIZONTAL_LINE -# define __API_CAFWM_CFG_1_HORIZONTAL_LINE 0 -#endif - -#ifndef __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT -# define __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT 0 -#endif - - -#if __API_CAFWM_CFG_1_HORIZONTAL_LINE && !__API_CAFWM_CFG_CHANNEL_8in32_SUPPORT -//! rename functions for 'c8bit' 1 horizontal line target mask -# define masks_fill src_msk_1h_des_msk_fill -# define masks_fill_x_mirror src_msk_1h_des_msk_fill_x_mirror -# define masks_fill_y_mirror src_msk_1h_des_msk_fill_y_mirror -# define masks_fill_xy_mirror src_msk_1h_des_msk_fill_xy_mirror -# define masks_fill_mirror src_msk_1h_des_msk_fill_mirror - -# define des_msk_fill 1h_des_msk_fill -# define des_msk_fill_x_mirror 1h_des_msk_fill_x_mirror -# define des_msk_fill_y_mirror 1h_des_msk_fill_y_mirror -# define des_msk_fill_xy_mirror 1h_des_msk_fill_xy_mirror -# define des_msk_fill_mirror 1h_des_msk_fill_mirror - - -# define masks_copy src_msk_1h_des_msk_copy -# define masks_copy_x_mirror src_msk_1h_des_msk_copy_x_mirror -# define masks_copy_y_mirror src_msk_1h_des_msk_copy_y_mirror -# define masks_copy_xy_mirror src_msk_1h_des_msk_copy_xy_mirror -# define masks_copy_mirror src_msk_1h_des_msk_copy_mirror - -# define des_msk_copy 1h_des_msk_copy -# define des_msk_copy_x_mirror 1h_des_msk_copy_x_mirror -# define des_msk_copy_y_mirror 1h_des_msk_copy_y_mirror -# define des_msk_copy_xy_mirror 1h_des_msk_copy_xy_mirror -# define des_msk_copy_mirror 1h_des_msk_copy_mirror - -#elif __API_CAFWM_CFG_1_HORIZONTAL_LINE && __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT -//! rename functions for '8in32 channel' 1 horizontal line target mask - -# error Do NOT Support this combination: __API_CAFWM_CFG_1_HORIZONTAL_LINE=1 \ - and __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT=1 ! - -#elif !__API_CAFWM_CFG_1_HORIZONTAL_LINE && __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT -//! rename functions for '8in32 channel' - -# define des_msk_fill des_chn_msk_fill -# define des_msk_fill_x_mirror des_chn_msk_fill_x_mirror -# define des_msk_fill_y_mirror des_chn_msk_fill_y_mirror -# define des_msk_fill_xy_mirror des_chn_msk_fill_xy_mirror -# define des_msk_fill_mirror des_chn_msk_fill_mirror - -# define des_msk_copy des_chn_msk_copy -# define des_msk_copy_x_mirror des_chn_msk_copy_x_mirror -# define des_msk_copy_y_mirror des_chn_msk_copy_y_mirror -# define des_msk_copy_xy_mirror des_chn_msk_copy_xy_mirror -# define des_msk_copy_mirror des_chn_msk_copy_mirror - -# define src_msk_fill src_chn_msk_fill -# define src_msk_fill_x_mirror src_chn_msk_fill_x_mirror -# define src_msk_fill_y_mirror src_chn_msk_fill_y_mirror -# define src_msk_fill_xy_mirror src_chn_msk_fill_xy_mirror -# define src_msk_fill_mirror src_chn_msk_fill_mirror - -# define src_msk_copy src_chn_msk_copy -# define src_msk_copy_x_mirror src_chn_msk_copy_x_mirror -# define src_msk_copy_y_mirror src_chn_msk_copy_y_mirror -# define src_msk_copy_xy_mirror src_chn_msk_copy_xy_mirror -# define src_msk_copy_mirror src_chn_msk_copy_mirror - -#endif - - - -#undef ____CAFWM_FUNC -#undef ___CAFWM_FUNC -#undef __CAFWM_FUNC - - - -#ifndef __API_CAFWM_OP_NAME -# define ____CAFWM_FUNC(__NAME, __COLOUR) \ - __arm_2d_impl_##__COLOUR##_##__NAME -# define ___CAFWM_FUNC(__NAME, __COLOUR) ____CAFWM_FUNC(__NAME, __COLOUR) -#else -# define _____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ - __arm_2d_impl_##__COLOUR##_##__OP_NAME##_##__NAME -# define ____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) \ - _____CAFWM_FUNC(__OP_NAME, __NAME, __COLOUR) -# define ___CAFWM_FUNC(__NAME, __COLOUR) \ - ____CAFWM_FUNC(__API_CAFWM_OP_NAME, __NAME, __COLOUR) -#endif - -#define __CAFWM_FUNC(__NAME) ___CAFWM_FUNC(__NAME, __API_CAFWM_COLOUR) - - -#undef ____CAFWM_TYPE -#undef ___CAFWM_TYPE -#undef __CAFWM_TYPE - -#ifndef __API_CAFWM_OP_NAME -# define ____CAFWM_TYPE(__NAME, __COLOUR) arm_2d_##__COLOUR##_##__NAME -# define ___CAFWM_TYPE(__NAME, __COLOUR) ____CAFWM_TYPE(__NAME, __COLOUR) -#else -# define _____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ - arm_2d_##__COLOUR##_##__OP_NAME##_##__NAME -# define ____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) \ - _____CAFWM_TYPE(__OP_NAME, __NAME, __COLOUR) -# define ___CAFWM_TYPE(__NAME, __COLOUR) \ - ____CAFWM_TYPE(__API_CAFWM_OP_NAME, __NAME, __COLOUR) -#endif - - -#define __CAFWM_TYPE(__NAME) ___CAFWM_TYPE(__NAME, __API_CAFWM_COLOUR) - -/*----------------------------------------------------------------------------* - * Fill with Mirroring (both masks) * - *----------------------------------------------------------------------------*/ - - - -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - -/*! \note source mask only */ -# define __API_MCWM_COLOUR __API_CAFWM_COLOUR - -# if defined(__API_CAFWM_OP_NAME) -# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME -# endif - -# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ - __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 - -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 0 - -# define masks_fill src_chn_msk_des_msk_fill -# define masks_fill_x_mirror src_chn_msk_des_msk_fill_x_mirror -# define masks_fill_y_mirror src_chn_msk_des_msk_fill_y_mirror -# define masks_fill_xy_mirror src_chn_msk_des_msk_fill_xy_mirror -# define masks_fill_mirror src_chn_msk_des_msk_fill_mirror - -# define masks_copy src_chn_msk_des_msk_copy -# define masks_copy_x_mirror src_chn_msk_des_msk_copy_x_mirror -# define masks_copy_y_mirror src_chn_msk_des_msk_copy_y_mirror -# define masks_copy_xy_mirror src_chn_msk_des_msk_copy_xy_mirror -# define masks_copy_mirror src_chn_msk_des_msk_copy_mirror - - -# include "__arm_2d_meta_copy_with_masks_helium.inc" - - - -/*! \note source mask only */ -# define __API_MCWM_COLOUR __API_CAFWM_COLOUR - -# if defined(__API_CAFWM_OP_NAME) -# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME -# endif - -# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ - __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - -# define __API_MCWM_CFG_1_HORIZONTAL_LINE 1 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 - -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 0 - -# define masks_fill src_chn_msk_1h_des_msk_fill -# define masks_fill_x_mirror src_chn_msk_1h_des_msk_fill_x_mirror -# define masks_fill_y_mirror src_chn_msk_1h_des_msk_fill_y_mirror -# define masks_fill_xy_mirror src_chn_msk_1h_des_msk_fill_xy_mirror -# define masks_fill_mirror src_chn_msk_1h_des_msk_fill_mirror - -# define masks_copy src_chn_msk_1h_des_msk_copy -# define masks_copy_x_mirror src_chn_msk_1h_des_msk_copy_x_mirror -# define masks_copy_y_mirror src_chn_msk_1h_des_msk_copy_y_mirror -# define masks_copy_xy_mirror src_chn_msk_1h_des_msk_copy_xy_mirror -# define masks_copy_mirror src_chn_msk_1h_des_msk_copy_mirror - - -# include "__arm_2d_meta_copy_with_masks_helium.inc" - - -/*! \note des mask only */ -# define __API_MCWM_COLOUR __API_CAFWM_COLOUR - -# if defined(__API_CAFWM_OP_NAME) -# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME -# endif - -# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ - __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 - -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 0 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 1 - -# define masks_fill src_msk_des_chn_msk_fill -# define masks_fill_x_mirror src_msk_des_chn_msk_fill_x_mirror -# define masks_fill_y_mirror src_msk_des_chn_msk_fill_y_mirror -# define masks_fill_xy_mirror src_msk_des_chn_msk_fill_xy_mirror -# define masks_fill_mirror src_msk_des_chn_msk_fill_mirror - -# define masks_copy src_msk_des_chn_msk_copy -# define masks_copy_x_mirror src_msk_des_chn_msk_copy_x_mirror -# define masks_copy_y_mirror src_msk_des_chn_msk_copy_y_mirror -# define masks_copy_xy_mirror src_msk_des_chn_msk_copy_xy_mirror -# define masks_copy_mirror src_msk_des_chn_msk_copy_mirror - - -# include "__arm_2d_meta_copy_with_masks_helium.inc" - - -/*! \note both masks */ -# define __API_MCWM_COLOUR __API_CAFWM_COLOUR - -# if defined(__API_CAFWM_OP_NAME) -# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME -# endif - -# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ - __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -# define __API_MCWM_CFG_1_HORIZONTAL_LINE 0 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 1 - -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_SOURCE_SIDE 1 -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT_ON_TARGET_SIDE 1 - -# define masks_fill src_chn_msk_des_chn_msk_fill -# define masks_fill_x_mirror src_chn_msk_des_chn_msk_fill_x_mirror -# define masks_fill_y_mirror src_chn_msk_des_chn_msk_fill_y_mirror -# define masks_fill_xy_mirror src_chn_msk_des_chn_msk_fill_xy_mirror -# define masks_fill_mirror src_chn_msk_des_chn_msk_fill_mirror - -# define masks_copy src_chn_msk_des_chn_msk_copy -# define masks_copy_x_mirror src_chn_msk_des_chn_msk_copy_x_mirror -# define masks_copy_y_mirror src_chn_msk_des_chn_msk_copy_y_mirror -# define masks_copy_xy_mirror src_chn_msk_des_chn_msk_copy_xy_mirror -# define masks_copy_mirror src_chn_msk_des_chn_msk_copy_mirror - - -# include "__arm_2d_meta_copy_with_masks_helium.inc" - -#else - -# define __API_MCWM_COLOUR __API_CAFWM_COLOUR - -# if defined(__API_CAFWM_OP_NAME) -# define __API_MCWM_OP_NAME __API_CAFWM_OP_NAME -# endif - -# define __API_MCWM_CFG_SUPPORT_SRC_MSK_WRAPING \ - __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -# define __API_MCWM_CFG_1_HORIZONTAL_LINE \ - __API_CAFWM_CFG_1_HORIZONTAL_LINE -# define __API_MCWM_CFG_CHANNEL_8in32_SUPPORT 0 - -# include "__arm_2d_meta_copy_with_masks_helium.inc" - -#endif - - -/* to be enabled */ -#if 0 - -/*----------------------------------------------------------------------------* - * Fill with Mirroring (target mask only) * - *----------------------------------------------------------------------------*/ - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_fill)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskBase, - #else - uint8_t *__RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize) -{ -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#endif - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #endif - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource += iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMaskLineBase = ptTargetMaskBase; - #else - ptTargetMaskLineBase += iTargetMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_fill_x_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskBase, - #else - uint8_t *__RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize) -{ -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#endif - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #endif - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - - ptSrc += ptSourceSize->iWidth - 1; - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource += iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMaskLineBase = ptTargetMaskBase; - #else - ptTargetMaskLineBase += iTargetMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - - -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_fill_y_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskBase, - #else - uint8_t *__RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize) -{ -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#endif - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #endif - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource -= iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMaskLineBase = ptTargetMaskBase; - #else - ptTargetMaskLineBase += iTargetMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_fill_xy_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskBase, - #else - uint8_t *__RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize) -{ -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#else - uint8_t *__RESTRICT ptTargetMaskLineBase = ptTargetMaskBase; -#endif - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #else - uint8_t *__RESTRICT ptTargetMask = ptTargetMaskLineBase; - #endif - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - ptSrc += ptSourceSize->iWidth - 1; - - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource -= iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMaskLineBase = ptTargetMaskBase; - #else - ptTargetMaskLineBase += iTargetMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - -} - - - - - -/*----------------------------------------------------------------------------* - * Fill with Mirroring (src mask only) * - *----------------------------------------------------------------------------*/ -#if !__API_CAFWM_CFG_1_HORIZONTAL_LINE -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_fill)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize) -{ - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; - #else - uint8_t *ptSourceMask = ptSourceMaskBase; - #endif - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; - #endif - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; - #else - uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; - #endif - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptSrcMsk++); - #else - uint16_t hwOpacity = 256 - (*ptSrcMsk++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource += iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - iSourceMaskY++; - //! handle source mask - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= ptSourceSize->iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask += iSourceMaskStride; - } - #else - ptSourceMask += iSourceMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_fill_x_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize) -{ - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource = ptSourceBase; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; - #else - uint8_t *ptSourceMask = ptSourceMaskBase; - #endif - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; - #endif - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; - #else - uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; - #endif - - ptSrc += ptSourceSize->iWidth - 1; - ptSrcMsk += ptSourceSize->iWidth - 1; - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptSrcMsk--); - #else - uint16_t hwOpacity = 256 - (*ptSrcMsk--); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource += iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - iSourceMaskY++; - //! handle source mask - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= ptSourceSize->iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask += iSourceMaskStride; - } - #else - ptSourceMask += iSourceMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - - -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_fill_y_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize) -{ - - assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); - ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; - #else - uint8_t *ptSourceMask = ptSourceMaskBase; - #endif - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; - #endif - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; - #else - uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; - #endif - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptSrcMsk++); - #else - uint16_t hwOpacity = 256 - (*ptSrcMsk++); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc++, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource -= iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - iSourceMaskY++; - //! handle source mask - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= ptSourceSize->iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask -= iSourceMaskStride; - } - #else - ptSourceMask -= iSourceMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - -} - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_fill_xy_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT ptSourceBase, - int16_t iSourceStride, - arm_2d_size_t *__RESTRICT ptSourceSize, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE *__RESTRICT ptTargetBase, - int16_t iTargetStride, - arm_2d_size_t *__RESTRICT ptTargetSize) -{ - assert(ptSourceSize->iHeight <= ptSourceMaskSize->iHeight); - ptSourceMaskBase += iSourceMaskStride * (ptSourceSize->iHeight - 1); - - for (int_fast16_t iTargetY = 0; iTargetY < ptTargetSize->iHeight;) { - - //! reset source - __API_CAFWM_INT_TYPE *__RESTRICT ptSource - = ptSourceBase + iSourceStride * (ptSourceSize->iHeight - 1); - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; - #else - uint8_t *ptSourceMask = ptSourceMaskBase; - #endif - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; - #endif - - for (int_fast16_t iSourceY = 0; iSourceY < ptSourceSize->iHeight; iSourceY++) { - __API_CAFWM_INT_TYPE *__RESTRICT ptTarget = ptTargetBase; - - /*---------------- Height Loop Begin----------------*/ - uint_fast32_t wLengthLeft = ptTargetSize->iWidth; - - do { - uint_fast32_t wLength = MIN(wLengthLeft, ptSourceSize->iWidth); - /*---------------- Width Loop Begin----------------*/ - - __API_CAFWM_INT_TYPE *__RESTRICT ptSrc = ptSource; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *__RESTRICT ptSrcMsk = ptSourceMask; - #else - uint8_t *__RESTRICT ptSrcMsk = ptSourceMask; - #endif - - ptSrc += ptSourceSize->iWidth - 1; - ptSrcMsk += ptSourceSize->iWidth - 1; - - - for (int_fast16_t x = 0; x < wLength; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptSrcMsk--); - #else - uint16_t hwOpacity = 256 - (*ptSrcMsk--); - #endif - __API_CAFWM_PIXEL_BLENDING(ptSrc--, ptTarget++, hwOpacity); - } - - /*---------------- Width Loop End----------------*/ - wLengthLeft -= wLength; - } while (wLengthLeft); - - /*---------------- Height Loop End----------------*/ - ptSource -= iSourceStride; - ptTargetBase += iTargetStride; - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - iSourceMaskY++; - //! handle source mask - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= ptSourceSize->iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask -= iSourceMaskStride; - } - #else - ptSourceMask -= iSourceMaskStride; - #endif - - iTargetY++; - if (iTargetY >= ptTargetSize->iHeight) { - break; - } - } - } - -} - - - - -#endif - - -/*----------------------------------------------------------------------------* - * Copy with Mirroring (target mask only) * - *----------------------------------------------------------------------------*/ - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_copy)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptTargetMaskBase, - #else - uint8_t * __RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - //uint16_t hwRatioCompl = 256 - chRatio; -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptTargetMask = ptTargetMaskBase; -#else - uint8_t *ptTargetMask = ptTargetMaskBase; -#endif - - for ( int_fast16_t y = 0; - y < iHeight; - y++) { - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING( pSourceBase++, pTargetBase++, hwOpacity); - - } - pSourceBase += (iSourceStride - iWidth); - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMask = ptTargetMaskBase; - #else - ptTargetMask += (iTargetMaskStride - iWidth); - #endif - } -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_copy_x_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptTargetMaskBase, - #else - uint8_t * __RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptTargetMask = ptTargetMaskBase; -#else - uint8_t *ptTargetMask = ptTargetMaskBase; -#endif - - for ( int_fast16_t y = 0; - y < iHeight; - y++) { - - //__API_CAFWM_INT_TYPE *ptTargetCur = pTargetBase; - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - - ptSourceCur += ptCopySize->iWidth - 1; - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity); - - } - pSourceBase += iSourceStride; - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMask = ptTargetMaskBase; - #else - ptTargetMask += (iTargetMaskStride - iWidth); - #endif - } -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_copy_y_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptTargetMaskBase, - #else - uint8_t * __RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - - pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptTargetMask = ptTargetMaskBase; -#else - uint8_t *ptTargetMask = ptTargetMaskBase; -#endif - - for ( int_fast16_t y = 0; y < iHeight; y++) { - - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - __API_CAFWM_PIXEL_BLENDING( ptSourceCur++, pTargetBase++, hwOpacity); - - } - pSourceBase -= iSourceStride; - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMask = ptTargetMaskBase; - #else - ptTargetMask += (iTargetMaskStride - iWidth); - #endif - } - -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(des_msk_copy_xy_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptTargetMaskBase, - #else - uint8_t * __RESTRICT ptTargetMaskBase, - #endif - int16_t iTargetMaskStride, - arm_2d_size_t *__RESTRICT ptTargetMaskSize, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - - pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptTargetMask = ptTargetMaskBase; -#else - uint8_t *ptTargetMask = ptTargetMaskBase; -#endif - - for ( int_fast16_t y = 0; y < iHeight; y++) { - - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - - ptSourceCur += ptCopySize->iWidth - 1; - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptTargetMask++); - #else - uint16_t hwOpacity = 256 - (*ptTargetMask++); - #endif - - __API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity); - - } - pSourceBase -= iSourceStride; - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_1_HORIZONTAL_LINE - ptTargetMask = ptTargetMaskBase; - #else - ptTargetMask += (iTargetMaskStride - iWidth); - #endif - } - -} - - - -/*----------------------------------------------------------------------------* - * Copy with Mirroring (src mask only) * - *----------------------------------------------------------------------------*/ -#if !__API_CAFWM_CFG_1_HORIZONTAL_LINE -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_copy)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; -#else - uint8_t *ptSourceMask = ptSourceMaskBase; -#endif - -#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; -#endif - - for (int_fast16_t y = 0; y < iHeight; y++) { - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(ptSourceMask++); - #else - uint16_t hwOpacity = 256 - (*ptSourceMask++); - #endif - __API_CAFWM_PIXEL_BLENDING( pSourceBase++, pTargetBase++, hwOpacity); - - } - pSourceBase += (iSourceStride - iWidth); - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask - iSourceMaskY++; - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask += (iSourceMaskStride - iWidth); - } - #else - ptSourceMask += (iSourceMaskStride - iWidth); - #endif - } -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_copy_x_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; -#else - uint8_t *ptSourceMask = ptSourceMaskBase; -#endif - -#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; -#endif - - for (int_fast16_t y = 0; y < iHeight; y++) { - - __API_CAFWM_INT_TYPE *ptTargetCur = pTargetBase; - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *pchSourceMaskCur = ptSourceMask; - #else - uint8_t *pchSourceMaskCur = ptSourceMask; - #endif - - ptSourceCur += ptCopySize->iWidth - 1; - //! \note do not use ptSourceMaskSize->iWidth - pchSourceMaskCur += ptCopySize->iWidth - 1; - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(pchSourceMaskCur--); - #else - uint16_t hwOpacity = 256 - (*pchSourceMaskCur--); - #endif - __API_CAFWM_PIXEL_BLENDING( ptSourceCur--, ptTargetCur++, hwOpacity); - - } - pSourceBase += iSourceStride; - pTargetBase += iTargetStride; - - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask - iSourceMaskY++; - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask += iSourceMaskStride; - } - #else - ptSourceMask += iSourceMaskStride; - #endif - } -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_copy_y_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - - pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); - - assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); - ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); - -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; -#else - uint8_t *ptSourceMask = ptSourceMaskBase; -#endif - -#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; -#endif - - for (int_fast16_t y = 0; y < iHeight; y++) { - - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *pchSourceMaskCur = ptSourceMask; - #else - uint8_t *pchSourceMaskCur = ptSourceMask; - #endif - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(pchSourceMaskCur++); - #else - uint16_t hwOpacity = 256 - (*pchSourceMaskCur++); - #endif - __API_CAFWM_PIXEL_BLENDING( ptSourceCur++, pTargetBase++, hwOpacity); - } - - pSourceBase -= iSourceStride; - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask - iSourceMaskY++; - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask -= iSourceMaskStride; - } - #else - ptSourceMask -= iSourceMaskStride; - #endif - } - -} - - -__OVERRIDE_WEAK -void __CAFWM_FUNC(src_msk_copy_xy_mirror)( - __API_CAFWM_INT_TYPE * __RESTRICT pSourceBase, - int16_t iSourceStride, - - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t * __RESTRICT ptSourceMaskBase, - #else - uint8_t * __RESTRICT ptSourceMaskBase, - #endif - int16_t iSourceMaskStride, - arm_2d_size_t *__RESTRICT ptSourceMaskSize, - - __API_CAFWM_INT_TYPE * __RESTRICT pTargetBase, - int16_t iTargetStride, - - arm_2d_size_t * __RESTRICT ptCopySize) -{ - int_fast16_t iHeight = ptCopySize->iHeight; - int_fast16_t iWidth = ptCopySize->iWidth; - - pSourceBase += iSourceStride * (ptCopySize->iHeight - 1); - - assert (ptCopySize->iHeight <= ptSourceMaskSize->iHeight); - ptSourceMaskBase += iSourceMaskStride * (ptCopySize->iHeight - 1); - -#if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *ptSourceMask = ptSourceMaskBase; -#else - uint8_t *ptSourceMask = ptSourceMaskBase; -#endif - -#if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - int_fast16_t iSourceMaskY = 0; -#endif - - for (int_fast16_t y = 0; y < iHeight; y++) { - - __API_CAFWM_INT_TYPE *ptSourceCur = pSourceBase; - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint32_t *pchSourceMaskCur = ptSourceMask; - #else - uint8_t *pchSourceMaskCur = ptSourceMask; - #endif - - ptSourceCur += ptCopySize->iWidth - 1; - //! \note do not use ptSourceMaskSize->iWidth - pchSourceMaskCur += ptCopySize->iWidth - 1; - - for (int_fast16_t x = 0; x < iWidth; x++) { - #if __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - uint16_t hwOpacity = 256 - *(uint8_t *)(pchSourceMaskCur--); - #else - uint16_t hwOpacity = 256 - (*pchSourceMaskCur--); - #endif - - __API_CAFWM_PIXEL_BLENDING( ptSourceCur--, pTargetBase++, hwOpacity); - - } - pSourceBase -= iSourceStride; - pTargetBase += (iTargetStride - iWidth); - - #if __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING - //! handle source mask - iSourceMaskY++; - if ( (iSourceMaskY >= ptSourceMaskSize->iHeight) - || (iSourceMaskY >= iHeight)) { - ptSourceMask = ptSourceMaskBase; - iSourceMaskY = 0; - } else { - ptSourceMask -= iSourceMaskStride; - } - #else - ptSourceMask -= iSourceMaskStride; - #endif - } - -} - - - -#endif - -#endif - -#undef masks_fill -#undef masks_fill_x_mirror -#undef masks_fill_y_mirror -#undef masks_fill_xy_mirror -#undef masks_fill_mirror - -#undef des_msk_fill -#undef des_msk_fill_x_mirror -#undef des_msk_fill_y_mirror -#undef des_msk_fill_xy_mirror -#undef des_msk_fill_mirror - - -#undef masks_copy -#undef masks_copy_x_mirror -#undef masks_copy_y_mirror -#undef masks_copy_xy_mirror -#undef masks_copy_mirror - -#undef des_msk_copy -#undef des_msk_copy_x_mirror -#undef des_msk_copy_y_mirror -#undef des_msk_copy_xy_mirror -#undef des_msk_copy_mirror - -#undef src_msk_fill -#undef src_msk_fill_x_mirror -#undef src_msk_fill_y_mirror -#undef src_msk_fill_xy_mirror -#undef src_msk_fill_mirror - -#undef src_msk_copy -#undef src_msk_copy_x_mirror -#undef src_msk_copy_y_mirror -#undef src_msk_copy_xy_mirror -#undef src_msk_copy_mirror - - -#undef __API_CAFWM_COPY_LIKE_OP_NAME -#undef __API_CAFWM_OP_NAME -#undef __API_CAFWM_PIXEL_BLENDING -#undef ____CAFWM_FUNC -#undef ___CAFWM_FUNC -#undef __CAFWM_FUNC -#undef __API_CAFWM_COLOUR -#undef __API_CAFWM_INT_TYPE -#undef __API_CAFWM_INT_TYPE_BIT_NUM -#undef ____CAFWM_TYPE -#undef ___CAFWM_TYPE -#undef __CAFWM_TYPE -#undef __API_CAFWM_CFG_SUPPORT_SRC_MSK_WRAPING -#undef __API_CAFWM_CFG_1_HORIZONTAL_LINE -#undef __API_CAFWM_CFG_CHANNEL_8in32_SUPPORT - diff --git a/package/Arm2D/__arm_2d_tile.c b/package/Arm2D/__arm_2d_tile.c deleted file mode 100644 index f95ca6460..000000000 --- a/package/Arm2D/__arm_2d_tile.c +++ /dev/null @@ -1,1294 +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_tile.c - * Description: Basic Tile operations - * - * $Date: 01. December 2020 - * $Revision: V.0.9.0 - * - * Target Processor: Cortex-M cores - * - * -------------------------------------------------------------------- */ - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wempty-translation-unit" -#endif - - -#ifdef __ARM_2D_COMPILATION_UNIT - -#define __ARM_2D_IMPL__ - -#include "arm_2d.h" -#include "__arm_2d_impl.h" -#include "__arm_2d_paving.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 "-Wmissing-prototypes" -#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 - -/*----------------------------------------------------------------------------* - * Code Template * - *----------------------------------------------------------------------------*/ - -#define __API_COLOUR c8bit -#define __API_INT_TYPE uint8_t -#define __API_INT_TYPE_BIT_NUM 8 - -#include "__arm_2d_copy.inc" - - -#define __API_COLOUR rgb16 -#define __API_INT_TYPE uint16_t -#define __API_INT_TYPE_BIT_NUM 16 - -#include "__arm_2d_copy.inc" - - -#define __API_COLOUR rgb32 -#define __API_INT_TYPE uint32_t -#define __API_INT_TYPE_BIT_NUM 32 - -#include "__arm_2d_copy.inc" - -/*----------------------------------------------------------------------------* - * Tile Operations * - *----------------------------------------------------------------------------*/ - -/* - HOW IT WORKS: - - Input Region 0 - +------------------------------------------------------+ - | | - | | - | | - | +------------------------------+---------+ - | | |/////////| - | | Output Region |/////////| - | | |/////////| - +-----------------------+------------------------------+/////////| - |////////////////////////////////////////| - |////////////////////////////////////////| - +----------------------------------------+ - Input Region 1 - */ -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) -{ - assert(ptRegionIn0 != NULL); - assert(ptRegionIn1 != NULL); - - do { - arm_2d_location_t tLocationIn0End = { - .iX = ptRegionIn0->tLocation.iX - + ptRegionIn0->tSize.iWidth - - 1, - .iY = ptRegionIn0->tLocation.iY - + ptRegionIn0->tSize.iHeight - - 1, - }; - - arm_2d_location_t tLocationIn1End = { - .iX = ptRegionIn1->tLocation.iX - + ptRegionIn1->tSize.iWidth - - 1, - .iY = ptRegionIn1->tLocation.iY - + ptRegionIn1->tSize.iHeight - - 1, - }; - - arm_2d_location_t tLocationOutStart = { - .iX = MAX( ptRegionIn0->tLocation.iX, - ptRegionIn1->tLocation.iX), - - .iY = MAX( ptRegionIn0->tLocation.iY, - ptRegionIn1->tLocation.iY), - }; - - arm_2d_location_t tLocationOutEnd = { - .iX = MIN( tLocationIn0End.iX, - tLocationIn1End.iX), - .iY = MIN( tLocationIn0End.iY, - tLocationIn1End.iY), - }; - - if ( (tLocationOutStart.iX > tLocationOutEnd.iX) - || (tLocationOutStart.iY > tLocationOutEnd.iY)) { - return false; - } - - if (NULL != ptRegionOut) { - ptRegionOut->tLocation = tLocationOutStart; - ptRegionOut->tSize.iWidth = tLocationOutEnd.iX - - tLocationOutStart.iX - + 1; - - ptRegionOut->tSize.iHeight = tLocationOutEnd.iY - - tLocationOutStart.iY - + 1; - } - } while(0); - - return true; -} - -ARM_NONNULL(1,2) -bool arm_2d_is_point_inside_region( const arm_2d_region_t *ptRegion, - const arm_2d_location_t *ptPoint) -{ - assert(ptRegion != NULL); - assert(ptPoint != NULL); - - do { - if (ptPoint->iX < ptRegion->tLocation.iX) { - break; - } else if (ptPoint->iY < ptRegion->tLocation.iY) { - break; - } else if (ptPoint->iX >= ptRegion->tLocation.iX + ptRegion->tSize.iWidth) { - break; - } else if (ptPoint->iY >= ptRegion->tLocation.iY + ptRegion->tSize.iHeight) { - break; - } - - return true; - } while(0); - - return false; -} - - -/* - HOW IT WORKS: - - Root Tile (Output Tile) - +------------------------------------------------------------------------+ - | ... ... | - | | - | Parent Tile | - | +------------------------------------+ | - | | Child Tile | | - | | +------------------------------+---------+ | - | | | |/////////| | - | | | Valid Region |/////////| | - | | | |/////////| | - | +-----+------------------------------+/////////| | - | |////////////////////////////////////////| | - | |////////////////////////////////////////| | - | +----------------------------------------+ | - | | - +------------------------------------------------------------------------+ - */ -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) -{ - assert(NULL != ptTile); - assert(NULL != ptValidRegion); - - *ptValidRegion = ptTile->tRegion; - - if (NULL != ptOffset) { - ptOffset->iX = 0; - ptOffset->iY = 0; - } - - if (arm_2d_is_root_tile(ptTile)) { - return ptTile; - } - - do { - //! get parent - ptTile = (const arm_2d_tile_t *)ptTile->ptParent; - if (NULL == ptTile) { - break; - } - - /*! \note Calculate the relative position between valid region and - *! the tile's original region. Usually, the tile's region - *! is inside the parent tile, but when the tile's location is - *! out of the parent's region with one or more negative axies, - *! the offset will be non-zero. - *! The offset is used to indicate the tile's view, and the - *! valid region is seen as inside the tile's region. - *! - *! Figure: What's the meaning of offset location - *! - *! The special case, where the child tile has a negative coordinates, - *! hence, the offset is (a,b) **as if** the valid region is inside - *! the child tile. - *! - *! (-a,-b) Child Tile - *! +------------------------------------+ - *! |///(0,0) Parent Tile ///////////////| - *! |/////+------------------------------+---------+ - *! |/////| | | - *! |/////| Valid Region | | - *! |/////| | | - *! +-----+------------------------------+ | - *! | | - *! | | - *! +----------------------------------------+ - *! - */ - if (NULL != ptOffset) { - arm_2d_location_t tOffset = ptValidRegion->tLocation; - tOffset.iX = MAX(0, -tOffset.iX); - tOffset.iY = MAX(0, -tOffset.iY); - - ptOffset->iX += tOffset.iX; - ptOffset->iY += tOffset.iY; - } - - /*! calculate the valid range in parent tile - *! - *! \note the location of the parent tile is used to indicate its - *! relative location between the it and its parent. - *! when calculate the valid range in parent, we have to assume - *! that the location is always (0,0) - *! - *! \note the location of a root tile is always (0,0) - */ - arm_2d_region_t tParentRegion = { - .tSize = ptTile->tRegion.tSize, - }; - - /*! make sure the output region is valid */ - if (!arm_2d_region_intersect( &tParentRegion, - ptValidRegion, - ptValidRegion)) { - /* out of range */ - return NULL; - } - - if (arm_2d_is_root_tile(ptTile)) { - break; - } - - ptValidRegion->tLocation.iX += ptTile->tRegion.tLocation.iX; - ptValidRegion->tLocation.iY += ptTile->tRegion.tLocation.iY; - - } while(true); - - return ptTile; -} - - - -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) -{ - assert(ptTarget != NULL); - assert(ptReference != NULL); - arm_2d_region_t tTargetRegion; - arm_2d_region_t tReferenceRegion; - - ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); - ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); - - if (NULL == ptTarget) { - if (NULL != ptReference) { - return ARM_2D_CMP_SMALLER; - } - return ARM_2D_CMP_EQUALS; - } else if (NULL == ptReference) { - return ARM_2D_CMP_LARGER; - } - - if (tTargetRegion.tSize.iWidth > tReferenceRegion.tSize.iWidth) { - return ARM_2D_CMP_LARGER; - } else if (tTargetRegion.tSize.iWidth < tReferenceRegion.tSize.iWidth) { - return ARM_2D_CMP_SMALLER; - } - - return ARM_2D_CMP_EQUALS; -} - - -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) -{ - assert(ptTarget != NULL); - assert(ptReference != NULL); - arm_2d_region_t tTargetRegion; - arm_2d_region_t tReferenceRegion; - - ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); - ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); - - if (NULL == ptTarget) { - if (NULL != ptReference) { - return ARM_2D_CMP_SMALLER; - } - return ARM_2D_CMP_EQUALS; - } else if (NULL == ptReference) { - return ARM_2D_CMP_LARGER; - } - - if (tTargetRegion.tSize.iHeight > tReferenceRegion.tSize.iHeight) { - return ARM_2D_CMP_LARGER; - } else if (tTargetRegion.tSize.iHeight < tReferenceRegion.tSize.iHeight) { - return ARM_2D_CMP_SMALLER; - } - - return ARM_2D_CMP_EQUALS; -} - -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) -{ - assert(ptTarget != NULL); - assert(ptReference != NULL); - arm_2d_region_t tTargetRegion; - arm_2d_region_t tReferenceRegion; - - ptTarget = arm_2d_tile_get_root(ptTarget, &tTargetRegion, NULL); - ptReference = arm_2d_tile_get_root(ptReference, &tReferenceRegion, NULL); - - if (NULL == ptTarget) { - if (NULL != ptReference) { - return ARM_2D_CMP_SMALLER; - } - return ARM_2D_CMP_EQUALS; - } else if (NULL == ptReference) { - return ARM_2D_CMP_LARGER; - } - - if (tTargetRegion.tSize.iWidth < tReferenceRegion.tSize.iWidth) { - return ARM_2D_CMP_SMALLER; - } - - if (tTargetRegion.tSize.iHeight < tReferenceRegion.tSize.iHeight) { - return ARM_2D_CMP_SMALLER; - } - - if ( (tTargetRegion.tSize.iWidth == tReferenceRegion.tSize.iWidth) - && (tTargetRegion.tSize.iHeight == tReferenceRegion.tSize.iHeight)) { - return ARM_2D_CMP_EQUALS; - } - - return ARM_2D_CMP_LARGER; -} - - -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) -{ - - assert(NULL != ptTile); - assert(NULL != ptLocation); - - ptLocation->iX = 0; - ptLocation->iY = 0; - - while( !ptTile->tInfo.bIsRoot ) { - ptLocation->iX += ptTile->tRegion.tLocation.iX; - ptLocation->iY += ptTile->tRegion.tLocation.iY; - - ptTile = ptTile->ptParent; - } - - return ptTile; -} - -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) -{ - assert(NULL != ptTarget); - assert(NULL != ptReference); - assert(NULL != ptBuffer); - - //! get the absolute location - arm_2d_location_t tTargetAbsoluteLocaton, tReferenceAbsoluteLocation; - - ptBuffer->tSize.iWidth = ptTarget->tRegion.tSize.iWidth - - ptReference->tRegion.tSize.iWidth; - ptBuffer->tSize.iHeight = ptTarget->tRegion.tSize.iHeight - - ptReference->tRegion.tSize.iHeight; - - ptTarget = arm_2d_get_absolute_location(ptTarget, &tTargetAbsoluteLocaton); - ptReference = arm_2d_get_absolute_location(ptReference, &tReferenceAbsoluteLocation); - - if (ptTarget != ptReference) { - //! they don't have the same root - return NULL; - } - - ptBuffer->tLocation.iX = tTargetAbsoluteLocaton.iX - - tReferenceAbsoluteLocation.iX; - ptBuffer->tLocation.iY = tTargetAbsoluteLocaton.iY - - tReferenceAbsoluteLocation.iY; - - return ptBuffer; -} - -/* - HOW IT WORKS: - - Parent Tile (Are NOT necessarily a ROOT tile ) - +------------------------------------------------------+ - | | - | | - | Target Region | - | +------------------------------+---------+ - | | |/////////| - | | New Child Tile (Output) |/////////| - | | |/////////| - +-----------------------+------------------------------+/////////| - |////////////////////////////////////////| - |////////////////////////////////////////| - +----------------------------------------+ - - */ -ARM_NONNULL(1,2,3) -arm_2d_tile_t *arm_2d_tile_generate_child( - const arm_2d_tile_t *ptParentTile, - const arm_2d_region_t *ptRegion, - arm_2d_tile_t *ptOutput, - bool bClipRegion) -{ - assert(NULL != ptParentTile); - assert(NULL != ptRegion); - assert(NULL != ptOutput); - - memset(ptOutput, 0, sizeof(arm_2d_tile_t)); - ptOutput->tRegion = *ptRegion; - - arm_2d_region_t tParentRegion = { - .tSize = ptParentTile->tRegion.tSize, - }; - - if (bClipRegion) { - if (!arm_2d_region_intersect( &tParentRegion, - &(ptOutput->tRegion), - &(ptOutput->tRegion) - )) { - /* out of range */ - return NULL; - } - } else { - /*! \note since you are allowed to generate a child tile whose region is - *! bigger than its parent, so we don't have to clip it, see **note** - *! below. - */ - if (!arm_2d_region_intersect( &tParentRegion, - &(ptOutput->tRegion), - NULL //&(ptOutput->tRegion) //!< **note** - )) { - /* out of range */ - return NULL; - } - } - - ptOutput->tInfo = ptParentTile->tInfo; - ptOutput->tInfo.bIsRoot = false; - - #if 0 - if (!ptParentTile->tInfo.bIsRoot && ptParentTile->tInfo.bDerivedResource) { - ptOutput->tInfo.bDerivedResource = true; - } - #endif - - ptOutput->ptParent = (arm_2d_tile_t *)ptParentTile; - - return ptOutput; -} - - -/*----------------------------------------------------------------------------* - * Copy tile to destination directly * - *----------------------------------------------------------------------------*/ - -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) -{ - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_C8BIT; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - - -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) -{ - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_RGB16; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - - -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) -{ - - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - //memset(ptThis, 0, sizeof(*ptThis)); - - OP_CORE.ptOp = &ARM_2D_OP_TILE_COPY_RGB32; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - -/*! \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. - *! - */ - -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) -{ - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - OP_CORE.ptOp = - &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - this.chColour = chMaskColour; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - -/*! \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 - */ - -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) -{ - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - OP_CORE.ptOp = - &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - this.hwColour = hwMaskColour; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - -/*! \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. - */ -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) -{ - assert(NULL != ptSource); - assert(NULL != ptTarget); - - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptOP); - - if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { - return arm_fsm_rt_on_going; - } - - OP_CORE.ptOp = - &ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32; - - this.Target.ptTile = ptTarget; - this.Target.ptRegion = ptRegion; - this.Source.ptTile = ptSource; - this.wMode = wMode; - this.wColour = wMaskColour; - - return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); -} - - -arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_c8bit_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode); - - - } else { - __arm_2d_impl_c8bit_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_rgb16_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode); - - - } else { - __arm_2d_impl_rgb16_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize); - } - - return arm_fsm_rt_cpl; -} - - -arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_rgb32_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode); - - } else { - __arm_2d_impl_rgb32_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - __arm_2d_impl_c8bit_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode); - } else { - __arm_2d_impl_c8bit_copy( ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - __arm_2d_impl_rgb16_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode); - } else { - __arm_2d_impl_rgb16_copy( ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy( __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - __arm_2d_impl_rgb32_copy_mirror(ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode); - } else { - __arm_2d_impl_rgb32_copy( ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize); - } - - return arm_fsm_rt_cpl; -} - - -arm_fsm_rt_t __arm_2d_c8bit_sw_tile_copy_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) - - assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_c8bit_cl_key_copy_mirror( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode, - this.hwColour); - - } else { - __arm_2d_impl_c8bit_cl_key_copy( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - this.hwColour); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb16_sw_tile_copy_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) - - assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_rgb16_cl_key_copy_mirror( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode, - this.hwColour); - - } else { - __arm_2d_impl_rgb16_cl_key_copy( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - this.hwColour); - } - - return arm_fsm_rt_cpl; -} - - -arm_fsm_rt_t __arm_2d_rgb32_sw_tile_copy_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP) - - assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_rgb32_cl_key_copy_mirror( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - wMode, - this.wColour); - } else { - __arm_2d_impl_rgb32_cl_key_copy( - ptTask->Param.tCopy.tSource.pBuffer, - ptTask->Param.tCopy.tSource.iStride, - ptTask->Param.tCopy.tTarget.pBuffer, - ptTask->Param.tCopy.tTarget.iStride, - &ptTask->Param.tCopy.tCopySize, - this.wColour); - } - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_c8bit_sw_tile_fill_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - __arm_2d_impl_c8bit_cl_key_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode, - this.hwColour); - } else { - __arm_2d_impl_c8bit_cl_key_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - this.hwColour); - } - - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb16_sw_tile_fill_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_16BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - __arm_2d_impl_rgb16_cl_key_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode, - this.hwColour); - } else { - __arm_2d_impl_rgb16_cl_key_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - this.hwColour); - } - - - return arm_fsm_rt_cpl; -} - -arm_fsm_rt_t __arm_2d_rgb32_sw_tile_fill_with_colour_keying( - __arm_2d_sub_task_t *ptTask) -{ - ARM_2D_IMPL(arm_2d_op_cp_cl_key_t, ptTask->ptOP); - assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ); - - uint32_t wMode = this.wMode; - - if (wMode & (ARM_2D_CP_MODE_Y_MIRROR | ARM_2D_CP_MODE_X_MIRROR)) { - - __arm_2d_impl_rgb32_cl_key_fill_mirror( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - wMode, - this.wColour); - - } else { - - __arm_2d_impl_rgb32_cl_key_fill( - ptTask->Param.tFill.tSource.pBuffer, - ptTask->Param.tFill.tSource.iStride, - &ptTask->Param.tFill.tSource.tValidRegion.tSize, - ptTask->Param.tFill.tTarget.pBuffer, - ptTask->Param.tFill.tTarget.iStride, - &ptTask->Param.tFill.tTarget.tValidRegion.tSize, - this.wColour); - - } - - - return arm_fsm_rt_cpl; -} - - -/*----------------------------------------------------------------------------* - * Low Level IO Interfaces * - *----------------------------------------------------------------------------*/ -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_C8BIT, __arm_2d_c8bit_sw_tile_copy); -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_RGB16, __arm_2d_rgb16_sw_tile_copy); -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_RGB32, __arm_2d_rgb32_sw_tile_copy); - -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_C8BIT, __arm_2d_c8bit_sw_tile_fill); -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_RGB16, __arm_2d_rgb16_sw_tile_fill); -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_RGB32, __arm_2d_rgb32_sw_tile_fill); - -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_C8BIT, - __arm_2d_c8bit_sw_tile_copy_with_colour_keying); -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB16, - __arm_2d_rgb16_sw_tile_copy_with_colour_keying); -__WEAK -def_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB32, - __arm_2d_rgb32_sw_tile_copy_with_colour_keying); - -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_C8BIT, - __arm_2d_c8bit_sw_tile_fill_with_colour_keying); -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB16, - __arm_2d_rgb16_sw_tile_fill_with_colour_keying); -__WEAK -def_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB32, - __arm_2d_rgb32_sw_tile_fill_with_colour_keying); - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_C8BIT = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_8BIT, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_C8BIT), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_C8BIT), - }, - }, -}; - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB16 = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_RGB565, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_RGB16), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_RGB16), - }, - }, -}; - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_RGB32 = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_RGB888, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_RGB32), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_RGB32), - }, - }, -}; - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_C8BIT = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_8BIT, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_C8BIT), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_C8BIT), - }, - }, -}; - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB16 = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_RGB16, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB16), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB16), - }, - }, -}; - -const __arm_2d_op_info_t ARM_2D_OP_TILE_COPY_WITH_COLOUR_KEYING_RGB32 = { - .Info = { - .Colour = { - .chScheme = ARM_2D_COLOUR_RGB32, - }, - .Param = { - .bHasSource = true, - .bHasTarget = true, - }, - .chOpIndex = __ARM_2D_OP_IDX_COPY_WITH_COLOUR_KEYING, - - .LowLevelIO = { - .ptCopyLike = ref_low_lv_io(__ARM_2D_IO_COPY_WITH_COLOUR_MASKING_RGB32), - .ptFillLike = ref_low_lv_io(__ARM_2D_IO_FILL_WITH_COLOUR_MASKING_RGB32), - }, - }, -}; - - - -#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 - -#endif - diff --git a/package/Arm2D/__arm_2d_utils_helium.h b/package/Arm2D/__arm_2d_utils_helium.h deleted file mode 100644 index fa582c933..000000000 --- a/package/Arm2D/__arm_2d_utils_helium.h +++ /dev/null @@ -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 - -#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__ - diff --git a/package/Arm2D/arm_2d.h b/package/Arm2D/arm_2d.h deleted file mode 100644 index b144b30ff..000000000 --- a/package/Arm2D/arm_2d.h +++ /dev/null @@ -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 diff --git a/package/Arm2D/arm_2d_helper_pfb.h b/package/Arm2D/arm_2d_helper_pfb.h deleted file mode 100644 index d05d425f7..000000000 --- a/package/Arm2D/arm_2d_helper_pfb.h +++ /dev/null @@ -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 diff --git a/package/Arm2D/arm_2d_op.h b/package/Arm2D/arm_2d_op.h deleted file mode 100644 index bcfb2d114..000000000 --- a/package/Arm2D/arm_2d_op.h +++ /dev/null @@ -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 diff --git a/package/Arm2D/arm_2d_rotation.c b/package/Arm2D/arm_2d_rotation.c deleted file mode 100644 index 00decb653..000000000 --- a/package/Arm2D/arm_2d_rotation.c +++ /dev/null @@ -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 - -/*============================ 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 diff --git a/package/Arm2D/arm_2d_rotation.h b/package/Arm2D/arm_2d_rotation.h deleted file mode 100644 index f75b448b6..000000000 --- a/package/Arm2D/arm_2d_rotation.h +++ /dev/null @@ -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 diff --git a/package/Arm2D/arm_2d_tile.h b/package/Arm2D/arm_2d_tile.h deleted file mode 100644 index 5918829ea..000000000 --- a/package/Arm2D/arm_2d_tile.h +++ /dev/null @@ -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 diff --git a/package/Arm2D/arm_2d_types.h b/package/Arm2D/arm_2d_types.h deleted file mode 100644 index 63c5de49b..000000000 --- a/package/Arm2D/arm_2d_types.h +++ /dev/null @@ -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 -#include -#include -#include - -#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__ - -