[waimea] Cairo 1.0.2 compliant

Mathieu Berland mathieubrlnd at yahoo.fr
Wed Jan 25 21:43:59 EET 2006


Hi all,

I made a patch from the last dist tarball for waimea to build with 
Cairo 1.0.2.

(last dist tarball seems to be here :
http://lists.freedesktop.org/archives/waimea/2006-January/000193.html )

Note that I've only made the diff in the source directory (no autoconf 
and others...). I've named this version 0.6.0, if David agree ;-)

And..... note that I don't know anything to Cairo ! I've made the 
modifications from the great '<old function>_deprecated_by_<new 
function>' macros. Waimea builds and works on my Debian 
powerpc-unstable GNU/Linux but I'm not sure of what I've made.

Regards.



=========================================================

diff -urN waimea-0.5.1/src/Event.cc waimea-0.6.0/src/Event.cc
--- waimea-0.5.1/src/Event.cc	2006-01-18 20:11:41.000000000 +0100
+++ waimea-0.6.0/src/Event.cc	2006-01-21 14:48:55.000000000 +0100
@@ -146,18 +146,6 @@
                  if (*it == dw) it = __render_list.erase(it);
                  else it++;
              }
-
-            static cairo_t *cr = NULL;
-            if (cr == NULL) {
-                cr = cairo_create();
-                /* XXX: cairo need a call to this function for text
-                   support to be initialized, will probably dissapear 
soon. */
-                cairo_set_target_drawable(cr, waimea->display,
-                                          
DefaultRootWindow(waimea->display));
-            }
-
-            dw->renderWindow(cr);
-
          } else {
              FD_ZERO(&rfds);
              FD_SET(xfd, &rfds);
diff -urN waimea-0.5.1/src/Render.cc waimea-0.6.0/src/Render.cc
--- waimea-0.5.1/src/Render.cc	2006-01-18 20:11:41.000000000 +0100
+++ waimea-0.6.0/src/Render.cc	2006-01-18 21:25:20.000000000 +0100
@@ -364,21 +364,21 @@
          if (crsurface) {
              groupsurface =
                  cairo_surface_create_similar(crsurface,
-                                             CAIRO_FORMAT_ARGB32,
+                                             CAIRO_CONTENT_COLOR_ALPHA,
                                               width, height);
          } else if (parent_surface) {
            groupsurface =
                  cairo_surface_create_similar(parent_surface,
-                                             CAIRO_FORMAT_ARGB32,
+                                             CAIRO_CONTENT_COLOR_ALPHA,
                                               width, height);
          } else {
              if (ws->waimea->client_side_rendering) {
                  data = new unsigned char[width * height * 
sizeof(WaPixel)];
                  memset (data, 0, width * height * sizeof(WaPixel));
                  groupsurface =
-                    cairo_surface_create_for_image((char *) data,
-                                                   CAIRO_FORMAT_ARGB32,
-                                                   width, height, 
width * 4);
+                    cairo_image_surface_create_for_data(data,
+                                                        
CAIRO_FORMAT_ARGB32,
+                                                        width, height, 
width * 4);
              } else {
                  GC gc;
                  XGCValues gcv;
@@ -400,8 +400,8 @@
              }
          }

-        cairo_set_target_surface(cr, groupsurface);
-        cairo_default_matrix(cr);
+        cr = cairo_create(groupsurface);
+        cairo_identity_matrix(cr);
          cairo_set_operator(cr, RENDER_OPERATOR_DEFAULT);
          list<RenderOp *>::iterator oit = operations.begin();
          for (; oit != operations.end(); oit++) {
@@ -419,13 +419,14 @@
      }

      if (crsurface) {
-        cairo_set_target_surface(cr, crsurface);
+        cr = cairo_create(crsurface);
          cairo_set_operator(cr, RENDER_OPERATOR_DEFAULT);
          if (xrop_set) cairo_set_operator(cr, xrop);
          cairo_translate(cr, x, y);
          cairo_rotate(cr, rotation);
-        cairo_set_alpha(cr, opacity);
-        cairo_show_surface(cr, cache_surface->crsurface, width, 
height);
+        cairo_paint_with_alpha(cr, opacity);
+        cairo_set_source_surface(cr, cache_surface->crsurface, width, 
height);
+        cairo_paint(cr);
      }

      if (return_surface)
@@ -822,11 +823,8 @@
        if (rx != ry) {
          cairo_matrix_t *matrix;

-        matrix = cairo_matrix_create ();
          cairo_matrix_scale (matrix, ry / rx, 1.0);
          cairo_pattern_set_matrix (pattern, matrix);
-
-        cairo_matrix_destroy (matrix);
        }
      } break;
      case GroupPatternType: {
@@ -842,13 +840,13 @@
          group->return_surface = NULL;
          group->parent_surface = NULL;

-        cairo_default_matrix(cr);
+        cairo_identity_matrix(cr);
          cairo_move_to(cr, 0.0, 0.0);
          pattern = 
cairo_pattern_create_for_surface(subsurface->crsurface);
          subsurface->unref();
          cairo_restore(cr);
        } else {
-        cairo_set_rgb_color (cr, 1.0, 1.0, 1.0);
+        cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
          return;
        }
      } break;
@@ -857,23 +855,23 @@
    int stops = 0;
    list<WaColorStop *>::iterator it = color_stops.begin();
    for (; it != color_stops.end(); ++it) {
-    cairo_pattern_add_color_stop (pattern, (*it)->offset,
-                                  (*it)->color->red,
-                                  (*it)->color->green,
-                                  (*it)->color->blue,
-                                  (*it)->color->alpha);
+    cairo_pattern_add_color_stop_rgba (pattern, (*it)->offset,
+                                       (*it)->color->red,
+                                       (*it)->color->green,
+                                       (*it)->color->blue,
+                                       (*it)->color->alpha);
      stops++;
    }

    if (stops == 0) {
-    cairo_pattern_add_color_stop (pattern, 0.0, 0.0, 0.0, 0.0, 1.0);
-    cairo_pattern_add_color_stop (pattern, 1.0, 1.0, 1.0, 1.0, 1.0);
+    cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0.0, 0.0, 0.0, 
1.0);
+    cairo_pattern_add_color_stop_rgba (pattern, 1.0, 1.0, 1.0, 1.0, 
1.0);
    }

    cairo_pattern_set_filter (pattern, filter);
    cairo_pattern_set_extend (pattern, extend);

-  cairo_set_pattern (cr, pattern);
+  cairo_set_source (cr, pattern);

    cairo_pattern_destroy (pattern);
  }
@@ -1098,7 +1096,7 @@
            fill_color.setcairo_color(cr);
            if (fill_pattern)
              fill_pattern->setcairo_pattern(dwo, cr, NULL, w, h);
-          cairo_set_alpha(cr, fill_color.alpha);
+          cairo_paint_with_alpha(cr, fill_color.alpha);
            cairo_fill(cr);
            cairo_restore(cr);
          }
@@ -1417,7 +1415,7 @@
      if (name) delete [] name;
      if (bg_group) bg_group->unref();
      clear();
-    if (font) cairo_font_destroy(font);
+    if (font) cairo_font_face_destroy(font);
  }

  void RenderOpText::clear(void) {
@@ -1592,20 +1590,14 @@
      calc_length(bottom_spacing, bottom_spacing_u, dwo->ws->vdpi, h,
                  &bottom_space);

-    cairo_default_matrix(cr);
+    cairo_identity_matrix(cr);

      if (!font) {
-        cairo_select_font(cr, family, slant, weight);
-        /* font = cairo_current_font(cr);
-        if (!font)
-          return;
-
-        cairo_font_reference (font);
-        */
+        cairo_select_font_face(cr, family, slant, weight);
      } else
-      cairo_set_font (cr, font);
+      cairo_set_font_face (cr, font);

-    cairo_scale_font (cr, font_size);
+    cairo_set_font_size (cr, font_size);

      if (is_static)
          text = utf8;
@@ -1645,7 +1637,7 @@
              str[end_offset] = '\0';
              sinfo->text = str;

-            cairo_text_extents(cr, (unsigned char *) sinfo->text, 
&extents);
+            cairo_text_extents(cr, sinfo->text, &extents);
              str_y_pos = extents.height - extents.y_bearing;
              str_width = extents.width;
              str_height = extents.height;
@@ -1658,9 +1650,9 @@
              if (textptr[end_offset] == '\t') {
                  double tab, with_space;
                  if (space_width < 0.0) {
-                    cairo_text_extents(cr, (unsigned char *) "1 1", 
&extents);
+                    cairo_text_extents(cr, "1 1", &extents);
                      with_space = extents.width;
-                    cairo_text_extents(cr, (unsigned char *) "11", 
&extents);
+                    cairo_text_extents(cr, "11", &extents);
                      space_width = with_space - extents.width;
                  }
                  tab = ceil((linfo->width + space_width) / tab_space);
@@ -1731,13 +1723,13 @@
      cairo_save(cr);

      text_region = cairo_surface_create_similar(
-        cairo_current_target_surface(cr), CAIRO_FORMAT_ARGB32,
+        cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA,
          (unsigned int) ceil(width), (unsigned int) ceil(height));

-    cairo_set_target_surface(cr, text_region);
+    cr = cairo_create(text_region);

      if (bg_group) {
-        bg_group->parent_surface = cairo_current_target_surface(cr);
+        bg_group->parent_surface = cairo_get_target(cr);
          bg_group->return_surface = &subsurface;
          cairo_save(cr);
          bg_group->render(dwo, cr, NULL, (unsigned int) ceil(width),
@@ -1750,9 +1742,9 @@
              cairo_pattern_t *pattern;

              cairo_save(cr);
-            cairo_surface_set_repeat(subsurface->crsurface, true);
              pattern = 
cairo_pattern_create_for_surface(subsurface->crsurface);
-            cairo_set_pattern(cr, pattern);
+            cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+            cairo_set_source(cr, pattern);
              cairo_pattern_destroy(pattern);
              cairo_rectangle(cr, 0.0, 0.0, ceil(width), ceil(height));
              cairo_fill(cr);
@@ -1777,7 +1769,7 @@
              if (stroke || fill_pattern) {
                cairo_move_to(cr, (int) (left_space + (*sit)->x + pos_x),
                              (int) (y_off + y_pos));
-              cairo_text_path(cr, (unsigned char *) (*sit)->text);
+              cairo_text_path(cr, (*sit)->text);
                cairo_move_to(cr, 0.0, 0.0);
                draw(dwo, cr, crsurface, WA_ROUND_U(width),
                     WA_ROUND_U(height));
@@ -1787,12 +1779,12 @@
                  cairo_move_to(cr, (int) (left_space + (*sit)->x + 
pos_x +
                                           shadow_x_offset),
                                (int) (y_off + y_pos + shadow_y_offset));
-                cairo_show_text(cr, (unsigned char *) (*sit)->text);
+                cairo_show_text(cr, (*sit)->text);
                }
                fill_color.setcairo_color(cr);
                cairo_move_to(cr, (int) (left_space + (*sit)->x + pos_x),
                              (int) (y_off + y_pos));
-              cairo_show_text(cr, (unsigned char *) (*sit)->text);
+              cairo_show_text(cr, (*sit)->text);
              }
          }

@@ -1804,8 +1796,9 @@
      if (x || y) cairo_translate(cr, x, y);
      if (xrop_set) cairo_set_operator(cr, xrop);
      if (rotation) cairo_rotate(cr, rotation);
-    cairo_show_surface(cr, text_region, (unsigned int) ceil(width),
+    cairo_set_source_surface(cr, text_region, (unsigned int) 
ceil(width),
                         (unsigned int) ceil(height));
+    cairo_paint(cr);

      cairo_surface_destroy(text_region);

@@ -1848,7 +1841,7 @@
      calcPositionAndSize(w, h, dwo->ws->hdpi, dwo->ws->vdpi, &x, &y,
                          &width, &height);

-    if (color.alpha == 1.0) cairo_set_operator(cr, CAIRO_OPERATOR_SRC);
+    if (color.alpha == 1.0) cairo_set_operator(cr, 
CAIRO_OPERATOR_SOURCE);
      if (xrop_set) cairo_set_operator(cr, xrop);
      color.setcairo_color(cr);
      cairo_rectangle(cr, x, y, width, height);
@@ -1934,54 +1927,58 @@

      switch (scale) {
          case ImageNormalScaleType:
-            cairo_default_matrix(cr);
+            cairo_identity_matrix(cr);

              if (width != img->width || height != img->height) {
                  if (xrop_set) cairo_set_operator(cr, xrop);
-                cairo_operator_t op = cairo_current_operator(cr);
+                cairo_operator_t op = cairo_get_operator(cr);

-                cairo_surface_t *target = 
cairo_current_target_surface(cr);
+                cairo_surface_t *target = cairo_get_target(cr);
                  cairo_surface_t *scaled =
-                    cairo_surface_create_similar(target, 
CAIRO_FORMAT_ARGB32,
+                    cairo_surface_create_similar(target, 
CAIRO_CONTENT_COLOR_ALPHA,
                                                   (int) width + 2,
                                                   (int) height + 2);
-                cairo_set_target_surface(cr, scaled);
+                cr = cairo_create(scaled);
                  cairo_scale(cr, (double) width / (img->width -
                                                    ((img->width > 1)? 
1: 0)),
                              (double) height / (img->height -
                                                 ((img->height > 1)? 1: 
0)));
-                cairo_surface_set_filter(img->crsurface, filter);
-                cairo_set_operator(cr, CAIRO_OPERATOR_SRC);
-                cairo_show_surface(cr, img->crsurface,
-                                   img->width + 1, img->height + 1);
-                cairo_set_target_surface(cr, target);
-                cairo_default_matrix(cr);
+                pattern = 
cairo_pattern_create_for_surface(img->crsurface);
+                cairo_pattern_set_filter(pattern, filter);
+                cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+                cairo_set_source_surface(cr, img->crsurface,
+                                         img->width + 1, img->height + 
1);
+                cairo_paint(cr);
+                cr = cairo_create(target);
+                cairo_identity_matrix(cr);
                  cairo_translate(cr, x, y);
                  cairo_set_operator(cr, op);
-                cairo_show_surface(cr, scaled, (int) width + 2,
-                                   (int) height + 2);
+                cairo_set_source_surface(cr, scaled, (int) width + 2,
+                                         (int) height + 2);
+                cairo_paint(cr);
                  cairo_surface_destroy(scaled);
              } else {
                  if (xrop_set) cairo_set_operator(cr, xrop);
                  cairo_translate(cr, x, y);
                  cairo_rotate(cr, rotation);
-                cairo_show_surface(cr, img->crsurface,
-                                   img->width + 1, img->height + 1);
+                cairo_set_source_surface(cr, img->crsurface,
+                                         img->width + 1, img->height + 
1);
+                cairo_paint(cr);
              }
              break;
          case ImageTileScaleType: {
-            cairo_default_matrix(cr);
-            cairo_surface_set_repeat(img->crsurface, true);
+            cairo_identity_matrix(cr);
              cairo_translate(cr, x, y);
              cairo_rectangle(cr, 0, 0, width, height);
              cairo_move_to(cr, 0.0, 0.0);
-            cairo_default_matrix(cr);
+            cairo_identity_matrix(cr);
              pattern = cairo_pattern_create_for_surface(img->crsurface);
-            cairo_set_pattern(cr, pattern);
+            cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+            cairo_set_source(cr, pattern);
              cairo_pattern_destroy(pattern);
              if (xrop_set) cairo_set_operator(cr, xrop);
              cairo_fill(cr);
-            cairo_surface_set_repeat(img->crsurface, false);
+            cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
          } break;
      }

@@ -2275,16 +2272,19 @@
      cairo_operator_t crop;
  } operator_map[] = {
      { "clear", CAIRO_OPERATOR_CLEAR },
-    { "src", CAIRO_OPERATOR_SRC },
-    { "dst", CAIRO_OPERATOR_DST },
+
+    { "source", CAIRO_OPERATOR_SOURCE },
      { "over", CAIRO_OPERATOR_OVER },
-    { "overreverse", CAIRO_OPERATOR_OVER_REVERSE },
      { "in", CAIRO_OPERATOR_IN },
-    { "inreverse", CAIRO_OPERATOR_IN_REVERSE },
      { "out", CAIRO_OPERATOR_OUT },
-    { "outreverse", CAIRO_OPERATOR_OUT_REVERSE },
      { "atop", CAIRO_OPERATOR_ATOP },
-    { "atopreverse", CAIRO_OPERATOR_ATOP_REVERSE },
+
+    { "dest", CAIRO_OPERATOR_DEST },
+    { "destover", CAIRO_OPERATOR_DEST_OVER },
+    { "destin", CAIRO_OPERATOR_DEST_IN },
+    { "destout", CAIRO_OPERATOR_DEST_OUT },
+    { "destatop", CAIRO_OPERATOR_DEST_ATOP },
+
      { "xor", CAIRO_OPERATOR_XOR },
      { "add", CAIRO_OPERATOR_ADD },
      { "saturate", CAIRO_OPERATOR_SATURATE }
diff -urN waimea-0.5.1/src/Render.hh waimea-0.6.0/src/Render.hh
--- waimea-0.5.1/src/Render.hh	2006-01-18 20:11:41.000000000 +0100
+++ waimea-0.6.0/src/Render.hh	2006-01-18 20:55:39.000000000 +0100
@@ -247,8 +247,8 @@
      double getOpacity(void) { return alpha; }

      inline void setcairo_color(cairo_t *cr) {
-        cairo_set_rgb_color(cr, red, green, blue);
-        cairo_set_alpha(cr, alpha);
+        cairo_set_source_rgb(cr, red, green, blue);
+        cairo_paint_with_alpha(cr, alpha);
      }

      double red, green, blue, alpha;
@@ -503,7 +503,7 @@
      HorizontalAlignment text_halign;
      WaColor shadow_color;
      char *family;
-    cairo_font_t *font;
+    cairo_font_face_t *font;
      RenderGroup *bg_group;
      cairo_font_weight_t weight;
      cairo_font_slant_t slant;
diff -urN waimea-0.5.1/src/Screen.cc waimea-0.6.0/src/Screen.cc
--- waimea-0.5.1/src/Screen.cc	2006-01-18 20:11:41.000000000 +0100
+++ waimea-0.6.0/src/Screen.cc	2006-01-18 20:17:41.000000000 +0100
@@ -1561,10 +1561,10 @@

      if (waimea->client_side_rendering) {
          data = rgba;
-        surface = cairo_surface_create_for_image((char *) rgba,
-                                                 CAIRO_FORMAT_ARGB32,
-                                                 width, height,
-                                                 width * 
sizeof(WaPixel));
+        surface = cairo_image_surface_create_for_data(rgba,
+                                                      
CAIRO_FORMAT_ARGB32,
+                                                      width, height,
+                                                      width * 
sizeof(WaPixel));
      } else {
          pixmap = XCreatePixmap(display, id, width, height, 32);
          XImage *image = XCreateImage(display, visual, 32, ZPixmap, 0,
diff -urN waimea-0.5.1/src/Style.cc waimea-0.6.0/src/Style.cc
--- waimea-0.5.1/src/Style.cc	2006-01-18 20:11:41.000000000 +0100
+++ waimea-0.6.0/src/Style.cc	2006-01-18 20:34:21.000000000 +0100
@@ -647,9 +647,9 @@
                    (bgsurface)? bgsurface->height: 0,
                    p_x, p_y, w, h);
                  root_surface =
-                  cairo_surface_create_for_image((char *) root_data,
-                                                 CAIRO_FORMAT_ARGB32,
-                                                 w, h, w * 
sizeof(WaPixel));
+                  cairo_image_surface_create_for_data(root_data,
+                                                      
CAIRO_FORMAT_ARGB32,
+                                                      w, h, w * 
sizeof(WaPixel));
                } else {
                  root_pixmap = ws->getRootBgPixmap(
                    (bgsurface)? bgsurface->pixmap: None,
@@ -679,13 +679,14 @@
          sb->style->parent_surface = NULL;

          if (root_surface) {
-            cairo_set_target_surface(cr, root_surface);
+            cr = cairo_create(root_surface);
              cairo_set_operator(cr, RENDER_OPERATOR_DEFAULT);
              if (sb->style->xrop_set)
                  cairo_set_operator(cr, sb->style->xrop);
-            cairo_set_alpha(cr, sb->style->opacity);
-            cairo_default_matrix(cr);
-            cairo_show_surface(cr, return_surface->crsurface, w, h);
+            cairo_paint_with_alpha(cr, sb->style->opacity);
+            cairo_identity_matrix(cr);
+            cairo_set_source_surface(cr, return_surface->crsurface, w, 
h);
+            cairo_paint(cr);
          }

          if (shape) {
@@ -695,9 +696,9 @@
                  shape_data = new unsigned char[w * h * 
sizeof(WaPixel)];
                  memset (shape_data, 0, w * h * sizeof(WaPixel));
                  alpha_surface =
-                    cairo_surface_create_for_image((char *) shape_data,
-                                                   CAIRO_FORMAT_ARGB32,
-                                                   w, h, w * 
sizeof(WaPixel));
+                    cairo_image_surface_create_for_data(shape_data,
+                                                        
CAIRO_FORMAT_ARGB32,
+                                                        w, h, w * 
sizeof(WaPixel));
              } else {
                  GC gc;
                  XGCValues gcv;
@@ -715,15 +716,16 @@
                                                ws->colormap);
              }

-            cairo_set_target_surface(cr, alpha_surface);
+            cr = cairo_create(alpha_surface);

              if (sb->style->shapemask) {
                  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
                  sb->style->shapemask->render(this, cr, alpha_surface, 
w, h);
              } else {
                  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-                cairo_set_alpha(cr, sb->style->opacity);
-                cairo_show_surface(cr, return_surface->crsurface, w, 
h);
+                cairo_paint_with_alpha(cr, sb->style->opacity);
+                cairo_set_source_surface(cr, 
return_surface->crsurface, w, h);
+                cairo_paint(cr);
              }

              if (ws->waimea->client_side_rendering) {

=========================================================


	

	
		
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com



More information about the waimea mailing list