@geastack/engine 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +29 -0
- package/bitmap_font.cpp +165 -0
- package/canvas.cpp +4608 -0
- package/components/Button.d.ts +4 -0
- package/components/Button.tsx +32 -0
- package/components/Image.d.ts +3 -0
- package/components/Image.tsx +17 -0
- package/components/Text.d.ts +3 -0
- package/components/Text.tsx +9 -0
- package/components/View.d.ts +3 -0
- package/components/View.tsx +24 -0
- package/components/index.d.ts +8 -0
- package/components/index.ts +4 -0
- package/css/animation.h +252 -0
- package/css/declarative.h +131 -0
- package/css/easing.h +160 -0
- package/css/engine.h +223 -0
- package/css/interpolate.h +38 -0
- package/image_store.cpp +807 -0
- package/package.json +62 -0
- package/rasterized_font.cpp +570 -0
- package/touch_runtime.cpp +513 -0
- package/ui/absolute_leaf_refresh.cpp +279 -0
- package/ui/absolute_leaf_refresh.h +12 -0
- package/ui/canvas_element.cpp +2314 -0
- package/ui/canvas_element.h +353 -0
- package/ui/canvas_store.cpp +188 -0
- package/ui/canvas_store.h +59 -0
- package/ui/core.cpp +135 -0
- package/ui/css_atom.cpp +155 -0
- package/ui/css_atom.h +21 -0
- package/ui/dirty_regions.cpp +66 -0
- package/ui/dirty_regions.h +34 -0
- package/ui/display_invalidation.cpp +101 -0
- package/ui/display_invalidation.h +15 -0
- package/ui/document.cpp +356 -0
- package/ui/document.h +101 -0
- package/ui/image.h +16 -0
- package/ui/image_element.cpp +13 -0
- package/ui/image_node.cpp +165 -0
- package/ui/input.cpp +936 -0
- package/ui/input_render.cpp +213 -0
- package/ui/internal.h +567 -0
- package/ui/layout.cpp +2025 -0
- package/ui/layout_snapshot.cpp +82 -0
- package/ui/layout_snapshot.h +12 -0
- package/ui/mirror.h +25 -0
- package/ui/node.cpp +243 -0
- package/ui/node.h +154 -0
- package/ui/node_lifecycle.cpp +137 -0
- package/ui/node_lifecycle.h +13 -0
- package/ui/node_model.h +597 -0
- package/ui/refresh_perf.h +235 -0
- package/ui/refresh_trace.h +68 -0
- package/ui/render.cpp +12097 -0
- package/ui/root_scroll_refresh.cpp +859 -0
- package/ui/root_scroll_refresh.h +30 -0
- package/ui/state_init.h +21 -0
- package/ui/style.cpp +14994 -0
- package/ui/style.h +727 -0
- package/ui/style_values.h +31 -0
- package/ui/text.cpp +2010 -0
- package/ui/text.h +15 -0
- package/ui/text_element.cpp +15 -0
- package/ui/tree_events.cpp +621 -0
- package/ui/tree_events.h +69 -0
- package/ui/tree_internal.h +191 -0
- package/ui/tree_nodes.cpp +628 -0
- package/ui/tree_render.cpp +3138 -0
- package/ui/tree_scroll_mirror.cpp +101 -0
- package/ui/tree_state.cpp +574 -0
- package/ui/tree_state.h +235 -0
- package/ui/tree_style.cpp +698 -0
- package/ui/ui.h +9 -0
- package/ui/view.cpp +2232 -0
- package/ui/view.h +14 -0
- package/ui/view_element.cpp +13 -0
- package/ui/viewport_region.cpp +36 -0
- package/ui/viewport_region.h +12 -0
- package/ui/virtual_keyboard.cpp +908 -0
- package/ui/virtual_keyboard.h +59 -0
- package/vendor/AnimatedGIF/AnimatedGIF.c +982 -0
- package/vendor/AnimatedGIF/AnimatedGIF.h +216 -0
- package/vendor/stb/stb_image.h +7988 -0
- package/vendor/stb/stb_truetype.h +5079 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Copyright 2020 BitBank Software, Inc. All Rights Reserved.
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
8
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
// See the License for the specific language governing permissions and
|
|
10
|
+
// limitations under the License.
|
|
11
|
+
//===========================================================================
|
|
12
|
+
|
|
13
|
+
#ifndef __ANIMATEDGIF__
|
|
14
|
+
#define __ANIMATEDGIF__
|
|
15
|
+
// #if defined( PICO_BUILD ) || defined( __MACH__ ) || defined( __LINUX__ ) || defined( __MCUXPRESSO )
|
|
16
|
+
#include <stdio.h>
|
|
17
|
+
#include <stdint.h>
|
|
18
|
+
#include <string.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
#define memcpy_P memcpy
|
|
21
|
+
#define PROGMEM
|
|
22
|
+
// #else
|
|
23
|
+
// #include <Arduino.h>
|
|
24
|
+
// #endif
|
|
25
|
+
//
|
|
26
|
+
// GIF Animator
|
|
27
|
+
// Written by Larry Bank
|
|
28
|
+
// Copyright (c) 2020 BitBank Software, Inc.
|
|
29
|
+
// bitbank@pobox.com
|
|
30
|
+
//
|
|
31
|
+
// Designed to decode images up to 480x320
|
|
32
|
+
// using less than 22K of RAM
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
/* GIF Defines and variables */
|
|
36
|
+
#define MAX_CHUNK_SIZE 255
|
|
37
|
+
#define LZW_BUF_SIZE (6 * MAX_CHUNK_SIZE)
|
|
38
|
+
#define LZW_HIGHWATER (4 * MAX_CHUNK_SIZE)
|
|
39
|
+
#ifndef MAX_WIDTH
|
|
40
|
+
#ifdef __EMSCRIPTEN__
|
|
41
|
+
#define MAX_WIDTH 2048
|
|
42
|
+
#else
|
|
43
|
+
#define MAX_WIDTH 512
|
|
44
|
+
#endif
|
|
45
|
+
#endif
|
|
46
|
+
#define FILE_BUF_SIZE 2048 // this is 4096 in original, but seems unnecessarily large in our use
|
|
47
|
+
|
|
48
|
+
#define PIXEL_FIRST 0
|
|
49
|
+
#define PIXEL_LAST 4096
|
|
50
|
+
#define LINK_UNUSED 5911 // 0x1717 to use memset
|
|
51
|
+
#define LINK_END 5912
|
|
52
|
+
#define MAX_HASH 5003
|
|
53
|
+
#define MAXMAXCODE 4096
|
|
54
|
+
|
|
55
|
+
// RGB565 pixel byte order in the palette
|
|
56
|
+
#define BIG_ENDIAN_PIXELS 0
|
|
57
|
+
#define LITTLE_ENDIAN_PIXELS 1
|
|
58
|
+
|
|
59
|
+
enum
|
|
60
|
+
{
|
|
61
|
+
GIF_PALETTE_RGB565 = 0, // default
|
|
62
|
+
// GIF_PALETTE_RGB888
|
|
63
|
+
};
|
|
64
|
+
//
|
|
65
|
+
// Draw callback pixel type
|
|
66
|
+
// RAW = 8-bit palettized pixels requiring transparent pixel handling
|
|
67
|
+
// COOKED = 16 or 24-bpp fully rendered pixels ready for display
|
|
68
|
+
//
|
|
69
|
+
// enum {
|
|
70
|
+
// GIF_DRAW_RAW = 0,
|
|
71
|
+
// GIF_DRAW_COOKED
|
|
72
|
+
//};
|
|
73
|
+
|
|
74
|
+
enum
|
|
75
|
+
{
|
|
76
|
+
GIF_SUCCESS = 0,
|
|
77
|
+
GIF_DECODE_ERROR,
|
|
78
|
+
GIF_TOO_WIDE,
|
|
79
|
+
GIF_INVALID_PARAMETER,
|
|
80
|
+
GIF_UNSUPPORTED_FEATURE,
|
|
81
|
+
GIF_FILE_NOT_OPEN,
|
|
82
|
+
GIF_EARLY_EOF,
|
|
83
|
+
GIF_EMPTY_FRAME,
|
|
84
|
+
GIF_BAD_FILE,
|
|
85
|
+
GIF_ERROR_MEMORY
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
typedef struct gif_file_tag
|
|
89
|
+
{
|
|
90
|
+
int32_t iPos; // current file position
|
|
91
|
+
int32_t iSize; // file size
|
|
92
|
+
uint8_t *pData; // memory file pointer
|
|
93
|
+
void *fHandle; // class pointer to File/SdFat or whatever you want
|
|
94
|
+
} GIFFILE;
|
|
95
|
+
|
|
96
|
+
typedef struct gif_info_tag
|
|
97
|
+
{
|
|
98
|
+
int32_t iFrameCount; // total frames in file
|
|
99
|
+
int32_t iDuration; // duration of animation in milliseconds
|
|
100
|
+
int32_t iMaxDelay; // maximum frame delay
|
|
101
|
+
int32_t iMinDelay; // minimum frame delay
|
|
102
|
+
uint16_t sGlobalColorTableSize;
|
|
103
|
+
uint8_t ucHasLocalColorTable;
|
|
104
|
+
uint8_t ucHasTransparent;
|
|
105
|
+
} GIFINFO;
|
|
106
|
+
|
|
107
|
+
typedef struct gif_draw_tag
|
|
108
|
+
{
|
|
109
|
+
int iX, iY; // Corner offset of this frame on the canvas
|
|
110
|
+
int y; // current line being drawn (0 = top line of image)
|
|
111
|
+
int iWidth, iHeight; // size of this frame
|
|
112
|
+
uint8_t *pPixels; // 8-bit source pixels for this line
|
|
113
|
+
uint16_t *pPalette; // little or big-endian RGB565 palette entries (default)
|
|
114
|
+
// uint8_t *pPalette24; // RGB888 palette (optional)
|
|
115
|
+
uint8_t ucTransparent; // transparent color
|
|
116
|
+
uint8_t ucHasTransparency; // flag indicating the transparent color is in use
|
|
117
|
+
uint8_t ucDisposalMethod; // frame disposal method
|
|
118
|
+
uint8_t ucBackground; // background color
|
|
119
|
+
} GIFDRAW;
|
|
120
|
+
|
|
121
|
+
// Callback function prototypes
|
|
122
|
+
typedef int32_t(GIF_READ_CALLBACK)(GIFFILE *pFile, uint8_t *pBuf, int32_t iLen);
|
|
123
|
+
typedef int32_t(GIF_SEEK_CALLBACK)(GIFFILE *pFile, int32_t iPosition);
|
|
124
|
+
typedef void(GIF_DRAW_CALLBACK)(GIFDRAW *pDraw);
|
|
125
|
+
typedef void *(GIF_OPEN_CALLBACK)(const char *szFilename, int32_t *pFileSize);
|
|
126
|
+
typedef void(GIF_CLOSE_CALLBACK)(void *pHandle);
|
|
127
|
+
typedef void *(GIF_ALLOC_CALLBACK)(uint32_t iSize);
|
|
128
|
+
typedef void(GIF_FREE_CALLBACK)(void *buffer);
|
|
129
|
+
//
|
|
130
|
+
// our private structure to hold a GIF image decode state
|
|
131
|
+
//
|
|
132
|
+
typedef struct gif_image_tag
|
|
133
|
+
{
|
|
134
|
+
int iWidth, iHeight, iCanvasWidth, iCanvasHeight;
|
|
135
|
+
int iX, iY; // GIF corner offset
|
|
136
|
+
int iBpp;
|
|
137
|
+
int iError; // last error
|
|
138
|
+
int iFrameDelay; // delay in milliseconds for this frame
|
|
139
|
+
int iXCount, iYCount; // decoding position in image (countdown values)
|
|
140
|
+
int iLZWOff; // current LZW data offset
|
|
141
|
+
int iLZWSize; // current quantity of data in the LZW buffer
|
|
142
|
+
int iCommentPos; // file offset of start of comment data
|
|
143
|
+
short sCommentLen; // length of comment
|
|
144
|
+
GIF_READ_CALLBACK *pfnRead;
|
|
145
|
+
GIF_SEEK_CALLBACK *pfnSeek;
|
|
146
|
+
GIF_DRAW_CALLBACK *pfnDraw;
|
|
147
|
+
GIF_OPEN_CALLBACK *pfnOpen;
|
|
148
|
+
GIF_CLOSE_CALLBACK *pfnClose;
|
|
149
|
+
GIFFILE GIFFile;
|
|
150
|
+
unsigned char *pFrameBuffer;
|
|
151
|
+
unsigned char *pPixels;
|
|
152
|
+
unsigned char ucLineBuf[MAX_WIDTH]; // current line
|
|
153
|
+
unsigned char ucFileBuf[FILE_BUF_SIZE]; // holds temp data and pixel stack
|
|
154
|
+
unsigned short pPalette[256]; // RGB565
|
|
155
|
+
unsigned short pLocalPalette[256]; // color palettes for GIF images
|
|
156
|
+
unsigned char ucLZW[LZW_BUF_SIZE]; // holds 6 chunks (6x255) of GIF LZW data packed together
|
|
157
|
+
unsigned short usGIFTable[4096];
|
|
158
|
+
unsigned char ucGIFPixels[8192];
|
|
159
|
+
unsigned char bEndOfFrame;
|
|
160
|
+
unsigned char ucGIFBits, ucBackground, ucTransparent, ucCodeStart, ucMap, bUseLocalPalette, ucLittleEndian;
|
|
161
|
+
unsigned char ucPaletteType; // RGB565 or RGB888
|
|
162
|
+
unsigned char ucDrawType; // RAW or COOKED
|
|
163
|
+
short sGlobalColorTableCount;
|
|
164
|
+
} GIFIMAGE;
|
|
165
|
+
|
|
166
|
+
#ifdef __cplusplus
|
|
167
|
+
//
|
|
168
|
+
// The GIF class wraps portable C code which does the actual work
|
|
169
|
+
//
|
|
170
|
+
class AnimatedGIF
|
|
171
|
+
{
|
|
172
|
+
public:
|
|
173
|
+
int open(uint8_t *pData, int iDataSize, GIF_DRAW_CALLBACK *pfnDraw);
|
|
174
|
+
int open(const char *szFilename, GIF_OPEN_CALLBACK *pfnOpen, GIF_CLOSE_CALLBACK *pfnClose, GIF_READ_CALLBACK *pfnRead, GIF_SEEK_CALLBACK *pfnSeek, GIF_DRAW_CALLBACK *pfnDraw);
|
|
175
|
+
void close();
|
|
176
|
+
void reset();
|
|
177
|
+
void begin(int iEndian, unsigned char ucPaletteType = GIF_PALETTE_RGB565);
|
|
178
|
+
int playFrame(bool bSync, int *delayMilliseconds);
|
|
179
|
+
int getCanvasWidth();
|
|
180
|
+
int allocFrameBuf(GIF_ALLOC_CALLBACK *pfnAlloc);
|
|
181
|
+
int setDrawType(int iType);
|
|
182
|
+
int freeFrameBuf(GIF_FREE_CALLBACK *pfnFree);
|
|
183
|
+
uint8_t *getFrameBuf();
|
|
184
|
+
int getCanvasHeight();
|
|
185
|
+
int getInfo(GIFINFO *pInfo);
|
|
186
|
+
int getLastError();
|
|
187
|
+
int getComment(char *destBuffer);
|
|
188
|
+
|
|
189
|
+
private:
|
|
190
|
+
GIFIMAGE _gif;
|
|
191
|
+
};
|
|
192
|
+
#else
|
|
193
|
+
// C interface
|
|
194
|
+
int GIF_openRAM(GIFIMAGE *pGIF, uint8_t *pData, int iDataSize, GIF_DRAW_CALLBACK *pfnDraw);
|
|
195
|
+
int GIF_openFile(GIFIMAGE *pGIF, const char *szFilename, GIF_DRAW_CALLBACK *pfnDraw);
|
|
196
|
+
void GIF_close(GIFIMAGE *pGIF);
|
|
197
|
+
void GIF_begin(GIFIMAGE *pGIF, int iEndian, unsigned char ucPaletteType);
|
|
198
|
+
void GIF_reset(GIFIMAGE *pGIF);
|
|
199
|
+
int GIF_playFrame(GIFIMAGE *pGIF, int *delayMilliseconds);
|
|
200
|
+
int GIF_getCanvasWidth(GIFIMAGE *pGIF);
|
|
201
|
+
int GIF_getCanvasHeight(GIFIMAGE *pGIF);
|
|
202
|
+
int GIF_getComment(GIFIMAGE *pGIF, char *destBuffer);
|
|
203
|
+
int GIF_getInfo(GIFIMAGE *pGIF, GIFINFO *pInfo, unsigned short *pPalette);
|
|
204
|
+
int GIF_getLastError(GIFIMAGE *pGIF);
|
|
205
|
+
#endif // __cplusplus
|
|
206
|
+
|
|
207
|
+
// Due to unaligned memory causing an exception, we have to do these macros the slow way
|
|
208
|
+
#define INTELSHORT(p) ((*p) + (*(p + 1) << 8))
|
|
209
|
+
#define INTELLONG(p) ((*p) + (*(p + 1) << 8) + (*(p + 2) << 16) + (*(p + 3) << 24))
|
|
210
|
+
#define MOTOSHORT(p) (((*(p)) << 8) + (*(p + 1)))
|
|
211
|
+
#define MOTOLONG(p) (((*p) << 24) + ((*(p + 1)) << 16) + ((*(p + 2)) << 8) + (*(p + 3)))
|
|
212
|
+
|
|
213
|
+
// Must be a 32-bit target processor
|
|
214
|
+
#define REGISTER_WIDTH 32
|
|
215
|
+
|
|
216
|
+
#endif // __ANIMATEDGIF__
|