mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2025-01-13 14:30:01 +00:00
try a different strategy for managing mangled cached commands
This commit is contained in:
parent
c17620ce52
commit
32b72fe50d
BIN
dist/MessagesForMacintosh.dsk
vendored
BIN
dist/MessagesForMacintosh.dsk
vendored
Binary file not shown.
BIN
dist/MessagesForMacintosh.zip
vendored
BIN
dist/MessagesForMacintosh.zip
vendored
Binary file not shown.
38
nuklear.h
38
nuklear.h
@ -4050,25 +4050,25 @@ NK_API void nk_textedit_redo(struct nk_text_edit*);
|
||||
update what is actually necessary which is crucial for performance.
|
||||
*/
|
||||
enum nk_command_type {
|
||||
NK_COMMAND_NOP,
|
||||
NK_COMMAND_SCISSOR,
|
||||
NK_COMMAND_LINE,
|
||||
NK_COMMAND_CURVE,
|
||||
NK_COMMAND_RECT,
|
||||
NK_COMMAND_RECT_FILLED,
|
||||
NK_COMMAND_RECT_MULTI_COLOR,
|
||||
NK_COMMAND_CIRCLE,
|
||||
NK_COMMAND_CIRCLE_FILLED,
|
||||
NK_COMMAND_ARC,
|
||||
NK_COMMAND_ARC_FILLED,
|
||||
NK_COMMAND_TRIANGLE,
|
||||
NK_COMMAND_TRIANGLE_FILLED,
|
||||
NK_COMMAND_POLYGON,
|
||||
NK_COMMAND_POLYGON_FILLED,
|
||||
NK_COMMAND_POLYLINE,
|
||||
NK_COMMAND_TEXT,
|
||||
NK_COMMAND_IMAGE,
|
||||
NK_COMMAND_CUSTOM
|
||||
NK_COMMAND_NOP, // 0
|
||||
NK_COMMAND_SCISSOR, // 1
|
||||
NK_COMMAND_LINE, // 2
|
||||
NK_COMMAND_CURVE, // 3
|
||||
NK_COMMAND_RECT, // 4
|
||||
NK_COMMAND_RECT_FILLED, // 5
|
||||
NK_COMMAND_RECT_MULTI_COLOR, // 6
|
||||
NK_COMMAND_CIRCLE, // 7
|
||||
NK_COMMAND_CIRCLE_FILLED, // 8
|
||||
NK_COMMAND_ARC, // 9
|
||||
NK_COMMAND_ARC_FILLED, // 10
|
||||
NK_COMMAND_TRIANGLE, // 11
|
||||
NK_COMMAND_TRIANGLE_FILLED, // 12
|
||||
NK_COMMAND_POLYGON, // 13
|
||||
NK_COMMAND_POLYGON_FILLED, // 14
|
||||
NK_COMMAND_POLYLINE, // 15
|
||||
NK_COMMAND_TEXT, // 16
|
||||
NK_COMMAND_IMAGE, // 17
|
||||
NK_COMMAND_CUSTOM // 18
|
||||
};
|
||||
|
||||
/* command base and header of every command inside the buffer */
|
||||
|
@ -52,7 +52,7 @@ NK_API NkQuickDrawFont* nk_quickdraw_font_create_from_file();
|
||||
*
|
||||
* ===============================================================
|
||||
*/
|
||||
#define MAX_MEMORY_IN_KB 8
|
||||
#define MAX_MEMORY_IN_KB 6
|
||||
#ifdef NK_QUICKDRAW_IMPLEMENTATION
|
||||
#ifndef NK_QUICKDRAW_TEXT_MAX
|
||||
#define NK_QUICKDRAW_TEXT_MAX 256
|
||||
@ -495,6 +495,13 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: runDrawCommand");
|
||||
#endif
|
||||
|
||||
char x[255];
|
||||
sprintf(x, "cmd: %d", cmd->type);
|
||||
writeSerialPortDebug(boutRefNum, x);
|
||||
char y[255];
|
||||
sprintf(y, "lastCmd: %d", lastCmd->type);
|
||||
writeSerialPortDebug(boutRefNum, y);
|
||||
|
||||
switch (cmd->type) {
|
||||
|
||||
case NK_COMMAND_NOP:
|
||||
@ -559,13 +566,6 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
|
||||
#ifdef COMMAND_CACHING
|
||||
|
||||
char x[255];
|
||||
sprintf(x, "cmd: %d", cmd->type);
|
||||
writeSerialPortDebug(boutRefNum, x);
|
||||
char y[255];
|
||||
sprintf(y, "lastCmd: %d", lastCmd->type);
|
||||
writeSerialPortDebug(boutRefNum, y);
|
||||
|
||||
if (!lastInputWasBackspace && cmd->type == lastCmd->type && memcmp(r, lastCmd, sizeof(struct nk_command_rect)) == 0) {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
@ -630,13 +630,6 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED5");
|
||||
#ifdef COMMAND_CACHING
|
||||
|
||||
char x[255];
|
||||
sprintf(x, "cmd: %d", cmd->type);
|
||||
writeSerialPortDebug(boutRefNum, x);
|
||||
char y[255];
|
||||
sprintf(y, "lastCmd: %d", lastCmd->type);
|
||||
writeSerialPortDebug(boutRefNum, y);
|
||||
|
||||
if (!lastInputWasBackspace && cmd->type == lastCmd->type && memcmp(r, lastCmd, sizeof(struct nk_command_rect_filled)) == 0) {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
@ -1114,6 +1107,27 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
int lastCalls = 0;
|
||||
int currentCalls;
|
||||
const struct nk_command *lastCmd;
|
||||
|
||||
Boolean VALID_COMMANDS[18] = {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
};
|
||||
#endif
|
||||
|
||||
NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
|
||||
@ -1180,10 +1194,8 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "COMMAND_CACHING: get next cached command");
|
||||
#endif
|
||||
// TODO: if this becomes worth pursuing later, it causes address errors. I suspect that the memcpy
|
||||
// command that builds up the last variable is not properly allocating memory.
|
||||
// the address error pops up on the line of the conditional itself and can sometimes take hours to trigger.
|
||||
if (currentCalls < lastCalls - 1 && lastCmd && lastCmd->next) {
|
||||
|
||||
if (currentCalls < lastCalls && lastCmd && VALID_COMMANDS[lastCmd->type]) {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "COMMAND_CACHING: inside conditional");
|
||||
|
Loading…
x
Reference in New Issue
Block a user