enhanced logging
[swftools.git] / lib / devices / opengl.c
index 2a57216..b897120 100644 (file)
@@ -15,7 +15,6 @@
 
 typedef struct _fontlist {
     gfxfont_t*font;
-    char*id;
     struct _fontlist*next;
 } fontlist_t;
 
@@ -30,8 +29,7 @@ typedef struct _internal {
     GLUtesselator *tesselator_tex;
 } internal_t;
 
-int verbose = 1;
-
+static int verbose = 1;
 static void dbg(char*format, ...)
 {
     char buf[1024];
@@ -123,6 +121,7 @@ void opengl_endclip(struct _gfxdevice*dev)
 
 void opengl_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
 {
+    dbg("stroke");
     internal_t*i = (internal_t*)dev->internal;
     char running = 0;
     gfxline_t*l=0;
@@ -154,6 +153,7 @@ void opengl_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxc
 
 void opengl_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
 {
+    dbg("fill");
     internal_t*i = (internal_t*)dev->internal;
     char running = 0;
     int len = 0;
@@ -203,6 +203,7 @@ void opengl_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
 
 void opengl_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
 {
+    dbg("fillbitmap");
     internal_t*i = (internal_t*)dev->internal;
     char running = 0;
     int len = 0;
@@ -253,6 +254,7 @@ void opengl_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gf
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
     
+    
     gluTessBeginPolygon(i->tesselator_tex, NULL);
     l = line;
     len = 0;
@@ -287,6 +289,7 @@ void opengl_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gf
 
        l=l->next;
     }
+
     if(running) {
        running = 0;
        gluTessEndContour(i->tesselator_tex);
@@ -303,21 +306,20 @@ void opengl_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gr
     dbg("fillgradient");
 }
 
-void opengl_addfont(gfxdevice_t*dev, char*fontid, gfxfont_t*font)
+void opengl_addfont(gfxdevice_t*dev, gfxfont_t*font)
 {
     internal_t*i = (internal_t*)dev->internal;
     
     fontlist_t*last=0,*l = i->fontlist;
     while(l) {
        last = l;
-       if(!strcmp((char*)l->id, fontid)) {
+       if(!strcmp((char*)l->font->id, font->id)) {
            return; // we already know this font
        }
        l = l->next;
     }
     l = (fontlist_t*)rfx_calloc(sizeof(fontlist_t));
     l->font = font;
-    l->id = strdup(fontid);
     l->next = 0;
     if(last) {
        last->next = l;
@@ -326,26 +328,24 @@ void opengl_addfont(gfxdevice_t*dev, char*fontid, gfxfont_t*font)
     }
 }
 
-void opengl_drawchar(gfxdevice_t*dev, char*fontid, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
+void opengl_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     internal_t*i = (internal_t*)dev->internal;
 
-    if(i->font && i->fontid && !strcmp(fontid, i->fontid)) {
+    if(i->font && i->font->id && !strcmp(font->id, i->font->id)) {
        // current font is correct
     } else {
        fontlist_t*l = i->fontlist;
        i->font = 0;
-       i->fontid = 0;
        while(l) {
-           if(!strcmp((char*)l->id, fontid)) {
+           if(!strcmp((char*)l->font->id, font->id)) {
                i->font = l->font;
-               i->fontid = l->id;
                break;
            }
            l = l->next;
        }
        if(i->font == 0) {
-           fprintf(stderr, "Unknown font id: %s", fontid);
+           fprintf(stderr, "Unknown font id: %s", font->id);
            return;
        }
     }