CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_draw.c-Dateireferenz
#include "platform.h"
#include "touchscreen.h"
#include "conf.h"
#include "font.h"
#include "lang.h"
#include "gui_draw.h"
#include "../lib/font/font_8x16_uni_packed.h"
+ Include-Abhängigkeitsdiagramm für gui_draw.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  FontData
 

Makrodefinitionen

#define GET_FONT_COMPRESSION_MODE   1
 
#define GUARD_VAL   COLOR_GREY_DK
 
#define swap(v1, v2)   {v1^=v2; v2^=v1; v1^=v2;}
 

Funktionen

static void draw_pixel_std (unsigned int offset, color cl)
 
unsigned int color_to_rawpx (__attribute__((unused)) color cl, __attribute__((unused)) unsigned int *op)
 
void draw_dblpixel_raw (__attribute__((unused)) unsigned int offset, __attribute__((unused)) unsigned int px, __attribute__((unused)) unsigned int op)
 
void erase_zebra ()
 
void draw_pixel_proc_rotated (unsigned int offset, color cl)
 
void draw_set_draw_proc (void(*pixel_proc)(unsigned int offset, color cl))
 
void update_draw_proc ()
 
void draw_set_guard ()
 
int draw_test_guard ()
 
void draw_init ()
 
void draw_suspend (int ms)
 
int draw_is_suspended (void)
 
void draw_restore ()
 
void draw_pixel (coord x, coord y, color cl)
 
void draw_or_erase_edge_pixel (coord px, coord py, color cl, int is_draw)
 
color draw_get_pixel (coord x, coord y)
 
void draw_line (coord x1, coord y1, coord x2, coord y2, color cl)
 
void draw_hline (coord x, coord y, int len, color cl)
 
void draw_vline (coord x, coord y, int len, color cl)
 
void draw_rectangle (coord x1, coord y1, coord x2, coord y2, twoColors cl, int flags)
 
static unsigned char * get_cdata (unsigned int *offset, unsigned int *size, const char ch)
 
void draw_char (coord x, coord y, const char ch, twoColors cl)
 
void draw_char_scaled (coord x, coord y, const char ch, twoColors cl, int xsize, int ysize)
 
int draw_string_clipped (coord x, coord y, const char *s, twoColors cl, int max_width)
 
int draw_string (coord x, coord y, const char *s, twoColors cl)
 
int draw_string_justified (coord x, coord y, const char *s, twoColors cl, int xo, int max_width, int justification)
 
int text_dimensions (const char *s, int width, int max_chars, int *max_lines)
 
int draw_text_justified (coord x, coord y, const char *s, twoColors cl, int max_chars, int max_lines, int justification)
 
void draw_string_scaled (coord x, coord y, const char *s, twoColors cl, int xsize, int ysize)
 
void draw_osd_string (OSD_pos pos, int xo, int yo, char *s, twoColors c, OSD_scale scale)
 
void draw_txt_string (coord col, coord row, const char *str, twoColors cl)
 
void draw_ellipse (coord CX, coord CY, unsigned int XRadius, unsigned int YRadius, color cl, int flags)
 
void draw_button (int x, int y, int w, int str_id, int active)
 
void draw_icon_cmds (coord x, coord y, icon_cmd *cmds)
 
void set_palette ()
 
color get_script_color (int cl)
 
color chdkColorToCanonColor (chdkColor col)
 
twoColors user_color (confColor cc)
 

Variablen

static char * frame_buffer [2]
 
int draw_restore_suspend_tick
 
void(* draw_pixel_proc )(unsigned int offset, color cl)
 
void(* draw_pixel_proc_norm )(unsigned int offset, color cl)
 
unsigned int rotate_base
 
unsigned char ply_colors []
 
unsigned char rec_colors []
 
unsigned char * chdk_colors = ply_colors
 

Makro-Dokumentation

#define GET_FONT_COMPRESSION_MODE   1

Definiert in Zeile 8 der Datei gui_draw.c.

#define GUARD_VAL   COLOR_GREY_DK

Definiert in Zeile 471 der Datei gui_draw.c.

#define swap (   v1,
  v2 
)    {v1^=v2; v2^=v1; v1^=v2;}

Definiert in Zeile 697 der Datei gui_draw.c.

Dokumentation der Funktionen

color chdkColorToCanonColor ( chdkColor  col)

Definiert in Zeile 1672 der Datei gui_draw.c.

1673 {
1674  if (col.type)
1675  return chdk_colors[col.col];
1676  return col.col;
1677 }
unsigned int color_to_rawpx ( __attribute__((unused)) color  cl,
__attribute__((unused)) unsigned int *  op 
)

Definiert in Zeile 207 der Datei gui_draw.c.

207 { return 0; }
void draw_button ( int  x,
int  y,
int  w,
int  str_id,
int  active 
)

Definiert in Zeile 1554 der Datei gui_draw.c.

1555 {
1557  w = w * FONT_WIDTH;
1558 
1559  draw_rectangle(x-2, y-2, x+w+2, y+FONT_HEIGHT+2, cl, RECT_BORDER1|DRAW_FILLED|RECT_SHADOW1); // main box
1560  draw_string(x+((w-(strlen(lang_str(str_id))*FONT_WIDTH))>>1), y, lang_str(str_id), cl);
1561 }
void draw_char ( coord  x,
coord  y,
const char  ch,
twoColors  cl 
)

Definiert in Zeile 890 der Datei gui_draw.c.

891 {
892  unsigned i, ii;
893 
894  unsigned int offset, size;
895  unsigned char *sym = get_cdata(&offset, &size, ch);
896 
897  // First draw blank lines at top
898  for (i=0; i<offset; i++)
900 
901  // Now draw character data
902 
903  unsigned j;
904  for (j=i; i<size;)
905  {
906  unsigned int dsym;
907  int rep;
908 #ifdef BUILTIN_FONT_RLE_COMPRESSED
909  dsym = fontdata_lookup[sym[j] & 0x7f];
910  rep = sym[j] & 0x80;
911 #else
912  dsym = sym[j];
913  rep = 0;
914 #endif
915  for (ii=0; ii<FONT_WIDTH; ii++)
916  {
917  draw_pixel(x+ii, y+i, (dsym & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl));
918  }
919  if (rep)
920  {
921  i++;
922  for (ii=0; ii<FONT_WIDTH; ii++)
923  {
924  draw_pixel(x+ii, y+i, (dsym & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl));
925  }
926  }
927  i++;
928  j++;
929  }
930 
931  // Last draw blank lines at bottom
932  for (; i<FONT_HEIGHT; i++)
933  draw_hline(x, y+i, FONT_WIDTH, BG_COLOR(cl));
934 }
void draw_char_scaled ( coord  x,
coord  y,
const char  ch,
twoColors  cl,
int  xsize,
int  ysize 
)

Definiert in Zeile 1093 der Datei gui_draw.c.

1094 {
1095  unsigned i, ii;
1096 
1099 
1100  unsigned int offset, size;
1101  unsigned char *sym = get_cdata(&offset, &size, ch);
1102 
1103  // First draw blank lines at top
1104  if (offset > 0)
1105  draw_rectangle(x,y,x+FONT_WIDTH*xsize-1,y+offset*ysize+ysize-1,clb,RECT_BORDER0|DRAW_FILLED);
1106 
1107  // Now draw character data
1108  unsigned j;
1109  for (j=i=offset; i<size;)
1110  {
1111  unsigned int dsym;
1112  int rep;
1113  unsigned int last;
1114  int len;
1115 #ifdef BUILTIN_FONT_RLE_COMPRESSED
1116  dsym = fontdata_lookup[sym[j] & 0x7f];
1117  rep = sym[j] & 0x80;
1118 #else
1119  dsym = sym[j];
1120  rep = 0;
1121 #endif
1122  while (rep >= 0)
1123  {
1124  last = dsym & 0x80;
1125  len = 1;
1126  for (ii=1; ii<FONT_WIDTH; ii++)
1127  {
1128  if (((dsym << ii) & 0x80) != last)
1129  {
1130  draw_rectangle(x+(ii-len)*xsize,y+i*ysize,x+ii*xsize-1,y+i*ysize+ysize-1,(last)?clf:clb,RECT_BORDER0|DRAW_FILLED);
1131  last = (dsym << ii) & 0x80;
1132  len = 1;
1133  }
1134  else
1135  {
1136  len++;
1137  }
1138  }
1139  draw_rectangle(x+(ii-len)*xsize,y+i*ysize,x+ii*xsize-1,y+i*ysize+ysize-1,(last)?clf:clb,RECT_BORDER0|DRAW_FILLED);
1140  i++;
1141  rep -= 0x80;
1142  }
1143  j++;
1144  }
1145 
1146  // Last draw blank lines at bottom
1147  if (i < FONT_HEIGHT)
1148  draw_rectangle(x,y+i*ysize,x+FONT_WIDTH*xsize-1,y+FONT_HEIGHT*ysize+ysize-1,clb,RECT_BORDER0|DRAW_FILLED);
1149 }
void draw_dblpixel_raw ( __attribute__((unused)) unsigned int  offset,
__attribute__((unused)) unsigned int  px,
__attribute__((unused)) unsigned int  op 
)

Definiert in Zeile 208 der Datei gui_draw.c.

208 {}
void draw_ellipse ( coord  CX,
coord  CY,
unsigned int  XRadius,
unsigned int  YRadius,
color  cl,
int  flags 
)

Definiert in Zeile 1468 der Datei gui_draw.c.

1469 {
1470  // Bresenham fast ellipse algorithm - http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
1471  int X, Y;
1472  int XChange, YChange;
1473  int EllipseError;
1474  int TwoASquare, TwoBSquare;
1475  int StoppingX, StoppingY;
1476  TwoASquare = 2*XRadius*XRadius;
1477  TwoBSquare = 2*YRadius*YRadius;
1478  X = XRadius;
1479  Y = 0;
1480  XChange = YRadius*YRadius*(1-2*XRadius);
1481  YChange = XRadius*XRadius;
1482  EllipseError = 0;
1483  StoppingX = TwoBSquare*XRadius;
1484  StoppingY = 0;
1485  while ( StoppingX >= StoppingY )
1486  {
1487  if (flags & DRAW_FILLED)
1488  {
1489  draw_hline(CX-X,CY-Y,X*2+1,cl);
1490  draw_hline(CX-X,CY+Y,X*2+1,cl);
1491  }
1492  else
1493  {
1494  draw_pixel(CX-X,CY-Y,cl);
1495  draw_pixel(CX-X,CY+Y,cl);
1496  draw_pixel(CX+X,CY-Y,cl);
1497  draw_pixel(CX+X,CY+Y,cl);
1498  }
1499  Y++;
1500  StoppingY += TwoASquare;
1501  EllipseError += YChange;
1502  YChange += TwoASquare;
1503  if ((2*EllipseError + XChange) > 0 )
1504  {
1505  X--;
1506  StoppingX -= TwoBSquare;
1507  EllipseError += XChange;
1508  XChange += TwoBSquare;
1509  }
1510  }
1511  X = 0;
1512  Y = YRadius;
1513  XChange = YRadius*YRadius;
1514  YChange = XRadius*XRadius*(1-2*YRadius);
1515  EllipseError = 0;
1516  StoppingX = 0;
1517  StoppingY = TwoASquare*YRadius;
1518  int lastY = Y + 1;
1519  while ( StoppingX <= StoppingY )
1520  {
1521  if (flags & DRAW_FILLED)
1522  {
1523  // Only draw lines if Y has changed
1524  if (lastY != Y)
1525  {
1526  draw_hline(CX-X,CY-Y,X*2+1,cl);
1527  draw_hline(CX-X,CY+Y,X*2+1,cl);
1528  lastY = Y;
1529  }
1530  }
1531  else
1532  {
1533  draw_pixel(CX-X,CY-Y,cl);
1534  draw_pixel(CX-X,CY+Y,cl);
1535  draw_pixel(CX+X,CY-Y,cl);
1536  draw_pixel(CX+X,CY+Y,cl);
1537  }
1538  X++;
1539  StoppingX += TwoBSquare;
1540  EllipseError += XChange;
1541  XChange += TwoBSquare;
1542  if ((2*EllipseError + YChange) > 0 )
1543  {
1544  Y--;
1545  StoppingY -= TwoASquare;
1546  EllipseError += YChange;
1547  YChange += TwoASquare;
1548  }
1549  }
1550 }
color draw_get_pixel ( coord  x,
coord  y 
)

Definiert in Zeile 669 der Datei gui_draw.c.

670 {
671 #ifndef THUMB_FW
672  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return 0;
673  if (conf.rotate_osd)
674  {
675 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
677 #else
679 #endif
680  }
681  else
682  {
683 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
685 #else
687 #endif
688  }
689 #else
690  // DIGIC 6 not supported
691  (void)x; (void)y;
692  return 0;
693 #endif
694 }
void draw_hline ( coord  x,
coord  y,
int  len,
color  cl 
)

Definiert in Zeile 776 der Datei gui_draw.c.

777 {
778  if ((y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return;
779  if (x < 0) { len += x; x = 0; }
780  if ((x + len) > camera_screen.width) len = camera_screen.width - x;
781 #ifndef CAM_HAS_DISPLAY_REFRESH_FLAG
782  if (conf.rotate_osd)
783  {
784  if ((y == camera_screen.height-1) && ((x+len) >= camera_screen.width-1)) { x--; len--; } // Skip guard pixel
785  }
786  else
787  {
788  if ((y == 0) && (x == 0)) { x++; len--; } // Skip guard pixel
789  }
790 #endif
791  register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x);
792  len = ASPECT_XCORRECTION(len); // Scale the line length if needed
793  for (; len>0; len--, offset++)
794  draw_pixel_proc(offset, cl);
795 }
void draw_icon_cmds ( coord  x,
coord  y,
icon_cmd cmds 
)

Definiert in Zeile 1566 der Datei gui_draw.c.

1567 {
1568  int x1, y1, x2, y2;
1569 #ifdef THUMB_FW
1570  int thickness = RECT_BORDER2;
1571 #else
1572  int thickness = RECT_BORDER1;
1573 #endif
1574  while (1)
1575  {
1576 #ifdef THUMB_FW
1577  x1 = cmds->x1<<1;
1578  y1 = cmds->y1<<1;
1579  x2 = cmds->x2<<1;
1580  y2 = cmds->y2<<1;
1581 #else
1582  x1 = cmds->x1;
1583  y1 = cmds->y1;
1584  x2 = cmds->x2;
1585  y2 = cmds->y2;
1586 #endif
1587  color cf = chdk_colors[cmds->cf]; // Convert color indexes to actual colors
1588  color cb = chdk_colors[cmds->cb];
1589  switch (cmds->action)
1590  {
1591  default:
1592  case IA_END:
1593  return;
1594  case IA_HLINE:
1595  draw_hline(x+x1, y+y1, x2, cb);
1596 #ifdef THUMB_FW
1597  draw_hline(x+x1, y+y1+1, x2, cb);
1598 #endif
1599  break;
1600  case IA_VLINE:
1601  draw_vline(x+x1, y+y1, y2, cb);
1602 #ifdef THUMB_FW
1603  draw_vline(x+x1+1, y+y1, y2, cb);
1604 #endif
1605  break;
1606  case IA_LINE:
1607 #ifdef THUMB_FW
1608  draw_line_x2(x+x1, y+y1, x+x2, y+y2, cb);
1609 #else
1610  draw_line(x+x1, y+y1, x+x2, y+y2, cb);
1611 #endif
1612  break;
1613  case IA_RECT:
1614 #ifdef THUMB_FW
1615  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness);
1616 #else
1617  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness);
1618 #endif
1619  break;
1620  case IA_FILLED_RECT:
1621 #ifdef THUMB_FW
1622  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED);
1623 #else
1624  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED);
1625 #endif
1626  break;
1627  case IA_ROUND_RECT:
1628 #ifdef THUMB_FW
1629  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|RECT_ROUND_CORNERS);
1630 #else
1631  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|RECT_ROUND_CORNERS);
1632 #endif
1633  break;
1634  case IA_FILLED_ROUND_RECT:
1635 #ifdef THUMB_FW
1636  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED|RECT_ROUND_CORNERS);
1637 #else
1638  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED|RECT_ROUND_CORNERS);
1639 #endif
1640  break;
1641  }
1642  cmds++;
1643  }
1644 }
void draw_init ( )

Definiert in Zeile 521 der Datei gui_draw.c.

522 {
523 #ifndef THUMB_FW
524 #ifndef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
527 #endif
528 #endif
530 
531  draw_set_guard();
532 }
int draw_is_suspended ( void  )

Definiert in Zeile 544 der Datei gui_draw.c.

545 {
547 }
void draw_line ( coord  x1,
coord  y1,
coord  x2,
coord  y2,
color  cl 
)

Definiert in Zeile 699 der Datei gui_draw.c.

700 {
701  unsigned char steep = abs(y2 - y1) > abs(x2 - x1);
702  if (steep)
703  {
704  swap(x1, y1);
705  swap(x2, y2);
706  }
707  if (x1 > x2)
708  {
709  swap(x1, x2);
710  swap(y1, y2);
711  }
712  int deltax = x2 - x1;
713  int deltay = abs(y2 - y1);
714  int error = 0;
715  int y = y1;
716  int ystep = (y1 < y2)?1:-1;
717  int x;
718  for (x=x1; x<=x2; ++x)
719  {
720  if (steep) draw_pixel(y, x, cl);
721  else draw_pixel(x, y, cl);
722  error += deltay;
723  if ((error<<1) >= deltax)
724  {
725  y += ystep;
726  error -= deltax;
727  }
728  }
729 }
void draw_or_erase_edge_pixel ( coord  px,
coord  py,
color  cl,
int  is_draw 
)

Definiert in Zeile 581 der Datei gui_draw.c.

582 {
583  // Make sure pixel is on screen. Skip top left pixel if screen erase detection is on to avoid triggering the detector.
584  if ((px < 0) || (py < 0) || (px >= camera_screen.width) || (py >= camera_screen.height) || ((px == 0) && (py == 0))) return;
585 
586  // bitmap buffer offset
587  register unsigned int offset = py * camera_screen.buffer_width + ASPECT_XCORRECTION(px);
588 
589 #ifndef THUMB_FW
590 
591  // See if we need to erase, do nothing if not drawing and current pixel is not edge pixel, otherwise set draw color to transparent.
592  if (!is_draw)
593  {
594 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
595  if (bitmap_buffer[active_bitmap_buffer][offset] != cl) return;
596 #else
597  if (frame_buffer[0][offset] != cl) return;
598 #endif
599  cl = 0; // Transparent
600  }
601 
602  // Draw pixel
603  draw_pixel_proc_norm(offset, cl);
604 #if CAM_USES_ASPECT_CORRECTION
605  draw_pixel_proc_norm(offset+1, cl); // Draw second pixel if screen scaling is needed
606 #endif
607 
608 #else // THUMB_FW
609 
610  // See if we need to erase, do nothing if not drawing and current pixel is not edge pixel, otherwise set draw color to transparent.
611  if (!is_draw)
612  {
613 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
614  if (opacity_buffer[active_bitmap_buffer&1][offset] != 254) return;
615 #else
616  if (opacity_buffer[0][offset] != 254) return;
617 #endif
618  cl = 0; // Transparent
619  }
620 
621  unsigned int y;
622  unsigned int o;
623  CALC_YUV_LUMA_OPACITY_FOR_COLOR(cl,y,o);
624  unsigned int u;
625  unsigned int v;
626  CALC_YUV_CHROMA_FOR_COLOR(cl,u,v);
627 
628  if (o == 255) o = 254; // Adjust opacity so we can test for erasing later
629 
630  register unsigned int offs2 = (offset>>1)<<2;
631 
632 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
633  unsigned char *obu = (unsigned char *)(&opacity_buffer[active_bitmap_buffer&1][0]);
634  unsigned char *bbu = (unsigned char *)(&bitmap_buffer[active_bitmap_buffer&1][0]);
635  obu[offset] = o;
636  if (offset&1) // x is odd
637  {
638  bbu[offs2+3] = y; // Y
639  }
640  else // x is even
641  {
642  bbu[offs2+1] = y; // Y
643  }
644  bbu[offs2+0] = u; // U?
645  bbu[offs2+2] = v; // V?
646 #else
647  opacity_buffer[0][offset] = o;
648  opacity_buffer[1][offset] = o;
649  if (offset&1) // x is odd
650  {
651  (bitmap_buffer[0])[offs2+3] = y; // Y
652  (bitmap_buffer[1])[offs2+3] = y; // Y
653  }
654  else // x is even
655  {
656  (bitmap_buffer[0])[offs2+1] = y; // Y
657  (bitmap_buffer[1])[offs2+1] = y; // Y
658  }
659  (bitmap_buffer[0])[offs2+0] = u; // U?
660  (bitmap_buffer[1])[offs2+0] = u; // U?
661  (bitmap_buffer[0])[offs2+2] = v; // V?
662  (bitmap_buffer[1])[offs2+2] = v; // V?
663 #endif
664 
665 #endif // THUMB_FW
666 }
void draw_osd_string ( OSD_pos  pos,
int  xo,
int  yo,
char *  s,
twoColors  c,
OSD_scale  scale 
)

Definiert in Zeile 1403 der Datei gui_draw.c.

1404 {
1405  if ((scale.x == 0) || (scale.y == 0) || ((scale.x == 1) && (scale.y == 1)))
1406  draw_string(pos.x+xo, pos.y+yo, s, c);
1407  else
1408  draw_string_scaled(pos.x+(xo*scale.x), pos.y+(yo*scale.y), s, c, scale.x, scale.y);
1409 }
void draw_pixel ( coord  x,
coord  y,
color  cl 
)

Definiert in Zeile 564 der Datei gui_draw.c.

565 {
566  // Make sure pixel is on screen. Skip top left pixel if screen erase detection is on to avoid triggering the detector.
567  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height) || ((x == 0) && (y == 0))) return;
568  else
569  {
570  register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x);
571  draw_pixel_proc(offset, cl);
572 #if CAM_USES_ASPECT_CORRECTION
573  draw_pixel_proc(offset+1, cl); // Draw second pixel if screen scaling is needed
574 #endif
575  }
576 }
void draw_pixel_proc_rotated ( unsigned int  offset,
color  cl 
)

Definiert in Zeile 215 der Datei gui_draw.c.

216 {
218 }
static void draw_pixel_std ( unsigned int  offset,
color  cl 
)
static

Definiert in Zeile 61 der Datei gui_draw.c.

62 {
63 #ifndef THUMB_FW
64  // drawing on 8bpp paletted overlay
65 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
67 #else
69 #endif
70 #else
71  // DIGIC 6, drawing on 16bpp YUV overlay
72 
73  unsigned int y;
74  unsigned int o;
75  CALC_YUV_LUMA_OPACITY_FOR_COLOR(cl,y,o);
76  unsigned int u;
77  unsigned int v;
78  CALC_YUV_CHROMA_FOR_COLOR(cl,u,v);
79 
80 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
81  int active_buffer_index = active_bitmap_buffer & 1;
82  unsigned char *obu = (unsigned char *)(&opacity_buffer[active_buffer_index][0]);
83  unsigned char *bbu = (unsigned char *)(&bitmap_buffer[active_buffer_index][0]);
84  obu[offset] = o;
85  register unsigned int offs2 = (offset>>1)<<2;
86  if (offset&1) // x is odd
87  {
88  bbu[offs2+3] = y; // Y
89  }
90  else // x is even
91  {
92  bbu[offs2+1] = y; // Y
93  }
94  bbu[offs2+0] = u; // U?
95  bbu[offs2+2] = v; // V?
96 #else
97  opacity_buffer[0][offset] = o;
98  opacity_buffer[1][offset] = o;
99  register unsigned int offs2 = (offset>>1)<<2;
100  if (offset&1) // x is odd
101  {
102  (bitmap_buffer[0])[offs2+3] = y; // Y
103  (bitmap_buffer[1])[offs2+3] = y; // Y
104  }
105  else // x is even
106  {
107  (bitmap_buffer[0])[offs2+1] = y; // Y
108  (bitmap_buffer[1])[offs2+1] = y; // Y
109  }
110  (bitmap_buffer[0])[offs2+0] = u; // U?
111  (bitmap_buffer[1])[offs2+0] = u; // U?
112  (bitmap_buffer[0])[offs2+2] = v; // V?
113  (bitmap_buffer[1])[offs2+2] = v; // V?
114 #endif
115 #endif
116 }
void draw_rectangle ( coord  x1,
coord  y1,
coord  x2,
coord  y2,
twoColors  cl,
int  flags 
)

Definiert in Zeile 809 der Datei gui_draw.c.

810 {
811  // Normalise values
812  if (x1 > x2)
813  swap(x1, x2);
814  if (y1 > y2)
815  swap(y1, y2);
816 
817  // Check if completely off screen
818  if ((x2 < 0) || (y2 < 0) || (x1 >= camera_screen.width) || (y1 >= camera_screen.height))
819  return;
820 
821  int round = (flags & RECT_ROUND_CORNERS) ? 1 : 0;
822  int thickness;
823  int i;
824 
825  // Shadow (do this first, as edge draw shrinks rectangle for fill)
826  if (flags & RECT_SHADOW_MASK)
827  {
828  thickness = ((flags & RECT_SHADOW_MASK) >> 4);
829  for (i=1; i<=thickness; i++)
830  {
831  draw_vline(x2+i, y1+1, y2 - y1, COLOR_BLACK);
832  draw_hline(x1+1, y2+i, x2 - x1 + thickness, COLOR_BLACK);
833  }
834  }
835 
836  // Edge
837  thickness = flags & RECT_BORDER_MASK;
838  for (i=0; i<thickness; i++)
839  {
840  // Clipping done in draw_hline and draw_vline
841  draw_vline(x1, y1 + round * 2, y2 - y1 - round * 4 + 1, FG_COLOR(cl));
842  draw_vline(x2, y1 + round * 2, y2 - y1 - round * 4 + 1, FG_COLOR(cl));
843  draw_hline(x1 + 1 + round, y1, x2 - x1 - round * 2 - 1, FG_COLOR(cl));
844  draw_hline(x1 + 1 + round, y2, x2 - x1 - round * 2 - 1, FG_COLOR(cl));
845 
846  x1++; x2--;
847  y1++; y2--;
848 
849  round = 0;
850  }
851 
852  // Fill
853  if (flags & DRAW_FILLED)
854  {
855  // Clip values
856  if (x1 < 0) x1 = 0;
857  if (y1 < 0) y1 = 0;
858  if (x2 >= camera_screen.width) x2 = camera_screen.width - 1;
859  if (y2 >= camera_screen.height) y2 = camera_screen.height - 1;
860 
861  coord y;
862  for (y = y1; y <= y2; ++y)
863  draw_hline(x1, y, x2 - x1 + 1, BG_COLOR(cl));
864  }
865 }
void draw_restore ( )

Definiert in Zeile 550 der Datei gui_draw.c.

551 {
552  if(draw_is_suspended()) {
553  return;
554  }
556 
557  draw_set_guard();
558 #ifdef CAM_TOUCHSCREEN_UI
559  redraw_buttons = 1;
560 #endif
561 }
void draw_set_draw_proc ( void(*)(unsigned int offset, color cl pixel_proc)

Definiert in Zeile 220 der Datei gui_draw.c.

221 {
222  draw_pixel_proc_norm = (pixel_proc)?pixel_proc:draw_pixel_std;
223  if (conf.rotate_osd)
224  {
227  }
228  else
229  {
231  }
232 }
void draw_set_guard ( )

Definiert in Zeile 473 der Datei gui_draw.c.

474 {
475 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
476  *((unsigned char*)(bitmap_buffer[0])) = GUARD_VAL;
477  *((unsigned char*)(bitmap_buffer[1])) = GUARD_VAL;
478 #else
479  *((unsigned char*)(frame_buffer[0])) = GUARD_VAL;
480  *((unsigned char*)(frame_buffer[1])) = GUARD_VAL;
481 #endif
482 }
int draw_string ( coord  x,
coord  y,
const char *  s,
twoColors  cl 
)

Definiert in Zeile 1249 der Datei gui_draw.c.

1250 {
1252 }
int draw_string_clipped ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  max_width 
)

Definiert in Zeile 1231 der Datei gui_draw.c.

1232 {
1233  while (*s && (*s != '\n') && (max_width >= FONT_WIDTH))
1234  {
1235  draw_char(x, y, *s, cl);
1236  s++;
1237  max_width -= FONT_WIDTH;
1238  x += FONT_WIDTH;
1239  if ((x>=camera_screen.width) && (*s))
1240  {
1241  draw_char(x-FONT_WIDTH,y, '>', cl);
1242  break;
1243  }
1244  }
1245  return x;
1246 }
int draw_string_justified ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  xo,
int  max_width,
int  justification 
)

Definiert in Zeile 1259 der Datei gui_draw.c.

1260 {
1261  // Get length in pixels
1262  const char *e = strchr(s, '\n');
1263  int l;
1264  if (e)
1265  l = (e - s) * FONT_WIDTH;
1266  else
1267  l = strlen(s) * FONT_WIDTH;
1268  if (l > max_width) l = max_width;
1269 
1270  // Calculate justification offset
1271  switch (justification & 0xF)
1272  {
1273  case TEXT_RIGHT:
1274  xo = (max_width - l);
1275  break;
1276  case TEXT_CENTER:
1277  xo = ((max_width - l) >> 1);
1278  break;
1279  }
1280 
1281  // Fill left side
1282  if ((justification & TEXT_FILL) && (xo > 0))
1284 
1285  // Draw string (get length drawn in pixels)
1286  l = draw_string_clipped(x+xo, y, s, cl, max_width - xo) - x;
1287 
1288  // Fill right side
1289  if ((justification & TEXT_FILL) && (l < max_width))
1290  draw_rectangle(x+l, y, x+max_width-1, y+FONT_HEIGHT-1, cl, RECT_BORDER0|DRAW_FILLED);
1291 
1292  // Return start of first character
1293  return x+xo;
1294 }
void draw_string_scaled ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  xsize,
int  ysize 
)

Definiert in Zeile 1351 der Datei gui_draw.c.

1352 {
1353  while (*s && (*s != '\n'))
1354  {
1355  draw_char_scaled(x, y, *s, cl, xsize, ysize);
1356  s++;
1357  x+=FONT_WIDTH*xsize;
1358  if ((x>=camera_screen.width) && (*s))
1359  {
1360  draw_char_scaled(x-FONT_WIDTH*xsize,y, '>', cl, xsize, ysize);
1361  break;
1362  }
1363  }
1364 }
void draw_suspend ( int  ms)

Definiert in Zeile 535 der Datei gui_draw.c.

536 {
537  int t=get_tick_count() + ms;
538  // only change if not already suspended to a later time
539  if(t > draw_restore_suspend_tick) {
541  }
542 }
int draw_test_guard ( )

Definiert in Zeile 484 der Datei gui_draw.c.

485 {
486 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
487  if (*((unsigned char*)(bitmap_buffer[active_bitmap_buffer])) != GUARD_VAL) return 0;
488 #else
489  if (*((unsigned char*)(frame_buffer[0])) != GUARD_VAL) return 0;
490  if (*((unsigned char*)(frame_buffer[1])) != GUARD_VAL) return 0;
491 #endif
492  return 1;
493 }
int draw_text_justified ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  max_chars,
int  max_lines,
int  justification 
)

Definiert in Zeile 1332 der Datei gui_draw.c.

1333 {
1334  int rx = 0;
1335  while (s && *s && (max_lines > 0))
1336  {
1337  const char *e = strchr(s, '\n');
1338  if (e) e++;
1339 
1340  rx = draw_string_justified(x, y, s, cl, 0, max_chars*FONT_WIDTH, justification);
1341 
1342  s = e;
1343  y += FONT_HEIGHT;
1344  max_lines--;
1345  }
1346  return rx;
1347 }
void draw_txt_string ( coord  col,
coord  row,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 1433 der Datei gui_draw.c.

1434 {
1436 }
void draw_vline ( coord  x,
coord  y,
int  len,
color  cl 
)

Definiert in Zeile 797 der Datei gui_draw.c.

798 {
799  if ((x < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return;
800  if (y < 0) { len += y; y = 0; }
802  for (; len>0; len--, y++)
803  draw_pixel(x, y, cl);
804 }
void erase_zebra ( )

Definiert in Zeile 209 der Datei gui_draw.c.

209 {}
static unsigned char* get_cdata ( unsigned int *  offset,
unsigned int *  size,
const char  ch 
)
static

Definiert in Zeile 876 der Datei gui_draw.c.

877 {
879 
880  *offset = f->skips >> 4; // # of blank lines at top
881  *size = 16 - (f->skips & 0xF); // last line of non-blank data
882  if (*size == *offset) // special case for blank char (top == 15 && bottom == 1)
883  *offset += 1;
884 
885  return (unsigned char*)f + sizeof(FontData) - *offset;
886 }
color get_script_color ( int  cl)

Definiert in Zeile 1663 der Datei gui_draw.c.

1664 {
1665  if (cl < 256)
1666  return cl;
1667  else
1668  return chdk_colors[cl-256];
1669 }
void set_palette ( )

Definiert in Zeile 1653 der Datei gui_draw.c.

1654 {
1655 #ifndef THUMB_FW
1658  else
1660 #endif
1661 }
int text_dimensions ( const char *  s,
int  width,
int  max_chars,
int *  max_lines 
)

Definiert in Zeile 1301 der Datei gui_draw.c.

1302 {
1303  int l = 0, n;
1304  while (s && *s && (l < *max_lines))
1305  {
1306  const char *e = strchr(s, '\n');
1307  if (e)
1308  {
1309  n = e - s;
1310  e++;
1311  }
1312  else
1313  {
1314  n = strlen(s);
1315  }
1316 
1317  if (n > width) width = n;
1318 
1319  s = e;
1320  l++;
1321  }
1322  *max_lines = l;
1323  if (width > max_chars) width = max_chars;
1324  return width;
1325 }
void update_draw_proc ( )

Definiert in Zeile 234 der Datei gui_draw.c.

twoColors user_color ( confColor  cc)

Definiert in Zeile 1679 der Datei gui_draw.c.

1680 {
1681  color fg = chdkColorToCanonColor(cc.fg);
1682  color bg = chdkColorToCanonColor(cc.bg);
1683 
1684  return MAKE_COLOR(bg,fg);
1685 }

Variablen-Dokumentation

unsigned char* chdk_colors = ply_colors

Definiert in Zeile 1651 der Datei gui_draw.c.

void(* draw_pixel_proc)(unsigned int offset, color cl)

Definiert in Zeile 56 der Datei gui_draw.c.

void(* draw_pixel_proc_norm)(unsigned int offset, color cl)

Definiert in Zeile 57 der Datei gui_draw.c.

int draw_restore_suspend_tick

Definiert in Zeile 54 der Datei gui_draw.c.

char* frame_buffer[2]
static

Definiert in Zeile 46 der Datei gui_draw.c.

unsigned char ply_colors[]

Definiert in Zeile 8 der Datei platform_palette.c.

unsigned char rec_colors[]

Definiert in Zeile 33 der Datei platform_palette.c.

unsigned int rotate_base

Definiert in Zeile 213 der Datei gui_draw.c.