glamor_priv.h 5.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*
 * Copyright © 2008 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>
 *
 */

#ifndef GLAMOR_PRIV_H
#define GLAMOR_PRIV_H

#include "glamor.h"
Eric Anholt's avatar
Eric Anholt committed
32
#include <GL/glew.h>
33

34 35 36 37 38 39 40
typedef struct glamor_transform_uniforms {
    GLint x_bias;
    GLint x_scale;
    GLint y_bias;
    GLint y_scale;
} glamor_transform_uniforms;

41 42 43 44 45 46 47
typedef struct glamor_composite_shader {
    GLuint prog;
    GLint dest_to_dest_uniform_location;
    GLint dest_to_source_uniform_location;
    GLint dest_to_mask_uniform_location;
} glamor_composite_shader;

48 49 50 51
typedef struct glamor_screen_private {
    CreateGCProcPtr saved_create_gc;
    CreatePixmapProcPtr saved_create_pixmap;
    DestroyPixmapProcPtr saved_destroy_pixmap;
52
    GetSpansProcPtr saved_get_spans;
53
    GetImageProcPtr saved_get_image;
54
    CompositeProcPtr saved_composite;
Eric Anholt's avatar
Eric Anholt committed
55
    TrapezoidsProcPtr saved_trapezoids;
56 57 58 59 60

    /* glamor_solid */
    GLint solid_prog;
    GLint solid_color_uniform_location;
    glamor_transform_uniforms solid_transform;
61

62
    /* glamor_tile */
63 64
    GLint tile_prog;
    glamor_transform_uniforms tile_transform;
65 66 67

    /* glamor_composite */
    glamor_composite_shader composite_shader[2];
68 69
} glamor_screen_private;

Eric Anholt's avatar
Eric Anholt committed
70 71 72 73 74
typedef struct glamor_pixmap_private {
    GLuint tex;
    GLuint fb;
} glamor_pixmap_private;

75
extern DevPrivateKey glamor_screen_private_key;
Eric Anholt's avatar
Eric Anholt committed
76
extern DevPrivateKey glamor_pixmap_private_key;
77 78 79 80 81 82
static inline glamor_screen_private *
glamor_get_screen_private(ScreenPtr screen)
{
    return (glamor_screen_private *)dixLookupPrivate(&screen->devPrivates,
						     glamor_screen_private_key);
}
Eric Anholt's avatar
Eric Anholt committed
83 84 85 86 87
static inline glamor_pixmap_private *
glamor_get_pixmap_private(PixmapPtr pixmap)
{
    return dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
}
88

89 90 91 92
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define ALIGN(i,m)	(((i) + (m) - 1) & ~((m) - 1))
#define MIN(a,b)	((a) < (b) ? (a) : (b))

93 94 95 96 97 98 99 100 101 102 103
/**
 * Returns TRUE if the given planemask covers all the significant bits in the
 * pixel values for pDrawable.
 */
static inline Bool
glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
{
    return (planemask & FbFullMask(drawable->depth)) ==
	FbFullMask(drawable->depth);
}

104 105 106 107 108
/* glamor.c */
PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);

/* glamor_core.c */
Bool glamor_create_gc(GCPtr gc);
109 110 111 112 113
void glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
		    int x, int y, int width, int height,
		    unsigned char alu, unsigned long planemask,
		    unsigned long fg_pixel, unsigned long bg_pixel,
		    int stipple_x, int stipple_y);
114 115 116 117 118
GLint glamor_compile_glsl_prog(GLenum type, const char *source);
void glamor_link_glsl_prog(GLint prog);
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
				    GLfloat *color);
Bool glamor_set_destination_pixmap(PixmapPtr pixmap);
119
void glamor_set_alu(unsigned char alu);
120
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
121 122 123 124
void glamor_get_transform_uniform_locations(GLint prog,
					    glamor_transform_uniforms *uniform_locations);
void glamor_set_transform_for_pixmap(PixmapPtr pixmap,
				     glamor_transform_uniforms *uniform_locations);
125 126 127 128 129 130 131 132

/* glamor_fill.c */
void glamor_fill(DrawablePtr drawable,
		 GCPtr gc,
		 int x,
		 int y,
		 int width,
		 int height);
133 134 135
void glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
		  unsigned char alu, unsigned long planemask,
		  unsigned long fg_pixel);
136 137
void glamor_solid_fail_region(PixmapPtr pixmap,
			      int x, int y, int width, int height);
138 139 140 141 142 143 144 145

/* glamor_fillspans.c */
void glamor_fill_spans(DrawablePtr drawable,
		       GCPtr	gc,
		       int n,
		       DDXPointPtr points,
		       int *widths,
		       int sorted);
146

147 148
void glamor_init_solid_shader(ScreenPtr screen);

149 150 151 152 153 154 155 156 157
/* glamor_getspans.c */
void
glamor_get_spans(DrawablePtr drawable,
		 int wmax,
		 DDXPointPtr points,
		 int *widths,
		 int nspans,
		 char *dst_start);

158 159 160 161
/* glamor_setspans.c */
void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
		      DDXPointPtr points, int *widths, int n, int sorted);

162 163 164 165 166
/* glamor_putimage.c */
void
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
		 int w, int h, int leftPad, int format, char *bits);

167 168 169 170 171 172 173 174 175 176 177 178 179
/* glamor_render.c */
void glamor_composite(CARD8 op,
		      PicturePtr pSrc,
		      PicturePtr pMask,
		      PicturePtr pDst,
		      INT16 xSrc,
		      INT16 ySrc,
		      INT16 xMask,
		      INT16 yMask,
		      INT16 xDst,
		      INT16 yDst,
		      CARD16 width,
		      CARD16 height);
Eric Anholt's avatar
Eric Anholt committed
180 181 182 183
void glamor_trapezoids(CARD8 op,
		       PicturePtr src, PicturePtr dst,
		       PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
		       int ntrap, xTrapezoid *traps);
184
void glamor_init_composite_shaders(ScreenPtr screen);
185

186 187 188 189 190 191 192
/* glamor_tile.c */
void 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);
void glamor_init_tile_shader(ScreenPtr screen);

193
#endif /* GLAMOR_PRIV_H */