From 4f139db92fb283792adae8d39a49a083e4382fb5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 20 Aug 2009 14:43:43 -0700 Subject: [PATCH] glamor: Add getspans implementation. --- glamor/Makefile.am | 1 + glamor/glamor.c | 4 +++ glamor/glamor_getspans.c | 74 ++++++++++++++++++++++++++++++++++++++++ glamor/glamor_priv.h | 10 ++++++ 4 files changed, 89 insertions(+) create mode 100644 glamor/glamor_getspans.c diff --git a/glamor/Makefile.am b/glamor/Makefile.am index b6a64fbe2..2d9fdf57c 100644 --- a/glamor/Makefile.am +++ b/glamor/Makefile.am @@ -18,4 +18,5 @@ libglamor_la_SOURCES = \ glamor_core.c \ glamor_fill.c \ glamor_fillspans.c \ + glamor_getspans.c \ glamor.h diff --git a/glamor/glamor.c b/glamor/glamor.c index 050dd3d66..0aa9db83b 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -123,6 +123,9 @@ glamor_init(ScreenPtr screen) glamor_priv->saved_destroy_pixmap = screen->DestroyPixmap; screen->DestroyPixmap = glamor_destroy_pixmap; + glamor_priv->saved_get_spans = screen->GetSpans; + screen->GetSpans = glamor_get_spans; + glamor_init_solid_shader(screen); return TRUE; @@ -141,4 +144,5 @@ glamor_fini(ScreenPtr screen) screen->CreateGC = glamor_priv->saved_create_gc; screen->CreatePixmap = glamor_priv->saved_create_pixmap; screen->DestroyPixmap = glamor_priv->saved_destroy_pixmap; + screen->GetSpans = glamor_priv->saved_get_spans; } diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c new file mode 100644 index 000000000..b10a29dcd --- /dev/null +++ b/glamor/glamor_getspans.c @@ -0,0 +1,74 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "glamor_priv.h" + +void +glamor_get_spans(DrawablePtr drawable, + int wmax, + DDXPointPtr points, + int *widths, + int count, + char *dst) +{ + ScreenPtr screen = drawable->pScreen; + PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen); + PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); + + if (screen_pixmap != pixmap) { + fbGetSpans(drawable, wmax, points, widths, count, dst); + return; + } else { + GLenum format, type; + int i; + switch (drawable->depth) { + case 24: + case 32: + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + default: + ErrorF("Unknown getspans depth %d\n", drawable->depth); + return; + } + if (!glamor_set_destination_pixmap(pixmap)) + return; + for (i = 0; i < count; i++) { + glReadPixels(points[i].x - pixmap->screen_x, + points[i].y - pixmap->screen_y, + widths[i], + 1, + format, type, + dst); + dst += PixmapBytePad(widths[i], drawable->depth); + } + } +} diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 3216a7a4a..016a404bc 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -42,6 +42,7 @@ typedef struct glamor_screen_private { CreateGCProcPtr saved_create_gc; CreatePixmapProcPtr saved_create_pixmap; DestroyPixmapProcPtr saved_destroy_pixmap; + GetSpansProcPtr saved_get_spans; /* glamor_solid */ GLint solid_prog; @@ -102,4 +103,13 @@ void glamor_fill_spans(DrawablePtr drawable, void glamor_init_solid_shader(ScreenPtr screen); +/* glamor_getspans.c */ +void +glamor_get_spans(DrawablePtr drawable, + int wmax, + DDXPointPtr points, + int *widths, + int nspans, + char *dst_start); + #endif /* GLAMOR_PRIV_H */