Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2006:
[Freeciv-Dev] (PR#16431) [PATCH] cairo conversion of gtk2 client
Home

[Freeciv-Dev] (PR#16431) [PATCH] cairo conversion of gtk2 client

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: patg@xxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#16431) [PATCH] cairo conversion of gtk2 client
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Fri, 21 Apr 2006 11:06:31 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=16431 >

This made the terrain look right with the "nv" driver, so the image
probably gets corrupted somewhere in the outcommented part. 

struct sprite *load_gfxfile(const char *filename)
{
  cairo_surface_t *img, *surface;
  cairo_t *cr;
  int w, h;

  img = cairo_image_surface_create_from_png(filename);

  if (cairo_surface_status(img) != CAIRO_STATUS_SUCCESS) {
    freelog(LOG_FATAL, "Failed reading graphics file: %s", filename);
    freelog(LOG_FATAL, "  %s", cairo_status_to_string(
                                cairo_surface_status(img)));
    exit(EXIT_FAILURE);
  }

  w = cairo_image_surface_get_width(img);
  h = cairo_image_surface_get_height(img);
  /* Creating a surface of the same type as the one used by GDK
   * This groups everything server-side, reducing memory use/round trips */
  /* TODO: Benchmark glitz to see how much juice you can get from it */
#if 0  
  cr = gdk_cairo_create(GDK_DRAWABLE(root_window));
  assert(cairo_status(cr) == CAIRO_STATUS_SUCCESS);
  surface = cairo_surface_create_similar(cairo_get_target(cr), 
                                         CAIRO_CONTENT_COLOR_ALPHA, w, h);
  assert(cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS);
  cairo_destroy(cr);
  cr = cairo_create(surface);
  assert(cairo_status(cr) == CAIRO_STATUS_SUCCESS);

  /* Cleaning that surface and getting a copy of the image */
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
  cairo_rectangle(cr, 0.0, 0.0, w, h);
  cairo_fill(cr);

  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
  cairo_set_source_surface(cr, img, 0.0, 0.0);
  cairo_paint(cr);
  cairo_destroy(cr);
  cairo_surface_destroy(img);
#endif 
  return surface_to_sprite(/*surface*/img, w, h);
}





[Prev in Thread] Current Thread [Next in Thread]