MHEG5  18.9.0
MHEG5 Documentation
mg_dla.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2006 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 #undef DEBUG_FUNCTION
26 #define INTELLIGENT_RENDER_WITH_SCREEN_COORDS
27 
28 /*---includes for this file--------------------------------------------------*/
29 
30 /* compiler library header files */
31 
32 /* third party header files */
33 
34 /* OBS header files */
35 #include "osd_utils.h"
36 #include "glue_memory.h"
37 #include "glue_debug.h"
38 #include "mg_osd.h"
39 #include "mg_api.h"
40 
41 #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
42  #define DLA_struct _DLA4_Surface
43  #define DLA_Surface DLA4_Surface
44  #define DLA_FUNCTION(func) DLA_PC4_ ## func
45  #define DLAColor OSDColor
46  #include "dla_inl.h"
47  #if defined(OSD_16_BIT) || defined(OSD_8_BIT)
48  #undef DLA_struct
49  #undef DLA_Surface
50  #undef DLA_FUNCTION
51  #undef DLAColor
52  #undef DLA_INL_H
53  #endif
54 #endif
55 #ifdef OSD_16_BIT
56  #define DLA_struct _DLA2_Surface
57  #define DLA_Surface DLA2_Surface
58  #define DLA_FUNCTION(func) DLA_PC2_ ## func
59  #define DLAColor HD2Color
60  #include "dla_inl.h"
61  #ifdef OSD_8_BIT
62  #undef DLA_struct
63  #undef DLA_Surface
64  #undef DLA_FUNCTION
65  #undef DLAColor
66  #undef DLA_INL_H
67  #endif
68 #endif
69 #ifdef OSD_8_BIT
70  #define DLA_struct _DLA1_Surface
71  #define DLA_Surface DLA1_Surface
72  #define DLA_FUNCTION(func) DLA_PC1_ ## func
73  #define DLAColor U8BIT
74  #include "dla_inl.h"
75 #endif
76 #undef DLA_struct
77 #undef DLA_Surface
78 #undef DLA_FUNCTION
79 #undef DLAColor
80 
81 /*---constant definitions for this file--------------------------------------*/
82 
83 #define MAX(a, b) ((a) > (b) ? (a) : (b))
84 #define MIN(a, b) ((a) < (b) ? (a) : (b))
85 
86 #ifdef INTELLIGENT_RENDER_WITH_SCREEN_COORDS
87 #define HD_SCALEUP_RECT(dli, x, y, w, h, lw) \
88  if (mg_ctxt.osd_y.mlt != mg_ctxt.osd_y.div) \
89  { \
90  w = HD_X_SCALEUP(dli->sd_x + w + x); \
91  x = HD_X_SCALEUP(dli->sd_x + x); \
92  w -= x; \
93  x -= HD_X_SCALEUP(dli->sd_x); \
94  h = HD_Y_SCALEUP(dli->sd_y + h + y); \
95  y = HD_Y_SCALEUP(dli->sd_y + y); \
96  h -= y; \
97  y -= HD_Y_SCALEUP(dli->sd_y); \
98  if (lw) { \
99  lw = HD_W_SCALEUP(lw); \
100  } \
101  }
102 
103 #define HD_SCALEUP_REGN(dli, l, t, r, b) \
104  if (mg_ctxt.osd_y.mlt != mg_ctxt.osd_y.div) \
105  { \
106  r = HD_X_SCALEUP(dli->sd_x + r) - HD_X_SCALEUP(dli->sd_x); \
107  l = HD_X_SCALEUP(dli->sd_x + l) - HD_X_SCALEUP(dli->sd_x); \
108  t = HD_Y_SCALEUP(dli->sd_y + t) - HD_Y_SCALEUP(dli->sd_y); \
109  b = HD_Y_SCALEUP(dli->sd_y + b) - HD_Y_SCALEUP(dli->sd_y); \
110  }
111 
112 #else /*INTELLIGENT_RENDER_WITH_SCREEN_COORDS*/
113 
114 #define HD_SCALEUP_RECT(dli, x, y, w, h, lw) \
115  if (mg_ctxt.osd_y.mlt != mg_ctxt.osd_y.div) \
116  { \
117  w = HD_X_SCALEUP(w + x); \
118  x = HD_X_SCALEUP(x); \
119  w -= x; \
120  h = HD_Y_SCALEUP(h + y); \
121  y = HD_Y_SCALEUP(y); \
122  h -= y; \
123  if (lw) { \
124  lw = HD_W_SCALEUP(lw); \
125  } \
126  }
127 
128 #define HD_SCALEUP_REGN(dli, l, t, r, b) \
129  if (mg_ctxt.osd_y.mlt != mg_ctxt.osd_y.div) \
130  { \
131  r = HD_X_SCALEUP(r); \
132  l = HD_X_SCALEUP(l); \
133  t = HD_Y_SCALEUP(t); \
134  b = HD_Y_SCALEUP(b); \
135  }
136 
137 #endif /*INTELLIGENT_RENDER_WITH_SCREEN_COORDS*/
138 
139 #define LOCK_BUFFER( di, c_sz ) \
140  if (di->canvas.col_buff == NULL) { \
141  di->canvas.col_buff = STB_OSDMhegLockBuffer( di->canvas.hw_handle, &di->canvas.buff_pitch ); \
142  }
143 
144 #define UNLOCK_BUFFER( di ) \
145  if (di->canvas.col_buff != NULL) { \
146  STB_OSDMhegUnlockBuffer( di->canvas.hw_handle ); \
147  di->canvas.col_buff = NULL; \
148  }
149 
150 /* did you know...?
151  * #define PI (3.1415926535897F)
152  */
153 
154 
155 /*---local typedef structs for this file-------------------------------------*/
156 
157 typedef struct _DLA_Info
158 {
164  #ifdef INTELLIGENT_RENDER_WITH_SCREEN_COORDS
169  #endif
171 } DLA_Info;
172 
173 /*---global function definitions---------------------------------------------*/
174 
184 {
185  DLA_Info *dla_info;
186  U32BIT c_col, c_size;
187 
189 
190  if (data != NULL)
191  {
192  dla_info = (DLA_Info *)data;
193 
194  /* Clear canvas */
196  {
197  #ifdef OSD_8_BIT
198  c_size = dla_info->canvas.width * dla_info->canvas.height;
199  c_col = OSD_FindNearestColourIndex(dla_info->canvas_colour);
200  memset(dla_info->canvas.col_buff, c_col, c_size );
201 
202  /* Reset opacity information */
203  if (OSD_IsColourOpaque(c_col))
204  {
205  if (dla_info->border_width == 0)
206  {
207  dla_info->canvas.opaque = TRUE;
208  }
209  else
210  {
211  c_col = OSD_FindNearestColourIndex(dla_info->border_colour);
212  dla_info->canvas.opaque = OSD_IsColourOpaque(c_col);
213  }
214  }
215  else
216  {
217  dla_info->canvas.opaque = FALSE;
218  }
219  #endif /*OSD_8_BIT*/
220  }
222  {
223  #ifdef OSD_16_BIT
224  HD2Color col;
225  HD2Color *c_buf;
226 
227  LOCK_BUFFER( dla_info, 2 )
228 
229  c_size = (dla_info->canvas.buff_pitch * dla_info->canvas.height) / 2;
230  c_buf = (HD2Color *)dla_info->canvas.col_buff;
231  c_col = dla_info->canvas_colour;
232  col = MakeHD2Color(c_col);
233  while (c_size != 0)
234  {
235  c_size--;
236  *c_buf = col;
237  c_buf++;
238  }
239  if ((col >> 12) == 0xf)
240  {
241  if (dla_info->border_width == 0)
242  {
243  dla_info->canvas.opaque = TRUE;
244  }
245  else
246  {
247  dla_info->canvas.opaque = (dla_info->border_colour >> 28) == 0xf;
248  }
249  }
250  else
251  {
252  dla_info->canvas.opaque = FALSE;
253  }
254  #endif /*OSD_16_BIT*/
255  }
256 
257  ELSE
258  {
259  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
260  OSDColor *c_buf;
261 
262  LOCK_BUFFER( dla_info, 4 )
263 
264  c_size = (dla_info->canvas.buff_pitch * dla_info->canvas.height) / 4;
265  c_buf = (OSDColor *)dla_info->canvas.col_buff;
266  ConvertAlpha(dla_info->canvas_colour, c_col);
267  while (c_size != 0)
268  {
269  c_size--;
270  *c_buf = c_col;
271  c_buf++;
272  }
273  if ((c_col >> 24) == MAX_ALPHA)
274  {
275  if (dla_info->border_width == 0)
276  {
277  dla_info->canvas.opaque = TRUE;
278  }
279  else
280  {
281  dla_info->canvas.opaque = (dla_info->border_colour >> 24) == 0xff;
282  }
283  }
284  else
285  {
286  dla_info->canvas.opaque = FALSE;
287  }
288  #endif /*OSD_32_BIT*/
289  }
290  }
291 
293 }
294 
311 void* OSDinitDynamicLineart(int x, int y, int w, int h,
312  int line_width, int bordered,
313  OSDColor line_colour, OSDColor fill_colour)
314 {
315  S16BIT sd_width = w, sd_height = h;
316  DLA_Info *new_info = 0;
317 
319 
320  if (!bordered)
321  line_width = 0;
322 
323  if (mg_ctxt.osd_y.mlt != mg_ctxt.osd_y.div)
324  {
325  w = HD_X_SCALEUP(x + w);
326  w -= HD_X_SCALEUP(x);
327  h = HD_Y_SCALEUP(y + h);
328  h -= HD_Y_SCALEUP(y);
329  }
330  if (w > 0 && h > 0)
331  {
332  /* Allocate dynamic line-art info, and space for the canvas */
333  new_info = (DLA_Info *)OSD_MemAlloc( sizeof(DLA_Info));
334  if (new_info != NULL)
335  {
336  TRACE(TGRAPHICS, ("(%d,%d,%d,%d,lw=%d,b=%d,lcol=0x%x,fcol=0x%x)", x, y, w, h,
337  line_width, bordered, line_colour, fill_colour))
338  new_info->canvas_colour = fill_colour;
339  new_info->border_colour = line_colour;
340  new_info->border_width = line_width;
341  new_info->canvas.width = w;
342  new_info->canvas.height = h;
343  new_info->sd_width = sd_width;
344  new_info->sd_height = sd_height;
345  #ifdef INTELLIGENT_RENDER_WITH_SCREEN_COORDS
346  new_info->sd_x = x;
347  new_info->sd_y = y;
348  new_info->hd_x = HD_X_SCALEUP(x);
349  new_info->hd_y = HD_Y_SCALEUP(y);
350  #endif
352  {
353  #ifdef OSD_8_BIT
354  U8BIT col = OSD_FindNearestColourIndex(new_info->canvas_colour);
355 
356  new_info->canvas.buff_pitch = w;
357  new_info->canvas.hw_handle = NULL;
358  new_info->canvas.col_buff = OSD_MemAlloc( w * h );
359 
360  if (new_info->canvas.col_buff)
361  {
362  memset( new_info->canvas.col_buff, col, w * h );
363  }
364  if (OSD_IsColourOpaque( col ))
365  {
366  if (line_width == 0)
367  {
368  new_info->canvas.opaque = TRUE;
369  }
370  else
371  {
372  col = OSD_FindNearestColourIndex( line_colour );
373  new_info->canvas.opaque = OSD_IsColourOpaque(col);
374  }
375  }
376  else
377  {
378  new_info->canvas.opaque = FALSE;
379  }
380  #endif
381  }
383  {
384  #if defined(OSD_16_BIT)
385  HD2Color col = MakeHD2Color(fill_colour);
386  new_info->canvas.buff_pitch = w << 1;
387  new_info->canvas.hw_handle = STB_OSDMhegCreateSurface( w, h, TRUE, col );
388  OSD_DbgAddSurf( &new_info->canvas );
389  new_info->canvas.col_buff = NULL;
390  if ((col >> 12) == 0xf)
391  {
392  if (line_width == 0)
393  {
394  new_info->canvas.opaque = TRUE;
395  }
396  else
397  {
398  new_info->canvas.opaque = (line_colour >> 28) == 0xf;
399  }
400  }
401  else
402  {
403  new_info->canvas.opaque = FALSE;
404  }
405  #endif
406  }
407 
408  ELSE
409  {
410  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
411  OSDColor f_col;
412  new_info->canvas.buff_pitch = w << 2;
413  ConvertAlpha(fill_colour, f_col);
414  new_info->canvas.hw_handle = STB_OSDMhegCreateSurface( w, h, TRUE, f_col );
415  OSD_DbgAddSurf( &new_info->canvas );
416  new_info->canvas.col_buff = NULL;
417  if ((f_col >> 24) == MAX_ALPHA)
418  {
419  if (line_width == 0)
420  {
421  new_info->canvas.opaque = TRUE;
422  }
423  else
424  {
425  new_info->canvas.opaque = (line_colour >> 24) == 0xff;
426  }
427  }
428  else
429  {
430  new_info->canvas.opaque = FALSE;
431  }
432  #endif
433  }
434  new_info->polygon.point_list = NULL;
435  new_info->polygon.num_points = 0;
436  }
437  }
438 
440 
441  return new_info;
442 }
443 
453 {
454  DLA_Info *dla_info;
456 
457  assert( data != NULL );
458 
459  if (data != NULL)
460  {
461  dla_info = (DLA_Info *)data;
463  {
464  #ifdef OSD_8_BIT
465  OSD_MemFree( dla_info->canvas.col_buff );
466  #endif
467  }
468  ELSE
469  {
470  #if defined(OSD_16_BIT) || defined(OSD_31_BIT) || defined(OSD_32_BIT)
471  UNLOCK_BUFFER( dla_info )
473  OSD_DbgRemSurf( &dla_info->canvas );
474  #endif
475  }
476  OSD_MemFree( data );
477  }
478 
480 }
481 
499 void OSDdrawArc(void *data, int x, int y, int w, int h,
500  int start_angle, int arc_angle, int line_width,
501  OSDColor line_colour)
502 {
503  DLA_Info *dla_info;
504 
506  if (data != NULL)
507  {
508  dla_info = (DLA_Info *)data;
510  {
511  #ifdef OSD_8_BIT
512  U8BIT c_ndx = OSD_FindNearestColourIndex(line_colour);
513 
514  DLA_PC1_Arc((DLA1_Surface *)&dla_info->canvas, x, y, w, h,
515  start_angle, arc_angle, line_width, c_ndx );
516 
517  if (!OSD_IsColourOpaque(c_ndx))
518  {
519  dla_info->canvas.opaque = FALSE;
520  }
521  #endif /*OSD_8_BIT*/
522  }
524  {
525  #ifdef OSD_16_BIT
526  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
527 
528  LOCK_BUFFER( dla_info, 2 )
529 
530  DLA_PC2_Arc((DLA2_Surface *)&dla_info->canvas, x, y, w, h,
531  start_angle, arc_angle, line_width, MakeHD2Color(line_colour));
532 
533  if ((line_colour >> 28) != 0xf)
534  {
535  dla_info->canvas.opaque = FALSE;
536  }
537  #endif /*OSD_16_BIT*/
538  }
539 
540  ELSE
541  {
542  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
543  OSDColor l_col;
544  ConvertAlpha(line_colour, l_col);
545 
546  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
547 
548  LOCK_BUFFER( dla_info, 4 )
549 
550  DLA_PC4_Arc((DLA4_Surface *)&dla_info->canvas, x, y, w, h,
551  start_angle, arc_angle, line_width, l_col );
552 
553  if ((l_col >> 24) != MAX_ALPHA)
554  {
555  dla_info->canvas.opaque = FALSE;
556  }
557  #endif /*OSD_32_BIT*/
558  }
559  }
561 }
562 
579 void OSDdrawEllipse(void *data, int x, int y, int w, int h,
580  int line_width, OSDColor line_colour, OSDColor fill_colour)
581 {
582  DLA_Info *dla_info;
583 
585  if (data != NULL)
586  {
587  dla_info = (DLA_Info *)data;
589  {
590  #ifdef OSD_8_BIT
591  U8BIT f_ndx = OSD_FindNearestColourIndex(fill_colour);
592  U8BIT l_ndx = OSD_FindNearestColourIndex(line_colour);
593 
594  DLA_PC1_Ellipse((DLA1_Surface *)&dla_info->canvas, x, y, w, h,
595  line_width, f_ndx, l_ndx );
596 
597  if (!OSD_IsColourOpaque(f_ndx) || !OSD_IsColourOpaque(l_ndx))
598  {
599  dla_info->canvas.opaque = FALSE;
600  }
601  #endif /*OSD_8_BIT*/
602  }
604  {
605  #ifdef OSD_16_BIT
606  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
607 
608  LOCK_BUFFER( dla_info, 2 )
609 
610  DLA_PC2_Ellipse((DLA2_Surface *)&dla_info->canvas, x, y, w, h,
611  line_width, MakeHD2Color(fill_colour), MakeHD2Color(line_colour));
612 
613  if (((fill_colour >> 28) != 0xf) || ((line_colour >> 28) != 0xf))
614  {
615  dla_info->canvas.opaque = FALSE;
616  }
617  #endif /*OSD_16_BIT*/
618  }
619 
620  ELSE
621  {
622  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
623  OSDColor f_col, l_col;
624  ConvertAlpha(fill_colour, f_col);
625  ConvertAlpha(line_colour, l_col);
626 
627  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
628 
629  LOCK_BUFFER( dla_info, 4 )
630 
631  DLA_PC4_Ellipse((DLA4_Surface *)&dla_info->canvas, x, y, w, h,
632  line_width, f_col, l_col );
633 
634  if (((f_col >> 24) != MAX_ALPHA) || ((l_col >> 24) != MAX_ALPHA))
635  {
636  dla_info->canvas.opaque = FALSE;
637  }
638  #endif /*OSD_32_BIT*/
639  }
640  }
642 }
643 
662 void OSDdrawSector(void *data, int x, int y, int w, int h,
663  int start_angle, int arc_angle, int line_width,
664  OSDColor line_colour, OSDColor fill_colour)
665 {
666  DLA_Info *dla_info;
667 
669  if (data != NULL)
670  {
671  dla_info = (DLA_Info *)data;
673  {
674  #ifdef OSD_8_BIT
675  U8BIT f_ndx = OSD_FindNearestColourIndex(fill_colour);
676  U8BIT l_ndx = OSD_FindNearestColourIndex(line_colour);
677 
678  DLA_PC1_Sector((DLA1_Surface *)&dla_info->canvas, x, y, w, h,
679  start_angle, arc_angle, line_width, f_ndx, l_ndx );
680 
681  if (!OSD_IsColourOpaque(f_ndx) || !OSD_IsColourOpaque(l_ndx))
682  {
683  dla_info->canvas.opaque = FALSE;
684  }
685  #endif /*OSD_8_BIT*/
686  }
688  {
689  #ifdef OSD_16_BIT
690  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
691 
692  LOCK_BUFFER( dla_info, 2 )
693 
694  DLA_PC2_Sector((DLA2_Surface *)&dla_info->canvas, x, y + 1, w, h,
695  start_angle, arc_angle, line_width,
696  MakeHD2Color(fill_colour), MakeHD2Color(line_colour));
697 
698  if (((fill_colour >> 28) != 0xf) || ((line_colour >> 28) != 0xf))
699  {
700  dla_info->canvas.opaque = FALSE;
701  }
702  #endif /*OSD_16_BIT*/
703  }
704 
705  ELSE
706  {
707  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
708  OSDColor f_col, l_col;
709  ConvertAlpha(fill_colour, f_col);
710  ConvertAlpha(line_colour, l_col);
711 
712  HD_SCALEUP_RECT(dla_info, x, y, w, h, line_width);
713 
714  LOCK_BUFFER( dla_info, 4 )
715 
716  DLA_PC4_Sector((DLA4_Surface *)&dla_info->canvas, x, y + 1, w, h,
717  start_angle, arc_angle, line_width, f_col, l_col );
718 
719  if (((f_col >> 24) != MAX_ALPHA) || ((l_col >> 24) != MAX_ALPHA))
720  {
721  dla_info->canvas.opaque = FALSE;
722  }
723  #endif /*OSD_32_BIT*/
724  }
725  }
727 }
728 
741 void OSDdrawDrawLine(void *data, int x1, int y1, int x2, int y2,
742  int line_width, OSDColor line_colour)
743 {
744  DLA_Info *dla_info;
745 
747  if (data != NULL)
748  {
749  dla_info = (DLA_Info *)data;
750  HD_SCALEUP_REGN(dla_info, x1, y1, x2, y2);
751  line_width = HD_W_SCALEUP(line_width);
753  {
754  #ifdef OSD_8_BIT
755  U8BIT l_ndx = OSD_FindNearestColourIndex(line_colour);
756 
757  DLA_PC1_Line((DLA1_Surface *)&dla_info->canvas, x1, y1, x2, y2,
758  line_width, l_ndx );
759 
760  if (!OSD_IsColourOpaque(l_ndx))
761  {
762  dla_info->canvas.opaque = FALSE;
763  }
764  #endif /*OSD_8_BIT*/
765  }
767  {
768  #ifdef OSD_16_BIT
769  LOCK_BUFFER( dla_info, 2 )
770 
771  DLA_PC2_Line((DLA2_Surface *)&dla_info->canvas, x1, y1, x2, y2,
772  line_width, MakeHD2Color(line_colour));
773 
774  if ((line_colour >> 28) != 0xf)
775  {
776  dla_info->canvas.opaque = FALSE;
777  }
778  #endif /*OSD_16_BIT*/
779  }
780 
781  ELSE
782  {
783  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
784  OSDColor l_col;
785  ConvertAlpha(line_colour, l_col);
786 
787  LOCK_BUFFER( dla_info, 4 )
788 
789  DLA_PC4_Line((DLA4_Surface *)&dla_info->canvas, x1, y1, x2, y2,
790  line_width, l_col );
791 
792  if ((l_col >> 24) != MAX_ALPHA)
793  {
794  dla_info->canvas.opaque = FALSE;
795  }
796  #endif /*OSD_32_BIT*/
797  }
798  }
800 }
801 
809 {
810  DLA_Info *dla_info;
811 
813 
814  if (data != NULL)
815  {
816  dla_info = (DLA_Info *)data;
817  dla_info->polygon.point_list = NULL;
818  dla_info->polygon.num_points = 0;
819  }
820 
822 }
823 
832 void OSDdrawPolygonAdd(void *data, int x, int y)
833 {
834  DLA_Info *dla_info;
835  S_POINT_LIST *pl;
836 
838 
839  if (data != NULL)
840  {
841  dla_info = (DLA_Info *)data;
842  pl = (S_POINT_LIST *)OSD_MemAlloc( sizeof(S_POINT_LIST));
843  if (pl != NULL)
844  {
845  #ifdef INTELLIGENT_RENDER_WITH_SCREEN_COORDS
846  pl->point.x = HD_X_SCALEUP(dla_info->sd_x + x) - dla_info->hd_x;
847  pl->point.y = HD_Y_SCALEUP(dla_info->sd_y + y) - dla_info->hd_y;
848  #else
849  pl->point.x = HD_X_SCALEUP(x);
850  pl->point.y = HD_Y_SCALEUP(y);
851  #endif
852  pl->next = dla_info->polygon.point_list;
853  dla_info->polygon.point_list = pl;
854  dla_info->polygon.num_points++;
855  }
856  }
857 
859 }
860 
871 void OSDdrawPolygon(void *data, int line_width, OSDColor line_colour,
872  OSDColor fill_colour, int filled)
873 {
874  DLA_Info *dla_info;
875 
877 
878  if (data != NULL)
879  {
880  dla_info = (DLA_Info *)data;
882  {
883  #ifdef OSD_8_BIT
884  U8BIT f_ndx = OSD_FindNearestColourIndex(fill_colour);
885  U8BIT l_ndx = OSD_FindNearestColourIndex(line_colour);
886 
887  if (filled)
888  {
889  DLA_PC1_Polygon((DLA1_Surface *)&dla_info->canvas, dla_info->polygon,
890  line_width, f_ndx, l_ndx );
891  }
892  else
893  {
894  DLA_PC1_Polyline((DLA1_Surface *)&dla_info->canvas, dla_info->polygon,
895  line_width, l_ndx );
896  }
897 
898  if (!OSD_IsColourOpaque(f_ndx) || !OSD_IsColourOpaque(l_ndx))
899  {
900  dla_info->canvas.opaque = FALSE;
901  }
902  #endif /*OSD_8_BIT*/
903  }
905  {
906  #ifdef OSD_16_BIT
907 
908  line_width = HD_W_SCALEUP(line_width);
909 
910  LOCK_BUFFER( dla_info, 2 )
911 
912  if (filled)
913  {
914  DLA_PC2_Polygon((DLA2_Surface *)&dla_info->canvas, dla_info->polygon,
915  line_width, MakeHD2Color(fill_colour), MakeHD2Color(line_colour));
916  }
917  else
918  {
919  DLA_PC2_Polyline((DLA2_Surface *)&dla_info->canvas, dla_info->polygon,
920  line_width, MakeHD2Color(line_colour));
921  }
922  if (((fill_colour >> 28) != 0xf) || ((line_colour >> 28) != 0xf))
923  {
924  dla_info->canvas.opaque = FALSE;
925  }
926  #endif /*OSD_16_BIT*/
927  }
928 
929  ELSE
930  {
931  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
932  OSDColor f_col, l_col;
933  ConvertAlpha(fill_colour, f_col);
934  ConvertAlpha(line_colour, l_col);
935 
936  line_width = HD_W_SCALEUP(line_width);
937 
938  LOCK_BUFFER( dla_info, 4 )
939 
940  if (filled)
941  {
942  DLA_PC4_Polygon((DLA4_Surface *)&dla_info->canvas, dla_info->polygon,
943  line_width, f_col, l_col );
944  }
945  else
946  {
947  DLA_PC4_Polyline((DLA4_Surface *)&dla_info->canvas, dla_info->polygon,
948  line_width, l_col );
949  }
950  if (((f_col >> 24) != MAX_ALPHA) || ((l_col >> 24) != MAX_ALPHA))
951  {
952  dla_info->canvas.opaque = FALSE;
953  }
954  #endif /*OSD_32_BIT*/
955  }
956  }
957 
959 }
960 
974 void OSDdrawRectangle(void *data, int x1, int y1, int x2, int y2,
975  int line_width, OSDColor line_colour, OSDColor fill_colour)
976 {
977  DLA_Info *dla_info;
978 
980  if (data != NULL)
981  {
982  dla_info = (DLA_Info *)data;
983  TRACE(TGRAPHICS, ("sd(l=%d,t=%d,r=%d,b=%d)", x1, y1, x2, y2))
985  {
986  #ifdef OSD_8_BIT
987  U8BIT f_ndx = OSD_FindNearestColourIndex(fill_colour);
988  U8BIT l_ndx = OSD_FindNearestColourIndex(line_colour);
989 
990  DLA_PC1_Rectangle((DLA1_Surface *)&dla_info->canvas, x1, y1, x2, y2,
991  line_width, line_width, f_ndx, l_ndx );
992 
993  if (!OSD_IsColourOpaque(f_ndx) || !OSD_IsColourOpaque(l_ndx))
994  {
995  dla_info->canvas.opaque = FALSE;
996  }
997  #endif /*OSD_8_BIT*/
998  }
1000  {
1001  #ifdef OSD_16_BIT
1002  HD_SCALEUP_REGN(dla_info, x1, y1, x2, y2);
1003 
1004  LOCK_BUFFER( dla_info, 2 )
1005 
1006  TRACE(TGRAPHICS, ("hd(l=%d,t=%d,r=%d,b=%d)", x1, y1, x2, y2))
1007  DLA_PC2_Rectangle((DLA2_Surface *)&dla_info->canvas, x1, y1, x2, y2,
1008  HD_X_SCALEUP(line_width), HD_Y_SCALEUP(line_width),
1009  MakeHD2Color(fill_colour), MakeHD2Color(line_colour));
1010 
1011  if (((fill_colour >> 28) != 0xf) || ((line_colour >> 28) != 0xf))
1012  {
1013  dla_info->canvas.opaque = FALSE;
1014  }
1015  #endif /*OSD_16_BIT*/
1016  }
1017 
1018  ELSE
1019  {
1020  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
1021  OSDColor f_col, l_col;
1022  ConvertAlpha(fill_colour, f_col);
1023  ConvertAlpha(line_colour, l_col);
1024 
1025  HD_SCALEUP_REGN(dla_info, x1, y1, x2, y2);
1026 
1027  LOCK_BUFFER( dla_info, 4 )
1028 
1029  TRACE(TGRAPHICS, ("hd(l=%d,t=%d,r=%d,b=%d)", x1, y1, x2, y2))
1030  DLA_PC4_Rectangle((DLA4_Surface *)&dla_info->canvas, x1, y1, x2, y2,
1031  HD_W_SCALEUP(line_width), HD_W_SCALEUP(line_width),
1032  f_col, l_col );
1033 
1034  if (((f_col >> 24) != MAX_ALPHA) || ((l_col >> 24) != MAX_ALPHA))
1035  {
1036  dla_info->canvas.opaque = FALSE;
1037  }
1038  #endif /*OSD_32_BIT*/
1039  }
1040  }
1042 }
1043 
1050 void MG_OSDdisplayDynamicLineart(void *data, S_REGION *overlap, int x, int y )
1051 {
1052  DLA_Info *dla_info;
1053  U16BIT x1_bw, y1_bw, x2_bw, y2_bw;
1054 
1055  FUNCTION_START(OSDdisplayDynamicLineart);
1056 
1057  if (data != NULL)
1058  {
1059  dla_info = (DLA_Info *)data;
1060  if (mg_ctxt.osd_y.mlt == mg_ctxt.osd_y.div)
1061  {
1062  x1_bw = y1_bw = x2_bw = y2_bw = dla_info->border_width;
1063  }
1064  else
1065  {
1066  #ifdef INTELLIGENT_RENDER_WITH_SCREEN_COORDS
1067  x1_bw = HD_X_SCALEUP(dla_info->border_width);
1068  y1_bw = HD_Y_SCALEUP(dla_info->border_width);
1069  x2_bw = HD_X_SCALEUP(dla_info->border_width);
1070  y2_bw = HD_Y_SCALEUP(dla_info->border_width);
1071  #else
1072  #error Be intelligent
1073  x1_bw = HD_W_SCALEUP(dla_info->border_width);
1074  y1_bw = HD_W_SCALEUP(dla_info->border_width);
1075  x2_bw = dla_info->canvas.width - HD_W_SCALEUP(dla_info->sd_width - dla_info->border_width);
1076  y2_bw = dla_info->canvas.height - HD_W_SCALEUP(dla_info->sd_height - dla_info->border_width);
1077  #endif
1078  }
1079  if (dla_info->border_width != 0)
1080  {
1081  TRACE(TGRAPHICS, ("bord_width=%d", dla_info->border_width))
1082  /* Draw border (must be done last) */
1084  {
1085  #ifdef OSD_8_BIT
1086  DLA_PC1_Border((DLA1_Surface *)&dla_info->canvas, x1_bw, y1_bw, x2_bw, y2_bw,
1087  OSD_FindNearestColourIndex(dla_info->border_colour));
1088 
1089  #endif /*OSD_8_BIT*/
1090  }
1092  {
1093  #ifdef OSD_16_BIT
1094  LOCK_BUFFER( dla_info, 2 )
1095 
1096  DLA_PC2_Border((DLA2_Surface *)&dla_info->canvas, x1_bw, y1_bw, x2_bw, y2_bw,
1097  MakeHD2Color(dla_info->border_colour));
1098  #endif /*OSD_16_BIT*/
1099  }
1100 
1101  ELSE
1102  {
1103  #if defined(OSD_31_BIT) || defined(OSD_32_BIT)
1104  OSDColor b_col;
1105  ConvertAlpha(dla_info->border_colour, b_col);
1106 
1107  LOCK_BUFFER( dla_info, 4 )
1108 
1109  DLA_PC4_Border((DLA4_Surface *)&dla_info->canvas, x1_bw, y1_bw, x2_bw, y2_bw, b_col );
1110 
1111  #endif /*OSD_32_BIT*/
1112  }
1113  }
1114  /* Write canvas to OSD buffer */
1116  {
1117  }
1118  ELSE
1119  {
1120  #if defined(OSD_16_BIT) || defined(OSD_31_BIT) || defined(OSD_32_BIT)
1121  UNLOCK_BUFFER( dla_info )
1122  #endif
1123  }
1124  MG_DisplayImage( &dla_info->canvas, overlap, HD_X_SCALEUP(x), HD_Y_SCALEUP(y));
1125  }
1126 
1127  FUNCTION_FINISH(OSDdisplayDynamicLineart);
1128 }
1129 
OSD utility functions.
#define IF_COL_DEPTH(cd)
Definition: mg_ctxt.h:65
S_POINT point
Definition: dla_inl.h:42
#define FUNCTION_FINISH(name)
Definition: glue_debug.h:143
#define OSD_MemAlloc
Definition: glue_memory.h:96
S_POLYGON polygon
Definition: mg_dla.c:161
void * col_buff
Definition: mg_osd.h:41
#define HD_W_SCALEUP(w)
Definition: mg_ctxt.h:102
U16BIT mlt
Definition: mg_ctxt.h:73
const char * data
Definition: mh5gate.c:56
#define HD_Y_SCALEUP(y)
Definition: mg_ctxt.h:106
void OSDdrawEllipse(void *data, int x, int y, int w, int h, int line_width, OSDColor line_colour, OSDColor fill_colour)
Add a draw ellipse action to the action list.
Definition: mg_dla.c:579
void MG_OSDdisplayDynamicLineart(void *data, S_REGION *overlap, int x, int y)
Display dynamic lineart.
Definition: mg_dla.c:1050
S16BIT x
Definition: dla_inl.h:35
Debug tracing.
#define MakeHD2Color(osdcol)
Definition: osd_utils.h:56
U32BIT OSDColor
Definition: osdtypes.h:41
#define COLOUR_FORMAT_ARGB4444
Definition: mheg5_control.h:80
#define HD_SCALEUP_RECT(dli, x, y, w, h, lw)
Definition: mg_dla.c:87
S16BIT hd_y
Definition: mg_dla.c:168
S_RATIO osd_y
Definition: mg_ctxt.h:86
OSDColor canvas_colour
Definition: mg_dla.c:159
OSDColor border_colour
Definition: mg_dla.c:160
void * STB_OSDMhegCreateSurface(U16BIT width, U16BIT height, BOOLEAN init, U32BIT colour)
Creates a hardware surface on which MHEG5 engine will draw an individual MHEG object. At its basic the function can just allocate the buffer to be returned by STB_OSDMhegLockBuffer(). It&#39;s size being: (width * height * bytes_per_pixel) Also, when &#39;init&#39; is TRUE, function initialises surface buffer to the specified colour. For pixel colour format of less than four bytes, use least significant bits of &#39;colour&#39;.
S16BIT border_width
Definition: mg_dla.c:162
struct point_list * next
Definition: dla_inl.h:41
S16BIT y
Definition: dla_inl.h:36
MHEG-5 Graphics: Dynamic Line-Art utility functions.
int16_t S16BIT
Definition: techtype.h:85
S16BIT sd_x
Definition: mg_dla.c:165
U32BIT buff_pitch
Definition: mg_osd.h:43
uint8_t U8BIT
Definition: techtype.h:82
void * hw_handle
Definition: mg_osd.h:42
S_POINT_LIST * point_list
Definition: dla_inl.h:47
Memory functions.
void OSDdrawDrawLine(void *data, int x1, int y1, int x2, int y2, int line_width, OSDColor line_colour)
Add a line draw action to the list.
Definition: mg_dla.c:741
S16BIT hd_x
Definition: mg_dla.c:167
#define OSD_DbgRemSurf(s)
Definition: mg_osd.h:91
void STB_OSDMhegDestroySurface(void *surface)
This function destroys surface and all data allocated by STB_OSDMhegCreateSurface() ...
S_MGContext mg_ctxt
Definition: mg_osd.c:144
void MG_DisplayImage(S_SURFACE *data, S_REGION *overlap, S32BIT x, S32BIT y)
Copy the image to the screen buffer.
Definition: mg_osd.c:1266
U16BIT height
Definition: mg_osd.h:40
Interface to OSD.
U16BIT num_points
Definition: dla_inl.h:48
#define ELSE
Definition: mg_ctxt.h:66
#define OSD_DbgAddSurf(s)
Definition: mg_osd.h:90
#define UNLOCK_BUFFER(di)
Definition: mg_dla.c:144
U8BIT opaque
Definition: mg_osd.h:44
void OSDclearDynamicLineart(void *data)
On screen display - clear dynamic line art.
Definition: mg_dla.c:183
uint16_t U16BIT
Definition: techtype.h:84
void OSDdrawPolygon(void *data, int line_width, OSDColor line_colour, OSDColor fill_colour, int filled)
Add a draw polygon instruction to the action list.
Definition: mg_dla.c:871
U16BIT width
Definition: mg_osd.h:39
void OSDdrawPolygonAdd(void *data, int x, int y)
Add co-ordinates that describe a polygon to draw to the action list.
Definition: mg_dla.c:832
struct _DLA_Info DLA_Info
#define COLOUR_FORMAT_PALETTE
Definition: mheg5_control.h:79
#define FALSE
Definition: techtype.h:68
#define HD_SCALEUP_REGN(dli, l, t, r, b)
Definition: mg_dla.c:103
#define HD_X_SCALEUP(x)
Definition: mg_ctxt.h:104
#define LOCK_BUFFER(di, c_sz)
Definition: mg_dla.c:139
U16BIT div
Definition: mg_ctxt.h:74
void OSDdrawSector(void *data, int x, int y, int w, int h, int start_angle, int arc_angle, int line_width, OSDColor line_colour, OSDColor fill_colour)
Add a draw sector action to the action list.
Definition: mg_dla.c:662
#define TRUE
Definition: techtype.h:69
S16BIT sd_y
Definition: mg_dla.c:166
void OSDfreeDynamicLineart(void *data)
On screen display - free resources dla.
Definition: mg_dla.c:452
void OSDdrawPolygonStart(void *data)
Initialise a new draw polygon to add to the action list.
Definition: mg_dla.c:808
void * OSDinitDynamicLineart(int x, int y, int w, int h, int line_width, int bordered, OSDColor line_colour, OSDColor fill_colour)
On screen display - initialise dynamic line art.
Definition: mg_dla.c:311
U16BIT HD2Color
Definition: osd_utils.h:70
void OSDdrawArc(void *data, int x, int y, int w, int h, int start_angle, int arc_angle, int line_width, OSDColor line_colour)
Add a draw arc action to the action list.
Definition: mg_dla.c:499
#define FUNCTION_START(name)
Definition: glue_debug.h:142
#define OSD_MemFree
Definition: glue_memory.h:97
uint32_t U32BIT
Definition: techtype.h:86
S16BIT sd_width
Definition: mg_dla.c:163
void OSDdrawRectangle(void *data, int x1, int y1, int x2, int y2, int line_width, OSDColor line_colour, OSDColor fill_colour)
Add a draw rectangle action to the action list.
Definition: mg_dla.c:974
#define TRACE(t, x)
Definition: glue_debug.h:118
S_SURFACE canvas
Definition: mg_dla.c:170
S16BIT sd_height
Definition: mg_dla.c:163