pikapython/package/Arm2D/Arm2D_Window.c

84 lines
2.7 KiB
C
Raw Normal View History

2021-11-02 22:58:30 +08:00
#include "Arm2D_Window.h"
#include "Arm2D_Background.h"
#include "Arm2D_ElementList.h"
2021-11-03 20:11:31 +08:00
#include "Arm2D_common.h"
2021-11-02 22:58:30 +08:00
#include "arm_2d.h"
#include "arm_2d_helper.h"
#include "pikaScript.h"
pika_arm2d_window_t pika_arm2d_window;
static arm_2d_helper_pfb_t s_tPFBHelper;
static IMPL_PFB_ON_LOW_LV_RENDERING(__pfb_render_handler) {
2021-11-03 20:11:31 +08:00
const arm_2d_tile_t* pfb_tile = &(ptPFB->tTile);
2021-11-02 22:58:30 +08:00
2021-11-03 20:11:31 +08:00
ARM_2D_UNUSED(pTarget);
ARM_2D_UNUSED(bIsNewFrame);
2021-11-02 22:58:30 +08:00
2021-11-20 20:23:11 +08:00
__Arm2D_platform_drawRegin(
pfb_tile->tRegion.tLocation.iX, pfb_tile->tRegion.tLocation.iY,
pfb_tile->tRegion.tSize.iWidth, pfb_tile->tRegion.tSize.iHeight,
pfb_tile->pchBuffer);
2021-11-02 22:58:30 +08:00
2021-11-03 20:11:31 +08:00
arm_2d_helper_pfb_report_rendering_complete(&s_tPFBHelper,
(arm_2d_pfb_t*)ptPFB);
2021-11-02 22:58:30 +08:00
}
static IMPL_PFB_ON_DRAW(pika_pfb_drow_window_hanlder) {
2021-11-03 20:11:31 +08:00
ARM_2D_UNUSED(pTarget);
ARM_2D_UNUSED(bIsNewFrame);
2021-11-02 22:58:30 +08:00
2021-11-03 20:11:31 +08:00
pika_arm2d_window.pfb_tile_now = (arm_2d_tile_t*)ptTile;
pika_arm2d_window.pfb_is_new_frame = bIsNewFrame;
PikaObj* background = pika_arm2d_window.pika_background_object;
PikaObj* elems = pika_arm2d_window.pika_elems_object;
Arm2D_BackGround_update(background);
Arm2D_ElementList_update(elems);
return arm_fsm_rt_cpl;
2021-11-02 22:58:30 +08:00
}
void pika_arm2d_init(void) {
2021-11-03 20:11:31 +08:00
arm_irq_safe { arm_2d_init(); }
//! initialise FPB helper
if (ARM_2D_HELPER_PFB_INIT(
2021-11-20 20:23:11 +08:00
&s_tPFBHelper, //!< FPB Helper object
ARM2D_LCD_WIDTH, //!< screen width
ARM2D_LCD_HEIGHT, //!< screen height
2021-11-20 20:23:11 +08:00
uint16_t, //!< colour date type
ARM2D_PFB_BLOCK_WIDTH, //!< PFB block width
ARM2D_PFB_BLOCK_HEIGHT, //!< PFB block height
2021-11-20 20:23:11 +08:00
1, //!< number of PFB in the PFB pool
2021-11-03 20:11:31 +08:00
{
.evtOnLowLevelRendering =
{
//! callback for low level rendering
.fnHandler = &__pfb_render_handler,
},
.evtOnDrawing =
{
//! callback for drawing GUI
.fnHandler = &pika_pfb_drow_window_hanlder,
},
}) < 0) {
//! error detected
assert(false);
}
2021-11-02 22:58:30 +08:00
}
2021-11-03 20:11:31 +08:00
void Arm2D_Window_init(PikaObj* self) {
2021-11-20 20:23:11 +08:00
__Arm2D_platform_Init();
2021-11-03 20:11:31 +08:00
obj_run(self, "background.init()");
pika_arm2d_init();
pika_arm2d_window.pika_windows_object = self;
2022-04-26 08:53:45 +00:00
pika_arm2d_window.pika_elems_object = obj_getObj(self, "elems");
2021-11-20 20:23:11 +08:00
pika_arm2d_window.pika_background_object =
2022-04-26 08:53:45 +00:00
obj_getObj(self, "background");
2021-11-04 23:50:03 +08:00
pika_arm2d_window.dirty_region_list = NULL;
2021-11-02 22:58:30 +08:00
}
2021-11-03 20:11:31 +08:00
void Arm2D_Window_update(PikaObj* self) {
2021-11-20 20:23:11 +08:00
while (arm_fsm_rt_cpl != arm_2d_helper_pfb_task(&s_tPFBHelper, NULL))
2021-11-03 20:11:31 +08:00
;
2021-11-02 22:58:30 +08:00
}