-
Notifications
You must be signed in to change notification settings - Fork 57
/
eel_lice.h
3216 lines (2837 loc) · 106 KB
/
eel_lice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef _EEL_LICE_H_
#define _EEL_LICE_H_
// #define EEL_LICE_GET_FILENAME_FOR_STRING(idx, fs, p) (((sInst*)opaque)->GetFilenameForParameter(idx,fs,p))
// #define EEL_LICE_GET_CONTEXT(opaque) (((opaque) ? (((sInst *)opaque)->m_gfx_state) : NULL)
void eel_lice_register();
#ifdef DYNAMIC_LICE
#define LICE_IBitmap LICE_IBitmap_disabledAPI
#include "../lice/lice.h"
#undef LICE_IBitmap
typedef void LICE_IBitmap; // prevent us from using LICE api directly, in case it ever changes
class LICE_IFont;
#ifdef EEL_LICE_API_ONLY
#define EEL_LICE_FUNCDEF extern
#else
#define EEL_LICE_FUNCDEF
#endif
#define LICE_FUNCTION_VALID(x) (x)
EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_CreateBitmap)(int, int, int);
EEL_LICE_FUNCDEF void (*__LICE_Clear)(LICE_IBitmap *dest, LICE_pixel color);
EEL_LICE_FUNCDEF void (*__LICE_Line)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa);
EEL_LICE_FUNCDEF bool (*__LICE_ClipLine)(int* pX1, int* pY1, int* pX2, int* pY2, int xLo, int yLo, int xHi, int yHi);
EEL_LICE_FUNCDEF void (*__LICE_DrawText)(LICE_IBitmap *bm, int x, int y, const char *string,
LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_DrawChar)(LICE_IBitmap *bm, int x, int y, char c,
LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_MeasureText)(const char *string, int *w, int *h);
EEL_LICE_FUNCDEF void (*__LICE_PutPixel)(LICE_IBitmap *bm, int x, int y, LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF LICE_pixel (*__LICE_GetPixel)(LICE_IBitmap *bm, int x, int y);
EEL_LICE_FUNCDEF void (*__LICE_FillRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_DrawRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_LoadImage)(const char* filename, LICE_IBitmap* bmp, bool tryIgnoreExtension);
EEL_LICE_FUNCDEF void (*__LICE_Blur)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch); // src and dest can overlap, however it may look fudgy if they do
EEL_LICE_FUNCDEF void (*__LICE_ScaledBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth,
float srcx, float srcy, float srcw, float srch, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_Circle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa);
EEL_LICE_FUNCDEF void (*__LICE_FillCircle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa);
EEL_LICE_FUNCDEF void (*__LICE_FillTriangle)(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_FillConvexPolygon)(LICE_IBitmap* dest, const int* x, const int* y, int npoints, LICE_pixel color, float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_RoundRect)(LICE_IBitmap *drawbm, float xpos, float ypos, float w, float h, int cornerradius, LICE_pixel col, float alpha, int mode, bool aa);
EEL_LICE_FUNCDEF void (*__LICE_Arc)(LICE_IBitmap* dest, float cx, float cy, float r, float minAngle, float maxAngle, LICE_pixel color, float alpha, int mode, bool aa);
// if cliptosourcerect is false, then areas outside the source rect can get in (otherwise they are not drawn)
EEL_LICE_FUNCDEF void (*__LICE_RotatedBlit)(LICE_IBitmap *dest, LICE_IBitmap *src,
int dstx, int dsty, int dstw, int dsth,
float srcx, float srcy, float srcw, float srch,
float angle,
bool cliptosourcerect, float alpha, int mode,
float rotxcent, float rotycent); // these coordinates are offset from the center of the image, in source pixel coordinates
EEL_LICE_FUNCDEF void (*__LICE_MultiplyAddRect)(LICE_IBitmap *dest, int x, int y, int w, int h,
float rsc, float gsc, float bsc, float asc, // 0-1, or -100 .. +100 if you really are insane
float radd, float gadd, float badd, float aadd); // 0-255 is the normal range on these.. of course its clamped
EEL_LICE_FUNCDEF void (*__LICE_GradRect)(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth,
float ir, float ig, float ib, float ia,
float drdx, float dgdx, float dbdx, float dadx,
float drdy, float dgdy, float dbdy, float dady,
int mode);
EEL_LICE_FUNCDEF void (*__LICE_TransformBlit2)(LICE_IBitmap *dest, LICE_IBitmap *src,
int dstx, int dsty, int dstw, int dsth,
double *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates
float alpha, int mode);
EEL_LICE_FUNCDEF void (*__LICE_DeltaBlit)(LICE_IBitmap *dest, LICE_IBitmap *src,
int dstx, int dsty, int dstw, int dsth,
float srcx, float srcy, float srcw, float srch,
double dsdx, double dtdx, double dsdy, double dtdy,
double dsdxdy, double dtdxdy,
bool cliptosourcerect, float alpha, int mode);
#define LICE_Blur __LICE_Blur
#define LICE_Clear __LICE_Clear
#define LICE_Line __LICE_Line
#define LICE_ClipLine __LICE_ClipLine
#define LICE_FillRect __LICE_FillRect
#define LICE_DrawRect __LICE_DrawRect
#define LICE_PutPixel __LICE_PutPixel
#define LICE_GetPixel __LICE_GetPixel
#define LICE_DrawText __LICE_DrawText
#define LICE_DrawChar __LICE_DrawChar
#define LICE_MeasureText __LICE_MeasureText
#define LICE_LoadImage __LICE_LoadImage
#define LICE_RotatedBlit __LICE_RotatedBlit
#define LICE_ScaledBlit __LICE_ScaledBlit
#define LICE_MultiplyAddRect __LICE_MultiplyAddRect
#define LICE_GradRect __LICE_GradRect
#define LICE_TransformBlit2 __LICE_TransformBlit2
#define LICE_DeltaBlit __LICE_DeltaBlit
#define LICE_Circle __LICE_Circle
#define LICE_FillCircle __LICE_FillCircle
#define LICE_FillTriangle __LICE_FillTriangle
#define LICE_FillConvexPolygon __LICE_FillConvexPolygon
#define LICE_RoundRect __LICE_RoundRect
#define LICE_Arc __LICE_Arc
EEL_LICE_FUNCDEF HDC (*LICE__GetDC)(LICE_IBitmap *bm);
EEL_LICE_FUNCDEF int (*LICE__GetWidth)(LICE_IBitmap *bm);
EEL_LICE_FUNCDEF int (*LICE__GetHeight)(LICE_IBitmap *bm);
EEL_LICE_FUNCDEF void (*LICE__Destroy)(LICE_IBitmap *bm);
EEL_LICE_FUNCDEF bool (*LICE__resize)(LICE_IBitmap *bm, int w, int h);
EEL_LICE_FUNCDEF void (*LICE__DestroyFont)(LICE_IFont* font);
EEL_LICE_FUNCDEF LICE_IFont *(*LICE_CreateFont)();
EEL_LICE_FUNCDEF void (*LICE__SetFromHFont)(LICE_IFont* ifont, HFONT font, int flags);
EEL_LICE_FUNCDEF LICE_pixel (*LICE__SetTextColor)(LICE_IFont* ifont, LICE_pixel color);
EEL_LICE_FUNCDEF void (*LICE__SetTextCombineMode)(LICE_IFont* ifont, int mode, float alpha);
EEL_LICE_FUNCDEF int (*LICE__DrawText)(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags);
#else
#include "../lice/lice.h"
#include "../lice/lice_text.h"
#define LICE_FUNCTION_VALID(x) (sizeof(int) > 0)
static HDC LICE__GetDC(LICE_IBitmap *bm)
{
return bm->getDC();
}
static int LICE__GetWidth(LICE_IBitmap *bm)
{
return bm->getWidth();
}
static int LICE__GetHeight(LICE_IBitmap *bm)
{
return bm->getHeight();
}
static void LICE__Destroy(LICE_IBitmap *bm)
{
delete bm;
}
static void LICE__SetFromHFont(LICE_IFont * ifont, HFONT font, int flags)
{
if (ifont) ifont->SetFromHFont(font,flags);
}
static LICE_pixel LICE__SetTextColor(LICE_IFont* ifont, LICE_pixel color)
{
if (ifont) return ifont->SetTextColor(color);
return 0;
}
static void LICE__SetTextCombineMode(LICE_IFont* ifont, int mode, float alpha)
{
if (ifont) ifont->SetCombineMode(mode, alpha);
}
static int LICE__DrawText(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags)
{
if (ifont) return ifont->DrawText(bm, str, strcnt, rect, dtFlags);
return 0;
}
static LICE_IFont *LICE_CreateFont()
{
return new LICE_CachedFont();
}
static void LICE__DestroyFont(LICE_IFont *bm)
{
delete bm;
}
static bool LICE__resize(LICE_IBitmap *bm, int w, int h)
{
return bm->resize(w,h);
}
static LICE_IBitmap *__LICE_CreateBitmap(int mode, int w, int h)
{
if (mode==1) return new LICE_SysBitmap(w,h);
return new LICE_MemBitmap(w,h);
}
#endif
#include "../wdlutf8.h"
class eel_lice_state
{
public:
eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots);
~eel_lice_state();
void resetVarsToStock()
{
if (m_gfx_a&&m_gfx_r&&m_gfx_g&&m_gfx_b) *m_gfx_r=*m_gfx_g=*m_gfx_b=*m_gfx_a=1.0;
if (m_gfx_a2) *m_gfx_a2=1.0;
if (m_gfx_dest) *m_gfx_dest=-1.0;
if (m_mouse_wheel) *m_mouse_wheel=0.0;
if (m_mouse_hwheel) *m_mouse_hwheel=0.0;
// todo: reset others?
}
LICE_IBitmap *m_framebuffer, *m_framebuffer_extra;
int m_framebuffer_dirty;
struct img_shared_state
{
LICE_IBitmap *bm;
int refcnt;
img_shared_state(LICE_IBitmap *b) : bm(b), refcnt(1) { }
void release()
{
if (wdl_atomic_decr(&refcnt)==0) delete this;
}
private:
~img_shared_state()
{
s_img_cache_mutex.Enter();
for (int x = 0; x < s_img_cache.GetSize(); x ++)
{
if (s_img_cache.Enumerate(x) == this)
{
s_img_cache.DeleteByIndex(x);
break;
}
}
s_img_cache_mutex.Leave();
if (LICE_FUNCTION_VALID(LICE__Destroy))
LICE__Destroy(bm);
}
};
static WDL_StringKeyedArray<img_shared_state *> s_img_cache;
static WDL_Mutex s_img_cache_mutex;
struct img_state
{
LICE_IBitmap *bm;
img_shared_state *shared;
void clear(LICE_IBitmap *bmnew=NULL, img_shared_state *sharednew=NULL)
{
if (shared) shared->release();
if (bm && LICE_FUNCTION_VALID(LICE__Destroy))
LICE__Destroy(bm);
bm = bmnew;
shared = sharednew;
}
void on_write()
{
if (shared && WDL_NORMALLY(shared->bm))
{
const int bmw = LICE__GetWidth(shared->bm), bmh = LICE__GetHeight(shared->bm);
bm = __LICE_CreateBitmap(1,bmw,bmh);
LICE_ScaledBlit(bm,shared->bm, // copy the entire image
0,0,bmw,bmh,
0.0f,0.0f,(float)bmw,(float)bmh,
1.0f,LICE_BLIT_MODE_COPY);
shared->release();
shared = NULL;
}
}
};
bool do_load_image(int img, const char *str);
WDL_TypedBuf<img_state> m_gfx_images;
struct gfxFontStruct {
LICE_IFont *font;
char last_fontname[128];
char actual_fontname[128];
int last_fontsize;
int last_fontflag;
int use_fonth;
};
WDL_TypedBuf<gfxFontStruct> m_gfx_fonts;
enum {
EELFONT_FLAG_BOLD = (1<<24),
EELFONT_FLAG_ITALIC = (2<<24),
EELFONT_FLAG_UNDERLINE = (4<<24),
EELFONT_FLAG_MASK = EELFONT_FLAG_BOLD|EELFONT_FLAG_ITALIC|EELFONT_FLAG_UNDERLINE
};
int m_gfx_font_active; // -1 for default, otherwise index into gfx_fonts (NOTE: this differs from the exposed API, which defines 0 as default, 1-n)
LICE_IFont *GetActiveFont() { return m_gfx_font_active>=0&&m_gfx_font_active<m_gfx_fonts.GetSize() && m_gfx_fonts.Get()[m_gfx_font_active].use_fonth ? m_gfx_fonts.Get()[m_gfx_font_active].font : NULL; }
LICE_IBitmap *GetImageForIndex(EEL_F idx, const char *callername, bool is_wr=true)
{
if (idx>-2.0)
{
if (idx < 0.0) return m_framebuffer;
const int a = (int)idx;
if (a >= 0 && a < m_gfx_images.GetSize())
{
img_state *rec = m_gfx_images.Get() + a;
if (is_wr) rec->on_write();
return rec->shared ? rec->shared->bm : rec->bm;
}
}
return NULL;
};
void SetImageDirty(LICE_IBitmap *bm)
{
if (bm == m_framebuffer && !m_framebuffer_dirty)
{
if (m_gfx_clear && *m_gfx_clear > -1.0)
{
const int a=(int)*m_gfx_clear;
if (LICE_FUNCTION_VALID(LICE_Clear)) LICE_Clear(m_framebuffer,LICE_RGBA((a&0xff),((a>>8)&0xff),((a>>16)&0xff),0));
}
m_framebuffer_dirty=1;
}
}
// R, G, B, A, w, h, x, y, mode(1=add,0=copy)
EEL_F *m_gfx_r, *m_gfx_g, *m_gfx_b, *m_gfx_w, *m_gfx_h, *m_gfx_a, *m_gfx_x, *m_gfx_y, *m_gfx_mode, *m_gfx_clear, *m_gfx_texth,*m_gfx_dest, *m_gfx_a2;
EEL_F *m_mouse_x, *m_mouse_y, *m_mouse_cap, *m_mouse_wheel, *m_mouse_hwheel;
EEL_F *m_gfx_ext_retina;
NSEEL_VMCTX m_vmref;
void *m_user_ctx;
int setup_frame(HWND hwnd, RECT r, int _mouse_x=0, int _mouse_y=0, int has_dpi=0); // mouse_x/y used only if hwnd is NULL
void finish_draw();
void gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag);
void gfx_rectto(EEL_F xpos, EEL_F ypos);
void gfx_line(int np, EEL_F **parms);
void gfx_rect(int np, EEL_F **parms);
void gfx_roundrect(int np, EEL_F **parms);
void gfx_arc(int np, EEL_F **parms);
void gfx_set(int np, EEL_F **parms);
void gfx_grad_or_muladd_rect(int mode, int np, EEL_F **parms);
void gfx_setpixel(EEL_F r, EEL_F g, EEL_F b);
void gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b);
void gfx_drawnumber(EEL_F n, EEL_F ndigits);
void gfx_drawchar(EEL_F ch);
void gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h);
EEL_F gfx_setimgdim(int img, EEL_F *w, EEL_F *h);
void gfx_blurto(EEL_F x, EEL_F y);
void gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle);
void gfx_blitext2(int np, EEL_F **parms, int mode); // 0=blit, 1=deltablit
void gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab); // parms[0]=src, 1-4=x,y,w,h
void gfx_circle(float x, float y, float r, bool fill, bool aaflag);
void gfx_triangle(EEL_F** parms, int nparms);
void gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode); // formatmode=1 for format, 2 for purely measure no format, 3 for measure char
EEL_F gfx_loadimg(void *opaque, int img, EEL_F loadFrom);
EEL_F gfx_setfont(void *opaque, int np, EEL_F **parms);
EEL_F gfx_getfont(void *opaque, int np, EEL_F **parms);
EEL_F gfx_getdropfile(void *opaque, int np, EEL_F **parms);
LICE_pixel getCurColor();
int getCurMode();
int getCurModeForBlit(bool isFBsrc);
#ifdef EEL_LICE_WANT_STANDALONE
HWND create_wnd(HWND par, int isChild);
HWND hwnd_standalone;
int hwnd_standalone_kb_state[32]; // pressed keys, if any
// these have to be **parms because of the hack for getting string from parm index
EEL_F gfx_showmenu(void* opaque, EEL_F** parms, int nparms);
EEL_F gfx_setcursor(void* opaque, EEL_F** parms, int nparms);
int m_kb_queue[64];
unsigned char m_kb_queue_valid;
unsigned char m_kb_queue_pos;
HCURSOR m_cursor;
int m_cursor_resid;
#ifdef EEL_LICE_LOADTHEMECURSOR
char m_cursor_name[128];
#endif
#ifndef EEL_LICE_STANDALONE_NOINITQUIT
RECT m_last_undocked_r;
#endif
#endif
DWORD m_last_menu_time;
int m_last_menu_cnt;
int m_has_cap; // high 16 bits are current capture state, low 16 bits are temporary flags from mousedown
bool m_has_had_getch; // set on first gfx_getchar(), makes mouse_cap updated with modifiers even when no mouse click is down
WDL_PtrList<char> m_ddrop_files;
};
#ifndef EEL_LICE_API_ONLY
WDL_StringKeyedArray<eel_lice_state::img_shared_state *> eel_lice_state::s_img_cache(true);
WDL_Mutex eel_lice_state::s_img_cache_mutex;
eel_lice_state::eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots)
{
#ifdef EEL_LICE_WANT_STANDALONE
hwnd_standalone=NULL;
memset(hwnd_standalone_kb_state,0,sizeof(hwnd_standalone_kb_state));
m_kb_queue_valid=0;
m_cursor_resid=0;
m_cursor = NULL;
#ifndef EEL_LICE_STANDALONE_NOINITQUIT
memset(&m_last_undocked_r,0,sizeof(m_last_undocked_r));
#endif
#ifdef EEL_LICE_LOADTHEMECURSOR
m_cursor_name[0]=0;
#endif
#endif
m_user_ctx=ctx;
m_vmref= vm;
m_gfx_font_active=-1;
m_gfx_fonts.Resize(font_slots);
memset(m_gfx_fonts.Get(),0,m_gfx_fonts.GetSize()*sizeof(m_gfx_fonts.Get()[0]));
m_gfx_images.Resize(image_slots);
memset(m_gfx_images.Get(),0,m_gfx_images.GetSize()*sizeof(m_gfx_images.Get()[0]));
m_framebuffer=m_framebuffer_extra=0;
m_framebuffer_dirty=0;
m_gfx_r = NSEEL_VM_regvar(vm,"gfx_r");
m_gfx_g = NSEEL_VM_regvar(vm,"gfx_g");
m_gfx_b = NSEEL_VM_regvar(vm,"gfx_b");
m_gfx_a = NSEEL_VM_regvar(vm,"gfx_a");
m_gfx_a2 = NSEEL_VM_regvar(vm,"gfx_a2");
m_gfx_w = NSEEL_VM_regvar(vm,"gfx_w");
m_gfx_h = NSEEL_VM_regvar(vm,"gfx_h");
m_gfx_x = NSEEL_VM_regvar(vm,"gfx_x");
m_gfx_y = NSEEL_VM_regvar(vm,"gfx_y");
m_gfx_mode = NSEEL_VM_regvar(vm,"gfx_mode");
m_gfx_clear = NSEEL_VM_regvar(vm,"gfx_clear");
m_gfx_texth = NSEEL_VM_regvar(vm,"gfx_texth");
m_gfx_dest = NSEEL_VM_regvar(vm,"gfx_dest");
m_gfx_ext_retina = NSEEL_VM_regvar(vm,"gfx_ext_retina");
m_mouse_x = NSEEL_VM_regvar(vm,"mouse_x");
m_mouse_y = NSEEL_VM_regvar(vm,"mouse_y");
m_mouse_cap = NSEEL_VM_regvar(vm,"mouse_cap");
m_mouse_wheel=NSEEL_VM_regvar(vm,"mouse_wheel");
m_mouse_hwheel=NSEEL_VM_regvar(vm,"mouse_hwheel");
if (m_gfx_texth) *m_gfx_texth=8;
m_has_cap=0;
m_has_had_getch=false;
m_last_menu_time = GetTickCount() - 100000;
m_last_menu_cnt = 0;
}
eel_lice_state::~eel_lice_state()
{
#ifdef EEL_LICE_WANT_STANDALONE
if (hwnd_standalone) DestroyWindow(hwnd_standalone);
#endif
if (LICE_FUNCTION_VALID(LICE__Destroy))
{
LICE__Destroy(m_framebuffer_extra);
LICE__Destroy(m_framebuffer);
}
for (int x=0;x<m_gfx_images.GetSize();x++)
m_gfx_images.Get()[x].clear();
if (LICE_FUNCTION_VALID(LICE__DestroyFont))
{
for (int x=0;x<m_gfx_fonts.GetSize();x++)
{
if (m_gfx_fonts.Get()[x].font) LICE__DestroyFont(m_gfx_fonts.Get()[x].font);
}
}
m_ddrop_files.Empty(true,free);
}
int eel_lice_state::getCurMode()
{
const int gmode = (int) (*m_gfx_mode);
const int sm=(gmode>>4)&0xf;
if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) return sm;
return (gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY;
}
int eel_lice_state::getCurModeForBlit(bool isFBsrc)
{
const int gmode = (int) (*m_gfx_mode);
const int sm=(gmode>>4)&0xf;
int mode;
if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) mode=sm;
else mode=((gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY);
if (!isFBsrc && !(gmode&2)) mode|=LICE_BLIT_USE_ALPHA;
if (!(gmode&4)) mode|=LICE_BLIT_FILTER_BILINEAR;
return mode;
}
LICE_pixel eel_lice_state::getCurColor()
{
int red=(int) (*m_gfx_r*255.0);
int green=(int) (*m_gfx_g*255.0);
int blue=(int) (*m_gfx_b*255.0);
int a2=(int) (*m_gfx_a2*255.0);
if (red<0) red=0;else if (red>255)red=255;
if (green<0) green=0;else if (green>255)green=255;
if (blue<0) blue=0; else if (blue>255) blue=255;
if (a2<0) a2=0; else if (a2>255) a2=255;
return LICE_RGBA(red,green,blue,a2);
}
static EEL_F * NSEEL_CGEN_CALL _gfx_lineto(void *opaque, EEL_F *xpos, EEL_F *ypos, EEL_F *useaa)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_lineto(*xpos, *ypos, *useaa);
return xpos;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_lineto2(void *opaque, EEL_F *xpos, EEL_F *ypos)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_lineto(*xpos, *ypos, 1.0f);
return xpos;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_rectto(void *opaque, EEL_F *xpos, EEL_F *ypos)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_rectto(*xpos, *ypos);
return xpos;
}
static EEL_F NSEEL_CGEN_CALL _gfx_line(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_line((int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_rect(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_rect((int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_roundrect(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_roundrect((int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_arc(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_arc((int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_set(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_set((int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_gradrect(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_grad_or_muladd_rect(0,(int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_muladdrect(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_grad_or_muladd_rect(1,(int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_deltablit(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_blitext2((int)np,parms,1);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_transformblit(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx)
{
#ifndef EEL_LICE_NO_RAM
const int divw = (int) (parms[5][0]+0.5);
const int divh = (int) (parms[6][0]+0.5);
if (divw < 1 || divh < 1) return 0.0;
const int sz = divw*divh*2;
#ifdef EEL_LICE_RAMFUNC
EEL_F *d = EEL_LICE_RAMFUNC(opaque,7,sz);
if (!d) return 0.0;
#else
EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0;
if (!blocks || np < 8) return 0.0;
const int addr1= (int) (parms[7][0]+0.5);
EEL_F *d=__NSEEL_RAMAlloc(blocks,addr1);
if (sz>NSEEL_RAM_ITEMSPERBLOCK)
{
int x;
for(x=NSEEL_RAM_ITEMSPERBLOCK;x<sz-1;x+=NSEEL_RAM_ITEMSPERBLOCK)
if (__NSEEL_RAMAlloc(blocks,addr1+x) != d+x) return 0.0;
}
EEL_F *end=__NSEEL_RAMAlloc(blocks,addr1+sz-1);
if (end != d+sz-1) return 0.0; // buffer not contiguous
#endif
ctx->gfx_transformblit(parms,divw,divh,d);
#endif
}
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_circle(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
bool aa = true, fill = false;
if (np>3) fill = parms[3][0] > 0.5;
if (np>4) aa = parms[4][0] > 0.5;
if (ctx) ctx->gfx_circle((float)parms[0][0], (float)parms[1][0], (float)parms[2][0], fill, aa);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_triangle(void* opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_triangle(parms, (int)np);
return 0.0;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_drawnumber(void *opaque, EEL_F *n, EEL_F *nd)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_drawnumber(*n, *nd);
return n;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_drawchar(void *opaque, EEL_F *n)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_drawchar(*n);
return n;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_measurestr(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx)
{
EEL_F *p[3]={str,xOut,yOut};
ctx->gfx_drawstr(opaque,p,3,2);
}
return str;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_measurechar(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx)
{
EEL_F *p[3]={str,xOut,yOut};
ctx->gfx_drawstr(opaque,p,3,3);
}
return str;
}
static EEL_F NSEEL_CGEN_CALL _gfx_drawstr(void *opaque, INT_PTR nparms, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_drawstr(opaque,parms,(int)nparms,0);
return parms[0][0];
}
static EEL_F NSEEL_CGEN_CALL _gfx_printf(void *opaque, INT_PTR nparms, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx && nparms>0)
{
EEL_F v= **parms;
ctx->gfx_drawstr(opaque,parms,(int)nparms,1);
return v;
}
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_showmenu(void* opaque, INT_PTR nparms, EEL_F **parms)
{
eel_lice_state* ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_showmenu(opaque, parms, (int)nparms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_setcursor(void* opaque, INT_PTR nparms, EEL_F **parms)
{
eel_lice_state* ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_setcursor(opaque, parms, (int)nparms);
return 0.0;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_setpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_setpixel(*r, *g, *b);
return r;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_getpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_getpixel(r, g, b);
return r;
}
static EEL_F NSEEL_CGEN_CALL _gfx_setfont(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_setfont(opaque,(int)np,parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_getfont(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx)
{
const int idx=ctx->m_gfx_font_active;
if (idx>=0 && idx < ctx->m_gfx_fonts.GetSize())
{
eel_lice_state::gfxFontStruct* f=ctx->m_gfx_fonts.Get()+idx;
EEL_STRING_MUTEXLOCK_SCOPE
#ifdef NOT_EEL_STRING_UPDATE_STRING
NOT_EEL_STRING_UPDATE_STRING(parms[0][0],f->actual_fontname);
#else
WDL_FastString *fs=NULL;
EEL_STRING_GET_FOR_WRITE(parms[0][0],&fs);
if (fs) fs->Set(f->actual_fontname);
#endif
}
return idx;
}
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_blit2(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx && np>=3)
{
ctx->gfx_blitext2((int)np,parms,0);
return *(parms[0]);
}
return 0.0;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_blitext(void *opaque, EEL_F *img, EEL_F *coordidx, EEL_F *rotate)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx)
{
#ifndef EEL_LICE_NO_RAM
#ifdef EEL_LICE_RAMFUNC
EEL_F *buf = EEL_LICE_RAMFUNC(opaque,1,10);
if (!buf) return img;
#else
EEL_F fc = *coordidx;
if (fc < -0.5 || fc >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) return img;
int a=(int)fc;
if (a<0) return img;
EEL_F buf[10];
int x;
EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0;
if (!blocks) return img;
for (x = 0;x < 10; x ++)
{
EEL_F *d=__NSEEL_RAMAlloc(blocks,a++);
if (!d || d==&nseel_ramalloc_onfail) return img;
buf[x]=*d;
}
#endif
// read megabuf
ctx->gfx_blitext(*img,buf,*rotate);
#endif
}
return img;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_blurto(void *opaque, EEL_F *x, EEL_F *y)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_blurto(*x,*y);
return x;
}
static EEL_F * NSEEL_CGEN_CALL _gfx_getimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) ctx->gfx_getimgdim(*img,w,h);
return img;
}
static EEL_F NSEEL_CGEN_CALL _gfx_loadimg(void *opaque, EEL_F *img, EEL_F *fr)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_loadimg(opaque,(int)*img,*fr);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_getdropfile(void *opaque, INT_PTR np, EEL_F **parms)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_getdropfile(opaque,(int) np, parms);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_setimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
{
eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque);
if (ctx) return ctx->gfx_setimgdim((int)*img,w,h);
return 0.0;
}
static EEL_F NSEEL_CGEN_CALL _gfx_getsyscol(void* ctxe, INT_PTR np, EEL_F **parms)
{
return (EEL_F)LICE_RGBA_FROMNATIVE(GetSysColor(COLOR_3DFACE));
}
void eel_lice_state::gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_lineto");
if (!dest) return;
int x1=(int)floor(xpos),y1=(int)floor(ypos),x2=(int)floor(*m_gfx_x), y2=(int)floor(*m_gfx_y);
if (LICE_FUNCTION_VALID(LICE__GetWidth) && LICE_FUNCTION_VALID(LICE__GetHeight) && LICE_FUNCTION_VALID(LICE_Line) &&
LICE_FUNCTION_VALID(LICE_ClipLine) &&
LICE_ClipLine(&x1,&y1,&x2,&y2,0,0,LICE__GetWidth(dest),LICE__GetHeight(dest)))
{
SetImageDirty(dest);
LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float) *m_gfx_a,getCurMode(),aaflag > 0.5);
}
*m_gfx_x = xpos;
*m_gfx_y = ypos;
}
void eel_lice_state::gfx_circle(float x, float y, float r, bool fill, bool aaflag)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_circle");
if (!dest) return;
if (LICE_FUNCTION_VALID(LICE_Circle) && LICE_FUNCTION_VALID(LICE_FillCircle))
{
SetImageDirty(dest);
if(fill)
LICE_FillCircle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag);
else
LICE_Circle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag);
}
}
void eel_lice_state::gfx_triangle(EEL_F** parms, int np)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest, "gfx_triangle");
if (np >= 6)
{
np &= ~1;
SetImageDirty(dest);
if (np == 6)
{
if (!LICE_FUNCTION_VALID(LICE_FillTriangle)) return;
LICE_FillTriangle(dest, (int)parms[0][0], (int)parms[1][0], (int)parms[2][0], (int)parms[3][0],
(int)parms[4][0], (int)parms[5][0], getCurColor(), (float)*m_gfx_a, getCurMode());
}
else
{
if (!LICE_FUNCTION_VALID(LICE_FillConvexPolygon)) return;
const int maxpt = 512;
const int n = wdl_min(np/2, maxpt);
int i, rdi=0;
int x[maxpt], y[maxpt];
for (i=0; i < n; i++)
{
x[i]=(int)parms[rdi++][0];
y[i]=(int)parms[rdi++][0];
}
LICE_FillConvexPolygon(dest, x, y, n, getCurColor(), (float)*m_gfx_a, getCurMode());
}
}
}
void eel_lice_state::gfx_rectto(EEL_F xpos, EEL_F ypos)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rectto");
if (!dest) return;
EEL_F x1=xpos,y1=ypos,x2=*m_gfx_x, y2=*m_gfx_y;
if (x2<x1) { x1=x2; x2=xpos; }
if (y2<y1) { y1=y2; y2=ypos; }
if (LICE_FUNCTION_VALID(LICE_FillRect) && x2-x1 > 0.5 && y2-y1 > 0.5)
{
SetImageDirty(dest);
LICE_FillRect(dest,(int)x1,(int)y1,(int)(x2-x1),(int)(y2-y1),getCurColor(),(float)*m_gfx_a,getCurMode());
}
*m_gfx_x = xpos;
*m_gfx_y = ypos;
}
void eel_lice_state::gfx_line(int np, EEL_F **parms)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_line");
if (!dest) return;
int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),x2=(int)floor(parms[2][0]), y2=(int)floor(parms[3][0]);
if (LICE_FUNCTION_VALID(LICE__GetWidth) &&
LICE_FUNCTION_VALID(LICE__GetHeight) &&
LICE_FUNCTION_VALID(LICE_Line) &&
LICE_FUNCTION_VALID(LICE_ClipLine) && LICE_ClipLine(&x1,&y1,&x2,&y2,0,0,LICE__GetWidth(dest),LICE__GetHeight(dest)))
{
SetImageDirty(dest);
LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float)*m_gfx_a,getCurMode(),np< 5 || parms[4][0] > 0.5);
}
}
void eel_lice_state::gfx_rect(int np, EEL_F **parms)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rect");
if (!dest) return;
int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]),h=(int)floor(parms[3][0]);
int filled=(np < 5 || parms[4][0] > 0.5);
if (LICE_FUNCTION_VALID(LICE_FillRect) && LICE_FUNCTION_VALID(LICE_DrawRect) && w>0 && h>0)
{
SetImageDirty(dest);
if (filled) LICE_FillRect(dest,x1,y1,w,h,getCurColor(),(float)*m_gfx_a,getCurMode());
else LICE_DrawRect(dest, x1, y1, w-1, h-1, getCurColor(), (float)*m_gfx_a, getCurMode());
}
}
void eel_lice_state::gfx_roundrect(int np, EEL_F **parms)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_roundrect");
if (!dest) return;
const bool aa = np <= 5 || parms[5][0]>0.5;
if (LICE_FUNCTION_VALID(LICE_RoundRect) && parms[2][0]>0 && parms[3][0]>0)
{
SetImageDirty(dest);
LICE_RoundRect(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (int)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa);
}
}
void eel_lice_state::gfx_arc(int np, EEL_F **parms)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_arc");
if (!dest) return;
const bool aa = np <= 5 || parms[5][0]>0.5;
if (LICE_FUNCTION_VALID(LICE_Arc))
{
SetImageDirty(dest);
LICE_Arc(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (float)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa);
}
}
void eel_lice_state::gfx_grad_or_muladd_rect(int whichmode, int np, EEL_F **parms)
{
LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,whichmode==0?"gfx_gradrect":"gfx_muladdrect");
if (!dest) return;
const int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]), h=(int)floor(parms[3][0]);
if (w>0 && h>0)
{
SetImageDirty(dest);
if (whichmode==0 && LICE_FUNCTION_VALID(LICE_GradRect) && np > 7)
{