xserver-multidpi/glamor/glamor_getspans.c
2011-09-26 16:46:30 +08:00

75 lines
2.2 KiB
C

/*
* 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 <eric@anholt.net>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#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);
}
}
}