PageRenderTime 77ms CodeModel.GetById 66ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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/*
 26 * History:
 27 * ================================================================
 28 * 2011-04-18 Li XianJing <xianjimli@hotmail.com> created
 29 */
 30
 31#include "ftk_log.h"
 32#include "ftk_util.h"
 33#include "ftk_bitmap.h"
 34#include "ftk_canvas.h"
 35#include "ftk_globals.h"
 36
 37typedef struct _CanvasSkiaPrivInfo
 38{
 39	int w;
 40	int h;
 41}PrivInfo;
 42
 43static Ret ftk_canvas_dummy_sync_gc(FtkCanvas* thiz)
 44{
 45	int size = 0;
 46	DECL_PRIV(thiz, priv);
 47	FtkColor c = thiz->gc.fg;
 48	
 49	if(thiz->gc.font != NULL)
 50	{
 51		char desc[64] = {0};
 52		size = ftk_font_desc_get_size(thiz->gc.font);
 53	}
 54
 55	return RET_OK;
 56}
 57
 58static Ret ftk_canvas_dummy_set_clip(FtkCanvas* thiz, FtkRegion* clip)
 59{
 60	return RET_OK;
 61}
 62
 63static Ret ftk_canvas_dummy_draw_pixels(FtkCanvas* thiz, FtkPoint* points, int nr)
 64{
 65	DECL_PRIV(thiz, priv);
 66
 67	return RET_OK;
 68}
 69
 70static Ret ftk_canvas_dummy_draw_line(FtkCanvas* thiz, int x1, int y1, int x2, int y2)
 71{
 72	DECL_PRIV(thiz, priv);
 73
 74	return RET_OK;
 75}
 76
 77static Ret ftk_canvas_dummy_clear_rect(FtkCanvas* thiz, int x, int y, int w, int h)
 78{
 79	DECL_PRIV(thiz, priv);
 80	
 81	return RET_OK;
 82}
 83
 84static Ret ftk_canvas_dummy_draw_rect(FtkCanvas* thiz, int x, int y, int w, int h, 
 85	int round, int fill)
 86{
 87	return RET_OK;
 88}
 89
 90static Ret ftk_canvas_dummy_draw_bitmap(FtkCanvas* thiz, FtkBitmap* bitmap, 
 91	FtkRect* src_r, FtkRect* dst_r, int alpha)
 92{
 93	Ret ret = RET_FAIL;
 94	DECL_PRIV(thiz, priv);
 95
 96	return ret;
 97}
 98
 99static Ret ftk_canvas_dummy_draw_string(FtkCanvas* thiz, int x, int y, 
100	const char* str, int len, int vcenter)
101{
102	DECL_PRIV(thiz, priv);
103
104	return RET_OK;
105}
106
107static Ret fk_canvas_dummy_lock_buffer(FtkCanvas* thiz, FtkBitmap** bitmap)
108{
109	DECL_PRIV(thiz, priv);
110
111	return RET_OK;
112}
113
114static Ret ftk_canvas_dummy_unlock_buffer(FtkCanvas* thiz)
115{
116	return RET_OK;
117}
118
119static void ftk_canvas_dummy_destroy(FtkCanvas* thiz)
120{
121	DECL_PRIV(thiz, priv);
122
123	if(thiz != NULL)
124	{
125		FTK_FREE(thiz);
126	}
127
128	return;
129}
130
131static int ftk_canvas_dummy_get_char_extent(FtkCanvas* thiz, unsigned short code)
132{
133	return 0;
134}
135
136static int ftk_canvas_dummy_get_str_extent(FtkCanvas* thiz, const char* str, int len)
137{
138	return 0;
139}
140
141static const FtkCanvasVTable g_canvas_dummy_vtable=
142{
143	ftk_canvas_dummy_sync_gc,
144	ftk_canvas_dummy_set_clip,
145	ftk_canvas_dummy_draw_pixels,
146	ftk_canvas_dummy_draw_line,
147	ftk_canvas_dummy_clear_rect,
148	ftk_canvas_dummy_draw_rect,
149
150	ftk_canvas_dummy_draw_bitmap,
151	ftk_canvas_dummy_draw_string,
152	ftk_canvas_dummy_get_str_extent,
153	ftk_canvas_dummy_get_char_extent,
154	fk_canvas_dummy_lock_buffer,
155	ftk_canvas_dummy_unlock_buffer,
156	ftk_canvas_dummy_destroy
157};
158
159FtkCanvas* ftk_canvas_create(int w, int h, FtkColor* clear_color)
160{
161	FtkCanvas* thiz = NULL;
162	return_val_if_fail(w > 0 && h > 0 && clear_color != NULL, NULL);
163
164	thiz = (FtkCanvas*)FTK_ZALLOC(sizeof(FtkCanvas) + sizeof(PrivInfo));
165
166	ftk_logd("ftk_canvas_create: %d %d\n", w, h);
167	if(thiz != NULL)
168	{
169		DECL_PRIV(thiz, priv);
170
171		thiz->gc.bg = *clear_color;
172		thiz->gc.fg.a = 0xff;
173		thiz->gc.fg.r = 0xff - clear_color->r;
174		thiz->gc.fg.g = 0xff - clear_color->g;
175		thiz->gc.fg.b = 0xff - clear_color->b;
176		thiz->gc.mask = FTK_GC_FG | FTK_GC_BG;
177		thiz->vtable = &g_canvas_dummy_vtable;
178	}
179
180	return thiz;
181}
182