[PATCH 20/20] glamor: Remove old core rendering code
Keith Packard
keithp at keithp.com
Tue Mar 18 22:09:54 PDT 2014
The old core rendering paths are no longer in use, so remove the code.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
glamor/Makefile.am | 12 -
glamor/glamor.c | 6 -
glamor/glamor_copyarea.c | 630 -------------------------------------------
glamor/glamor_copyplane.c | 75 ------
glamor/glamor_copywindow.c | 56 ----
glamor/glamor_fill.c | 364 -------------------------
glamor/glamor_fillspans.c | 107 --------
glamor/glamor_getimage.c | 96 -------
glamor/glamor_getspans.c | 92 -------
glamor/glamor_polyfillrect.c | 123 ---------
glamor/glamor_polylines.c | 136 ----------
glamor/glamor_putimage.c | 161 -----------
glamor/glamor_setspans.c | 118 --------
glamor/glamor_tile.c | 298 --------------------
14 files changed, 2274 deletions(-)
delete mode 100644 glamor/glamor_copyarea.c
delete mode 100644 glamor/glamor_copyplane.c
delete mode 100644 glamor/glamor_copywindow.c
delete mode 100644 glamor/glamor_fill.c
delete mode 100644 glamor/glamor_fillspans.c
delete mode 100644 glamor/glamor_getimage.c
delete mode 100644 glamor/glamor_getspans.c
delete mode 100644 glamor/glamor_polyfillrect.c
delete mode 100644 glamor/glamor_polylines.c
delete mode 100644 glamor/glamor_putimage.c
delete mode 100644 glamor/glamor_setspans.c
delete mode 100644 glamor/glamor_tile.c
diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 0a38bc9..74f6ef1 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -8,21 +8,12 @@ libglamor_la_SOURCES = \
glamor.c \
glamor_context.h \
glamor_copy.c \
- glamor_copyarea.c \
- glamor_copywindow.c \
glamor_core.c \
glamor_debug.h \
- glamor_fill.c \
- glamor_fillspans.c \
glamor_font.c \
- glamor_getspans.c \
glamor_glx.c \
glamor_glyphs.c \
glamor_image.c \
- glamor_polyfillrect.c \
- glamor_polylines.c \
- glamor_putimage.c \
- glamor_setspans.c \
glamor_render.c \
glamor_gradient.c \
glamor_prepare.c \
@@ -35,11 +26,8 @@ libglamor_la_SOURCES = \
glamor_transfer.h \
glamor_transform.c \
glamor_trapezoid.c \
- glamor_tile.c \
glamor_triangles.c\
glamor_addtraps.c\
- glamor_getimage.c\
- glamor_copyplane.c\
glamor_glyphblt.c\
glamor_polyops.c\
glamor_priv.h\
diff --git a/glamor/glamor.c b/glamor/glamor.c
index cb509ee..fc6f9db 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -481,12 +481,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
#endif
glamor_init_vbo(screen);
glamor_init_pixmap_fbo(screen);
- glamor_init_solid_shader(screen);
- glamor_init_tile_shader(screen);
#ifdef GLAMOR_TRAPEZOID_SHADER
glamor_init_trapezoid_shader(screen);
#endif
- glamor_init_putimage_shaders(screen);
glamor_init_finish_access_shaders(screen);
#ifdef GLAMOR_GRADIENT_SHADER
glamor_init_gradient_shader(screen);
@@ -521,12 +518,9 @@ glamor_release_screen_priv(ScreenPtr screen)
#endif
glamor_fini_vbo(screen);
glamor_fini_pixmap_fbo(screen);
- glamor_fini_solid_shader(screen);
- glamor_fini_tile_shader(screen);
#ifdef GLAMOR_TRAPEZOID_SHADER
glamor_fini_trapezoid_shader(screen);
#endif
- glamor_fini_putimage_shaders(screen);
glamor_fini_finish_access_shaders(screen);
#ifdef GLAMOR_GRADIENT_SHADER
glamor_fini_gradient_shader(screen);
diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
deleted file mode 100644
index 996611c..0000000
--- a/glamor/glamor_copyarea.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * 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.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_copyarea.c
- *
- * GC CopyArea implementation
- */
-static Bool
-glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
- DrawablePtr dst,
- GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
-{
- ScreenPtr screen = dst->pScreen;
- PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
- PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
- glamor_pixmap_private *src_pixmap_priv, *dst_pixmap_priv;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
- int fbo_x_off, fbo_y_off;
- int src_fbo_x_off, src_fbo_y_off;
-
- if (!glamor_priv->has_fbo_blit) {
- glamor_delayed_fallback(screen, "no EXT_framebuffer_blit\n");
- return FALSE;
- }
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
- dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
-
- if (gc) {
- if (gc->alu != GXcopy) {
- glamor_delayed_fallback(screen, "non-copy ALU\n");
- return FALSE;
- }
- }
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
- glamor_delayed_fallback(screen, "no src fbo\n");
- return FALSE;
- }
-
- if (glamor_set_destination_pixmap(dst_pixmap))
- return FALSE;
-
- pixmap_priv_get_fbo_off(dst_pixmap_priv, &fbo_x_off, &fbo_y_off);
- pixmap_priv_get_fbo_off(src_pixmap_priv, &src_fbo_x_off, &src_fbo_y_off);
-
- glamor_get_context(glamor_priv);
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->base.fbo->fb);
- glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
- glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
- dst_x_off += fbo_x_off;
- dst_y_off += fbo_y_off;
- src_y_off += dy + src_fbo_y_off;
- src_x_off += src_fbo_x_off;
-
- for (i = 0; i < nbox; i++) {
- if (glamor_priv->yInverted) {
- glBlitFramebuffer(box[i].x1 + dx + src_x_off,
- box[i].y1 + src_y_off,
- box[i].x2 + dx + src_x_off,
- box[i].y2 + src_y_off,
- box[i].x1 + dst_x_off,
- box[i].y1 + dst_y_off,
- box[i].x2 + dst_x_off,
- box[i].y2 + dst_y_off,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
- else {
- int flip_dst_y1 =
- dst_pixmap->drawable.height - (box[i].y2 + dst_y_off);
- int flip_dst_y2 =
- dst_pixmap->drawable.height - (box[i].y1 + dst_y_off);
- int flip_src_y1 =
- src_pixmap->drawable.height - (box[i].y2 + src_y_off);
- int flip_src_y2 =
- src_pixmap->drawable.height - (box[i].y1 + src_y_off);
-
- glBlitFramebuffer(box[i].x1 + dx + src_x_off,
- flip_src_y1,
- box[i].x2 + dx + src_x_off,
- flip_src_y2,
- box[i].x1 + dst_x_off,
- flip_dst_y1,
- box[i].x2 + dst_x_off,
- flip_dst_y2,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
- }
- glamor_put_context(glamor_priv);
- glamor_priv->state = BLIT_STATE;
- return TRUE;
-}
-
-static Bool
-glamor_copy_n_to_n_textured(DrawablePtr src,
- DrawablePtr dst,
- GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
-{
- glamor_screen_private *glamor_priv =
- glamor_get_screen_private(dst->pScreen);
- PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
- PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
- int i;
- float vertices[8], texcoords[8];
- glamor_pixmap_private *src_pixmap_priv;
- glamor_pixmap_private *dst_pixmap_priv;
- int src_x_off, src_y_off, dst_x_off, dst_y_off;
- enum glamor_pixmap_status src_status = GLAMOR_NONE;
- GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
-
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
- dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
-
- if (src_pixmap_priv->base.gl_fbo == GLAMOR_FBO_UNATTACHED) {
-#ifndef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
- glamor_delayed_fallback(dst->pScreen, "src has no fbo.\n");
- return FALSE;
-#else
- src_status = glamor_upload_pixmap_to_texture(src_pixmap);
- if (src_status != GLAMOR_UPLOAD_DONE)
- return FALSE;
-
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
-#endif
- }
-
- pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
- pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
-
- glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
-
- glamor_get_context(glamor_priv);
-
- glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
- GL_FALSE, 2 * sizeof(float), vertices);
- glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-
- glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
- dx += src_x_off;
- dy += src_y_off;
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
- 2 * sizeof(float), texcoords);
- glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
- glUseProgram(glamor_priv->finish_access_prog[0]);
- glUniform1i(glamor_priv->finish_access_revert[0], REVERT_NONE);
- glUniform1i(glamor_priv->finish_access_swap_rb[0], SWAP_NONE_UPLOADING);
-
- for (i = 0; i < nbox; i++) {
-
- glamor_set_normalize_vcoords(dst_pixmap_priv,
- dst_xscale, dst_yscale,
- box[i].x1 + dst_x_off,
- box[i].y1 + dst_y_off,
- box[i].x2 + dst_x_off,
- box[i].y2 + dst_y_off,
- glamor_priv->yInverted, vertices);
-
- glamor_set_normalize_tcoords(src_pixmap_priv,
- src_xscale,
- src_yscale,
- box[i].x1 + dx,
- box[i].y1 + dy,
- box[i].x2 + dx,
- box[i].y2 + dy,
- glamor_priv->yInverted, texcoords);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
-
- glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
- glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
- /* The source texture is bound to a fbo, we have to flush it here. */
- glamor_put_context(glamor_priv);
- glamor_priv->state = RENDER_STATE;
- glamor_priv->render_idle_cnt = 0;
- return TRUE;
-}
-
-static Bool
-__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)
-{
- PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
- DrawablePtr temp_src = src;
- glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
- glamor_screen_private *glamor_priv;
- BoxRec bound;
- ScreenPtr screen;
- int temp_dx = dx;
- int temp_dy = dy;
- int src_x_off, src_y_off, dst_x_off, dst_y_off;
- int i;
- int overlaped = 0;
- Bool ret = FALSE;
-
- dst_pixmap = glamor_get_drawable_pixmap(dst);
- dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
- src_pixmap = glamor_get_drawable_pixmap(src);
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
- screen = dst_pixmap->drawable.pScreen;
- glamor_priv = glamor_get_screen_private(dst->pScreen);
- glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
-
- glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
-
- if (src_pixmap_priv->base.fbo
- && src_pixmap_priv->base.fbo->fb == dst_pixmap_priv->base.fbo->fb) {
- int x_shift = abs(src_x_off - dx - dst_x_off);
- int y_shift = abs(src_y_off - dy - dst_y_off);
-
- for (i = 0; i < nbox; i++) {
- if (x_shift < abs(box[i].x2 - box[i].x1)
- && y_shift < abs(box[i].y2 - box[i].y1)) {
- overlaped = 1;
- break;
- }
- }
- }
- DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
- box[0].x1, box[0].y1,
- box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
- dx, dy, src_pixmap, dst_pixmap);
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
- !overlaped &&
- (glamor_priv->state != RENDER_STATE
- || !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
- && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
- ret = TRUE;
- goto done;
- }
- glamor_calculate_boxes_bound(&bound, box, nbox);
-
- /* Overlaped indicate the src and dst are the same pixmap. */
- if (overlaped || (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)
- && (((bound.x2 - bound.x1) * (bound.y2 - bound.y1)
- * 4 >
- src_pixmap->drawable.width *
- src_pixmap->drawable.height)
- || !(glamor_check_fbo_size(glamor_priv,
- src_pixmap->drawable.width,
- src_pixmap->drawable.
- height))))) {
-
- temp_pixmap = glamor_create_pixmap(screen,
- bound.x2 - bound.x1,
- bound.y2 - bound.y1,
- src_pixmap->drawable.depth,
- overlaped ? 0 :
- GLAMOR_CREATE_PIXMAP_CPU);
- assert(bound.x2 - bound.x1 <= glamor_priv->max_fbo_size);
- assert(bound.y2 - bound.y1 <= glamor_priv->max_fbo_size);
- if (!temp_pixmap)
- goto done;
- glamor_translate_boxes(box, nbox, -bound.x1, -bound.y1);
- temp_src = &temp_pixmap->drawable;
-
- if (overlaped)
- glamor_copy_n_to_n_textured(src, temp_src, gc, box,
- nbox,
- temp_dx + bound.x1, temp_dy + bound.y1);
- else
- fbCopyNtoN(src, temp_src, gc, box, nbox,
- temp_dx + bound.x1, temp_dy + bound.y1,
- reverse, upsidedown, bitplane, closure);
- glamor_translate_boxes(box, nbox, bound.x1, bound.y1);
- temp_dx = -bound.x1;
- temp_dy = -bound.y1;
- }
- else {
- temp_dx = dx;
- temp_dy = dy;
- temp_src = src;
- }
-
- if (glamor_copy_n_to_n_textured
- (temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
- ret = TRUE;
- }
- done:
- if (temp_src != src)
- glamor_destroy_pixmap(temp_pixmap);
- return ret;
-}
-
-static Bool
-_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, Bool fallback)
-{
- ScreenPtr screen = dst->pScreen;
- PixmapPtr dst_pixmap, src_pixmap;
- glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
- glamor_screen_private *glamor_priv;
- BoxPtr extent;
- RegionRec region;
- int src_x_off, src_y_off, dst_x_off, dst_y_off;
- Bool ok = FALSE;
- int force_clip = 0;
-
- if (nbox == 0)
- return TRUE;
- dst_pixmap = glamor_get_drawable_pixmap(dst);
- dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
- src_pixmap = glamor_get_drawable_pixmap(src);
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
-
- glamor_priv = glamor_get_screen_private(screen);
-
- DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
- box[0].x1, box[0].y1,
- box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
- dx, dy, src_pixmap, dst_pixmap);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
- goto fall_back;
-
- if (gc) {
- if (!glamor_set_planemask(dst_pixmap, gc->planemask))
- goto fall_back;
- glamor_get_context(glamor_priv);
- if (!glamor_set_alu(screen, gc->alu)) {
- glamor_put_context(glamor_priv);
- goto fail;
- }
- glamor_put_context(glamor_priv);
- }
-
- if (!src_pixmap_priv) {
- glamor_set_pixmap_type(src_pixmap, GLAMOR_MEMORY);
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
- }
-
- glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
- glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
-
- RegionInitBoxes(®ion, box, nbox);
- extent = RegionExtents(®ion);
-
- if (!glamor_check_fbo_size(glamor_priv,
- extent->x2 - extent->x1, extent->y2 - extent->y1)
- && (src_pixmap_priv->type == GLAMOR_MEMORY
- || (src_pixmap_priv == dst_pixmap_priv))) {
- force_clip = 1;
- }
-
- if (force_clip || dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
- || src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
- glamor_pixmap_clipped_regions *clipped_dst_regions;
- int n_dst_region, i, j;
- PixmapPtr temp_source_pixmap;
- glamor_pixmap_private *temp_source_priv = NULL;
-
- RegionTranslate(®ion, dst_x_off, dst_y_off);
- if (!force_clip)
- clipped_dst_regions =
- glamor_compute_clipped_regions(dst_pixmap_priv, ®ion,
- &n_dst_region, 0, reverse,
- upsidedown);
- else
- clipped_dst_regions =
- glamor_compute_clipped_regions_ext(dst_pixmap_priv, ®ion,
- &n_dst_region,
- glamor_priv->max_fbo_size,
- glamor_priv->max_fbo_size,
- reverse, upsidedown);
- for (i = 0; i < n_dst_region; i++) {
- int n_src_region;
- glamor_pixmap_clipped_regions *clipped_src_regions;
- BoxPtr current_boxes;
- int n_current_boxes;
-
- SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
- clipped_dst_regions[i].block_idx);
-
- temp_source_pixmap = NULL;
- if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
- RegionTranslate(clipped_dst_regions[i].region,
- -dst_x_off + src_x_off + dx,
- -dst_y_off + src_y_off + dy);
- clipped_src_regions =
- glamor_compute_clipped_regions(src_pixmap_priv,
- clipped_dst_regions[i].
- region, &n_src_region, 0,
- reverse, upsidedown);
- DEBUGF("Source is large pixmap.\n");
- for (j = 0; j < n_src_region; j++) {
- if (src_pixmap_priv != dst_pixmap_priv)
- SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
- clipped_src_regions[j].
- block_idx);
- else if (src_pixmap_priv == dst_pixmap_priv &&
- clipped_src_regions[j].block_idx !=
- clipped_dst_regions[i].block_idx) {
- /* source and the dest are the same, but need different block_idx.
- * we create a empty pixmap and fill the required source fbo and box to
- * it. It's a little hacky, but avoid extra copy. */
- temp_source_pixmap =
- glamor_create_pixmap(src->pScreen, 0, 0, src->depth,
- 0);
- if (!temp_source_pixmap) {
- ok = FALSE;
- goto fail;
- }
- src->pScreen->ModifyPixmapHeader(temp_source_pixmap,
- src_pixmap->drawable.
- width,
- src_pixmap->drawable.
- height, 0, 0,
- src_pixmap->devKind,
- NULL);
- temp_source_priv =
- glamor_get_pixmap_private(temp_source_pixmap);
- *temp_source_priv = *src_pixmap_priv;
- temp_source_priv->large.box =
- src_pixmap_priv->large.
- box_array[clipped_src_regions[j].block_idx];
- temp_source_priv->base.fbo =
- src_pixmap_priv->large.
- fbo_array[clipped_src_regions[j].block_idx];
- temp_source_priv->base.pixmap = temp_source_pixmap;
- }
- assert(temp_source_pixmap ||
- !(src_pixmap_priv == dst_pixmap_priv &&
- (clipped_src_regions[j].block_idx !=
- clipped_dst_regions[i].block_idx)));
-
- RegionTranslate(clipped_src_regions[j].region,
- -src_x_off - dx, -src_y_off - dy);
- current_boxes = RegionRects(clipped_src_regions[j].region);
- n_current_boxes =
- RegionNumRects(clipped_src_regions[j].region);
- DEBUGF("dst pixmap fbo idx %d src pixmap fbo idx %d \n",
- clipped_dst_regions[i].block_idx,
- clipped_src_regions[j].block_idx);
- DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
- current_boxes[0].x1, current_boxes[0].y1,
- current_boxes[0].x2, current_boxes[0].y2, dx, dy,
- src_pixmap, dst_pixmap);
- if (!temp_source_pixmap)
- ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
- n_current_boxes, dx, dy,
- reverse, upsidedown, bitplane,
- closure);
- else {
- ok = __glamor_copy_n_to_n(&temp_source_pixmap->drawable,
- dst, gc, current_boxes,
- n_current_boxes, dx, dy,
- reverse, upsidedown, bitplane,
- closure);
- temp_source_priv->type = GLAMOR_MEMORY;
- temp_source_priv->base.fbo = NULL;
- glamor_destroy_pixmap(temp_source_pixmap);
- temp_source_pixmap = NULL;
- }
-
- RegionDestroy(clipped_src_regions[j].region);
- if (!ok) {
- assert(0);
- goto fail;
- }
- }
-
- if (n_src_region == 0)
- ok = TRUE;
- free(clipped_src_regions);
- }
- else {
- RegionTranslate(clipped_dst_regions[i].region,
- -dst_x_off, -dst_y_off);
- current_boxes = RegionRects(clipped_dst_regions[i].region);
- n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
-
- DEBUGF("dest pixmap fbo idx %d \n",
- clipped_dst_regions[i].block_idx);
- DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
- current_boxes[0].x1, current_boxes[0].y1,
- current_boxes[0].x2, current_boxes[0].y2,
- dx, dy, src_pixmap, dst_pixmap);
-
- ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
- n_current_boxes, dx, dy, reverse,
- upsidedown, bitplane, closure);
-
- }
- RegionDestroy(clipped_dst_regions[i].region);
- }
- if (n_dst_region == 0)
- ok = TRUE;
- free(clipped_dst_regions);
- RegionUninit(®ion);
- }
- else {
- ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
- reverse, upsidedown, bitplane, closure);
- }
-
- fail:
- glamor_get_context(glamor_priv);
- glamor_set_alu(screen, GXcopy);
- glamor_put_context(glamor_priv);
-
- if (ok)
- return TRUE;
- fall_back:
- if (!fallback && glamor_ddx_fallback_check_pixmap(src)
- && glamor_ddx_fallback_check_pixmap(dst))
- goto done;
-
- if (src_pixmap_priv->type == GLAMOR_DRM_ONLY
- || dst_pixmap_priv->type == GLAMOR_DRM_ONLY) {
- LogMessage(X_WARNING,
- "Access a DRM only pixmap is not allowed within glamor.\n");
- return TRUE;
- }
- glamor_report_delayed_fallbacks(src->pScreen);
- glamor_report_delayed_fallbacks(dst->pScreen);
-
- 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) &&
- glamor_prepare_access(src, GLAMOR_ACCESS_RO) &&
- glamor_prepare_access_gc(gc)) {
- fbCopyNtoN(src, dst, gc, box, nbox,
- dx, dy, reverse, upsidedown, bitplane, closure);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(src);
- glamor_finish_access(dst);
- ok = TRUE;
-
- done:
- glamor_clear_delayed_fallbacks(src->pScreen);
- glamor_clear_delayed_fallbacks(dst->pScreen);
- return ok;
-}
-
-RegionPtr
-glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
- int srcx, int srcy, int width, int height, int dstx, int dsty)
-{
- RegionPtr region;
-
- region = miDoCopy(src, dst, gc,
- srcx, srcy, width, height,
- dstx, dsty, glamor_copy_n_to_n, 0, NULL);
-
- return region;
-}
-
-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_copy_n_to_n(src, dst, gc, box, nbox, dx,
- dy, reverse, upsidedown, bitplane, closure, TRUE);
-}
-
-Bool
-glamor_copy_n_to_n_nf(DrawablePtr src,
- DrawablePtr dst,
- GCPtr gc,
- BoxPtr box,
- int nbox,
- int dx,
- int dy,
- Bool reverse,
- Bool upsidedown, Pixel bitplane, void *closure)
-{
- return _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
- dy, reverse, upsidedown, bitplane, closure,
- FALSE);
-}
diff --git a/glamor/glamor_copyplane.c b/glamor/glamor_copyplane.c
deleted file mode 100644
index 2bd2de3..0000000
--- a/glamor/glamor_copyplane.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * 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:
- * Zhigang Gong <zhigang.gong at gmail.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h, int dstx, int dsty,
- unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
-{
- if (!fallback && glamor_ddx_fallback_check_gc(pGC)
- && glamor_ddx_fallback_check_pixmap(pSrc)
- && glamor_ddx_fallback_check_pixmap(pDst))
- goto fail;
-
- if (glamor_prepare_access(pDst, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO) &&
- glamor_prepare_access_gc(pGC)) {
- *pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
- dstx, dsty, bitPlane);
- }
- glamor_finish_access_gc(pGC);
- glamor_finish_access(pSrc);
- glamor_finish_access(pDst);
- return TRUE;
-
- fail:
- return FALSE;
-}
-
-RegionPtr
-glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h, int dstx, int dsty,
- unsigned long bitPlane)
-{
- RegionPtr ret;
-
- _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
- dstx, dsty, bitPlane, &ret, TRUE);
- return ret;
-}
-
-Bool
-glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h, int dstx, int dsty,
- unsigned long bitPlane, RegionPtr *pRegion)
-{
- return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
- dstx, dsty, bitPlane, pRegion, FALSE);
-}
diff --git a/glamor/glamor_copywindow.c b/glamor/glamor_copywindow.c
deleted file mode 100644
index 1ced4b3..0000000
--- a/glamor/glamor_copywindow.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.
- */
-
-#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_fill.c b/glamor/glamor_fill.c
deleted file mode 100644
index 7461b62..0000000
--- a/glamor/glamor_fill.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * 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.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_fill.c
- *
- * GC fill implementation, based loosely on fb_fill.c
- */
-
-/**
- * Fills the given rectangle of a drawable with the GC's fill style.
- */
-Bool
-glamor_fill(DrawablePtr drawable,
- GCPtr gc, int x, int y, int width, int height, Bool fallback)
-{
- PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
- int off_x, off_y;
- PixmapPtr sub_pixmap = NULL;
- glamor_access_t sub_pixmap_access;
- DrawablePtr saved_drawable = NULL;
- int saved_x = x, saved_y = y;
-
- glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y);
-
- switch (gc->fillStyle) {
- case FillSolid:
- if (!glamor_solid(dst_pixmap,
- x + off_x,
- y + off_y,
- width, height, gc->alu, gc->planemask, gc->fgPixel))
- goto fail;
- break;
- case FillStippled:
- case FillOpaqueStippled:
- if (!glamor_stipple(dst_pixmap,
- gc->stipple,
- x + off_x,
- y + off_y,
- width,
- height,
- gc->alu,
- gc->planemask,
- gc->fgPixel,
- gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
- goto fail;
- break;
- case FillTiled:
- if (!glamor_tile(dst_pixmap,
- gc->tile.pixmap,
- x + off_x,
- y + off_y,
- width,
- height,
- gc->alu,
- gc->planemask,
- x - drawable->x - gc->patOrg.x,
- y - drawable->y - gc->patOrg.y))
- goto fail;
- break;
- }
- return TRUE;
-
- fail:
- if (!fallback) {
- if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
- && glamor_ddx_fallback_check_gc(gc))
- return FALSE;
- }
- /* Is it possible to set the access as WO? */
-
- sub_pixmap_access = GLAMOR_ACCESS_RW;
-
- sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
- y + off_y, width, height,
- sub_pixmap_access);
-
- if (sub_pixmap != NULL) {
- if (gc->fillStyle != FillSolid) {
- gc->patOrg.x += (drawable->x - x);
- gc->patOrg.y += (drawable->y - y);
- }
- saved_drawable = drawable;
- drawable = &sub_pixmap->drawable;
- saved_x = x;
- saved_y = y;
- x = 0;
- y = 0;
- }
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbFill(drawable, gc, x, y, width, height);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
-
- if (sub_pixmap != NULL) {
- if (gc->fillStyle != FillSolid) {
- gc->patOrg.x -= (saved_drawable->x - saved_x);
- gc->patOrg.y -= (saved_drawable->y - saved_y);
- }
-
- x = saved_x;
- y = saved_y;
-
- glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
- x + off_x, y + off_y,
- width, height, sub_pixmap_access);
- }
-
- return TRUE;
-}
-
-void
-glamor_init_solid_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
- const char *solid_vs =
- "attribute vec4 v_position;"
- "void main()\n"
- "{\n"
- " gl_Position = v_position;\n"
- "}\n";
- const char *solid_fs =
- GLAMOR_DEFAULT_PRECISION
- "uniform vec4 color;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = color;\n"
- "}\n";
- GLint fs_prog, vs_prog;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
- glamor_priv->solid_prog = glCreateProgram();
- vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, solid_vs);
- fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, solid_fs);
- glAttachShader(glamor_priv->solid_prog, vs_prog);
- glAttachShader(glamor_priv->solid_prog, fs_prog);
-
- glBindAttribLocation(glamor_priv->solid_prog,
- GLAMOR_VERTEX_POS, "v_position");
- glamor_link_glsl_prog(screen, glamor_priv->solid_prog, "solid");
-
- glamor_priv->solid_color_uniform_location =
- glGetUniformLocation(glamor_priv->solid_prog, "color");
- glamor_put_context(glamor_priv);
-}
-
-void
-glamor_fini_solid_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
- glDeleteProgram(glamor_priv->solid_prog);
- glamor_put_context(glamor_priv);
-}
-
-static void
-_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
-{
- ScreenPtr screen = pixmap->drawable.pScreen;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- GLfloat xscale, yscale;
- float stack_vertices[32];
- float *vertices = stack_vertices;
- int valid_nbox = ARRAY_SIZE(stack_vertices) / (4 * 2);
-
- glamor_set_destination_pixmap_priv_nc(pixmap_priv);
-
- glamor_get_context(glamor_priv);
- glUseProgram(glamor_priv->solid_prog);
-
- glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
-
- pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
-
- if (nbox > valid_nbox) {
- int allocated_nbox;
- float *new_vertices;
-
- if (nbox > GLAMOR_COMPOSITE_VBO_VERT_CNT / 6)
- allocated_nbox = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
- else
- allocated_nbox = nbox;
- new_vertices = malloc(allocated_nbox * 4 * 2 * sizeof(float));
- if (new_vertices) {
- vertices = new_vertices;
- valid_nbox = allocated_nbox;
- }
- }
-
- if (_X_UNLIKELY(nbox > 1))
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
-
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
- GL_FALSE, 2 * sizeof(float), vertices);
- glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-
- while (nbox) {
- int box_cnt, i;
- float *next_box;
-
- next_box = vertices;
- box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
- for (i = 0; i < box_cnt; i++) {
- glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
- box[i].x1, box[i].y1,
- box[i].x2, box[i].y2,
- glamor_priv->yInverted,
- next_box);
- next_box += 4 * 2;
- }
- if (box_cnt == 1)
- glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
- else {
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
- glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6,
- GL_UNSIGNED_SHORT, NULL);
- } else {
- glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT,
- NULL);
- }
- }
- nbox -= box_cnt;
- box += box_cnt;
- }
-
- if (vertices != stack_vertices)
- free(vertices);
-
- glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
- glamor_put_context(glamor_priv);
- glamor_priv->state = RENDER_STATE;
- glamor_priv->render_idle_cnt = 0;
-}
-
-/**
- * Fills the given rectangles of pixmap with an X pixel value.
- *
- * This is a helper used by other code after clipping and translation
- * of coordinates to a glamor backing pixmap.
- */
-Bool
-glamor_solid_boxes(PixmapPtr pixmap,
- BoxPtr box, int nbox, unsigned long fg_pixel)
-{
- glamor_pixmap_private *pixmap_priv;
- GLfloat color[4];
-
- pixmap_priv = glamor_get_pixmap_private(pixmap);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- return FALSE;
-
- glamor_get_rgba_from_pixel(fg_pixel,
- &color[0],
- &color[1],
- &color[2], &color[3], format_for_pixmap(pixmap));
-
- if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
- RegionRec region;
- int n_region;
- glamor_pixmap_clipped_regions *clipped_regions;
- int i;
-
- RegionInitBoxes(®ion, box, nbox);
- clipped_regions =
- glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0,
- 0, 0);
- for (i = 0; i < n_region; i++) {
- BoxPtr inner_box;
- int inner_nbox;
-
- SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
-
- inner_box = RegionRects(clipped_regions[i].region);
- inner_nbox = RegionNumRects(clipped_regions[i].region);
- _glamor_solid_boxes(pixmap, inner_box, inner_nbox, color);
- RegionDestroy(clipped_regions[i].region);
- }
- free(clipped_regions);
- RegionUninit(®ion);
- }
- else
- _glamor_solid_boxes(pixmap, box, nbox, color);
-
- return TRUE;
-}
-
-/**
- * Fills a rectangle of a pixmap with an X pixel value.
- *
- * This is a helper used by other glamor code mostly for clearing of
- * buffers to 0.
- */
-Bool
-glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
- unsigned char alu, unsigned long planemask, unsigned long fg_pixel)
-{
- ScreenPtr screen = pixmap->drawable.pScreen;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- glamor_pixmap_private *pixmap_priv;
- BoxRec box;
-
- pixmap_priv = glamor_get_pixmap_private(pixmap);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- return FALSE;
-
- if (!glamor_set_planemask(pixmap, planemask)) {
- glamor_fallback("Failedto set planemask in glamor_solid.\n");
- return FALSE;
- }
-
- glamor_get_context(glamor_priv);
- if (!glamor_set_alu(screen, alu)) {
- if (alu == GXclear)
- fg_pixel = 0;
- else {
- glamor_fallback("unsupported alu %x\n", alu);
- glamor_put_context(glamor_priv);
- return FALSE;
- }
- }
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + width;
- box.y2 = y + height;
- glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
-
- glamor_set_alu(screen, GXcopy);
- glamor_put_context(glamor_priv);
-
- return TRUE;
-}
diff --git a/glamor/glamor_fillspans.c b/glamor/glamor_fillspans.c
deleted file mode 100644
index 8cbd79f..0000000
--- a/glamor/glamor_fillspans.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-
-/** @file glamor_fillspans.c
- *
- * FillSpans implementation, taken from fb_fillsp.c
- */
-#include "glamor_priv.h"
-
-static Bool
-_glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted,
- Bool fallback)
-{
- DDXPointPtr ppt;
- int nbox;
- BoxPtr pbox;
- int x1, x2, y;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
- goto fail;
-
- ppt = points;
- while (n--) {
- x1 = ppt->x;
- y = ppt->y;
- x2 = x1 + (int) *widths;
- ppt++;
- widths++;
-
- nbox = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- while (nbox--) {
- int real_x1 = x1, real_x2 = x2;
-
- if (real_x1 < pbox->x1)
- real_x1 = pbox->x1;
-
- if (real_x2 > pbox->x2)
- real_x2 = pbox->x2;
-
- if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
- if (!glamor_fill(drawable, gc, real_x1, y,
- real_x2 - real_x1, 1, fallback))
- goto fail;
- }
- pbox++;
- }
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc)) {
- goto done;
- }
- glamor_fallback("to %p (%c)\n", drawable,
- glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbFillSpans(drawable, gc, n, points, widths, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
-{
- _glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
-}
-
-Bool
-glamor_fill_spans_nf(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted)
-{
- return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
-}
diff --git a/glamor/glamor_getimage.c b/glamor/glamor_getimage.c
deleted file mode 100644
index a932473..0000000
--- a/glamor/glamor_getimage.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * 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:
- * Zhigang Gong <zhigang.gong at gmail.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
- unsigned int format, unsigned long planeMask, char *d,
- Bool fallback)
-{
- PixmapPtr pixmap, sub_pixmap;
- struct glamor_pixmap_private *pixmap_priv;
- int x_off, y_off;
- int stride;
- void *data;
-
- pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
-
- if (format != ZPixmap)
- goto fall_back;
-
- if (!glamor_set_planemask(pixmap, planeMask)) {
- glamor_fallback("Failedto set planemask in glamor_solid.\n");
- goto fall_back;
- }
- pixmap_priv = glamor_get_pixmap_private(pixmap);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- goto fall_back;
- stride = PixmapBytePad(w, drawable->depth);
-
- x += drawable->x + x_off;
- y += drawable->y + y_off;
-
- data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, stride,
- d, 0, GLAMOR_ACCESS_RO);
- if (data != NULL) {
- assert(data == d);
- return TRUE;
- }
- fall_back:
- sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
- y + y_off + drawable->y, w, h,
- GLAMOR_ACCESS_RO);
- if (sub_pixmap) {
- fbGetImage(&sub_pixmap->drawable, 0, 0, w, h, format, planeMask, d);
- glamor_put_sub_pixmap(sub_pixmap, pixmap,
- x + x_off + drawable->x,
- y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RO);
- }
- else
- miGetImage(drawable, x, y, w, h, format, planeMask, d);
-
- return TRUE;
-}
-
-void
-glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
- unsigned int format, unsigned long planeMask, char *d)
-{
- _glamor_get_image(pDrawable, x, y, w, h, format, planeMask, d, TRUE);
-}
-
-Bool
-glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
- unsigned int format, unsigned long planeMask, char *d)
-{
- return _glamor_get_image(pDrawable, x, y, w,
- h, format, planeMask, d, FALSE);
-}
diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c
deleted file mode 100644
index 42df87f..0000000
--- a/glamor/glamor_getspans.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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 at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst,
- Bool fallback)
-{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- int i;
- uint8_t *readpixels_dst = (uint8_t *) dst;
- void *data;
- int x_off, y_off;
- Bool ret = FALSE;
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
- for (i = 0; i < count; i++) {
- data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
- points[i].y + y_off, widths[i],
- 1, PixmapBytePad(widths[i],
- drawable->
- depth),
- readpixels_dst, 0,
- GLAMOR_ACCESS_RO);
- (void)data;
- assert(data == readpixels_dst);
- readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
- }
-
- ret = TRUE;
- goto done;
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- ret = TRUE;
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
- fbGetSpans(drawable, wmax, points, widths, count, dst);
- }
- glamor_finish_access(drawable);
- done:
- return ret;
-}
-
-void
-glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- _glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
-}
-
-Bool
-glamor_get_spans_nf(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
-}
diff --git a/glamor/glamor_polyfillrect.c b/glamor/glamor_polyfillrect.c
deleted file mode 100644
index 1e361a4..0000000
--- a/glamor/glamor_polyfillrect.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * 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 at anholt.net>
- *
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_fillspans.c
- *
- * GC PolyFillRect implementation, taken straight from fb_fill.c
- */
-
-static Bool
-_glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
-{
- int fullX1, fullX2, fullY1, fullY2;
- int xorg, yorg;
- int n;
- register BoxPtr pbox;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- xorg = drawable->x;
- yorg = drawable->y;
-
- while (nrect--) {
- fullX1 = prect->x + xorg;
- fullY1 = prect->y + yorg;
- fullX2 = fullX1 + (int) prect->width;
- fullY2 = fullY1 + (int) prect->height;
-
- n = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- /*
- * clip the rectangle to each box in the clip region
- * this is logically equivalent to calling Intersect(),
- * but rectangles may overlap each other here.
- */
- while (n--) {
- int x1 = fullX1;
- int x2 = fullX2;
- int y1 = fullY1;
- int y2 = fullY2;
-
- if (pbox->x1 > x1)
- x1 = pbox->x1;
- if (pbox->x2 < x2)
- x2 = pbox->x2;
- if (pbox->y1 > y1)
- y1 = pbox->y1;
- if (pbox->y2 < y2)
- y2 = pbox->y2;
-
- pbox++;
- if (x1 >= x2 || y1 >= y2)
- continue;
- if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
- nrect++;
- goto fail;
- }
- }
- prect++;
- }
- ret = TRUE;
- goto done;
-
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc))
- goto done;
-
- glamor_fallback(" to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbPolyFillRect(drawable, gc, nrect, prect);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- _glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
-}
-
-Bool
-glamor_poly_fill_rect_nf(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
-}
diff --git a/glamor/glamor_polylines.c b/glamor/glamor_polylines.c
deleted file mode 100644
index 1adf45d..0000000
--- a/glamor/glamor_polylines.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * 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 at anholt.net>
- *
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_polylines.c
- *
- * GC PolyFillRect implementation, taken straight from fb_fill.c
- */
-
-/**
- * glamor_poly_lines() checks if it can accelerate the lines as a group of
- * horizontal or vertical lines (rectangles), and uses existing rectangle fill
- * acceleration if so.
- */
-static Bool
-_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
- DDXPointPtr points, Bool fallback)
-{
- xRectangle *rects;
- int x1, x2, y1, y2;
- int i;
-
- /* Don't try to do wide lines or non-solid fill style. */
- if (gc->lineWidth != 0) {
- /* This ends up in miSetSpans, which is accelerated as well as we
- * can hope X wide lines will be.
- */
- goto fail;
- }
-
- if (gc->lineStyle != LineSolid) {
- glamor_fallback("non-solid fill line style %d\n", gc->lineStyle);
- goto fail;
- }
- rects = malloc(sizeof(xRectangle) * (n - 1));
- x1 = points[0].x;
- y1 = points[0].y;
- /* If we have any non-horizontal/vertical, fall back. */
- for (i = 0; i < n - 1; i++) {
- if (mode == CoordModePrevious) {
- x2 = x1 + points[i + 1].x;
- y2 = y1 + points[i + 1].y;
- }
- else {
- x2 = points[i + 1].x;
- y2 = points[i + 1].y;
- }
- if (x1 != x2 && y1 != y2) {
- free(rects);
- glamor_fallback("stub diagonal poly_line\n");
- goto fail;
- }
- if (x1 < x2) {
- rects[i].x = x1;
- rects[i].width = x2 - x1 + 1;
- }
- else {
- rects[i].x = x2;
- rects[i].width = x1 - x2 + 1;
- }
- if (y1 < y2) {
- rects[i].y = y1;
- rects[i].height = y2 - y1 + 1;
- }
- else {
- rects[i].y = y2;
- rects[i].height = y1 - y2 + 1;
- }
-
- x1 = x2;
- y1 = y2;
- }
- gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
- free(rects);
- return TRUE;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc))
- return FALSE;
-
- switch (gc->lineStyle) {
- case LineSolid:
- if (gc->lineWidth == 0)
- miZeroLine(drawable, gc, mode, n, points);
- else
- miWideLine(drawable, gc, mode, n, points);
- break;
- case LineOnOffDash:
- case LineDoubleDash:
- miWideDash(drawable, gc, mode, n, points);
- break;
- }
-
- return TRUE;
-}
-
-void
-glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
- DDXPointPtr points)
-{
- _glamor_poly_lines(drawable, gc, mode, n, points, TRUE);
-}
-
-Bool
-glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
- DDXPointPtr points)
-{
- return _glamor_poly_lines(drawable, gc, mode, n, points, FALSE);
-}
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
deleted file mode 100644
index cf7197b..0000000
--- a/glamor/glamor_putimage.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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 at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-/** @file glamor_putaimge.c
- *
- * XPutImage implementation
- */
-#include "glamor_priv.h"
-
-void
-glamor_init_putimage_shaders(ScreenPtr screen)
-{
-}
-
-void
-glamor_fini_putimage_shaders(ScreenPtr screen)
-{
-}
-
-static Bool
-_glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
- int w, int h, int left_pad, int image_format, char *bits,
- Bool fallback)
-{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- RegionPtr clip;
- int x_off, y_off;
- Bool ret = FALSE;
- PixmapPtr temp_pixmap, sub_pixmap;
- glamor_pixmap_private *temp_pixmap_priv;
- BoxRec box;
-
- glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
- clip = fbGetCompositeClip(gc);
- if (image_format == XYBitmap) {
- assert(depth == 1);
- goto fail;
- }
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
- glamor_fallback("has no fbo.\n");
- goto fail;
- }
-
- if (image_format != ZPixmap) {
- glamor_fallback("non-ZPixmap\n");
- goto fail;
- }
-
- if (!glamor_set_planemask(pixmap, gc->planemask)) {
- goto fail;
- }
- /* create a temporary pixmap and upload the bits to that
- * pixmap, then apply clip copy it to the destination pixmap.*/
- box.x1 = x + drawable->x;
- box.y1 = y + drawable->y;
- box.x2 = x + w + drawable->x;
- box.y2 = y + h + drawable->y;
-
- if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
- || gc->alu != GXcopy) {
- temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
- if (temp_pixmap == NULL)
- goto fail;
-
- temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
-
- if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) {
- temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
- temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
- }
-
- glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
- pixmap->devKind, bits, 0);
-
- glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x,
- y);
- glamor_destroy_pixmap(temp_pixmap);
- }
- else
- glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off,
- y + drawable->y + y_off, w, h,
- PixmapBytePad(w, depth), bits, 0);
- ret = TRUE;
- goto done;
-
- fail:
- glamor_set_planemask(pixmap, ~0);
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
- goto done;
-
- glamor_fallback("to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
-
- sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
- y + y_off + drawable->y, w, h,
- GLAMOR_ACCESS_RW);
- if (sub_pixmap) {
- if (clip != NULL)
- pixman_region_translate(clip, -x - drawable->x, -y - drawable->y);
-
- fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
- left_pad, image_format, bits);
-
- glamor_put_sub_pixmap(sub_pixmap, pixmap,
- x + x_off + drawable->x,
- y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW);
- if (clip != NULL)
- pixman_region_translate(clip, x + drawable->x, y + drawable->y);
- }
- else
- fbPutImage(drawable, gc, depth, x, y, w, h,
- left_pad, image_format, bits);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
- int w, int h, int left_pad, int image_format, char *bits)
-{
- _glamor_put_image(drawable, gc, depth, x, y, w, h,
- left_pad, image_format, bits, TRUE);
-}
-
-Bool
-glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
- int w, int h, int left_pad, int image_format, char *bits)
-{
- return _glamor_put_image(drawable, gc, depth, x, y, w, h,
- left_pad, image_format, bits, FALSE);
-}
diff --git a/glamor/glamor_setspans.c b/glamor/glamor_setspans.c
deleted file mode 100644
index a51e4c5..0000000
--- a/glamor/glamor_setspans.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int numPoints, int sorted,
- Bool fallback)
-{
- PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *dest_pixmap_priv;
- int i;
- uint8_t *drawpixels_src = (uint8_t *) src;
- RegionPtr clip = fbGetCompositeClip(gc);
- BoxRec *pbox;
- int x_off, y_off;
- Bool ret = FALSE;
-
- dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
- glamor_fallback("pixmap has no fbo.\n");
- goto fail;
- }
-
- if (gc->alu != GXcopy) {
- glamor_fallback("SetSpans with non-copy ALU.\n");
- goto fail;
- }
-
- if (!glamor_set_planemask(dest_pixmap, gc->planemask))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
- for (i = 0; i < numPoints; i++) {
-
- int n = REGION_NUM_RECTS(clip);
-
- pbox = REGION_RECTS(clip);
- while (n--) {
- int x1 = points[i].x;
- int x2 = x1 + widths[i];
- int y1 = points[i].y;
-
- if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
- break;
- x1 = x1 > pbox->x1 ? x1 : pbox->x1;
- x2 = x2 < pbox->x2 ? x2 : pbox->x2;
- if (x1 >= x2)
- continue;
- glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off,
- y1 + y_off, x2 - x1, 1,
- PixmapBytePad(widths[i],
- drawable->depth),
- drawpixels_src, 0);
- }
- drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- glamor_fallback("to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- _glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
-}
-
-Bool
-glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- return _glamor_set_spans(drawable, gc, src, points,
- widths, n, sorted, FALSE);
-}
diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c
deleted file mode 100644
index 9e115ca..0000000
--- a/glamor/glamor_tile.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * 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 at anholt.net>
- * Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_tile.c
- *
- * Implements the basic fill-with-a-tile support used by multiple GC ops.
- */
-
-void
-glamor_init_tile_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
- const char *tile_vs =
- "attribute vec4 v_position;\n"
- "attribute vec4 v_texcoord0;\n"
- "varying vec2 tile_texture;\n"
- "void main()\n"
- "{\n"
- " gl_Position = v_position;\n"
- " tile_texture = v_texcoord0.xy;\n"
- "}\n";
- const char *tile_fs =
- GLAMOR_DEFAULT_PRECISION
- "varying vec2 tile_texture;\n"
- "uniform sampler2D sampler;\n"
- "uniform vec2 wh;"
- "void main()\n"
- "{\n"
- " vec2 rel_tex;"
- " rel_tex = tile_texture * wh; \n"
- " rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
- " gl_FragColor = texture2D(sampler, rel_tex);\n"
- "}\n";
- GLint fs_prog, vs_prog;
- GLint sampler_uniform_location;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
- glamor_priv->tile_prog = glCreateProgram();
- vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, tile_vs);
- fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, tile_fs);
- glAttachShader(glamor_priv->tile_prog, vs_prog);
- glAttachShader(glamor_priv->tile_prog, fs_prog);
-
- glBindAttribLocation(glamor_priv->tile_prog,
- GLAMOR_VERTEX_POS, "v_position");
- glBindAttribLocation(glamor_priv->tile_prog,
- GLAMOR_VERTEX_SOURCE, "v_texcoord0");
- glamor_link_glsl_prog(screen, glamor_priv->tile_prog, "tile");
-
- sampler_uniform_location =
- glGetUniformLocation(glamor_priv->tile_prog, "sampler");
- glUseProgram(glamor_priv->tile_prog);
- glUniform1i(sampler_uniform_location, 0);
-
- glamor_priv->tile_wh =
- glGetUniformLocation(glamor_priv->tile_prog, "wh");
- glamor_put_context(glamor_priv);
-}
-
-void
-glamor_fini_tile_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
- glDeleteProgram(glamor_priv->tile_prog);
- glamor_put_context(glamor_priv);
-}
-
-static void
-_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
- int x, int y, int width, int height, int tile_x, int tile_y)
-{
- ScreenPtr screen = pixmap->drawable.pScreen;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- int x1 = x;
- int x2 = x + width;
- int y1 = y;
- int y2 = y + height;
- int tile_x1 = tile_x;
- int tile_x2 = tile_x + width;
- int tile_y1 = tile_y;
- int tile_y2 = tile_y + height;
- float vertices[8];
- float source_texcoords[8];
- GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
- glamor_pixmap_private *src_pixmap_priv;
- glamor_pixmap_private *dst_pixmap_priv;
- float wh[4];
-
- src_pixmap_priv = glamor_get_pixmap_private(tile);
- dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
-
- glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
- pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
- pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
- glamor_get_context(glamor_priv);
- glUseProgram(glamor_priv->tile_prog);
-
- glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
- glUniform2fv(glamor_priv->tile_wh, 1, wh);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glamor_set_repeat_normalize_tcoords
- (src_pixmap_priv, RepeatNormal,
- src_xscale, src_yscale,
- tile_x1, tile_y1,
- tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
-
- glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
- 2 * sizeof(float), source_texcoords);
- glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-
- glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
- x1, y1,
- x2, y2, glamor_priv->yInverted, vertices);
-
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
- 2 * sizeof(float), vertices);
- glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
- glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
- glamor_put_context(glamor_priv);
-
- glamor_priv->state = RENDER_STATE;
- glamor_priv->render_idle_cnt = 0;
-}
-
-Bool
-glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
- int x, int y, int width, int height,
- unsigned char alu, unsigned long planemask, int tile_x, int tile_y)
-{
- ScreenPtr screen = pixmap->drawable.pScreen;
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- glamor_pixmap_private *dst_pixmap_priv;
- glamor_pixmap_private *src_pixmap_priv;
-
- dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
- src_pixmap_priv = glamor_get_pixmap_private(tile);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
- return FALSE;
-
- if (glamor_priv->tile_prog == 0) {
- glamor_fallback("Tiling unsupported\n");
- goto fail;
- }
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
- /* XXX dynamic uploading candidate. */
- glamor_fallback("Non-texture tile pixmap\n");
- goto fail;
- }
-
- if (!glamor_set_planemask(pixmap, planemask)) {
- glamor_fallback("unsupported planemask %lx\n", planemask);
- goto fail;
- }
-
- glamor_get_context(glamor_priv);
- if (!glamor_set_alu(screen, alu)) {
- glamor_fallback("unsupported alu %x\n", alu);
- glamor_put_context(glamor_priv);
- goto fail;
- }
-
- if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
- || src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
- glamor_pixmap_clipped_regions *clipped_dst_regions;
- int n_dst_region, i, j, k;
- BoxRec box;
- RegionRec region;
-
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + width;
- box.y2 = y + height;
- RegionInitBoxes(®ion, &box, 1);
- clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
- ®ion,
- &n_dst_region, 0,
- 0, 0);
- for (i = 0; i < n_dst_region; i++) {
- int n_src_region;
- glamor_pixmap_clipped_regions *clipped_src_regions;
- BoxPtr current_boxes;
- int n_current_boxes;
-
- SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
- clipped_dst_regions[i].block_idx);
-
- if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
- RegionTranslate(clipped_dst_regions[i].region,
- tile_x - x, tile_y - y);
- DEBUGF("tiled a large src pixmap. %dx%d \n",
- tile->drawable.width, tile->drawable.height);
- clipped_src_regions =
- glamor_compute_clipped_regions(src_pixmap_priv,
- clipped_dst_regions[i].
- region, &n_src_region, 1, 0,
- 0);
- DEBUGF("got %d src regions %d \n", n_src_region);
- for (j = 0; j < n_src_region; j++) {
-
- SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
- clipped_src_regions[j].block_idx);
-
- RegionTranslate(clipped_src_regions[j].region,
- x - tile_x, y - tile_y);
- current_boxes = RegionRects(clipped_src_regions[j].region);
- n_current_boxes =
- RegionNumRects(clipped_src_regions[j].region);
- for (k = 0; k < n_current_boxes; k++) {
- DEBUGF
- ("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
- current_boxes[k].x1, current_boxes[k].y1,
- current_boxes[k].x2 - current_boxes[k].x1,
- current_boxes[k].y2 - current_boxes[k].y1,
- clipped_dst_regions[i].block_idx,
- clipped_src_regions[j].block_idx,
- (tile_x + (current_boxes[k].x1 - x)),
- tile_y + (current_boxes[k].y1 - y));
-
- _glamor_tile(pixmap, tile,
- current_boxes[k].x1, current_boxes[k].y1,
- current_boxes[k].x2 - current_boxes[k].x1,
- current_boxes[k].y2 - current_boxes[k].y1,
- (tile_x + (current_boxes[k].x1 - x)),
- (tile_y + (current_boxes[k].y1 - y)));
- }
-
- RegionDestroy(clipped_src_regions[j].region);
- }
- free(clipped_src_regions);
- }
- else {
- current_boxes = RegionRects(clipped_dst_regions[i].region);
- n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
- for (k = 0; k < n_current_boxes; k++) {
- _glamor_tile(pixmap, tile,
- current_boxes[k].x1, current_boxes[k].y1,
- current_boxes[k].x2 - current_boxes[k].x1,
- current_boxes[k].y2 - current_boxes[k].y1,
- (tile_x + (current_boxes[k].x1 - x)),
- (tile_y + (current_boxes[k].y1 - y)));
- }
- }
- RegionDestroy(clipped_dst_regions[i].region);
- }
- free(clipped_dst_regions);
- RegionUninit(®ion);
- }
- else
- _glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
-
- glamor_set_alu(screen, GXcopy);
- glamor_put_context(glamor_priv);
- return TRUE;
- fail:
- return FALSE;
-
-}
--
1.9.0
More information about the xorg-devel
mailing list