I found what I think is a bug in XCopyArea. 

If you copy a pixmap to a window and some of the copied area is outside
the pixmap then that area in the destination window is cleared to the
background color (and possibly graphics exposes are sent).

If the GC has a clip region set so that the destination area that would
contain data from outside the pixmap is clipped out, then I would expect
it to not be cleared. 

However, that is not the case right now, even the clipped out area has
the destination cleared to the window background.

I'm attaching an xlib example.


#include  <X11/cursorfont.h> 
#include <stdio.h> 
#include <X11/Xlib.h> 

int
main (int argc, char *argv[]) 
{ 
  Display *display; 
  Window  win; 
  XSetWindowAttributes attributes; 
  GC gc;
  Colormap colormap;
  Pixmap pixmap; 
  Visual *visual; 
  int screen;
  int depth; 
  XGCValues gc_values; 
  XEvent event;
  XColor red = { 0, }; 
  XColor green = { 0, }; 
  XColor blue = { 0, };
  XRectangle rect;
  
  display = XOpenDisplay(NULL);
  screen = DefaultScreen(display);
  visual = DefaultVisual(display,screen); 
  depth  = DefaultDepth(display,screen);
  colormap = DefaultColormap (display, 0);
  
  red.red = 0xffff;
  XAllocColor (display, colormap, &red);
  green.green = 0xffff;
  XAllocColor (display, colormap, &green);
  blue.blue = 0xffff;
  XAllocColor (display, colormap, &blue);
  

  /* Create a 200x200 window with red background */
  attributes.background_pixel = red.pixel;
  win = XCreateWindow (display, XRootWindow(display,screen),
		       200,200, 200,200, 0, depth, InputOutput, visual,
		       CWBackPixel, &attributes);
  XSelectInput(display, win, ExposureMask | KeyPressMask);
  XMapWindow (display, win); 

  /* Create a 100x100 pixmap and fill it with green */
  pixmap = XCreatePixmap (display, win, 100, 100, depth);
  gc_values.foreground = green.pixel; 
  gc_values.background = WhitePixel(display,screen); 
  gc = XCreateGC (display, win, 
		  GCForeground | GCBackground, 
		  &gc_values); 
  XFillRectangle (display, pixmap, gc, 0, 0, 200, 200);

  do {
    XNextEvent(display, &event);
    
    if (event.type == Expose)
      {
	/* Fill the whole window with blue */
	XSetForeground (display, gc, blue.pixel);
	XFillRectangle (display, win, gc, 0, 0, 200, 200);

	/* Set up a clip region so that we only draw to the left
	   half of the window */
	rect.x = 0;
	rect.y = 0;
	rect.width = 100;
	rect.height = 200;
	XSetClipRectangles (display, gc, 0, 0, &rect, 1, Unsorted);

	/* Copy the pixmap to the middle of the window,
	   but use a y offset of 50 */
	XCopyArea (display,
		   pixmap, win, gc,
		   0, 50,
		   100, 100,
		   50, 50);
      }
  } while (event.type != KeyPress); 
  
  
  XCloseDisplay(display);
  
  return 0;
} 
  
_______________________________________________
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to