From 647b9fb49a5bb636c9b0da6b708083328238543a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Feb 2010 20:12:44 +0100 Subject: [PATCH] glamor: Add CopyWindow implementation so it doesn't crash. --- glamor/Makefile.am | 1 + glamor/glamor.c | 4 +++ glamor/glamor_copyarea.c | 18 ++++++++++-- glamor/glamor_copywindow.c | 60 ++++++++++++++++++++++++++++++++++++++ glamor/glamor_priv.h | 18 ++++++++++++ 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 glamor/glamor_copywindow.c diff --git a/glamor/Makefile.am b/glamor/Makefile.am index ce7869244..17139c09f 100644 --- a/glamor/Makefile.am +++ b/glamor/Makefile.am @@ -18,6 +18,7 @@ AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) libglamor_la_SOURCES = \ glamor.c \ glamor_copyarea.c \ + glamor_copywindow.c \ glamor_core.c \ glamor_fill.c \ glamor_fillspans.c \ diff --git a/glamor/glamor.c b/glamor/glamor.c index ba16d63fc..7bb093474 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -210,6 +210,9 @@ glamor_init(ScreenPtr screen) glamor_priv->saved_change_window_attributes = screen->ChangeWindowAttributes; screen->ChangeWindowAttributes = glamor_change_window_attributes; + glamor_priv->saved_copy_window = screen->CopyWindow; + screen->CopyWindow = glamor_copy_window; + glamor_priv->saved_bitmap_to_region = screen->BitmapToRegion; screen->BitmapToRegion = glamor_bitmap_to_region; @@ -247,6 +250,7 @@ glamor_fini(ScreenPtr screen) screen->DestroyPixmap = glamor_priv->saved_destroy_pixmap; screen->GetSpans = glamor_priv->saved_get_spans; screen->ChangeWindowAttributes = glamor_priv->saved_change_window_attributes; + screen->CopyWindow = glamor_priv->saved_copy_window; screen->BitmapToRegion = glamor_priv->saved_bitmap_to_region; #ifdef RENDER ps->Composite = glamor_priv->saved_composite; diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c index b0f6a7e2f..7f14f2a4c 100644 --- a/glamor/glamor_copyarea.c +++ b/glamor/glamor_copyarea.c @@ -32,7 +32,7 @@ * GC CopyArea implementation */ -static void +void glamor_copy_n_to_n(DrawablePtr src, DrawablePtr dst, GCPtr gc, @@ -49,6 +49,8 @@ glamor_copy_n_to_n(DrawablePtr src, PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst); int i; + goto fail; + glamor_set_alu(gc->alu); if (!glamor_set_planemask(dst_pixmap, gc->planemask)) goto fail; @@ -64,6 +66,18 @@ glamor_copy_n_to_n(DrawablePtr src, } fail: + glamor_fallback("from %p to %p (%c,%c)\n", src, dst, + glamor_get_drawable_location(src), + glamor_get_drawable_location(dst)); + if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) { + if (glamor_prepare_access(src, GLAMOR_ACCESS_RO)) { + fbCopyNtoN(src, dst, gc, box, nbox, + dx, dy, reverse, upsidedown, bitplane, + closure); + glamor_finish_access(src); + } + glamor_finish_access(dst); + } glamor_set_alu(GXcopy); glamor_set_planemask(dst_pixmap, ~0); } @@ -79,8 +93,6 @@ glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, glamor_pixmap_private *src_priv = glamor_get_pixmap_private(src_pixmap); RegionPtr region; - goto fail; - if (!GLEW_EXT_framebuffer_blit) { glamor_fallback("glamor_copy_area(): " "EXT_framebuffer_blit unsupported\n"); diff --git a/glamor/glamor_copywindow.c b/glamor/glamor_copywindow.c new file mode 100644 index 000000000..1e840a934 --- /dev/null +++ b/glamor/glamor_copywindow.c @@ -0,0 +1,60 @@ +/* + * Copyright © 2008 Intel Corporation + * Copyright © 1998 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "glamor_priv.h" + +/** @file glamor_copywindow.c + * + * Screen CopyWindow implementation. + */ + +void glamor_copy_window(WindowPtr win, DDXPointRec old_origin, + RegionPtr src_region) +{ + RegionRec dst_region; + int dx, dy; + PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win); + + dx = old_origin.x - win->drawable.x; + dy = old_origin.y - win->drawable.y; + REGION_TRANSLATE(win->drawable.pScreen, src_region, -dx, -dy); + + REGION_INIT(win->drawable.pScreen, &dst_region, NullBox, 0); + + REGION_INTERSECT(win->drawable.pScreen, &dst_region, &win->borderClip, + src_region); +#ifdef COMPOSITE + if (pixmap->screen_x || pixmap->screen_y) + REGION_TRANSLATE(win->drawable.pScreen, &dst_region, + -pixmap->screen_x, -pixmap->screen_y); +#endif + + miCopyRegion(&pixmap->drawable, &pixmap->drawable, + NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL); + + REGION_UNINIT(win->drawable.pScreen, &dst_region); +} diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index dc3b77860..adc6997cc 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -61,6 +61,7 @@ typedef struct glamor_screen_private { CompositeProcPtr saved_composite; TrapezoidsProcPtr saved_trapezoids; ChangeWindowAttributesProcPtr saved_change_window_attributes; + CopyWindowProcPtr saved_copy_window; BitmapToRegionProcPtr saved_bitmap_to_region; /* glamor_finishaccess */ @@ -138,6 +139,23 @@ PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable); RegionPtr glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc, int srcx, int srcy, int width, int height, int dstx, int dsty); +void +glamor_copy_n_to_n(DrawablePtr src, + DrawablePtr dst, + GCPtr gc, + BoxPtr box, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure); + +/* glamor_copywindow.c */ +void glamor_copy_window(WindowPtr win, DDXPointRec old_origin, + RegionPtr src_region); + /* glamor_core.c */ Bool glamor_prepare_access(DrawablePtr drawable, glamor_access_t access); void glamor_finish_access(DrawablePtr drawable);