summaryrefslogtreecommitdiff
path: root/legacy/evas/src/modules/engines/software_16_wince/evas_engine.c
blob: 886fa0f706f9e81ae05b2f4634a4ec3d480838f4 (plain)
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
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_16_WinCE.h"
#include "evas_common_soft16.h"

int _evas_engine_soft16_wince_log_dom = -1;

typedef enum
{
  EVAS_ENGINE_WINCE_FB,
  EVAS_ENGINE_WINCE_GAPI,
  EVAS_ENGINE_WINCE_DDRAW,
  EVAS_ENGINE_WINCE_GDI
} Evas_Engine_WinCE_Backend;


/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;

/* engine struct data */
typedef struct _Render_Engine Render_Engine;

struct _Render_Engine
{
   Evas_Engine_WinCE_Backend backend; /* 1: raw, 2: gapi, 3: ddraw, 4: GDI */
   void               *backend_priv;
   void              (*backend_shutdown)(void *priv);
   FB_Output_Buffer *(*backend_output_buffer_new)(void *priv,
                                                  int width,
                                                  int height);
   void              (*backend_output_buffer_free)(FB_Output_Buffer *fbob);
   void              (*backend_output_buffer_paste)(FB_Output_Buffer *fbob);
   void              (*backend_surface_resize)(FB_Output_Buffer *fbob);

   int               width;
   int               height;
   int               rotation;
   Tilebuf          *tb;
   Tilebuf_Rect     *rects;
   Tilebuf_Rect     *cur_rect;
   FB_Output_Buffer *fbob;
   Soft16_Image     *tmp_out; /* used by indirect render, like rotation */
   HRGN              clip_rects;
   unsigned char     end : 1;
};

/* prototypes we will use here */

static void *eng_info(Evas *e);
static void eng_info_free(Evas *e, void *info);
static int eng_setup(Evas *e, void *info);
static void eng_output_free(void *data);
static void eng_output_resize(void *data, int w, int h);
static void eng_output_tile_size_set(void *data, int w, int h);
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
static void eng_output_redraws_clear(void *data);
static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
static void eng_output_flush(void *data);
static void eng_output_idle_flush(void *data);

static int
_suspend(int backend)
{
   switch (backend)
     {
      case 2: /* gapi */
         return evas_software_wince_gapi_suspend();
      default: /* other engines do not need it */
         return 0;
     }
}

static int
_resume(int backend)
{
   switch (backend)
     {
      case 2: /* gapi */
         return evas_software_wince_gapi_resume();
      default: /* other engines do not need it */
         return 0;
     }
}

/* engine api this module provides */
static void *
eng_info(Evas *e)
{
   Evas_Engine_Info_Software_16_WinCE *info;
   info = calloc(1, sizeof(Evas_Engine_Info_Software_16_WinCE));
   if (!info) return NULL;
   info->magic.magic = rand();
   info->func.suspend = _suspend;
   info->func.resume = _resume;
   return info;
   e = NULL;
}

static void
eng_info_free(Evas *e, void *info)
{
   Evas_Engine_Info_Software_16_WinCE *in;
   in = (Evas_Engine_Info_Software_16_WinCE *)info;
   free(in);
}

static void
_tmp_out_alloc(Render_Engine *re)
{
   Tilebuf_Rect *r;
   int w = 0, h = 0;

   EINA_INLIST_FOREACH(re->rects, r)
     {
	if (r->w > w) w = r->w;
	if (r->h > h) h = r->h;
     }

   if (re->tmp_out)
     {
	if ((re->tmp_out->cache_entry.w < w) || (re->tmp_out->cache_entry.h < h))
	  {
             evas_cache_image_drop(&re->tmp_out->cache_entry);
	     re->tmp_out = NULL;
	  }
     }

   if (!re->tmp_out)
     {
	Soft16_Image *im;

        im = (Soft16_Image *) evas_cache_image_empty(evas_common_soft16_image_cache_get());
        im->cache_entry.flags.alpha = 0;
        evas_cache_image_surface_alloc(&im->cache_entry, w, h);

	re->tmp_out = im;
     }
}


static int
eng_setup(Evas *e, void *in)
{
   Render_Engine                      *re;
   Evas_Engine_Info_Software_16_WinCE *info;

   info = (Evas_Engine_Info_Software_16_WinCE *)in;
   if (!e->engine.data.output)
     {
	/* do common routine init - we wil at least use it for core
	 * image loading and font loading/glyph rendering & placement */
	evas_common_cpu_init();

	evas_common_blend_init();
	evas_common_image_init();
	evas_common_convert_init();
	evas_common_scale_init();
	evas_common_rectangle_init();
	evas_common_gradient_init();
	evas_common_polygon_init();
	evas_common_line_init();
	evas_common_font_init();
	evas_common_draw_init();
	evas_common_tilebuf_init();
	evas_common_soft16_image_init();

	/* render engine specific data */
	re = calloc(1, sizeof(Render_Engine));
        if (!re)
          return 0;
	e->engine.data.output = re;

        switch(info->info.backend)
          {
           case 1: /* FB */
              re->backend = EVAS_ENGINE_WINCE_FB;
              re->backend_priv = evas_software_wince_fb_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_fb_shutdown;
              re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_fb_surface_resize;
              break;
           case 2: /* GAPI */
              re->backend = EVAS_ENGINE_WINCE_GAPI;
              re->backend_priv = evas_software_wince_gapi_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_gapi_shutdown;
              re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_gapi_surface_resize;
              break;
           case 3: /* DirectDraw */
              re->backend = EVAS_ENGINE_WINCE_DDRAW;
              re->backend_priv = evas_software_wince_ddraw_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_ddraw_shutdown;
              re->backend_output_buffer_new = evas_software_wince_ddraw_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_ddraw_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_ddraw_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_ddraw_surface_resize;
              break;
           case 4: /* GDI */
              re->backend = EVAS_ENGINE_WINCE_GDI;
              re->backend_priv = evas_software_wince_gdi_init(info->info.window, info->info.width, info->info.height, info->info.fullscreen);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_gdi_shutdown;
              re->backend_output_buffer_new = evas_software_wince_gdi_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_gdi_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_gdi_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_gdi_surface_resize;
              break;
           default:
              free(re);
              return 0;
          }

	re->width = e->output.w;
	re->height = e->output.h;
	re->rotation = info->info.rotation;
	re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
	if (re->tb)
	  evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
     }
   else
     {
	re = e->engine.data.output;
	if (re->tb) evas_common_tilebuf_free(re->tb);

        switch(info->info.backend)
          {
           case 1: /* FB */
              re->backend = EVAS_ENGINE_WINCE_FB;
              re->backend_priv = evas_software_wince_fb_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_fb_shutdown;
              re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_fb_surface_resize;
              break;
           case 2: /* GAPI */
              re->backend = EVAS_ENGINE_WINCE_GAPI;
              re->backend_priv = evas_software_wince_gapi_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_gapi_shutdown;
              re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_gapi_surface_resize;
              break;
           case 3: /* DirectDraw */
              re->backend = EVAS_ENGINE_WINCE_DDRAW;
              re->backend_priv = evas_software_wince_ddraw_init(info->info.window, info->info.width, info->info.height);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_ddraw_shutdown;
              re->backend_output_buffer_new = evas_software_wince_ddraw_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_ddraw_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_ddraw_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_ddraw_surface_resize;
              break;
           case 4: /* GDI */
              re->backend = EVAS_ENGINE_WINCE_GDI;
              re->backend_priv = evas_software_wince_gdi_init(info->info.window, info->info.width, info->info.height, info->info.fullscreen);
              if (!re->backend_priv)
                {
                   free(re);
                   return 0;
                }
              re->backend_shutdown = evas_software_wince_gdi_shutdown;
              re->backend_output_buffer_new = evas_software_wince_gdi_output_buffer_new;
              re->backend_output_buffer_free = evas_software_wince_gdi_output_buffer_free;
              re->backend_output_buffer_paste = evas_software_wince_gdi_output_buffer_paste;
              re->backend_surface_resize = evas_software_wince_gdi_surface_resize;
              break;
           default:
              free(re);
              return 0;
          }

	re->width = e->output.w;
	re->height = e->output.h;
	re->rotation = info->info.rotation;
	re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
	if (re->tb)
	  evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
	if (re->tmp_out)
	  {
             evas_cache_image_drop(&re->tmp_out->cache_entry);
	     re->tmp_out = NULL;
	  }
     }
   if (!e->engine.data.output) return 0;
   /* add a draw context if we dont have one */
   if (!e->engine.data.context)
     e->engine.data.context =
     e->engine.func->context_new(e->engine.data.output);

   return 1;
}

static void
eng_output_free(void *data)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   if (re->fbob) re->backend_output_buffer_free(re->backend_priv);
   re->backend_shutdown(re->backend_priv);
   if (re->clip_rects) DeleteObject(re->clip_rects);
   if (re->tb) evas_common_tilebuf_free(re->tb);
   if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
   if (re->tmp_out) evas_cache_image_drop(&re->tmp_out->cache_entry);
   free(re);

   evas_common_font_shutdown();
   evas_common_image_shutdown();
   evas_common_soft16_image_shutdown();
}

static void
eng_output_resize(void *data, int w, int h)
{
   Render_Engine *re;

   re = (Render_Engine *)data;

   if ((re->width == w) && (re->height == h)) return;

   /* FIXME: is it needed ?? */
   if (re->fbob)
     re->backend_surface_resize(re->fbob);

   evas_common_tilebuf_free(re->tb);
   re->width = w;
   re->height = h;
   re->tb = evas_common_tilebuf_new(w, h);
   if (re->tb)
     evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
   if (re->fbob)
     {
        re->backend_output_buffer_free(re->fbob);
	re->fbob = NULL;
     }
   if (re->clip_rects)
     {
	DeleteObject(re->clip_rects);
	re->clip_rects = NULL;
     }
   if (re->tmp_out)
     {
	evas_cache_image_drop(&re->tmp_out->cache_entry);
	re->tmp_out = NULL;
     }
}

static void
eng_output_tile_size_set(void *data, int w, int h)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   evas_common_tilebuf_set_tile_size(re->tb, w, h);
}

static void
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
}

static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
}

static void
eng_output_redraws_clear(void *data)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   evas_common_tilebuf_clear(re->tb);
}

static inline void
_output_buffer_alloc(Render_Engine *re)
{
   int width;
   int height;

   if (re->fbob) return;

   if ((re->rotation == 0) || (re->rotation == 180))
     {
	width = re->width;
	height = re->height;
     }
   else
     {
	width = re->height;
	height = re->width;
     }

   re->fbob = re->backend_output_buffer_new(re->backend_priv,
                                            width,
                                            height);
}

static void *
eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
{
   Render_Engine *re;
   Tilebuf_Rect *rect;
   int ux, uy, uw, uh;

   re = (Render_Engine *)data;
   if (re->end)
     {
	re->end = 0;
	return NULL;
     }
   if (!re->rects)
     {
	re->rects = evas_common_tilebuf_get_render_rects(re->tb);
	if (!re->rects) return NULL;

	re->cur_rect = re->rects;
	_output_buffer_alloc(re);
	if (re->rotation != 0) _tmp_out_alloc(re); /* grows if required */
     }
   if (!re->cur_rect)
     {
	if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
	re->rects = NULL;
	return NULL;
     }
   rect = re->cur_rect;
   ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
   re->cur_rect = (Tilebuf_Rect *)((EINA_INLIST_GET(re->cur_rect))->next);
   if (!re->cur_rect)
     {
	evas_common_tilebuf_free_render_rects(re->rects);
	re->rects = NULL;
	re->end = 1;
     }

   *x = ux; *y = uy; *w = uw; *h = uh;
   if (re->rotation == 0)
     {
	*cx = ux; *cy = uy; *cw = uw; *ch = uh;
	return re->fbob->im;
     }
   else
     {
	*cx = 0; *cy = 0; *cw = uw; *ch = uh;
	return re->tmp_out;
     }
}

static void
_blit_rot_90(Soft16_Image *dst, const Soft16_Image *src,
	     int out_x, int out_y, int w, int h)
{
   DATA16 *dp, *sp;
   int x, y;

   sp = src->pixels;
   dp = dst->pixels + (out_x +
		       (w + out_y - 1) * dst->stride);

   for (y = 0; y < h; y++)
     {
	DATA16 *dp_itr, *sp_itr;

	sp_itr = sp;
	dp_itr = dp;

	for (x = 0; x < w; x++)
	  {
	     *dp_itr = *sp_itr;

	     sp_itr++;
	     dp_itr -= dst->stride;
	  }
	sp += src->stride;
	dp++;
     }
}

static void
_blit_rot_180(Soft16_Image *dst, const Soft16_Image *src,
	      int out_x, int out_y, int w, int h)
{
   DATA16 *dp, *sp;
   int x, y;

   sp = src->pixels;
   dp = dst->pixels + ((w + out_x - 1) +
		       (h + out_y - 1) * dst->stride);

   for (y = 0; y < h; y++)
     {
	DATA16 *dp_itr, *sp_itr;

	sp_itr = sp;
	dp_itr = dp;

	for (x = 0; x < w; x++)
	  {
	     *dp_itr = *sp_itr;

	     sp_itr++;
	     dp_itr--;
	  }
	sp += src->stride;
	dp -= dst->stride;
     }
}

static void
_blit_rot_270(Soft16_Image *dst, const Soft16_Image *src,
	      int out_x, int out_y, int w, int h)
{
   DATA16 *dp, *sp;
   int x, y;

   sp = src->pixels;
   dp = dst->pixels + ((h + out_x - 1) +
		       out_y * dst->stride);

   for (y = 0; y < h; y++)
     {
	DATA16 *dp_itr, *sp_itr;

	sp_itr = sp;
	dp_itr = dp;

	for (x = 0; x < w; x++)
	  {
	     *dp_itr = *sp_itr;

	     sp_itr++;
	     dp_itr += dst->stride;
	  }
	sp += src->stride;
	dp--;
     }
}

static void
_tmp_out_process(Render_Engine *re, int out_x, int out_y, int w, int h)
{
   Soft16_Image *d, *s;

   d = re->fbob->im;
   s = re->tmp_out;

   if ((w < 1) || (h < 1) || (out_x >= d->cache_entry.w) || (out_y >= d->cache_entry.h))
     return;

   if (re->rotation == 90)
     _blit_rot_90(d, s, out_x, out_y, w, h);
   else if (re->rotation == 180)
     _blit_rot_180(d, s, out_x, out_y, w, h);
   else if (re->rotation == 270)
     _blit_rot_270(d, s, out_x, out_y, w, h);
}

static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
   Render_Engine *re;
   HRGN           region;
   int            xx;
   int            yy;
   int            width;
   int            height;

   re = (Render_Engine *)data;

   if (!re->clip_rects)
      re->clip_rects = CreateRectRgn(0, 0, 0, 0);

   if (re->rotation == 0)
     {
	xx = x;
	yy = y;
	width = w;
	height = h;
     }
   else if (re->rotation == 90)
     {
	xx = y;
	yy = re->width - w - x;
	width = h;
	height = w;
     }
   else if (re->rotation == 180)
     {
	xx = re->width - w - x;
	yy = re->height - h - y;
	width = w;
	height = h;
     }
   else if (re->rotation == 270)
     {
	xx = re->height - h - y;
	yy = x;
	width = h;
	height = w;
     }

   region = CreateRectRgn(xx, yy, xx + width, yy + height);

   if (re->rotation != 0)
     _tmp_out_process(re, xx, yy, w, h);
   CombineRgn(re->clip_rects, re->clip_rects, region, RGN_OR);
}

static void
eng_output_flush(void *data)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   if (re->clip_rects)
     {
        /* FIXME : i have to manage that */
/* 	XSetRegion(re->disp, re->gc, re->clip_rects); */
	DeleteObject(re->clip_rects);
	re->clip_rects = NULL;
     }
   else return;

   re->backend_output_buffer_paste(re->fbob);

   /* FIXME : i have to manage that */
/*    XSetClipMask(re->disp, re->gc, None); */
}

static void
eng_output_idle_flush(void *data)
{
   Render_Engine *re;

   re = (Render_Engine *)data;
   if (re->fbob)
     {
	re->backend_output_buffer_free(re->fbob);
	re->fbob = NULL;
     }
   if (re->clip_rects)
     {
	DeleteObject(re->clip_rects);
	re->clip_rects = NULL;
     }
   if (re->tmp_out)
     {
	evas_cache_image_drop(&re->tmp_out->cache_entry);
	re->tmp_out = NULL;
     }
}

static Eina_Bool
eng_canvas_alpha_get(void *data, void *context)
{
   return EINA_FALSE;
}

/* module advertising code */
static int
module_open(Evas_Module *em)
{
   if (!em) return 0;
   /* get whatever engine module we inherit from */
   if (!_evas_module_engine_inherit(&pfunc, "software_16")) return 0;
   _evas_engine_soft16_wince_log_dom = eina_log_domain_register("EvasSoft16Wince", EVAS_DEFAULT_LOG_COLOR);
   
   if(_evas_engine_soft16_wince_log_dom < 0)
     {
        EINA_LOG_ERR("Impossible to create a log domain for the Soft16 Wince engine.");
        return 0;
     }

   /* store it for later use */
   func = pfunc;
   /* now to override methods */
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
   ORD(info);
   ORD(info_free);
   ORD(setup);
   ORD(canvas_alpha_get);
   ORD(output_free);
   ORD(output_resize);
   ORD(output_tile_size_set);
   ORD(output_redraws_rect_add);
   ORD(output_redraws_rect_del);
   ORD(output_redraws_clear);
   ORD(output_redraws_next_update_get);
   ORD(output_redraws_next_update_push);
   ORD(output_flush);
   ORD(output_idle_flush);
   /* now advertise out own api */
   em->functions = (void *)(&func);
   return 1;
}

static void
module_close(Evas_Module *em)
{
  eina_log_domain_unregister(_evas_engine_soft16_wince_log_dom);
}

static Evas_Module_Api evas_modapi =
{
   EVAS_MODULE_API_VERSION,
   "software_16_wince",
   "none",
   {
     module_open,
     module_close
   }
};

EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_16_wince);

#ifndef EVAS_STATIC_BUILD_SOFTWARE_16_WINCE
EVAS_EINA_MODULE_DEFINE(engine, software_16_wince);
#endif