comparison src/graph_engine_skia.cpp @ 479:9a867333018b Android_Skia

mbe_create() and mbe_destroy() pass the compilation. This is the first time that MadButterfly Skia backend can be built without error.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 15 Nov 2009 16:21:09 +0800
parents ba64f928542b
children d38aca825822
comparison
equal deleted inserted replaced
478:b27a3460c7bd 479:9a867333018b
1 #include <stdio.h> 1 #include <stdio.h>
2 #include <SkCanva.h> 2 #include <SkCanvas.h>
3 #include <SkBitmap.h> 3 #include <SkBitmap.h>
4 #include <SkShader.h> 4 #include <SkShader.h>
5 5
6 #define C_START extern "C" { 6 #define C_START extern "C" {
7 #define C_END } 7 #define C_END }
13 13
14 struct _mbe_scaled_font_t { 14 struct _mbe_scaled_font_t {
15 struct _mb_font_face_t *face; 15 struct _mb_font_face_t *face;
16 co_aix fnt_mtx[6]; 16 co_aix fnt_mtx[6];
17 co_aix ctm[6]; 17 co_aix ctm[6];
18 } 18 };
19 struct _mbe_font_face_t {}; 19 struct _mbe_font_face_t {};
20 struct _mbe_t { 20 struct _mbe_t {
21 SkCanvas *canvas; 21 SkCanvas *canvas;
22 SkShader *shader; 22 SkShader *shader;
23 int shader_owned; 23 int shader_owned;
96 int mbe_in_fill(mbe_t *canvas, co_aix x, co_aix y) {} 96 int mbe_in_fill(mbe_t *canvas, co_aix x, co_aix y) {}
97 void mbe_stroke(mbe_t *canvas) {} 97 void mbe_stroke(mbe_t *canvas) {}
98 98
99 mbe_t *mbe_create(mbe_surface_t *target) { 99 mbe_t *mbe_create(mbe_surface_t *target) {
100 mbe_t *mbe; 100 mbe_t *mbe;
101 SkBitmap *bitmap = (SkBitmap *)target;
101 102
102 mbe = malloc(sizeof(_mbe_t)); 103 mbe = (mbe_t *)malloc(sizeof(mbe_t));
103 if(mbe == NULL) 104 if(mbe == NULL)
104 return NULL; 105 return NULL;
105 106
106 mbe->canvas = new SkCanvas(target); 107 mbe->canvas = new SkCanvas(*bitmap);
108 if(mbe->canvas == NULL) {
109 free(mbe);
110 return NULL;
111 }
112
107 mbe->shader = NULL; 113 mbe->shader = NULL;
108 mbe->shader_owned = 0; 114 mbe->shader_owned = 0;
109 115
110 return mbe; 116 return mbe;
111 } 117 }
112 118
113 void mbe_destroy(mbe_t *canvas) { 119 void mbe_destroy(mbe_t *canvas) {
114 delete cnavas->canvas; 120 delete canvas->canvas;
115 if(cnavas->shader && cnavas->shader_owned) 121 if(canvas->shader && canvas->shader_owned)
116 delete cnavas->shader; 122 delete canvas->shader;
117 free(canvas); 123 free(canvas);
118 } 124 }
119 125
120 void mbe_paint(mbe_t *canvas) {} 126 void mbe_paint(mbe_t *canvas) {}
121 void mbe_save(mbe_t *canvas) {} 127 void mbe_save(mbe_t *canvas) {}