GadgetSeed  0.9.6
graphics.c
[詳解]
1 /** @file
2  @brief グラフィックス描画
3 
4  @date 2015.08.15
5  @date 2013.06.20
6  @date 2007.03.20
7  @author Takashi SHUDO
8 
9  @page graphics グラフィックス
10 
11  GadgetSeedは標準化された表示デバイスと表示デバイスへのグラフィックス描画APIを持ちます。
12 
13  グラフィックスを使用するには、以下のコンフィグ項目を有効にして下さい。
14 
15  * COMP_ENABLE_GRAPHICS
16 
17 
18  ---
19  @section graphics_struct グラフィックス関連データ構造体
20 
21  グラフィックス関連APIは以下の構造体を使用します。
22 
23  - @ref st_rect @copybrief st_rect
24  - @ref st_box @copybrief st_box
25  - @ref st_bitmap @copybrief st_bitmap
26 
27 
28  ---
29  @section graphics_api グラフィックスAPI
30 
31  @subsection graphics_dev_api グラフィックスデバイス制御API
32 
33  以下のAPIはグラフィックスデバイスに対する設定を行います。
34 
35  include ファイル : graphics.h
36 
37  | API名 | 機能 |
38  |:--------------------------|:--------------------------------------|
39  | register_graphics_dev() | @copybrief register_graphics_dev |
40  | get_frame_num() | @copybrief get_frame_num |
41  | set_display_frame() | @copybrief set_display_frame |
42  | get_display_frame() | @copybrief get_display_frame |
43  | set_draw_frame() | @copybrief set_draw_frame |
44  | get_draw_frame() | @copybrief get_draw_frame |
45  | init_graphics() | @copybrief init_graphics |
46  | get_screen_info() | @copybrief get_screen_info |
47 
48  @subsection graphics_draw_set_api グラフィックス描画設定API
49 
50  以下のAPIはグラフィックス描画に関する設定を行います。
51 
52  include ファイル : graphics.h
53 
54  | API名 | 機能 |
55  |:--------------------------|:------------------------------|
56  | clear_clip_rect() | @copybrief clear_clip_rect |
57  | set_clip_rect() | @copybrief set_clip_rect |
58  | set_clip_box() | @copybrief set_clip_box |
59  | get_clip_rect() | @copybrief get_clip_rect |
60  | clear_screen() | @copybrief clear_screen |
61  | set_forecolor() | @copybrief set_forecolor |
62  | get_forecolor() | @copybrief get_forecolor |
63  | set_backcolor() | @copybrief set_backcolor |
64  | get_backcolor() | @copybrief get_backcolor |
65  | set_draw_mode() | @copybrief set_draw_mode |
66  | get_draw_mode() | @copybrief get_draw_mode |
67 
68  @subsection graphics_draw_api グラフィックス描画API
69 
70  以下のAPIはグラフィックス描画を行います。
71 
72  include ファイル : graphics.h
73 
74  | API名 | 機能 |
75  |:--------------------------|:--------------------------------------|
76  | draw_point() | @copybrief draw_point |
77  | draw_h_line() | @copybrief draw_h_line |
78  | draw_v_line() | @copybrief draw_v_line |
79  | draw_line() | @copybrief draw_line |
80  | draw_rect() | @copybrief draw_rect |
81  | draw_round_rect() | @copybrief draw_round_rect |
82  | draw_fill_rect() | @copybrief draw_fill_rect |
83  | draw_round_fill_rect() | @copybrief draw_round_fill_rect |
84  | draw_bitdata() | @copybrief draw_bitdata |
85  | draw_enlarged_bitdata() | @copybrief draw_enlarged_bitdata |
86  | draw_bitmap() | @copybrief draw_bitmap |
87  | draw_enlarged_bitmap() | @copybrief draw_enlarged_bitmap |
88  | draw_circle() | @copybrief draw_circle |
89  | draw_quarter_circle() | @copybrief draw_quarter_circle |
90  | draw_fill_circle() | @copybrief draw_fill_circle |
91  | draw_ellipse() | @copybrief draw_ellipse |
92  | draw_fill_ellipse() | @copybrief draw_fill_ellipse |
93  | draw_box() | @copybrief draw_box |
94  | draw_round_box() | @copybrief draw_round_box |
95  | draw_round_fill_box() | @copybrief draw_round_fill_box |
96  | draw_fill_box() | @copybrief draw_fill_box |
97  | draw_vertex4_region() | @copybrief draw_vertex4_region |
98  | draw_sector() | @copybrief draw_sector |
99  | draw_image() | @copybrief draw_image |
100 
101  @subsection graphics_calc_api グラフィックス演算API
102 
103  以下のAPIはグラフィックスデータの演算を行います。
104 
105  include ファイル : graphics.h
106 
107  | API名 | 機能 |
108  |:--------------------------|:------------------------------|
109  | and_rect() | @copybrief and_rect |
110  | empty_rect() | @copybrief empty_rect |
111  | correct_rect() | @copybrief correct_rect |
112  | is_point_in_rect() | @copybrief is_point_in_rect |
113  | is_point_in_box() | @copybrief is_point_in_box |
114  | box2rect() | @copybrief box2rect |
115  | resize_image() | @copybrief resize_image |
116 */
117 
118 #include "graphics.h"
119 #include "device.h"
120 #include "device/video_ioctl.h"
121 #include "tkprintf.h"
122 #include "tprintf.h"
123 
124 //#define DEBUGTBITS 0x02
125 #include "dtprintf.h"
126 
127 
128 static struct st_device *fb_dev;
129 static short gdev_type;
130 static short screen_width;
131 static short screen_height;
132 static unsigned short color_depth;
133 static unsigned int screen_mem_size;
134 static unsigned short frame_num;
135 static unsigned int fore_color;
136 static unsigned int back_color;
137 static unsigned char pen_mode;
138 static struct st_rect i_clip_rect;
139 static struct st_rect clip_rect;
140 
141 /**
142  @brief グラフィックライブラリにデバイスを登録する
143 
144  @param[in] dev グラフィックデバイス
145 
146  @return !=0:エラー
147 */
149 {
150  struct st_video_info *v_info = (struct st_video_info *)(dev->info);
151 
152  static const char color_dep_str[5][20] = {
153  "1 bit monochrome",
154  "8 bit 256 colors",
155  "16 bit color",
156  "24 bit color",
157  "32 bit color"
158  };
159 
160  static const char graph_dev_type_str[5][20] = {
161  "Monochrome",
162  "No frame buffer",
163  "Frame buffer"
164  };
165 
166  if(v_info == 0) {
167  SYSERR_PRINT("Cannot find video info\n");
168  return -1;
169  }
170 
171  fb_dev = dev;
172 
173  gdev_type = v_info->type;
174  screen_width = v_info->width;
175  screen_height = v_info->height;
176  color_depth = v_info->color_depth;
177  screen_mem_size = v_info->mem_size;
178  frame_num = v_info->frame_num;
179  tkprintf("Graphics device \"%s\" Type : %s, Screen size %dx%d(%d), %s\n", dev->name,
180  graph_dev_type_str[gdev_type],
181  screen_width, screen_height, frame_num,
182  color_dep_str[color_depth]);
183 
184  pen_mode = GRP_DRAWMODE_NORMAL;
185  set_forecolor(RGB(255, 255, 255));
186  set_backcolor(RGB(0, 0, 0));
187 
188  i_clip_rect.top = 0;
189  i_clip_rect.left = 0;
190  i_clip_rect.right = screen_width;
191  i_clip_rect.bottom = screen_height;
192  clip_rect = i_clip_rect;
193 
194  return 0;
195 }
196 
197 /**
198  @brief 表示するフレームバッファ番号を設定する
199 
200  @param[in] fnum 表示するフレームバッファ番号
201 
202  @return !=0:エラー
203 */
204 int set_display_frame(int fnum)
205 {
206  return ioctl_device(fb_dev, IOCMD_VIDEO_SETDISPFRAME, fnum, 0);
207 }
208 
209 /**
210  @brief 表示しているフレームバッファ番号を取得する
211 
212  @return 表示しているフレームバッファ番号
213 */
215 {
216  return ioctl_device(fb_dev, IOCMD_VIDEO_GETDISPFRAME, 0, 0);
217 }
218 
219 /**
220  @brief フレームバッファ数を取得する
221 
222  @return フレームバッファ数
223 */
224 int get_frame_num(void)
225 {
226  return frame_num;
227 }
228 
229 /**
230  @brief 描画するフレームバッファ番号を設定する
231 
232  @param[in] fnum 描画するフレームバッファ番号
233 
234  @return !=0:エラー
235 */
236 int set_draw_frame(int fnum)
237 {
238  return ioctl_device(fb_dev, IOCMD_VIDEO_SETDRAWFRAME, fnum, 0);
239 }
240 
241 /**
242  @brief 描画するフレームバッファ番号を取得する
243 
244  @return 描画するフレームバッファ番号
245 */
246 int get_draw_frame(void)
247 {
248  return ioctl_device(fb_dev, IOCMD_VIDEO_GETDRAWFRAME, 0, 0);
249 }
250 
251 /**
252  @brief クリッピングエリアを無効にする
253 */
254 void clear_clip_rect(void)
255 {
256  clip_rect = i_clip_rect;
257 }
258 
259 /**
260  @brief クリッピングエリアを矩形で指定する
261 
262  @param[in] rect クリッピングエリア矩形
263 */
264 void set_clip_rect(struct st_rect *rect)
265 {
266  clip_rect = *rect;
267 
268  if(clip_rect.left < 0) clip_rect.left = 0;
269  if(clip_rect.top < 0) clip_rect.top = 0;
270  if(clip_rect.right > screen_width) clip_rect.right = screen_width;
271  if(clip_rect.bottom > screen_height) clip_rect.bottom = screen_height;
272 }
273 
274 /**
275  @brief クリッピングエリアを四角形で指定する
276 
277  @param[in] box クリッピングエリア四角形
278 */
279 void set_clip_box(struct st_box *box)
280 {
281  struct st_rect rect;
282 
283  box2rect(&rect, box);
284 
285  set_clip_rect(&rect);
286 }
287 
288 /**
289  @brief クリッピングエリアを矩形で取得する
290 
291  @param[out] rect 取得したクリッピングエリア矩形
292 */
293 void get_clip_rect(struct st_rect *rect)
294 {
295  *rect = clip_rect;
296 }
297 
298 /**
299  @brief グラフィックスライブラリを初期化する
300 
301  @param[in] devname グラフィックスデバイス名
302 
303  @return !=0:エラー
304 */
305 int init_graphics(char *devname)
306 {
307  struct st_device *dev;
308 
309  if(devname == 0) goto err;
310 
311  dev = open_device(devname);
312  if(dev == 0) {
313  SYSERR_PRINT("Cannot open device \"%s\"\n", devname);
314  goto err;
315  }
316 
317  return register_graphics_dev(dev);
318 
319  err:
320  return -1;
321 }
322 
323 /**
324  @brief スクリーンのサイズ情報を取得する
325 
326  @param[out] width スクリーン幅ピクセル数
327  @param[out] height スクリーン高さピクセル数
328 */
329 void get_screen_info(short *width, short *height)
330 {
331  *width = screen_width;
332  *height = screen_height;
333 }
334 
335 /**
336  @brief 画面を全て0で描画する
337 */
338 void clear_screen(void)
339 {
340  ioctl_device(fb_dev, IOCMD_VIDEO_CLEAR, 0, 0);
341 }
342 
343 static void prepare_color(void)
344 {
345  unsigned int fcolor;
346  unsigned int bcolor;
347 
348  switch(pen_mode) {
350  fcolor = back_color;
351  bcolor = fore_color;
352  break;
353 
354  case GRP_DRAWMODE_NORMAL:
355  default:
356  fcolor = fore_color;
357  bcolor = back_color;
358  break;
359  }
360 
361  ioctl_device(fb_dev, IOCMD_VIDEO_SET_FORECOLOR, fcolor, 0);
362  ioctl_device(fb_dev, IOCMD_VIDEO_SET_BACKCOLOR, bcolor, 0);
363 }
364 
365 /**
366  @brief 描画の色を設定する
367 
368  @param[in] color 描画の色
369 */
370 void set_forecolor(unsigned int color)
371 {
372  fore_color = color;
373 
374  prepare_color();
375 }
376 
377 /**
378  @brief 描画の色を取得する
379 
380  @return 描画の色
381 */
382 unsigned int get_forecolor(void)
383 {
384  return fore_color;
385 }
386 
387 /**
388  @brief 描画の背景色を設定する
389 
390  @param color 背景色
391 */
392 void set_backcolor(unsigned int color)
393 {
394  back_color = color;
395 
396  prepare_color();
397 }
398 
399 /**
400  @brief 描画の背景色を取得する
401 
402  @return 背景色
403 */
404 unsigned int get_backcolor(void)
405 {
406  return back_color;
407 }
408 
409 /**
410  @brief 描画モードを設定する
411 
412  @param[in] mode 描画モード
413 */
414 void set_draw_mode(unsigned char mode)
415 {
416  pen_mode = mode;
417 
418  prepare_color();
419 }
420 
421 /**
422  @brief 描画モードを取得する
423 
424  @return 描画モード
425 */
426 unsigned char get_draw_mode(void)
427 {
428  return pen_mode;
429 }
430 
431 /*
432  *
433  */
434 
435 static void _draw_point(short x, short y)
436 {
438  (((int)y) << 16) | (x & 0xffff), 0);
439 }
440 
441 /**
442  @brief 点を描画する
443 
444  @param[in] x 点のX座標
445  @param[in] y 点のY座標
446 */
447 void draw_point(short x, short y)
448 {
449  if(clip_rect.top > y) return;
450  if(clip_rect.bottom <= y) return;
451  if(clip_rect.left > x) return;
452  if(clip_rect.right <= x) return;
453 
454  _draw_point(x, y);
455 }
456 
457 static void _draw_h_line(short x, short y, short xe)
458 {
459  struct st_rect rect;
460 
461  rect.left = x;
462  rect.top = y;
463  rect.right = xe - 1;
464  rect.bottom = y;
465 
466  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&rect);
467  ioctl_device(fb_dev, IOCMD_VIDEO_REPEAT_DATA, xe - x, 0);
468 }
469 
470 /**
471  @brief 水平線を描画する
472 
473  @param[in] x 水平線のX座標
474  @param[in] y 水平線上のY座標
475  @param[in] width 水平線の長さ
476 */
477 void draw_h_line(short x, short y, short width)
478 {
479  short xe = x + width;
480 
481  if(clip_rect.top > y) return;
482  if(clip_rect.bottom <= y) return;
483  if(clip_rect.right <= x) return;
484  if(clip_rect.left > x) x = clip_rect.left;
485  if(clip_rect.right < xe) xe = clip_rect.right;
486  if(x >= xe) return;
487 
488  _draw_h_line(x, y, xe);
489 }
490 
491 static void _draw_v_line(short x, short y, short ye)
492 {
493  struct st_rect rect;
494 
495  rect.left = x;
496  rect.top = y;
497  rect.right = x;
498  rect.bottom = ye - 1;
499 
500  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&rect);
501  ioctl_device(fb_dev, IOCMD_VIDEO_REPEAT_DATA, ye - y, 0);
502 }
503 
504 /**
505  @brief 垂直線を描画する
506 
507  @param[in] x 垂直線左のX座標
508  @param[in] y 垂直線のY座標
509  @param[in] height 垂直線の長さ
510 */
511 void draw_v_line(short x, short y, short height)
512 {
513  short ye = y + height;
514 
515  if(clip_rect.left > x) return;
516  if(clip_rect.right <= x) return;
517  if(clip_rect.bottom <= y) return;
518  if(clip_rect.top > y) y = clip_rect.top;
519  if(clip_rect.bottom < ye) ye = clip_rect.bottom;
520 
521  _draw_v_line(x, y, ye);
522 }
523 
524 #define LEFT 1
525 #define RIGHT 2
526 #define TOP 4
527 #define BOTTOM 8
528 
529 static short calc_seq_code(short x, short y)
530 {
531  short code;
532 
533  code = 0;
534  if(x < clip_rect.left) code += LEFT;
535  if(x >= clip_rect.right) code += RIGHT;
536  if(y < clip_rect.top) code += TOP;
537  if(y >= clip_rect.bottom) code += BOTTOM;
538 
539  return code;
540 }
541 
542 static short calc_clipped_point(short code,
543  short x0, short y0,
544  short x1, short y1,
545  short *x, short *y)
546 {
547  short cx, cy;
548 
549  if((code & LEFT) != 0) {
550  cy = (y1 - y0) * (clip_rect.left - x0) / (x1 - x0) + y0;
551  if((cy >= clip_rect.top) && (cy <= clip_rect.bottom-1)) {
552  *x = clip_rect.left;
553  *y = cy;
554  return 1;
555  }
556  }
557 
558  if((code & RIGHT) != 0) {
559  cy = (y1 - y0) * (clip_rect.right-1 - x0) / (x1 - x0) + y0;
560  if((cy >= clip_rect.top) && (cy <= clip_rect.bottom-1)) {
561  *x = clip_rect.right-1;
562  *y = cy;
563  return 1;
564  }
565  }
566 
567  if((code & TOP) != 0) {
568  cx = (x1 - x0) * (clip_rect.top - y0) / (y1 - y0) + x0;
569  if((cx >= clip_rect.left) && (cx <= clip_rect.right-1)) {
570  *x = cx;
571  *y = clip_rect.top;
572  return 1;
573  }
574  }
575 
576  if((code & BOTTOM) != 0) {
577  cx = (x1 - x0) * (clip_rect.bottom-1 - y0) / (y1 - y0) + x0;
578  if((cx >= clip_rect.left) && (cx <= clip_rect.right-1)) {
579  *x = cx;
580  *y = clip_rect.bottom-1;
581  return 1;
582  }
583  }
584 
585  return -1;
586 }
587 
588 static short clipping(short *x0, short *y0, short *x1, short *y1)
589 {
590  short code0,code1;
591 
592  code0 = calc_seq_code(*x0, *y0);
593  code1 = calc_seq_code(*x1, *y1);
594 
595  if((code0 == 0) && (code1 == 0)) {
596  return 0;
597  }
598 
599  if((code0 & code1) != 0) {
600  return -1;
601  }
602 
603  if(code0 != 0) {
604  if(calc_clipped_point(code0, *x0, *y0, *x1, *y1, x0, y0) < 0) {
605  return -1;
606  }
607  }
608 
609  if(code1 != 0) {
610  if(calc_clipped_point(code1, *x0, *y0, *x1, *y1, x1, y1) < 0) {
611  return -1;
612  }
613  }
614 
615  return 1;
616 }
617 
618 static void line(short x0, short y0, short x1, short y1)
619 {
620  short E,x,y;
621  short dx,dy,sx,sy,i;
622 
623  sx = (x1 > x0) ? 1 : -1;
624  dx = (x1 > x0) ? x1 - x0 : x0 - x1;
625  sy = (y1 > y0) ? 1 : -1;
626  dy = (y1 > y0) ? y1 - y0 : y0 - y1;
627 
628  x = x0;
629  y = y0;
630 
631  if(dx >= dy) {
632  E = -dx;
633  for(i=0; i<=dx; i++) {
634  _draw_point(x, y);
635  x += sx;
636  E += 2 * dy;
637  if(E >= 0) {
638  y += sy;
639  E -= 2 * dx;
640  }
641  }
642  } else {
643  E = -dy;
644  for(i=0; i<=dy; i++) {
645  _draw_point(x, y);
646  y += sy;
647  E += 2 * dx;
648  if(E >= 0) {
649  x += sx;
650  E -= 2 * dy;
651  }
652  }
653  }
654 }
655 
656 /**
657  @brief 直線を描画する
658 
659  @param[in] x 直線描画開始X座標
660  @param[in] y 直線描画開始Y座標
661  @param[in] xe 直線描画終了X座標
662  @param[in] ye 直線描画終了Y座標
663 */
664 void draw_line(short x, short y, short xe, short ye)
665 {
666  if((x == xe) && (y == ye)) {
667  return;
668  }
669 
670  if(x > xe) {
671  x --;
672  } else if(xe > x){
673  xe --;
674  }
675 
676  if(y > ye) {
677  y --;
678  } else if(ye > y){
679  ye --;
680  }
681 
682  if(clipping(&x, &y, &xe, &ye) < 0) {
683  return;
684  }
685 
686  line(x, y, xe, ye);
687 }
688 
689 /**
690  @brief 矩形を描画する
691 
692  @param[in] rect 矩形
693 */
694 void draw_rect(struct st_rect *rect)
695 {
696  struct st_rect drect;
697  short tw = 0;
698  short lw = 0;
699  short bw = 0;
700 
701  and_rect(&drect, rect, &clip_rect);
702 
703  if(empty_rect(&drect) == 0) {
704  // 上
705  if((clip_rect.top <= rect->top) &&
706  (rect->top <= clip_rect.bottom)) {
707  tw = 1;
708  _draw_h_line(drect.left, drect.top, drect.right);
709  }
710 
711  // 左
712  if((clip_rect.left <= rect->left) &&
713  (rect->left <= clip_rect.right)) {
714  if((drect.top+tw) < drect.bottom) {
715  lw = 1;
716  _draw_v_line(drect.left, drect.top+tw,
717  drect.bottom);
718  }
719  }
720 
721  // 下
722  if((clip_rect.top <= rect->bottom) &&
723  (rect->bottom <= clip_rect.bottom)) {
724  if((drect.left+lw) < drect.right) {
725  bw = 1;
726  _draw_h_line(drect.left+lw, drect.bottom-1,
727  drect.right);
728  }
729  }
730 
731  // 右
732  if((clip_rect.left <= rect->right) &&
733  (rect->right <= clip_rect.right)) {
734  if((drect.top+tw) < (drect.bottom-bw)) {
735  _draw_v_line(drect.right-1, drect.top+tw,
736  drect.bottom-bw);
737  }
738  }
739  }
740 }
741 
742 /**
743  @brief 角の丸い矩形を描画する
744 
745  @param[in] rect 矩形
746  @param[in] r 角丸の半径
747 */
748 void draw_round_rect(struct st_rect *rect, short r)
749 {
750  short l_w = rect->right - rect->left - (r * 2);
751  short l_h = rect->bottom - rect->top - (r * 2);
752 
753  // 図形が成り立つ?
754  if(l_w < 0) {
755  return;
756  }
757 
758  if(l_h < 0) {
759  return;
760  }
761 
762  // 左上
763  draw_quarter_circle(rect->left + r, rect->top + r, r, 1);
764 
765  // 上
766  if((clip_rect.top <= rect->top) &&
767  (rect->top <= clip_rect.bottom)) {
768  draw_h_line(rect->left + r, rect->top, l_w);
769  }
770 
771  // 右上
772  draw_quarter_circle(rect->right - 1 - r, rect->top + r, r, 0);
773 
774  // 左
775  if((clip_rect.left <= rect->left) &&
776  (rect->left <= clip_rect.right)) {
777  draw_v_line(rect->left, rect->top + 1 + r, l_h);
778  }
779 
780  // 左下
781  draw_quarter_circle(rect->left + r, rect->bottom - 1 - r, r, 2);
782 
783  // 下
784  if((clip_rect.top <= rect->bottom) &&
785  (rect->bottom <= clip_rect.bottom)) {
786  draw_h_line(rect->left + r, rect->bottom - 1, l_w);
787  }
788 
789  // 右下
790  draw_quarter_circle(rect->right - 1 - r, rect->bottom - 1 - r, r, 3);
791 
792  // 右
793  if((clip_rect.left <= rect->right) &&
794  (rect->right <= clip_rect.right)) {
795  draw_v_line(rect->right - 1, rect->top + r, l_h);
796  }
797 }
798 
799 static void _draw_fill_rect(struct st_rect *rect)
800 {
801  struct st_rect tmp = *rect;
802 
803  if(tmp.left < tmp.right) {
804  tmp.right --;
805  }
806  if(tmp.top < tmp.bottom) {
807  tmp.bottom --;
808  }
809 
810  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&tmp);
812  (unsigned int)((rect->right - rect->left/* + 1*/) *
813  (rect->bottom - rect->top/* + 1*/)), 0);
814 }
815 
816 /**
817  @brief 塗りつぶした矩形を描画する
818 
819  @param[in] rect 矩形
820 */
821 void draw_fill_rect(struct st_rect *rect)
822 {
823  struct st_rect drect;
824 
825  and_rect(&drect, rect, &clip_rect);
826 
827  if(empty_rect(&drect) == 0) {
828  _draw_fill_rect(&drect);
829  }
830 }
831 
832 /**
833  @brief 角の丸い塗りつぶした矩形を描画する
834 
835  @param[in] rect 矩形
836  @param[in] r 角丸の半径
837 */
838 void draw_round_fill_rect(struct st_rect *rect, short r)
839 {
840  struct st_rect rrect = *rect;
841  struct st_rect drect;
842  short l_w = rect->right - rect->left - (r * 2);
843  short l_h = rect->bottom - rect->top - (r * 2);
844  short x0, y0;
845  short x, y, F;
846 
847  // 図形が成り立つ?
848  if(l_w < 0) {
849  return;
850  }
851 
852  if(l_h < 0) {
853  return;
854  }
855 
856  // 角丸上
857  x0 = rect->left + r;
858  y0 = rect->top + r;
859  x = r;
860  y = 0;
861  F = -2 * r + 3;
862 
863  while(x >= y) {
864  draw_h_line(x0 - x, y0 - y, l_w + x * 2);
865  draw_h_line(x0 - y, y0 - x, l_w + y * 2);
866  if(F >= 0) {
867  x--;
868  F -= 4 * x;
869  }
870  y++;
871  F += 4 * y + 2;
872  }
873 
874  // 中の長方形
875  rrect.top += r;
876  rrect.bottom -= r;
877 
878  and_rect(&drect, &rrect, &clip_rect);
879 
880  if(empty_rect(&drect) == 0) {
881  _draw_fill_rect(&drect);
882  }
883 
884  // 角丸下
885  y0 = rect->bottom - r - 1;
886  x = r;
887  y = 0;
888  F = -2 * r + 3;
889 
890  while(x >= y) {
891  draw_h_line(x0 - x, y0 + y, l_w + x * 2);
892  draw_h_line(x0 - y, y0 + x, l_w + y * 2);
893  if(F >= 0) {
894  x--;
895  F -= 4 * x;
896  }
897  y++;
898  F += 4 * y + 2;
899  }
900 }
901 
902 static void draw_bits(short x, short y, short width, short height,
903  short offset, unsigned char *data, short dw)
904 {
905  struct st_rect rect;
906  int j;
907  unsigned char *dp;
908 #ifdef BITS_WRITE_WORD
909  unsigned char pat;
910  int i;
911 #endif
912 
913  DTFPRINTF(0x01, "\n");
914  DTPRINTF(0x01, "x=%d y=%d\n", x, y);
915  DTPRINTF(0x01, "w=%d h=%d o=%d dw=%d\n", width, height, offset, dw);
916  DTPRINTF(0x01, "data=%p\n", data);
917 
918  rect.left = x;
919  rect.top = y;
920  rect.right = x + width - 1;
921  rect.bottom = y + height - 1;
922 
923  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&rect);
924 
925  for(j=0; j<height; j++) {
926  dp = data + (dw * j) + (offset/8);
927  DTPRINTF(0x02, "dp=%p\n", dp);
928 #ifdef BITS_WRITE_WORD
929  pat = (0x80 >> (offset & 7));
930  for(i=0; i<width; i++) {
931  if(pen_mode == GRP_DRAWMODE_REVERSE) {
932  if(*dp & pat) {
933  ioctl_device(fb_dev, IOCMD_VIDEO_WRITE_WORD, back_color, 0);
934  } else {
935  ioctl_device(fb_dev, IOCMD_VIDEO_WRITE_WORD, fore_color, 0);
936  }
937  } else {
938  if(*dp & pat) {
939  ioctl_device(fb_dev, IOCMD_VIDEO_WRITE_WORD, fore_color, 0);
940  } else {
941  ioctl_device(fb_dev, IOCMD_VIDEO_WRITE_WORD, back_color, 0);
942  }
943  }
944  if(pat == 0x01) {
945  dp ++;
946  pat = 0x80;
947  } else {
948  pat >>= 1;
949  }
950  }
951 #else
952  if(pen_mode == GRP_DRAWMODE_FOREONLY) {
953  unsigned char pat;
954  int i;
955  pat = (0x80 >> (offset & 7));
956  for(i=0; i<width; i++) {
957  if((*dp & pat) != 0) {
959  (((int)(y + j)) << 16) | ((x + i) & 0xffff), 0);
960  }
961  if(pat == 0x01) {
962  dp ++;
963  pat = 0x80;
964  } else {
965  pat >>= 1;
966  }
967  }
968  } else {
969  ioctl_device(fb_dev, IOCMD_VIDEO_DRAW_BITS | ((offset & 7) << 12) | (width & 0x0fff), 0, (void *)dp);
970  }
971 #endif
972  }
973 }
974 
975 static void draw_enlarged_bits(short x, short y,
976  short width, short height,
977  short offset, unsigned char *data, short dw,
978  int rate, short dox, short doy)
979 {
980  struct st_rect rect;
981  int i, j, n, m = doy;
982  unsigned char pat, *dp;
983 
984  DTFPRINTF(0x01, "\n");
985  DTPRINTF(0x01, "x=%d y=%d\n", x, y);
986  DTPRINTF(0x01, "w=%d h=%d o=%d dw=%d\n", width, height, offset, dw);
987  DTPRINTF(0x01, "data=%p\n", data);
988  DTPRINTF(0x01, "dox=%d doy=%d\n", dox, doy);
989 
990  rect.left = x;
991  rect.top = y;
992  rect.right = x + width - 1;
993  rect.bottom = y + height - 1;
994 
995  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&rect);
996 
997  for(j=0; j<height; j++) {
998  pat = (0x80 >> (offset & 7));
999  dp = data + (dw * ((j+m)/rate));
1000  n = dox;
1001  ioctl_device(fb_dev, IOCMD_VIDEO_LOCK_DEVICE, 0, 0);
1002  for(i=0; i<width; i++) {
1003  if(pen_mode == GRP_DRAWMODE_REVERSE) {
1004  if((*dp & pat) != 0) {
1005  ioctl_device(fb_dev, IOCMD_VIDEO_NOLOCK_WRITE_WORD, back_color, 0);
1006  } else {
1007  ioctl_device(fb_dev, IOCMD_VIDEO_NOLOCK_WRITE_WORD, fore_color, 0);
1008  }
1009  } else {
1010  if((*dp & pat) != 0) {
1011  ioctl_device(fb_dev, IOCMD_VIDEO_NOLOCK_WRITE_WORD, fore_color, 0);
1012  } else {
1013  ioctl_device(fb_dev, IOCMD_VIDEO_NOLOCK_WRITE_WORD, back_color, 0);
1014  }
1015  }
1016  n++;
1017  if(n >= rate) {
1018  if(pat == 0x01) {
1019  dp ++;
1020  pat = 0x80;
1021  } else {
1022  pat >>= 1;
1023  }
1024  n = 0;
1025  }
1026  }
1027  ioctl_device(fb_dev, IOCMD_VIDEO_UNLOCK_DEVICE, 0, 0);
1028  }
1029 }
1030 
1031 /**
1032  @brief ビットデータを描画する
1033 
1034  @param[in] px 描画開始X座標
1035  @param[in] py 描画開始Y座標
1036  @param[in] width 描画幅
1037  @param[in] height 描画高さ
1038  @param[in] data ビットデータポインタ
1039  @param[in] dw ビットデータ幅
1040 */
1041 void draw_bitdata(short px, short py, short width, short height,
1042  unsigned char *data, short dw)
1043 {
1044  struct st_rect wrect;
1045  struct st_rect drect;
1046 
1047  wrect.left = px;
1048  wrect.top = py;
1049  wrect.right = px + width;
1050  wrect.bottom = py + height;
1051 
1052  and_rect(&drect, &wrect, &clip_rect);
1053 
1054  if(empty_rect(&drect) == 0) {
1055  short offset = 0;
1056  if((clip_rect.top <= wrect.top) &&
1057  (wrect.top < clip_rect.bottom)) {
1058  } else {
1059  data += (clip_rect.top - wrect.top) * dw;
1060  }
1061 
1062  if((clip_rect.left <= wrect.left) &&
1063  (wrect.left < clip_rect.right)) {
1064  } else {
1065  data += (clip_rect.left-wrect.left)/8;
1066  offset = (clip_rect.left - wrect.left) & 7;
1067  }
1068  DTPRINTF(0x02, "data = %p\n", data);
1069  draw_bits(drect.left, drect.top,
1070  drect.right-drect.left, drect.bottom-drect.top,
1071  offset, data, dw);
1072  }
1073 }
1074 
1075 /**
1076  @brief 拡大したビットデータを描画する
1077 
1078  @param[in] px 描画開始X座標
1079  @param[in] py 描画開始Y座標
1080  @param[in] width 描画幅
1081  @param[in] height 描画高さ
1082  @param[in] data ビットデータポインタ
1083  @param[in] dw ビットデータ幅
1084  @param[in] rate 拡大率
1085 */
1086 void draw_enlarged_bitdata(short px, short py,
1087  short width, short height,
1088  unsigned char *data, short dw,
1089  int rate)
1090 {
1091  struct st_rect wrect;
1092  struct st_rect drect;
1093  short dox = 0, doy = 0;
1094 
1095  if(rate == 0) {
1096  return;
1097  }
1098 
1099  wrect.left = px;
1100  wrect.top = py;
1101  wrect.right = px + width * rate;
1102  wrect.bottom = py + height * rate;
1103 
1104  and_rect(&drect, &wrect, &clip_rect);
1105 
1106  DTPRINTF(0x01, "CLIP %d %d %d %d\n", clip_rect.left, clip_rect.top, clip_rect.right, clip_rect.bottom);
1107  DTPRINTF(0x01, "WRECT %d %d %d %d\n", wrect.left, wrect.top, wrect.right, wrect.bottom);
1108  DTPRINTF(0x01, "DRECT %d %d %d %d\n", drect.left, drect.top, drect.right, drect.bottom);
1109 
1110  if(empty_rect(&drect) == 0) {
1111  short offset = 0;
1112 
1113  if((clip_rect.top <= wrect.top) && (wrect.top < clip_rect.bottom)) {
1114  // データの開始位置は変わらない
1115  DTPRINTF(0x02, "V no change\n");
1116  } else {
1117  data += ((clip_rect.top - wrect.top)/rate) * dw;
1118  doy = (clip_rect.top - py) % rate;
1119  }
1120 
1121  if((clip_rect.left <= wrect.left) && (wrect.left < clip_rect.right)) {
1122  // データの開始位置は変わらない
1123  DTPRINTF(0x02, "H no change\n");
1124  } else {
1125  data += (clip_rect.left-wrect.left)/rate/8;
1126  offset = (clip_rect.left - wrect.left)/rate & 7;
1127  dox = (clip_rect.left - px) % rate;
1128  }
1129  DTPRINTF(0x02, "data = %p\n", data);
1130 
1131  draw_enlarged_bits(drect.left, drect.top,
1132  drect.right-drect.left, drect.bottom-drect.top,
1133  offset, data, dw,
1134  rate, dox, doy);
1135  }
1136 }
1137 
1138 
1139 /**
1140  @brief ビットマップデータを描画する
1141 
1142  @param[in] px 描画X座標
1143  @param[in] py 描画Y座標
1144  @param[in] bitmap ビットマップデータ
1145 */
1146 void draw_bitmap(short px, short py, struct st_bitmap *bitmap)
1147 {
1148  draw_bitdata(px, py, bitmap->width, bitmap->height, bitmap->data,
1149  (bitmap->width + 7)/8);
1150 }
1151 
1152 /**
1153  @brief 拡大したビットマップデータを描画する
1154 
1155  @param[in] px 描画X座標
1156  @param[in] py 描画Y座標
1157  @param[in] bitmap ビットマップデータ
1158  @param[in] rate 拡大率
1159 */
1160 void draw_enlarged_bitmap(short px, short py, struct st_bitmap *bitmap, int rate)
1161 {
1162  draw_enlarged_bitdata(px, py, bitmap->width, bitmap->height, bitmap->data,
1163  (bitmap->width + 7)/8, rate);
1164 }
1165 
1166 /**
1167  @brief 円を描画する
1168 
1169  @param[in] x0 円の中心X座標
1170  @param[in] y0 円の中心Y座標
1171  @param[in] r 円の半径
1172 */
1173 void draw_circle(short x0, short y0, short r)
1174 {
1175  short x, y, F;
1176 
1177  x = r;
1178  y = 0;
1179  F = -2 * r + 3;
1180 
1181  while(x >= y) {
1182  draw_point(x0 + x, y0 + y);
1183  draw_point(x0 - x, y0 + y);
1184  draw_point(x0 + x, y0 - y);
1185  draw_point(x0 - x, y0 - y);
1186  draw_point(x0 + y, y0 + x);
1187  draw_point(x0 - y, y0 + x);
1188  draw_point(x0 + y, y0 - x);
1189  draw_point(x0 - y, y0 - x);
1190  if(F >= 0) {
1191  x--;
1192  F -= 4 * x;
1193  }
1194  y++;
1195  F += 4 * y + 2;
1196  }
1197 }
1198 
1199 /**
1200  @brief 1/4の円を描画する
1201 
1202  @param[in] x0 円の中心X座標
1203  @param[in] y0 円の中心Y座標
1204  @param[in] r 円の半径
1205  @param[in] q 象限(0:第1象限 〜 3:4象限)
1206 */
1207 void draw_quarter_circle(short x0, short y0, short r, char q)
1208 {
1209  short x, y, F;
1210 
1211  x = r;
1212  y = 0;
1213  F = -2 * r + 3;
1214 
1215  while(x >= y) {
1216  switch(q) {
1217  case 0:
1218  draw_point(x0 + x, y0 - y);
1219  draw_point(x0 + y, y0 - x);
1220  break;
1221 
1222  case 1:
1223  draw_point(x0 - x, y0 - y);
1224  draw_point(x0 - y, y0 - x);
1225  break;
1226 
1227  case 2:
1228  draw_point(x0 - x, y0 + y);
1229  draw_point(x0 - y, y0 + x);
1230  break;
1231 
1232  case 3:
1233  draw_point(x0 + x, y0 + y);
1234  draw_point(x0 + y, y0 + x);
1235  break;
1236  }
1237  if(F >= 0) {
1238  x--;
1239  F -= 4 * x;
1240  }
1241  y++;
1242  F += 4 * y + 2;
1243  }
1244 }
1245 
1246 /**
1247  @brief 塗りつぶした円を描画する
1248 
1249  @param[in] x0 円の中心X座標
1250  @param[in] y0 円の中心Y座標
1251  @param[in] r 円の半径
1252 */
1253 void draw_fill_circle(short x0, short y0, short r)
1254 {
1255  short x, y, F;
1256 
1257  x = r;
1258  y = 0;
1259  F = -2 * r + 3;
1260 
1261  while(x >= y) {
1262  draw_h_line(x0 - x, y0 + y, x * 2 + 1);
1263  draw_h_line(x0 - x, y0 - y, x * 2 + 1);
1264  draw_h_line(x0 - y, y0 + x, y * 2 + 1);
1265  draw_h_line(x0 - y, y0 - x, y * 2 + 1);
1266  if(F >= 0) {
1267  x--;
1268  F -= 4 * x;
1269  }
1270  y++;
1271  F += 4 * y + 2;
1272  }
1273 }
1274 
1275 /**
1276  @brief 楕円を描画する
1277 
1278  @param[in] xc 楕円の中心X座標
1279  @param[in] yc 楕円の中心Y座標
1280  @param[in] rx 縦の半径
1281  @param[in] ry 横の半径
1282 */
1283 void draw_ellipse(short xc, short yc, short rx, short ry)
1284 {
1285  int x, x1, y, y1, r;
1286 
1287  if(rx == 0) return;
1288  if(ry == 0) return;
1289 
1290  if(rx > ry) {
1291  x = r = rx; y = 0;
1292  while(x >=y ) {
1293  x1 = x*ry/rx;
1294  y1 = y*ry/rx;
1295  draw_point(xc+x, yc+y1);
1296  draw_point(xc+x, yc-y1);
1297  draw_point(xc-x, yc+y1);
1298  draw_point(xc-x, yc-y1);
1299  draw_point(xc+y, yc+x1);
1300  draw_point(xc+y, yc-x1);
1301  draw_point(xc-y, yc+x1);
1302  draw_point(xc-y, yc-x1);
1303  if((r -= y++*2+1)<=0) {
1304  r+= --x*2;
1305  }
1306  }
1307  } else {
1308  x = r = ry; y = 0;
1309  while(x>=y) {
1310  x1 = x*rx/ry;
1311  y1 = y*rx/ry;
1312  draw_point(xc+x1, yc+y);
1313  draw_point(xc+x1, yc-y);
1314  draw_point(xc-x1, yc+y);
1315  draw_point(xc-x1, yc-y);
1316  draw_point(xc+y1, yc+x);
1317  draw_point(xc+y1, yc-x);
1318  draw_point(xc-y1, yc+x);
1319  draw_point(xc-y1, yc-x);
1320  if((r -= y++*2+1)<=0) {
1321  r += --x*2;
1322  }
1323  }
1324  }
1325 }
1326 
1327 /**
1328  @brief 塗りつぶした楕円を描画する
1329 
1330  @param[in] xc 楕円の中心X座標
1331  @param[in] yc 楕円の中心Y座標
1332  @param[in] rx 縦の半径
1333  @param[in] ry 横の半径
1334 */
1335 void draw_fill_ellipse(short xc, short yc, short rx, short ry)
1336 {
1337  int x, x1, y, y1, r;
1338 
1339  if(rx == 0) return;
1340  if(ry == 0) return;
1341 
1342  if(rx > ry) {
1343  x = r = rx;
1344  y = 0;
1345  while(x >=y ) {
1346  x1 = x*ry/rx;
1347  y1 = y*ry/rx;
1348  draw_h_line(xc-x, yc+y1, x*2 + 1);
1349  draw_h_line(xc-x, yc-y1, x*2 + 1);
1350  draw_h_line(xc-y, yc+x1, y*2 + 1);
1351  draw_h_line(xc-y, yc-x1, y*2 + 1);
1352  if((r -= y++*2+1)<=0) {
1353  r+= --x*2;
1354  }
1355  }
1356  } else {
1357  x = r = ry;
1358  y = 0;
1359  while(x>=y) {
1360  x1 = x*rx/ry;
1361  y1 = y*rx/ry;
1362  draw_h_line(xc-x1, yc+y, x1*2 + 1);
1363  draw_h_line(xc-x1, yc-y, x1*2 + 1);
1364  draw_h_line(xc-y1, yc+x, y1*2 + 1);
1365  draw_h_line(xc-y1, yc-x, y1*2 + 1);
1366  if((r -= y++*2+1)<=0) {
1367  r += --x*2;
1368  }
1369  }
1370  }
1371 }
1372 
1373 #if 0
1374 /**
1375  @brief スクリーンを上にx, 横にyドット分スクロールする
1376 
1377  @param[in] x 横スクロールドット数
1378  @param[in] y 縦スクロールドット数
1379 */
1380 void scroll_screen(short x, short y)
1381 {
1382  ioctl_device(fb_dev, IOCMD_VIDEO_SCROLL, (((long)y) << 16) | (x & 0xffff), 0);
1383 }
1384 #endif
1385 
1386 /**
1387  @brief 四角を描画する
1388 
1389  @param[in] box 四角
1390 */
1391 void draw_box(struct st_box *box)
1392 {
1393  struct st_rect rect;
1394 
1395  box2rect(&rect, box);
1396 
1397  draw_rect(&rect);
1398 }
1399 
1400 /**
1401  @brief 角の丸い四角を描画する
1402 
1403  @param[in] box 四角
1404  @param[in] r 角丸の半径
1405 */
1406 void draw_round_box(struct st_box *box, short r)
1407 {
1408  struct st_rect rect;
1409 
1410  box2rect(&rect, box);
1411 
1412  draw_round_rect(&rect, r);
1413 }
1414 
1415 /**
1416  @brief 塗りつぶした角の丸い四角を描画する
1417 
1418  @param[in] box 四角
1419  @param[in] r 角丸の半径
1420 */
1421 void draw_round_fill_box(struct st_box *box, short r)
1422 {
1423  struct st_rect rect;
1424 
1425  box2rect(&rect, box);
1426 
1427  draw_round_fill_rect(&rect, r);
1428 }
1429 
1430 /**
1431  @brief 塗りつぶした四角を描画する
1432 
1433  @param[in] box 四角
1434 */
1435 void draw_fill_box(struct st_box *box)
1436 {
1437  struct st_rect rect;
1438 
1439  box2rect(&rect, box);
1440 
1441  draw_fill_rect(&rect);
1442 }
1443 
1444 #include <limits.h>
1445 
1446 #define TOP_MAX SHRT_MAX
1447 #define LEFT_MAX SHRT_MAX
1448 #define RIGHT_MIN SHRT_MIN
1449 #define BOTTOM_MIN SHRT_MIN
1450 
1451 static short region_pos[2][GSC_GRAPHICS_DISPLAY_HEIGHT]; // [0][y] : left ,[1][y] : right
1452 // グラフィックデバイスの高さ分必要
1453 
1454 static void set_region_pos(short x0, short y0, short x1, short y1, int lr)
1455 {
1456  short E,x,y;
1457  short dx,dy,sx,sy,i;
1458 
1459  sx = (x1 > x0) ? 1 : -1;
1460  dx = (x1 > x0) ? x1 - x0 : x0 - x1;
1461  sy = (y1 > y0) ? 1 : -1;
1462  dy = (y1 > y0) ? y1 - y0 : y0 - y1;
1463 
1464  x = x0;
1465  y = y0;
1466 
1467  if(dx >= dy) {
1468  E = -dx;
1469  for(i=0; i<=dx; i++) {
1470  if((clip_rect.top <= y) && (y < clip_rect.bottom)) {
1471  region_pos[lr][y] = x;
1472  }
1473  DTPRINTF(0x02, "%d [L] %d, %d\n", i, x, y);
1474  x += sx;
1475  E += 2 * dy;
1476  if(E >= 0) {
1477  y += sy;
1478  E -= 2 * dx;
1479  }
1480  }
1481  } else {
1482  E = -dy;
1483  for(i=0; i<=dy; i++) {
1484  if((clip_rect.top <= y) && (y < clip_rect.bottom)) {
1485  region_pos[lr][y] = x;
1486  }
1487  DTPRINTF(0x02, "%d [R] %d, %d\n", i, x, y);
1488  y += sy;
1489  E += 2 * dx;
1490  if(E >= 0) {
1491  x += sx;
1492  E -= 2 * dy;
1493  }
1494  }
1495  }
1496 }
1497 
1498 /**
1499  @brief 塗りつぶした4頂点の領域を描画する
1500 
1501  @param[in] x0 頂点0のX座標
1502  @param[in] y0 頂点0のY座標
1503  @param[in] x1 頂点1のX座標
1504  @param[in] y1 頂点1のY座標
1505  @param[in] x2 頂点2のX座標
1506  @param[in] y2 頂点2のY座標
1507  @param[in] x3 頂点3のX座標
1508  @param[in] y3 頂点3のY座標
1509 */
1510 void draw_vertex4_region(short x0, short y0,
1511  short x1, short y1,
1512  short x2, short y2,
1513  short x3, short y3)
1514 {
1515  short xt = 0, yt = TOP_MAX; // 最も上の(Y値の大きい)座標
1516  short xl = LEFT_MAX, yl = 0; // 最も左の(X値の小さい)座標
1517  short xr = RIGHT_MIN, yr = 0; // 最も右の(X値の大きい)座標
1518  short xb = 0, yb = BOTTOM_MIN; // 最も下の(Y値の小さい)座標
1519  int top_pn = -1;
1520  int left_pn = -1;
1521 // int right_pn = -1;
1522  int bottom_pn = -1;
1523  short i;
1524 
1525  if(yt > y0) { yt = y0; xt = x0; top_pn = 0; }
1526  if(yt > y1) { yt = y1; xt = x1; top_pn = 1; }
1527  if(yt > y2) { yt = y2; xt = x2; top_pn = 2; }
1528  if(yt > y3) { yt = y3; xt = x3; top_pn = 3; }
1529 
1530  if((top_pn != 0) && (yb < y0)) { yb = y0; xb = x0; bottom_pn = 0; }
1531  if((top_pn != 1) && (yb < y1)) { yb = y1; xb = x1; bottom_pn = 1; }
1532  if((top_pn != 2) && (yb < y2)) { yb = y2; xb = x2; bottom_pn = 2; }
1533  if((top_pn != 3) && (yb < y3)) { yb = y3; xb = x3; bottom_pn = 3; }
1534 
1535  if((top_pn != 0) && (bottom_pn != 0) && (xl > x0)) { xl = x0; yl = y0; left_pn = 0; }
1536  if((top_pn != 1) && (bottom_pn != 1) && (xl > x1)) { xl = x1; yl = y1; left_pn = 1; }
1537  if((top_pn != 2) && (bottom_pn != 2) && (xl > x2)) { xl = x2; yl = y2; left_pn = 2; }
1538  if((top_pn != 2) && (bottom_pn != 3) && (xl > x3)) { xl = x3; yl = y3; left_pn = 3; }
1539 
1540  if((top_pn != 0) && (bottom_pn != 0) && (left_pn != 0) && (xr < x0)) { xr = x0; yr = y0; /*right_pn = 0;*/ }
1541  if((top_pn != 1) && (bottom_pn != 1) && (left_pn != 1) && (xr < x1)) { xr = x1; yr = y1; /*right_pn = 1;*/ }
1542  if((top_pn != 2) && (bottom_pn != 2) && (left_pn != 2) && (xr < x2)) { xr = x2; yr = y2; /*right_pn = 2;*/ }
1543  if((top_pn != 3) && (bottom_pn != 3) && (left_pn != 3) && (xr < x3)) { xr = x3; yr = y3; /*right_pn = 3;*/ }
1544 
1545  if(yt == yl) {
1546  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1547  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1548  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1549  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1550  if(xt < xl) {
1551  short xtmp = xt;
1552  short ytmp = yt;
1553  xt = xl;
1554  yt = yl;
1555  xl = xtmp;
1556  yl = ytmp;
1557  }
1558  }
1559 
1560  if(yt == yr) {
1561  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1562  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1563  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1564  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1565  if(xt > xr) {
1566  short xtmp = xt;
1567  short ytmp = yt;
1568  xt = xr;
1569  yt = yr;
1570  xr = xtmp;
1571  yr = ytmp;
1572  }
1573  }
1574 
1575  if(yb == yl) {
1576  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1577  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1578  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1579  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1580  if(xb < xl) {
1581  short xtmp = xb;
1582  short ytmp = yb;
1583  xb = xl;
1584  yb = yl;
1585  xl = xtmp;
1586  yl = ytmp;
1587  }
1588  }
1589 
1590  if(yb == yr) {
1591  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1592  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1593  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1594  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1595  if(xb > xr) {
1596  short xtmp = xb;
1597  short ytmp = yb;
1598  xb = xr;
1599  yb = yr;
1600  xr = xtmp;
1601  yr = ytmp;
1602  }
1603  }
1604 
1605  if(xl == xr) {
1606  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1607  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1608  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1609  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1610  if(yl > yr) {
1611  short xtmp = xl;
1612  short ytmp = yl;
1613  xl = xr;
1614  yl = yr;
1615  xr = xtmp;
1616  yr = ytmp;
1617  }
1618  }
1619  // もう少し良いアルゴリズムがありそう
1620 
1621  DTPRINTF(0x02, "T : %d, B : %d\n", top_pn, bottom_pn);
1622  DTPRINTF(0x02, "L : %d\n", left_pn);
1623 
1624  DTPRINTF(0x02, "XT = %d, YT = %d\n", xt, yt);
1625  DTPRINTF(0x02, "XL = %d, YL = %d\n", xl, yl);
1626  DTPRINTF(0x02, "XR = %d, YR = %d\n", xr, yr);
1627  DTPRINTF(0x02, "XB = %d, YB = %d\n", xb, yb);
1628 
1629 #ifdef DEBUG
1630  draw_line(xt, yt, xl, yl);
1631  draw_line(xt, yt, xr, yr);
1632  draw_line(xl, yl, xb, yb);
1633  draw_line(xr, yr, xb, yb);
1634 #endif
1635 
1636  if(xl == xr) {
1637 // if(xt < xl) {
1638  set_region_pos(xt, yt, xl, yl, 1);
1639  set_region_pos(xt, yt, xb, yb, 0);
1640  set_region_pos(xl, yl, xr, yr, 1);
1641  set_region_pos(xr, yr, xb, yb, 1);
1642  } else {
1643  set_region_pos(xt, yt, xl, yl, 0);
1644  set_region_pos(xt, yt, xr, yr, 1);
1645  set_region_pos(xl, yl, xb, yb, 0);
1646  set_region_pos(xr, yr, xb, yb, 1);
1647  }
1648 
1649  for(i=yt; i<yb; i++) {
1650  if(region_pos[0][i] > region_pos[1][i]) {
1651  draw_h_line(region_pos[1][i], i, region_pos[0][i] - region_pos[1][i]);
1652  } else {
1653  draw_h_line(region_pos[0][i], i, region_pos[1][i] - region_pos[0][i]);
1654  }
1655  }
1656 }
1657 
1658 
1659 static void set_arc(short x, short y, short r, char q, unsigned char lr)
1660 {
1661  short px, py, F;
1662 
1663  px = r;
1664  py = 0;
1665  F = -2 * r + 3;
1666 
1667  while(px >= py) {
1668  switch(q) {
1669  case 0:
1670  //draw_point(x + px, y - py);
1671  //draw_point(x + py, y - px);
1672  if((0 <= (y-py)) && ((y-py) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1673  region_pos[lr][y - py] = x + px;
1674  }
1675  if((0 <= (y-px)) && ((y-px) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1676  region_pos[lr][y - px] = x + py;
1677  }
1678  break;
1679 
1680  case 1:
1681  //draw_point(x - px, y - py);
1682  //draw_point(x - py, y - px);
1683  if((0 <= (y-py)) && ((y-py) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1684  region_pos[lr][y - py] = x - px;
1685  }
1686  if((0 <= (y-px)) && ((y-px) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1687  region_pos[lr][y - px] = x - py;
1688  }
1689  break;
1690 
1691  case 2:
1692  //draw_point(x - px, y + py);
1693  //draw_point(x - py, y + px);
1694  if((0 <= (y+py)) && ((y+py) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1695  region_pos[lr][y + py] = x - px;
1696  }
1697  if((0 <= (y+px)) && ((y+px) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1698  region_pos[lr][y + px] = x - py;
1699  }
1700  break;
1701 
1702  case 3:
1703  //draw_point(x + px, y + py);
1704  //draw_point(x + py, y + px);
1705  if((0 <= (y+py)) && ((y+py) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1706  region_pos[lr][y + py] = x + px;
1707  }
1708  if((0 <= (y+px)) && ((y+px) < GSC_GRAPHICS_DISPLAY_HEIGHT)) {
1709  region_pos[lr][y + px] = x + py;
1710  }
1711  break;
1712  }
1713  if(F >= 0) {
1714  px--;
1715  F -= 4 * px;
1716  }
1717  py++;
1718  F += 4 * py + 2;
1719  }
1720 }
1721 
1722 
1723 /**
1724  @brief 扇形を描画する
1725 
1726  @param[in] x 中心のX座標
1727  @param[in] y 中心のY座標
1728  @param[in] er 外径
1729  @param[in] ir 内径
1730  @param[in] q 象限(0:第1象限 〜 3:4象限)
1731 */
1732 void draw_sector(short x, short y, // 中心の座標
1733  short er, // 外形
1734  short ir, // 内径
1735  char q // 象限(0:第1象限 〜 3:4象限)
1736  )
1737 {
1738  short i, tp, bt;
1739 
1740  switch(q) {
1741  case 0:
1742  set_arc(x, y, er, q, 1);
1743  set_arc(x, y, ir, q, 0);
1744  tp = y-er;
1745  bt = y-ir;
1746  if(tp < 0) tp = 0;
1747  if(GSC_GRAPHICS_DISPLAY_HEIGHT <= bt) bt = (GSC_GRAPHICS_DISPLAY_HEIGHT - 1);
1748  for(i=tp; i<bt; i++) {
1749  region_pos[0][i] = x;
1750  }
1751  for(i=(y-er); i<y; i++) {
1752  draw_h_line(region_pos[0][i], i, region_pos[1][i] - region_pos[0][i]);
1753  }
1754  break;
1755 
1756  case 1:
1757  set_arc(x, y, er, q, 0);
1758  set_arc(x, y, ir, q, 1);
1759  tp = y-er;
1760  bt = y-ir;
1761  if(tp < 0) tp = 0;
1762  if(GSC_GRAPHICS_DISPLAY_HEIGHT <= bt) bt = (GSC_GRAPHICS_DISPLAY_HEIGHT - 1);
1763  for(i=tp; i<bt; i++) {
1764  region_pos[1][i] = x;
1765  }
1766  for(i=(y-er); i<y; i++) {
1767  draw_h_line(region_pos[0][i], i, region_pos[1][i] - region_pos[0][i]);
1768  }
1769  break;
1770 
1771  case 2:
1772  set_arc(x, y, er, q, 0);
1773  set_arc(x, y, ir, q, 1);
1774  tp = y+ir;
1775  bt = y+er;
1776  if(tp < 0) tp = 0;
1777  if(GSC_GRAPHICS_DISPLAY_HEIGHT <= bt) bt = (GSC_GRAPHICS_DISPLAY_HEIGHT - 1);
1778  for(i=tp; i<bt; i++) {
1779  region_pos[1][i] = x;
1780  }
1781  for(i=y; i<(y+er); i++) {
1782  draw_h_line(region_pos[0][i], i, region_pos[1][i] - region_pos[0][i]);
1783  }
1784  break;
1785 
1786  case 3:
1787  set_arc(x, y, er, q, 1);
1788  set_arc(x, y, ir, q, 0);
1789  tp = y+ir;
1790  bt = y+er;
1791  if(tp < 0) tp = 0;
1792  if(GSC_GRAPHICS_DISPLAY_HEIGHT <= bt) bt = (GSC_GRAPHICS_DISPLAY_HEIGHT - 1);
1793  for(i=tp; i<bt; i++) {
1794  region_pos[0][i] = x;
1795  }
1796  for(i=y; i<(y+er); i++) {
1797  draw_h_line(region_pos[0][i], i, region_pos[1][i] - region_pos[0][i]);
1798  }
1799  break;
1800  }
1801 }
1802 
1803 
1804 static void _draw_data(short x, short y, short width, short height,
1805  short offset, void *data, short dw)
1806 {
1807  struct st_rect rect;
1808  int j;
1809  PIXEL_DATA *dp;
1810 
1811  DTFPRINTF(0x01, "\n");
1812  DTPRINTF(0x01, "x=%d y=%d\n", x, y);
1813  DTPRINTF(0x01, "w=%d h=%d o=%d dw=%d\n", width, height, offset, dw);
1814  DTPRINTF(0x01, "data=%p\n", data);
1815 
1816  rect.left = x;
1817  rect.top = y;
1818  rect.right = x + width - 1;
1819  rect.bottom = y + height - 1;
1820 
1821  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&rect);
1822 
1823  for(j=0; j<height; j++) {
1824  dp = (PIXEL_DATA *)data + (dw * j) + offset;
1825  DTPRINTF(0x02, "dp=%p\n", dp);
1826  write_device(fb_dev, (unsigned char *)dp, width * sizeof(*dp));
1827  }
1828 }
1829 
1830 /**
1831  @brief イメージデータを描画する
1832 
1833  @param[in] px 描画X座標
1834  @param[in] py 描画Y座標
1835  @param[in] width 描画幅
1836  @param[in] height 描画高さ
1837  @param[in] image イメージデータポインタ
1838  @param[in] dw イメージデータ幅
1839 */
1840 void draw_image(short px, short py, short width, short height, void *image, short dw)
1841 {
1842  struct st_rect wrect;
1843  struct st_rect drect;
1844 
1845  wrect.left = px;
1846  wrect.top = py;
1847  wrect.right = px + width;
1848  wrect.bottom = py + height;
1849 
1850  and_rect(&drect, &wrect, &clip_rect);
1851 
1852  if(empty_rect(&drect) == 0) {
1853  short offset = 0;
1854  if((clip_rect.top <= wrect.top) &&
1855  (wrect.top < clip_rect.bottom)) {
1856  } else {
1857  image += (clip_rect.top - wrect.top) * width;
1858  offset = (clip_rect.left - wrect.left);
1859  }
1860 
1861  if((clip_rect.left <= wrect.left) &&
1862  (wrect.left < clip_rect.right)) {
1863  } else {
1864  image += (clip_rect.left-wrect.left);
1865  }
1866  DTPRINTF(0x02, "image = %p\n", image);
1867 
1868  _draw_data(drect.left, drect.top,
1869  drect.right-drect.left, drect.bottom-drect.top,
1870  offset, image, dw);
1871  }
1872 }
1873 
1874 static unsigned int graph_copy_buf[GSC_GRAPHICS_DISPLAY_WIDTH];
1875 
1876 /**
1877  @brief 矩形範囲を縦方向にスクロールする
1878 
1879  @param[in] rect スクロール範囲矩形
1880  @param[in] pixel スクロールドット数
1881 */
1882 void scroll_rect_v(struct st_rect *rect, short pixel)
1883 {
1884  struct st_rect tmp = *rect;
1885  struct st_rect crect;
1886  int dwidth;
1887  short height;
1888  short pos_x = rect->top;
1889  int i;
1890 
1891  if(pixel == 0) {
1892  return;
1893  }
1894 
1895 #if 0
1896  if(tmp.left < tmp.right) {
1897  tmp.right --;
1898  }
1899  if(tmp.top < tmp.bottom) {
1900  tmp.bottom --;
1901  }
1902 #endif
1903 
1904  dwidth = (tmp.right - tmp.left) * color_depth;
1905 
1906  crect.left = tmp.left;
1907  crect.right = tmp.right;
1908 
1909  if(pixel < 0) {
1910  height= (tmp.bottom - tmp.top) + pixel;
1911  for(i=0; i<height; i++) {
1912  crect.top = pos_x - pixel + i;
1913  crect.bottom = crect.top + 1;
1914 
1915  DTPRINTF(0x01, "- copy from rect(%d, %d, %d, %d)\n", crect.left, crect.top, crect.right, crect.bottom);
1916  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&crect);
1917  read_device(fb_dev, (unsigned char *)graph_copy_buf, dwidth);
1918 
1919  crect.top = pos_x + i;
1920  crect.bottom = crect.top + 1;
1921 
1922  DTPRINTF(0x01, "- copy to rect(%d, %d, %d, %d)\n", crect.left, crect.top, crect.right, crect.bottom);
1923  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&crect);
1924  write_device(fb_dev, (unsigned char *)graph_copy_buf, dwidth);
1925  }
1926  } else {
1927  height= (tmp.bottom - tmp.top) - pixel;
1928  for(i=height; i>=0; i--) {
1929  crect.top = pos_x + i;
1930  crect.bottom = crect.top + 1;
1931 
1932  DTPRINTF(0x01, "+ copy from rect(%d, %d, %d, %d)\n", crect.left, crect.top, crect.right, crect.bottom);
1933  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&crect);
1934  read_device(fb_dev, (unsigned char *)graph_copy_buf, dwidth);
1935 
1936  crect.top = pos_x + pixel + i;
1937  crect.bottom = crect.top + 1;
1938 
1939  DTPRINTF(0x01, "+ copy to rect(%d, %d, %d, %d)\n", crect.left, crect.top, crect.right, crect.bottom);
1940  ioctl_device(fb_dev, IOCMD_VIDEO_SETRECT, 0, (void *)&crect);
1941  write_device(fb_dev, (unsigned char *)graph_copy_buf, dwidth);
1942  }
1943  }
1944 }
struct st_device * dev
ビデオデバイスドライバ
Definition: video_ioctl.h:38
void draw_fill_box(struct st_box *box)
塗りつぶした四角を描画する
Definition: graphics.c:1435
void set_backcolor(unsigned int color)
描画の背景色を設定する
Definition: graphics.c:392
#define IOCMD_VIDEO_NOLOCK_WRITE_WORD
2バイト表示データを転送する(MUTEXロックは無視)
Definition: video_ioctl.h:62
#define IOCMD_VIDEO_GETDRAWFRAME
描画フレーム番号を取得する
Definition: video_ioctl.h:50
unsigned short height
表示高さドット数
Definition: video_ioctl.h:33
void * info
デバイス情報データポインタ
Definition: device.h:28
#define IOCMD_VIDEO_CLEAR
全画面初期化
Definition: video_ioctl.h:52
void draw_enlarged_bitdata(short px, short py, short width, short height, unsigned char *data, short dw, int rate)
拡大したビットデータを描画する
Definition: graphics.c:1086
void draw_circle(short x0, short y0, short r)
円を描画する
Definition: graphics.c:1173
#define GRP_DRAWMODE_NORMAL
Draw the foreground with fore color. Draw the background with back color.
Definition: graphics.h:60
画像表示デバイスドライバ ioctl 用マクロ定義
アプリケーション(タスク)デバッグ用マクロ
#define IOCMD_VIDEO_SETDRAWFRAME
描画フレーム番号を設定する
Definition: video_ioctl.h:49
#define IOCMD_VIDEO_UNLOCK_DEVICE
デバイスをMUTEXアンロックする
Definition: video_ioctl.h:45
void set_forecolor(unsigned int color)
描画の色を設定する
Definition: graphics.c:370
int get_display_frame(void)
表示しているフレームバッファ番号を取得する
Definition: graphics.c:214
void draw_vertex4_region(short x0, short y0, short x1, short y1, short x2, short y2, short x3, short y3)
塗りつぶした4頂点の領域を描画する
Definition: graphics.c:1510
#define IOCMD_VIDEO_SETRECT
描画データ転送範囲を矩形で設定する
Definition: video_ioctl.h:55
矩形
Definition: graphics.h:64
画像表示デバイス情報
Definition: video_ioctl.h:30
struct st_device * open_device(char *name)
デバイスをオープンする
Definition: device.c:262
#define IOCMD_VIDEO_REPEAT_DATA
指定ドット数分フォアカラーで描画する
Definition: video_ioctl.h:66
int get_frame_num(void)
フレームバッファ数を取得する
Definition: graphics.c:224
int write_device(struct st_device *dev, const void *buf, unsigned int count)
デバイスにデータを書き込む
Definition: device.c:451
int read_device(struct st_device *dev, void *buf, unsigned int count)
デバイスよりデータを読み出す
Definition: device.c:378
short top
左上頂点のY座標
Definition: graphics.h:66
short bottom
右下頂点のY座標
Definition: graphics.h:68
short left
左上頂点のX座標
Definition: graphics.h:65
ビットマップグラフィックデータ
Definition: graphics.h:86
長(正)方形
Definition: graphics.h:81
void set_clip_rect(struct st_rect *rect)
クリッピングエリアを矩形で指定する
Definition: graphics.c:264
#define IOCMD_VIDEO_DRAW_PIXEL
フォアカラーで1ドット描画する
Definition: video_ioctl.h:67
void draw_quarter_circle(short x0, short y0, short r, char q)
1/4の円を描画する
Definition: graphics.c:1207
void clear_clip_rect(void)
クリッピングエリアを無効にする
Definition: graphics.c:254
#define IOCMD_VIDEO_DRAW_BITS
ビットパターンを描画する
Definition: video_ioctl.h:68
int get_draw_frame(void)
描画するフレームバッファ番号を取得する
Definition: graphics.c:246
#define IOCMD_VIDEO_GETDISPFRAME
表示フレーム番号を取得する
Definition: video_ioctl.h:48
#define GRP_DRAWMODE_REVERSE
Draw the foreground with back color. Draw the background with fore color.
Definition: graphics.h:61
unsigned char * data
ビットマップデータポインタ
Definition: graphics.h:89
void draw_fill_ellipse(short xc, short yc, short rx, short ry)
塗りつぶした楕円を描画する
Definition: graphics.c:1335
void draw_round_rect(struct st_rect *rect, short r)
角の丸い矩形を描画する
Definition: graphics.c:748
int tkprintf(const char *fmt,...)
非タスクコンテキスト実行用メッセージ出力
Definition: tkprintf.c:100
unsigned short type
ビデオデバイスタイプ(VIDEOTYPE_*)
Definition: video_ioctl.h:31
short right
右下頂点のX座標
Definition: graphics.h:67
#define IOCMD_VIDEO_SCROLL
表示位置を変更(スクロール)する
Definition: video_ioctl.h:53
void draw_point(short x, short y)
点を描画する
Definition: graphics.c:447
unsigned char get_draw_mode(void)
描画モードを取得する
Definition: graphics.c:426
カーネル用機能限定printf
void draw_enlarged_bitmap(short px, short py, struct st_bitmap *bitmap, int rate)
拡大したビットマップデータを描画する
Definition: graphics.c:1160
int set_display_frame(int fnum)
表示するフレームバッファ番号を設定する
Definition: graphics.c:204
int init_graphics(char *devname)
グラフィックスライブラリを初期化する
Definition: graphics.c:305
void draw_v_line(short x, short y, short height)
垂直線を描画する
Definition: graphics.c:511
void set_clip_box(struct st_box *box)
クリッピングエリアを四角形で指定する
Definition: graphics.c:279
void draw_sector(short x, short y, short er, short ir, char q)
扇形を描画する
Definition: graphics.c:1732
void draw_round_fill_box(struct st_box *box, short r)
塗りつぶした角の丸い四角を描画する
Definition: graphics.c:1421
int set_draw_frame(int fnum)
描画するフレームバッファ番号を設定する
Definition: graphics.c:236
void clear_screen(void)
画面を全て0で描画する
Definition: graphics.c:338
unsigned short width
表示幅ドット数
Definition: video_ioctl.h:32
void get_screen_info(short *width, short *height)
スクリーンのサイズ情報を取得する
Definition: graphics.c:329
void draw_fill_circle(short x0, short y0, short r)
塗りつぶした円を描画する
Definition: graphics.c:1253
void draw_ellipse(short xc, short yc, short rx, short ry)
楕円を描画する
Definition: graphics.c:1283
void draw_bitmap(short px, short py, struct st_bitmap *bitmap)
ビットマップデータを描画する
Definition: graphics.c:1146
void draw_line(short x, short y, short xe, short ye)
直線を描画する
Definition: graphics.c:664
void scroll_rect_v(struct st_rect *rect, short pixel)
矩形範囲を縦方向にスクロールする
Definition: graphics.c:1882
void draw_round_fill_rect(struct st_rect *rect, short r)
角の丸い塗りつぶした矩形を描画する
Definition: graphics.c:838
#define IOCMD_VIDEO_LOCK_DEVICE
デバイスをMUTEXロックする
Definition: video_ioctl.h:44
short height
高さ
Definition: graphics.h:88
int register_graphics_dev(struct st_device *dev)
グラフィックライブラリにデバイスを登録する
Definition: graphics.c:148
void box2rect(struct st_rect *rect, struct st_box *box)
box -> rect 変換
Definition: graphics_op.c:162
void draw_image(short px, short py, short width, short height, void *image, short dw)
イメージデータを描画する
Definition: graphics.c:1840
unsigned short frame_num
表示可能フレーム数
Definition: video_ioctl.h:35
#define IOCMD_VIDEO_SET_BACKCOLOR
バックカラーを設定する
Definition: video_ioctl.h:65
void and_rect(struct st_rect *a, struct st_rect *s1, struct st_rect *s2)
2つの矩形のアンドを求める
Definition: graphics_op.c:24
short empty_rect(struct st_rect *r)
矩形が0か調べる
Definition: graphics_op.c:70
unsigned int mem_size
フレームバッファメモリサイズ
Definition: video_ioctl.h:37
#define IOCMD_VIDEO_SETDISPFRAME
表示フレーム番号を設定する
Definition: video_ioctl.h:47
void draw_round_box(struct st_box *box, short r)
角の丸い四角を描画する
Definition: graphics.c:1406
void draw_h_line(short x, short y, short width)
水平線を描画する
Definition: graphics.c:477
void draw_rect(struct st_rect *rect)
矩形を描画する
Definition: graphics.c:694
#define GRP_DRAWMODE_FOREONLY
Draw the foreground with back color. No draw the background.
Definition: graphics.h:62
デバイスドライバAPI
デバイスドライバ構造体
Definition: device.h:25
void get_clip_rect(struct st_rect *rect)
クリッピングエリアを矩形で取得する
Definition: graphics.c:293
unsigned int get_forecolor(void)
描画の色を取得する
Definition: graphics.c:382
#define IOCMD_VIDEO_WRITE_WORD
2バイト表示データを転送する(未使用)
Definition: video_ioctl.h:59
int ioctl_device(struct st_device *dev, unsigned int com, unsigned int arg, void *param)
デバイスを制御する
Definition: device.c:525
short width
Definition: graphics.h:87
char name[MAX_DEVNAMELRN]
デバイス名文字列
Definition: device.h:26
void draw_bitdata(short px, short py, short width, short height, unsigned char *data, short dw)
ビットデータを描画する
Definition: graphics.c:1041
void draw_fill_rect(struct st_rect *rect)
塗りつぶした矩形を描画する
Definition: graphics.c:821
#define IOCMD_VIDEO_SET_FORECOLOR
フォアカラーを設定する
Definition: video_ioctl.h:64
void draw_box(struct st_box *box)
四角を描画する
Definition: graphics.c:1391
グラフィックライブラリ
unsigned short PIXEL_DATA
$gsc グラフィックデバイスは24ビットカラー
Definition: graphics.h:17
機能限定printf
unsigned int get_backcolor(void)
描画の背景色を取得する
Definition: graphics.c:404
unsigned short color_depth
色深度(VCOLORDEP_*)
Definition: video_ioctl.h:34
void set_draw_mode(unsigned char mode)
描画モードを設定する
Definition: graphics.c:414