/src/canvas/dummy/ftk_canvas_dummy.c

http://ftk.googlecode.com/ · C · 182 lines · 120 code · 34 blank · 28 comment · 9 complexity · a0fe179fa462577f8f4601b65ba3f58a MD5 · raw file

  1. /*
  2. * File: ftk_canvas_dummy.c
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief: dummy canvas implemntation.
  5. *
  6. * Copyright (c) 2009 - 2011 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2011-04-18 Li XianJing <xianjimli@hotmail.com> created
  28. */
  29. #include "ftk_log.h"
  30. #include "ftk_util.h"
  31. #include "ftk_bitmap.h"
  32. #include "ftk_canvas.h"
  33. #include "ftk_globals.h"
  34. typedef struct _CanvasSkiaPrivInfo
  35. {
  36. int w;
  37. int h;
  38. }PrivInfo;
  39. static Ret ftk_canvas_dummy_sync_gc(FtkCanvas* thiz)
  40. {
  41. int size = 0;
  42. DECL_PRIV(thiz, priv);
  43. FtkColor c = thiz->gc.fg;
  44. if(thiz->gc.font != NULL)
  45. {
  46. char desc[64] = {0};
  47. size = ftk_font_desc_get_size(thiz->gc.font);
  48. }
  49. return RET_OK;
  50. }
  51. static Ret ftk_canvas_dummy_set_clip(FtkCanvas* thiz, FtkRegion* clip)
  52. {
  53. return RET_OK;
  54. }
  55. static Ret ftk_canvas_dummy_draw_pixels(FtkCanvas* thiz, FtkPoint* points, int nr)
  56. {
  57. DECL_PRIV(thiz, priv);
  58. return RET_OK;
  59. }
  60. static Ret ftk_canvas_dummy_draw_line(FtkCanvas* thiz, int x1, int y1, int x2, int y2)
  61. {
  62. DECL_PRIV(thiz, priv);
  63. return RET_OK;
  64. }
  65. static Ret ftk_canvas_dummy_clear_rect(FtkCanvas* thiz, int x, int y, int w, int h)
  66. {
  67. DECL_PRIV(thiz, priv);
  68. return RET_OK;
  69. }
  70. static Ret ftk_canvas_dummy_draw_rect(FtkCanvas* thiz, int x, int y, int w, int h,
  71. int round, int fill)
  72. {
  73. return RET_OK;
  74. }
  75. static Ret ftk_canvas_dummy_draw_bitmap(FtkCanvas* thiz, FtkBitmap* bitmap,
  76. FtkRect* src_r, FtkRect* dst_r, int alpha)
  77. {
  78. Ret ret = RET_FAIL;
  79. DECL_PRIV(thiz, priv);
  80. return ret;
  81. }
  82. static Ret ftk_canvas_dummy_draw_string(FtkCanvas* thiz, int x, int y,
  83. const char* str, int len, int vcenter)
  84. {
  85. DECL_PRIV(thiz, priv);
  86. return RET_OK;
  87. }
  88. static Ret fk_canvas_dummy_lock_buffer(FtkCanvas* thiz, FtkBitmap** bitmap)
  89. {
  90. DECL_PRIV(thiz, priv);
  91. return RET_OK;
  92. }
  93. static Ret ftk_canvas_dummy_unlock_buffer(FtkCanvas* thiz)
  94. {
  95. return RET_OK;
  96. }
  97. static void ftk_canvas_dummy_destroy(FtkCanvas* thiz)
  98. {
  99. DECL_PRIV(thiz, priv);
  100. if(thiz != NULL)
  101. {
  102. FTK_FREE(thiz);
  103. }
  104. return;
  105. }
  106. static int ftk_canvas_dummy_get_char_extent(FtkCanvas* thiz, unsigned short code)
  107. {
  108. return 0;
  109. }
  110. static int ftk_canvas_dummy_get_str_extent(FtkCanvas* thiz, const char* str, int len)
  111. {
  112. return 0;
  113. }
  114. static const FtkCanvasVTable g_canvas_dummy_vtable=
  115. {
  116. ftk_canvas_dummy_sync_gc,
  117. ftk_canvas_dummy_set_clip,
  118. ftk_canvas_dummy_draw_pixels,
  119. ftk_canvas_dummy_draw_line,
  120. ftk_canvas_dummy_clear_rect,
  121. ftk_canvas_dummy_draw_rect,
  122. ftk_canvas_dummy_draw_bitmap,
  123. ftk_canvas_dummy_draw_string,
  124. ftk_canvas_dummy_get_str_extent,
  125. ftk_canvas_dummy_get_char_extent,
  126. fk_canvas_dummy_lock_buffer,
  127. ftk_canvas_dummy_unlock_buffer,
  128. ftk_canvas_dummy_destroy
  129. };
  130. FtkCanvas* ftk_canvas_create(int w, int h, FtkColor* clear_color)
  131. {
  132. FtkCanvas* thiz = NULL;
  133. return_val_if_fail(w > 0 && h > 0 && clear_color != NULL, NULL);
  134. thiz = (FtkCanvas*)FTK_ZALLOC(sizeof(FtkCanvas) + sizeof(PrivInfo));
  135. ftk_logd("ftk_canvas_create: %d %d\n", w, h);
  136. if(thiz != NULL)
  137. {
  138. DECL_PRIV(thiz, priv);
  139. thiz->gc.bg = *clear_color;
  140. thiz->gc.fg.a = 0xff;
  141. thiz->gc.fg.r = 0xff - clear_color->r;
  142. thiz->gc.fg.g = 0xff - clear_color->g;
  143. thiz->gc.fg.b = 0xff - clear_color->b;
  144. thiz->gc.mask = FTK_GC_FG | FTK_GC_BG;
  145. thiz->vtable = &g_canvas_dummy_vtable;
  146. }
  147. return thiz;
  148. }