static void
gdk_quartz_draw_drawable (GdkDrawable *drawable,
			  GdkGC       *gc,
			  GdkPixmap   *src,
			  gint         xsrc,
			  gint         ysrc,
			  gint         xdest,
			  gint         ydest,
			  gint         width,
			  gint         height,
			  GdkDrawable *original_src)
{
  int src_depth = gdk_drawable_get_depth (src);
  int dest_depth = gdk_drawable_get_depth (drawable);
  GdkDrawableImplQuartz *src_impl;

  if (GDK_IS_WINDOW_IMPL_QUARTZ (src))
    {
      GdkWindowImplQuartz *window_impl;

      window_impl = GDK_WINDOW_IMPL_QUARTZ (src);

      /* We do support moving areas on the same drawable, if it can be done
       * by using a scroll. FIXME: We need to check that the params support
       * this hack, and make sure it's done properly with any offsets etc?
       */
      if (drawable == (GdkDrawable *)window_impl)
        {
          [window_impl->view scrollRect:NSMakeRect (xsrc, ysrc, width, height)
                                     by:NSMakeSize (xdest - xsrc, ydest - ysrc)];


        }
      else
static cairo_t *
gdk_cairo_create (GdkDrawable *drawable)
{
    int width, height;
    cairo_t *cr = NULL;
    cairo_surface_t *surface = NULL;
    GdkVisual *visual = gdk_drawable_get_visual (drawable);

    gdk_drawable_get_size (drawable, &width, &height);
    if (visual)
	surface = cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),
					     GDK_DRAWABLE_XID (drawable),
					     GDK_VISUAL_XVISUAL (visual),
					     width, height);
    else if (gdk_drawable_get_depth (drawable) == 1)
	surface = cairo_xlib_surface_create_for_bitmap
	    (GDK_PIXMAP_XDISPLAY (drawable),
	     GDK_PIXMAP_XID (drawable),
	     GDK_SCREEN_XSCREEN (gdk_drawable_get_screen (drawable)),
	     width, height);
    else {
	g_warning ("Using Cairo rendering requires the drawable argument to\n"
		   "have a specified colormap. All windows have a colormap,\n"
		   "however, pixmaps only have colormap by default if they\n"
		   "were created with a non-NULL window argument. Otherwise\n"
		   "a colormap must be set on them with "
		   "gdk_drawable_set_colormap");
	return NULL;
    }
    if (surface) {
	cr = cairo_create (surface);
	cairo_surface_destroy (surface);
    }
    return cr;
}
void GtkPaintContext::updatePixmap(GtkWidget *area, int w, int h) {
	if ((myPixmap != 0) && ((myWidth != w) || (myHeight != h))) {
		gdk_pixmap_unref(myPixmap);
		myPixmap = 0;
		if (myTextGC != 0) {
			gdk_gc_unref(myTextGC);
			gdk_gc_unref(myFillGC);
			gdk_gc_unref(myBackGC);
			myTextGC = 0;
			myFillGC = 0;
			myBackGC = 0;
		}
	}

	if (myPixmap == 0) {
		myWidth = w;
		myHeight = h;
		myPixmap = gdk_pixmap_new(area->window, myWidth, myHeight, gdk_drawable_get_depth(area->window));
	}

	if (myTextGC == 0) {
		myTextGC = gdk_gc_new(myPixmap);
		myFillGC = gdk_gc_new(myPixmap);
		myBackGC = gdk_gc_new(myPixmap);
	}

	if (myContext == 0) {
		myContext = gtk_widget_get_pango_context(area);
		if (myFontDescription != 0) {
			myAnalysis.font = pango_context_load_font(myContext, myFontDescription);
			myAnalysis.shape_engine = pango_font_find_shaper(myAnalysis.font, 0, 0);
		}
	}
}
static int
gdk_quartz_get_depth (GdkDrawable *drawable)
{
  /* This is a bit bogus but I'm not sure the other way is better */

  return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_QUARTZ (drawable)->wrapper);
}
Beispiel #5
0
GdkPixbuf *
meta_ui_get_pixbuf_from_pixmap (Pixmap   pmap)
{
  GdkPixmap *gpmap;
  GdkScreen *screen;
  GdkPixbuf *pixbuf;
  GdkColormap *cmap;
  int width, height, depth;

  gpmap = gdk_pixmap_foreign_new (pmap);
  screen = gdk_drawable_get_screen (gpmap);

  gdk_drawable_get_size (GDK_DRAWABLE (gpmap), &width, &height);
  
  depth = gdk_drawable_get_depth (GDK_DRAWABLE (gpmap));
  if (depth <= 24)
    cmap = gdk_screen_get_rgb_colormap (screen);
  else
    cmap = gdk_screen_get_rgba_colormap (screen);
  
  pixbuf = gdk_pixbuf_get_from_drawable (NULL, gpmap, cmap, 0, 0, 0, 0,
                                         width, height);

  g_object_unref (gpmap);

  return pixbuf;
}
Beispiel #6
0
XRenderPictFormat *
get_format_for_drawable (decor_t *d, GdkDrawable *drawable)
{
    if (!d->frame_window || gdk_drawable_get_depth (drawable) == 32)
	return xformat_rgba;

    return xformat_rgb;
}
static GdkColormap*
get_cmap (GdkPixmap *pixmap)
{
  GdkColormap *cmap;

  cmap = gdk_drawable_get_colormap (pixmap);
  if (cmap)
    g_object_ref (G_OBJECT (cmap));

  if (cmap == NULL)
    {
      if (gdk_drawable_get_depth (pixmap) == 1)
        {
          /* try null cmap */
          cmap = NULL;
        }
      else
        {
          /* Try system cmap */
          GdkScreen *screen = gdk_drawable_get_screen (GDK_DRAWABLE (pixmap));
          cmap = gdk_screen_get_system_colormap (screen);
          g_object_ref (G_OBJECT (cmap));
        }
    }

  /* Be sure we aren't going to blow up due to visual mismatch */
  if (cmap &&
#if GTK_CHECK_VERSION(2,21,0)
      (gdk_visual_get_depth (gdk_colormap_get_visual (cmap)) !=
       gdk_drawable_get_depth (pixmap))
#else
      (gdk_colormap_get_visual (cmap)->depth !=
       gdk_drawable_get_depth (pixmap))
#endif
     )
    {
      g_object_unref (G_OBJECT (cmap));
      cmap = NULL;
    }
  
  return cmap;
}
Beispiel #8
0
GdkColormap *
get_colormap_for_drawable (GdkDrawable *d)
{
    GdkDisplay *display = gdk_display_get_default ();
    GdkScreen  *screen  = gdk_display_get_default_screen (display);

    if (gdk_drawable_get_depth (d) == 32)
	return gdk_screen_get_rgba_colormap (screen);

    return gdk_screen_get_rgb_colormap (screen);
}
Beispiel #9
0
cdCtxCanvas *cdgdkCreateCanvas(cdCanvas* canvas, GdkDrawable* wnd, GdkScreen* scr, GdkVisual* vis)
{
  cdCtxCanvas *ctxcanvas = (cdCtxCanvas *)malloc(sizeof(cdCtxCanvas));
  memset(ctxcanvas, 0, sizeof(cdCtxCanvas));

  ctxcanvas->scr = scr;
  ctxcanvas->vis = vis;
  ctxcanvas->wnd = wnd;

  ctxcanvas->gc = gdk_gc_new(wnd);
  
  if (!ctxcanvas->gc) 
  {
    free(canvas);
    return NULL;
  }

  ctxcanvas->fontcontext = gdk_pango_context_get();
#if PANGO_VERSION_CHECK(1,16,0)
  pango_context_set_language(ctxcanvas->fontcontext, pango_language_get_default());
#endif

  ctxcanvas->canvas = canvas;
  canvas->ctxcanvas = ctxcanvas;
  
  gdk_drawable_get_size(wnd, &ctxcanvas->canvas->w, &ctxcanvas->canvas->h);
  ctxcanvas->depth = gdk_drawable_get_depth(wnd);

  canvas->bpp = ctxcanvas->depth;
  canvas->xres = ((double)gdk_screen_get_width(scr)  / (double)gdk_screen_get_width_mm(scr));
  canvas->yres = ((double)gdk_screen_get_height(scr) / (double)gdk_screen_get_height_mm(scr));
  canvas->w_mm = ((double)canvas->w) / canvas->xres;
  canvas->h_mm = ((double)canvas->h) / canvas->yres;
  canvas->invert_yaxis = 1;

  if (canvas->bpp <= 8)
  {
    ctxcanvas->colormap = gdk_gc_get_colormap(ctxcanvas->gc);
    if (!ctxcanvas->colormap)
    {
      ctxcanvas->colormap = gdk_colormap_get_system();
      gdk_gc_set_colormap(ctxcanvas->gc, ctxcanvas->colormap);
    }
    ctxcanvas->num_colors = ctxcanvas->colormap->size;
  }

  cdRegisterAttribute(canvas, &gc_attrib);
  cdRegisterAttribute(canvas, &rotate_attrib);
  cdRegisterAttribute(canvas, &pangoversion_attrib);
  cdRegisterAttribute(canvas, &imgdither_attrib);
  cdRegisterAttribute(canvas, &interp_attrib);

  return ctxcanvas;
}
Beispiel #10
0
gchar *
_gdk_win32_drawable_description (GdkDrawable *d)
{
  gint width, height, depth;

  gdk_drawable_get_size (d, &width, &height);
  depth = gdk_drawable_get_depth (d);

  return static_printf
    ("%s:%p:%dx%dx%d",
     G_OBJECT_TYPE_NAME (d),
     GDK_DRAWABLE_HANDLE (d),
     width, height, depth);
}
Beispiel #11
0
void iupDrawUpdateSize(IdrawCanvas* dc)
{
  int w, h;
  gdk_drawable_get_size(dc->wnd, &w, &h);

  if (w != dc->w || h != dc->h)
  {
    g_object_unref(dc->pixmap_gc); 
    g_object_unref(dc->pixmap); 

    dc->pixmap = gdk_pixmap_new(dc->wnd, dc->w, dc->h, gdk_drawable_get_depth(dc->wnd));
    dc->pixmap_gc = gdk_gc_new(dc->pixmap);
  }
}
Beispiel #12
0
IdrawCanvas* iupdrvDrawCreateCanvas(Ihandle* ih)
{
  IdrawCanvas* dc = calloc(1, sizeof(IdrawCanvas));

  dc->ih = ih;
  dc->wnd = (GdkWindow*)IupGetAttribute(ih, "DRAWABLE");
  dc->gc = gdk_gc_new(dc->wnd);

  gdk_drawable_get_size(dc->wnd, &dc->w, &dc->h);

  dc->pixmap = gdk_pixmap_new(dc->wnd, dc->w, dc->h, gdk_drawable_get_depth(dc->wnd));
  dc->pixmap_gc = gdk_gc_new(dc->pixmap);

  return dc;
}
Beispiel #13
0
IdrawCanvas* iupDrawCreateCanvas(Ihandle* ih)
{
  IdrawCanvas* dc = calloc(1, sizeof(IdrawCanvas));

  dc->ih = ih;
  dc->wnd = iupgtkGetWindow(ih->handle);
  dc->gc = gdk_gc_new(dc->wnd);

  gdk_drawable_get_size(dc->wnd, &dc->w, &dc->h);

  dc->pixmap = gdk_pixmap_new(dc->wnd, dc->w, dc->h, gdk_drawable_get_depth(dc->wnd));
  dc->pixmap_gc = gdk_gc_new(dc->pixmap);

  return dc;
}
Beispiel #14
0
static GdkColormap*
get_cmap (GdkPixmap *pixmap)
{
  GdkColormap *cmap;

  cmap = gdk_drawable_get_colormap (pixmap);
  if (cmap)
    g_object_ref (G_OBJECT (cmap));

  if (cmap == NULL)
    {
      if (gdk_drawable_get_depth (pixmap) == 1)
        {
          meta_verbose ("Using NULL colormap for snapshotting bitmap\n");
          cmap = NULL;
        }
      else
        {
          meta_verbose ("Using system cmap to snapshot pixmap\n");
          cmap = gdk_screen_get_system_colormap (gdk_drawable_get_screen (pixmap));

          g_object_ref (G_OBJECT (cmap));
        }
    }

  /* Be sure we aren't going to blow up due to visual mismatch */
  if (cmap &&
      (gdk_colormap_get_visual (cmap)->depth !=
       gdk_drawable_get_depth (pixmap)))
    {
      cmap = NULL;
      meta_verbose ("Switching back to NULL cmap because of depth mismatch\n");
    }

  return cmap;
}
Beispiel #15
0
static gboolean
cairo_menu_item_expose (GtkWidget *widget,GdkEventExpose *event)
{
  CairoMenuItemPrivate * priv = GET_PRIVATE(widget);  

  if (priv->cairo_style)
  {
    PangoLayout *layout;    
    double x,y,width,height;
    gchar * label;

    g_object_get (widget,
                  "label",&label,
                  NULL);
    cairo_t * cr = gdk_cairo_create (widget->window);
    g_debug ("%s:  bit depth = %d",__func__,gdk_drawable_get_depth (widget->window));
//    g_debug ("Region %d,%d: %dx%d",event->area.x, event->area.y,event->area.width, event->area.height);
    x = event->area.x;
    y = event->area.y;
    width = event->area.width;
    height = event->area.height;    
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);    
    cairo_set_source_rgba (cr,0.0,1.0,0.0,0.1);
    cairo_rectangle (cr, x,y,width,height);
    cairo_fill (cr);    
    layout = pango_cairo_create_layout (cr);

    pango_font_description_set_absolute_size (priv->font_description,  height * 0.8 * PANGO_SCALE);
    pango_layout_set_font_description (layout, priv->font_description);
    pango_layout_set_text (layout, label, -1);  

    cairo_set_source_rgba (cr,1.0,1.0,1.0,0.3);
    cairo_move_to (cr,x+height * 1.1,y+height*0.1);
    pango_cairo_show_layout (cr, layout);          
    cairo_destroy (cr);
    g_object_unref (layout);
    g_free (label);
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}
Beispiel #16
0
GdkPixmap *
create_native_pixmap_and_wrap (int	  w,
			       int	  h,
			       GtkWidget *parent_style_window)
{
    GdkWindow *window;

    if (w <= 0 || h <= 0)
	abort ();

    window = gtk_widget_get_window (parent_style_window);
    GdkPixmap *pixmap =
	   gdk_pixmap_foreign_new (XCreatePixmap (gdk_x11_display_get_xdisplay (gdk_display_get_default ()),
						  GDK_WINDOW_XID (window), w, h,
						  gdk_drawable_get_depth (window)));
    GdkColormap *cmap = get_colormap_for_drawable (GDK_DRAWABLE (pixmap));
    gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
    return pixmap;
}
Beispiel #17
0
GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
{
	GdkPixmap* gpmap;
	GdkScreen* screen;
	GdkPixbuf* pixbuf;
#if !GTK_CHECK_VERSION (3, 0, 0)
	GdkColormap* cmap;
#endif
	int width;
	int height;
	int depth;

	gpmap = gdk_pixmap_foreign_new(pmap);
	screen = gdk_drawable_get_screen(gpmap);

#if GTK_CHECK_VERSION(3, 0, 0)
	width = gdk_window_get_width(GDK_WINDOW(gpmap));
	height = gdk_window_get_height(GDK_WINDOW(gpmap));
#else
	gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
#endif

	depth = gdk_drawable_get_depth(GDK_DRAWABLE(gpmap));

#if !GTK_CHECK_VERSION (3, 0, 0)
	if (depth <= 24)
	{
		cmap = gdk_screen_get_system_colormap(screen);
	}
	else
	{
		cmap = gdk_screen_get_rgba_colormap(screen);
	}
#endif

	pixbuf = gdk_pixbuf_get_from_drawable(NULL, gpmap, cmap, 0, 0, 0, 0, width, height);

	g_object_unref(gpmap);

	return pixbuf;
}
Beispiel #18
0
void ZLGtkPaintContext::setFillColor(ZLColor color, FillStyle style) {
	if (style == SOLID_FILL) {
		::setColor(myFillGC, color);
		gdk_gc_set_fill(myFillGC, GDK_SOLID);
	} else {
		gdk_gc_set_fill(myFillGC, GDK_TILED);
		if (myPixmap != 0) {
			if (myTilePixmap != 0) {
				gdk_pixmap_unref(myTilePixmap);
			}
			static GdkColor fgColor;
			::setColor(fgColor, color);
			static GdkColor bgColor;
			::setColor(bgColor, myBackColor);
			static char data[] = { 0x0C, 0x0C, 0x03, 0x03 };
			myTilePixmap = gdk_pixmap_create_from_data(
				myPixmap, data, 4, 4, gdk_drawable_get_depth(myPixmap), &fgColor, &bgColor
			);
			gdk_gc_set_tile(myFillGC, myTilePixmap);
		}
	}
}
Beispiel #19
0
static gboolean
cairo_menu_expose (GtkWidget *widget,GdkEventExpose *event)
{
  struct {
    GtkWidget *container;
    GdkEventExpose *event;
  } data;

  CairoMenuPrivate * priv = GET_PRIVATE(widget);  
  data.container = widget;
  data.event = event;

  if (priv->cairo_style)
  {
    double x,y,width,height;

    cairo_t * cr = gdk_cairo_create (widget->window);
    g_debug ("%s:  bit depth = %d",__func__,gdk_drawable_get_depth (widget->window));
    //g_debug ("Region %d,%d: %dx%d",event->area.x, event->area.y,event->area.width, event->area.height);
    x = event->area.x;
    y = event->area.y;
    width = event->area.width;
    height = event->area.height;    
    cairo_set_source_rgba (cr,1.0,0.0,0.0,0.5);
    cairo_rectangle (cr, x,y,width,height);
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
    cairo_fill (cr);    

    gtk_container_forall (GTK_CONTAINER (widget),_expose_child,&data);

    cairo_destroy (cr);
    return TRUE;
  }
  else
  {    
    return FALSE;
  }
}
Beispiel #20
0
static gboolean
bb_sample_widget_expose_event (GtkWidget      *widget,
                               GdkEventExpose *expose)
{
  BbSampleWidget *swidget = BB_SAMPLE_WIDGET (widget);
  if (swidget->last_drawing == NULL
   || widget->allocation.width != (gint) swidget->last_width
   || widget->allocation.height != (gint) swidget->last_height)
    {
      guint8 *rgb_data;
      guint width = widget->allocation.width;
      guint height = widget->allocation.height;
      guint depth = gdk_drawable_get_depth (widget->window);
      if (swidget->last_drawing)
        g_object_unref (swidget->last_drawing);
      rgb_data = g_malloc (3 * width * height);
      switch (swidget->mode)
        {
        case BB_SAMPLE_WIDGET_MODE_AMPLITUDE:
          render_amplitude_image (swidget, width, height, rgb_data);
          break;
        case BB_SAMPLE_WIDGET_MODE_FREQUENCY:
          render_fft_image (swidget, width, height, rgb_data);
          break;
        default:
          g_assert_not_reached ();
        }
      swidget->last_drawing = gdk_pixmap_new (widget->window,
                                              width, height, depth);
      gdk_draw_rgb_image (swidget->last_drawing, widget->style->fg_gc[0],
                          0, 0, width, height, GDK_RGB_DITHER_NORMAL,
                          rgb_data, width * 3);
      g_free (rgb_data);
      swidget->last_width = width;
      swidget->last_height = height;
    }

  gdk_draw_drawable (widget->window, widget->style->fg_gc[0],
                     swidget->last_drawing,
                     expose->area.x, expose->area.y,
                     expose->area.x, expose->area.y,
                     expose->area.width, expose->area.height);
  if (swidget->has_time)
    {
      gint x = time_pixel (swidget);
      if (expose->area.x <= (int) x
       && (int)x < expose->area.x + expose->area.width)
        {
          if (swidget->time_line_gc == NULL)
            {
              GdkColor col;
              swidget->time_line_gc = gdk_gc_new (widget->window);
              col.red = 65535;
              col.green = 65535;
              col.blue = 0;
              gdk_gc_set_rgb_fg_color (swidget->time_line_gc, &col);
            }
          gdk_draw_line (widget->window, swidget->time_line_gc,
                         x, expose->area.y,
                         x, expose->area.y + expose->area.height);
        }
    }
  return TRUE;
}
Beispiel #21
0
GdkPixmap*
gdk_pixmap_create_from_data (GdkDrawable   *drawable,
                             const gchar *data,
                             gint         width,
                             gint         height,
                             gint         depth,
                             const GdkColor    *fg,
                             const GdkColor    *bg)
{
  GdkPixmap *pixmap;
  gi_gc_ptr_t gc;

  g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
  g_return_val_if_fail (data != NULL, NULL);
  g_return_val_if_fail (drawable != NULL || depth > 0, NULL);
  g_return_val_if_fail (width > 0 && height > 0, NULL);

  GDK_NOTE (MISC, g_print ("gdk_pixmap_create_from_data: %dx%dx%d\n",
                           width, height, depth));

  pixmap = gdk_pixmap_new (drawable, width, height, depth);

  if (pixmap)
    {
	  gi_window_id_t wid;
      gi_image_t* surface;
      gchar            *dst;
      gint              pitch;
      gint              src_pitch;
	  unsigned format ;	  

      depth = gdk_drawable_get_depth (pixmap);
      src_pitch = width * ((depth + 7) / 8);
	  format = gi_get_choose_format(depth); //FIMXE

      wid = GDK_DRAWABLE_IMPL_GIX (GDK_PIXMAP_OBJECT (pixmap)->impl)->window_id;

	   surface=gi_create_image_depth(width,height,format);
	   dst = (gchar*)surface->rgba;
	   pitch = surface->pitch;

        {
          gint i;

          for (i = 0; i < height; i++)
            {
              memcpy (dst, data, src_pitch);
              dst += pitch;
              data += src_pitch;
            }

		gc = gi_create_gc(wid,NULL);
			gi_draw_image(gc,surface,0,0);
		gi_destroy_gc(gc);
		gi_destroy_image(surface);

        }
    }

  return pixmap;
}
Beispiel #22
0
static void
desk_draw_bg(pager_priv *pg, desk *d1)
{
    Pixmap xpix;
    GdkPixmap *gpix;
    GdkPixbuf *p1, *p2;
    gint width, height, depth;
    FbBg *bg = pg->fbbg;
    GtkWidget *widget = d1->da;

    ENTER;
    if (d1->no) {
        desk *d0 = d1->pg->desks[0];
        if (d0->gpix && d0->xpix != None
              && d0->da->allocation.width == widget->allocation.width
              && d0->da->allocation.height == widget->allocation.height) {
            gdk_draw_drawable(d1->gpix,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  d0->gpix,0, 0, 0, 0,
                  widget->allocation.width,
                  widget->allocation.height);
            d1->xpix = d0->xpix;
            DBG("copy gpix from d0 to d%d\n", d1->no);
            RET();
        }
    }
    xpix = fb_bg_get_xrootpmap(bg);
    d1->xpix = None;
    width = widget->allocation.width;
    height = widget->allocation.height;
    DBG("w %d h %d\n", width, height);
    if (width < 3 || height < 3)
        RET();

    // create new pix
    xpix = fb_bg_get_xrootpmap(bg);
    if (xpix == None)
        RET();
    depth = gdk_drawable_get_depth(widget->window);
    gpix = fb_bg_get_xroot_pix_for_area(bg, 0, 0, gdk_screen_width(), gdk_screen_height(), depth);
    if (!gpix) {
        ERR("fb_bg_get_xroot_pix_for_area failed\n");
        RET();
    }
    p1 = gdk_pixbuf_get_from_drawable(NULL, gpix, NULL, 0, 0, 0, 0,
          gdk_screen_width(), gdk_screen_height());
    if (!p1) {
        ERR("gdk_pixbuf_get_from_drawable failed\n");
        goto err_gpix;
    }
    p2 = gdk_pixbuf_scale_simple(p1, width, height,
          //GDK_INTERP_NEAREST
          //GDK_INTERP_TILES
          //GDK_INTERP_BILINEAR
          GDK_INTERP_HYPER
        );
    if (!p2) {
        ERR("gdk_pixbuf_scale_simple failed\n");
        goto err_p1;
    }
    gdk_draw_pixbuf(d1->gpix, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
          p2, 0, 0, 0, 0, width, height,  GDK_RGB_DITHER_NONE, 0, 0);

    d1->xpix = xpix;
    g_object_unref(p2);
 err_p1:
    g_object_unref(p1);
 err_gpix:
    g_object_unref(gpix);
    RET();
}
Beispiel #23
0
/*
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None). See GLX 1.3 spec.
 */
GdkGLPixmap *
gdk_gl_pixmap_new (GdkGLConfig *glconfig,
                   GdkPixmap   *pixmap,
                   const int   *attrib_list)
{
  GdkGLPixmap *glpixmap;
  GdkGLPixmapImplWin32 *impl;

  gint width, height;
  gint depth;
  GdkPixmap *pixmap_gl = NULL;

  HBITMAP hbitmap_gl;
  HDC hdc_gl = NULL;
  PIXELFORMATDESCRIPTOR pfd;
  int pixel_format;

  HBITMAP hbitmap_gdk;
  HDC hdc_gdk = NULL;

  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_WIN32 (glconfig), NULL);
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);

  /*
   * Create offscreen rendering area.
   */

  gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
  depth = gdk_drawable_get_depth (GDK_DRAWABLE (pixmap));

  pixmap_gl = gdk_pixmap_new (NULL, width, height, depth);
  if (pixmap_gl == NULL)
    goto FAIL;

  /*
   * Source (OpenGL) DIB
   */

  hbitmap_gl = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap_gl));

  /* Create a memory DC. */
  hdc_gl = CreateCompatibleDC (NULL);
  if (hdc_gl == NULL)
    {
      g_warning ("cannot create a memory DC");
      goto FAIL;
    }

  /* Select the bitmap. */
  if (SelectObject (hdc_gl, hbitmap_gl) == NULL)
    {
      g_warning ("cannot select DIB");
      goto FAIL;
    }

  /*
   * Choose pixel format.
   */

  pfd = *(GDK_GL_CONFIG_PFD (glconfig));
  /* Draw to bitmap */
  pfd.dwFlags &= ~PFD_DRAW_TO_WINDOW;
  pfd.dwFlags |= PFD_DRAW_TO_BITMAP;

  /* Request pfd.cColorBits should exclude alpha bitplanes. */
  pfd.cColorBits = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits;

  GDK_GL_NOTE_FUNC_IMPL ("ChoosePixelFormat");

  pixel_format = ChoosePixelFormat (hdc_gl, &pfd);
  if (pixel_format == 0)
    {
      g_warning ("cannot choose pixel format");
      goto FAIL;
    }

  /*
   * Set pixel format.
   */

  GDK_GL_NOTE_FUNC_IMPL ("SetPixelFormat");

  if (!SetPixelFormat (hdc_gl, pixel_format, &pfd))
    {
      g_warning ("cannot set pixel format");
      goto FAIL;
    }

  DescribePixelFormat (hdc_gl, pixel_format, sizeof (pfd), &pfd);

  GDK_GL_NOTE (MISC, g_message (" -- impl->pixel_format = 0x%x", pixel_format));
  GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd));

  /*
   * Destination (GDK) DIB
   */

  hbitmap_gdk = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap));

  /* Create a memory DC. */
  hdc_gdk = CreateCompatibleDC (hdc_gl);
  if (hdc_gdk == NULL)
    {
      g_warning ("cannot create a memory DC");
      goto FAIL;
    }

  /*
   * Instantiate the GdkGLPixmapImplWin32 object.
   */

  glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_WIN32, NULL);
  impl = GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap);

  glpixmap->drawable = GDK_DRAWABLE (pixmap);
  g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable),
                             (gpointer *) &(glpixmap->drawable));

  impl->pixmap_gl = pixmap_gl;

  impl->width = width;
  impl->height = height;

  impl->pfd = pfd;
  impl->pixel_format = pixel_format;

  impl->glconfig = glconfig;
  g_object_ref (G_OBJECT (impl->glconfig));

  impl->hdc_gl = hdc_gl;

  impl->hdc_gdk = hdc_gdk;
  impl->hbitmap_gdk = hbitmap_gdk;

  impl->is_destroyed = FALSE;

  return glpixmap;

 FAIL:

  if (hdc_gdk != NULL)
    DeleteDC (hdc_gdk);

  if (hdc_gl != NULL)
    DeleteDC (hdc_gl);

  if (pixmap_gl != NULL)
    g_object_unref (G_OBJECT (pixmap_gl));

  return NULL;  
}
Beispiel #24
0
static VALUE
rg_depth(VALUE self)
{
    return INT2NUM(gdk_drawable_get_depth(_SELF(self)));
}