Skip to content

Commit eeab65f

Browse files
committed
minor update
1 parent 4ba85af commit eeab65f

File tree

7 files changed

+244
-53
lines changed

7 files changed

+244
-53
lines changed

ARM.Arm-2D.pdsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@
490490
</RTE_Components_h>
491491
</component>
492492

493-
<component Cclass="Acceleration" Cgroup="Arm-2D Extras" Csub="Loaders" Cversion="5.5.4" condition="Arm-2D-Loaders">
493+
<component Cclass="Acceleration" Cgroup="Arm-2D Extras" Csub="Loaders" Cversion="5.5.5" condition="Arm-2D-Loaders">
494494
<description>A helper service for loading various resource, e.g. loading baseline jpg files using TJpgDec, ZJpgDec, loading Lossless Compressed images (*.QOI) and loading font files using FreeType etc.</description>
495495
<files>
496496
<file category="include" name="examples/common/loader/" />

examples/common/loader/__arm_2d_loader_common.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ bool arm_loader_io_open(const arm_loader_io_t *ptIO,
193193
if (NULL == ptIO) {
194194
return true;
195195
}
196-
196+
#if 0
197197
if (NULL == ptIO->fnOpen) {
198198
return true;
199199
}
200-
200+
#endif
201201
return ptIO->fnOpen(pTarget,ptLoader);
202202
}
203203

@@ -211,9 +211,12 @@ void arm_loader_io_close( const arm_loader_io_t *ptIO,
211211
return ;
212212
}
213213

214-
ARM_2D_INVOKE_RT_VOID(ptIO->fnClose,
215-
ARM_2D_PARAM(pTarget,
216-
ptLoader));
214+
#if 0
215+
if (NULL == ptIO->fnClose) {
216+
return true;
217+
}
218+
#endif
219+
return ptIO->fnClose(pTarget,ptLoader);
217220
}
218221

219222
intptr_t arm_loader_io_get_position(const arm_loader_io_t *ptIO,
@@ -225,9 +228,12 @@ intptr_t arm_loader_io_get_position(const arm_loader_io_t *ptIO,
225228
return -1;
226229
}
227230

228-
return ARM_2D_INVOKE(ptIO->fnGetPosition,
229-
ARM_2D_PARAM(pTarget,
230-
ptLoader));
231+
#if 0
232+
if (NULL == ptIO->fnGetPosition) {
233+
return true;
234+
}
235+
#endif
236+
return ptIO->fnGetPosition(pTarget,ptLoader);
231237
}
232238

233239
bool arm_loader_io_seek(const arm_loader_io_t *ptIO,
@@ -241,9 +247,11 @@ bool arm_loader_io_seek(const arm_loader_io_t *ptIO,
241247
return true;
242248
}
243249

250+
#if 0
244251
if (NULL == ptIO->fnSeek) {
245252
return true;
246253
}
254+
#endif
247255

248256
return ptIO->fnSeek(pTarget, ptLoader, offset, whence);
249257
}
@@ -260,11 +268,15 @@ size_t arm_loader_io_read( const arm_loader_io_t *ptIO,
260268
return 0;
261269
}
262270

263-
return ARM_2D_INVOKE( ptIO->fnRead,
264-
ARM_2D_PARAM( pTarget,
265-
ptLoader,
266-
pchBuffer,
267-
tSize));
271+
#if 0
272+
if (NULL == ptIO->fnRead) {
273+
return true;
274+
}
275+
#endif
276+
return ptIO->fnRead(pTarget,
277+
ptLoader,
278+
pchBuffer,
279+
tSize);
268280
}
269281

270282

examples/common/loader/lmsk_loader/lmsk/__lmsk_common.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <stdint.h>
2323
#include <stdbool.h>
24+
#include <assert.h>
2425

2526
#ifdef __cplusplus
2627
extern "C" {
@@ -48,6 +49,17 @@ enum {
4849
TAG_U8_GRADIENT = 0xF9,
4950
};
5051

52+
typedef struct arm_lsmk_setting_t {
53+
int16_t iWidth;
54+
int16_t iHeight;
55+
56+
uint8_t u3AlphaMSBCount : 3; /* MSB alpha bits = u3AlphaBits + 1 */
57+
uint8_t bRaw : 1; /* whether the alpha is compressed or not */
58+
uint8_t u2TagSetBits : 2; /* must be 0x00 for now, reservef for the future */
59+
uint8_t : 2; /* must be 0x00 for now, reserved for the future */
60+
uint8_t chFloorCount;
61+
} arm_lsmk_setting_t;
62+
5163
/* 16byte header */
5264
typedef struct arm_lmsk_header_t {
5365
uint8_t chName[5]; /* "LMSK": Losslessly compressed MaSK */
@@ -58,15 +70,9 @@ typedef struct arm_lmsk_header_t {
5870
};
5971
uint8_t chValue;
6072
} Version;
61-
62-
int16_t iWidth;
63-
int16_t iHeight;
64-
65-
uint8_t u3AlphaMSBCount : 3; /* MSB alpha bits = u3AlphaBits + 1 */
66-
uint8_t bRaw : 1; /* whether the alpha is compressed or not */
67-
uint8_t u2TagSetBits : 2; /* must be 0x00 for now, reservef for the future */
68-
uint8_t : 2; /* must be 0x00 for now, reserved for the future */
69-
uint8_t chFloorCount;
73+
74+
arm_lsmk_setting_t tSetting;
75+
7076
uint32_t : 32; /* reserved */
7177
} arm_lmsk_header_t;
7278

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (c) 2009-2026 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/*============================ INCLUDES ======================================*/
20+
21+
22+
#include "lmsk_decoder.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/*============================ MACROS ========================================*/
29+
#undef this
30+
#define this (*ptThis)
31+
32+
/*============================ MACROFIED FUNCTIONS ===========================*/
33+
/*============================ TYPES =========================================*/
34+
/*============================ GLOBAL VARIABLES ==============================*/
35+
/*============================ PROTOTYPES ====================================*/
36+
/*============================ IMPLEMENTATION ================================*/
37+
38+
39+
static inline
40+
bool arm_lmsk_decoder_seek(arm_lmsk_decoder_t *ptThis, int32_t nOffset)
41+
{
42+
return this.tCFG.IO.fnSeek(this.tCFG.IO.pTarget, nOffset);
43+
}
44+
45+
static inline
46+
size_t arm_lmsk_decoder_read( arm_lmsk_decoder_t *ptThis,
47+
uint8_t *pchBuffer,
48+
size_t tLength)
49+
{
50+
return this.tCFG.IO.fnRead(this.tCFG.IO.pTarget, pchBuffer, tLength);
51+
}
52+
53+
int arm_lmsk_decoder_init( arm_lmsk_decoder_t *ptThis,
54+
arm_lmsk_decoder_cfg_t *ptCFG)
55+
{
56+
assert(NULL != ptThis);
57+
assert(NULL != ptCFG);
58+
59+
memset(ptThis, 0, sizeof(arm_lmsk_decoder_t));
60+
61+
this.tCFG = *ptCFG;
62+
63+
if (NULL == this.tCFG.IO.fnSeek || NULL == this.tCFG.IO.fnRead) {
64+
return -1;
65+
}
66+
67+
/* read header and palette */
68+
do {
69+
arm_lmsk_decoder_seek(ptThis, 0);
70+
71+
arm_lmsk_header_t tHeader;
72+
73+
if (sizeof(tHeader)
74+
!= arm_lmsk_decoder_read(ptThis, &tHeader, sizeof(tHeader))) {
75+
return -1;
76+
}
77+
78+
/* check signature */
79+
if (0 != memcmp(tHeader.chName, "LMSK", 4)) {
80+
return -1;
81+
}
82+
83+
/* check version */
84+
if (tHeader.Version.chValue > ARM_LMSK_VERSION) {
85+
return -1;
86+
}
87+
88+
/* to do */
89+
if (tHeader.tSetting.bRaw) {
90+
return -1;
91+
}
92+
93+
/* unsupported in this version */
94+
if (this.tSetting.u2TagSetBits > 0) {
95+
return -1;
96+
}
97+
98+
this.tSetting = tHeader.tSetting;
99+
100+
if (sizeof(this.chPalette)
101+
!= arm_lmsk_decoder_read(ptThis, this.chPalette, sizeof(this.chPalette))) {
102+
return -1;
103+
}
104+
105+
} while(0);
106+
107+
108+
return 0;
109+
}
110+
111+
112+
#ifdef __cplusplus
113+
}
114+
#endif
115+
116+
117+

examples/common/loader/lmsk_loader/lmsk/decoder/lmsk_decoder.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
#ifndef __LMSK_DECODER_H__
2121
#define __LMSK_DECODER_H__ 1
2222

23-
#include <stdint.h>
24-
#include <stdbool.h>
25-
#include <stdlib.h>
26-
#include <stdio.h>
27-
2823
#ifdef __ARM_LMSK_DECODER_CFG__
2924
# include __ARM_LMSK_DECODER_CFG__
3025
#else
@@ -42,14 +37,24 @@ extern "C" {
4237
/*============================ MACROFIED FUNCTIONS ===========================*/
4338
/*============================ TYPES =========================================*/
4439

45-
40+
typedef struct arm_lmsk_decoder_cfg_t {
41+
struct {
42+
bool (*fnSeek)( uintptr_t pTarget, int32_t offset);
43+
size_t (*fnRead) ( intptr_t pTarget,
44+
uint8_t *pchBuffer,
45+
size_t tLength);
46+
uintptr_t pTarget;
47+
} IO;
48+
} arm_lmsk_decoder_cfg_t;
4649

4750
typedef struct arm_lmsk_decoder_t {
51+
arm_lmsk_decoder_cfg_t tCFG;
4852

53+
arm_lsmk_setting_t tSetting;
54+
uint8_t chPalette[32];
4955

5056
} arm_lmsk_decoder_t;
5157

52-
5358
/*============================ GLOBAL VARIABLES ==============================*/
5459
/*============================ PROTOTYPES ====================================*/
5560
/*============================ IMPLEMENTATION ================================*/

0 commit comments

Comments
 (0)