1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright © 2008 Intel Corporation
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"),
6*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation
7*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the
9*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions:
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the next
12*4882a593Smuzhiyun * paragraph) shall be included in all copies or substantial portions of the
13*4882a593Smuzhiyun * Software.
14*4882a593Smuzhiyun *
15*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18*4882a593Smuzhiyun * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*4882a593Smuzhiyun * IN THE SOFTWARE.
22*4882a593Smuzhiyun *
23*4882a593Smuzhiyun * Authors:
24*4882a593Smuzhiyun * Eric Anholt <eric@anholt.net>
25*4882a593Smuzhiyun *
26*4882a593Smuzhiyun */
27*4882a593Smuzhiyun #ifndef GLAMOR_PRIV_H
28*4882a593Smuzhiyun #define GLAMOR_PRIV_H
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun #include "dix-config.h"
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun #include "glamor.h"
33*4882a593Smuzhiyun #include "xvdix.h"
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun #if XSYNC
36*4882a593Smuzhiyun #include "misyncshm.h"
37*4882a593Smuzhiyun #include "misyncstr.h"
38*4882a593Smuzhiyun #endif
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include <epoxy/gl.h>
41*4882a593Smuzhiyun #ifdef GLAMOR_HAS_GBM
42*4882a593Smuzhiyun #define MESA_EGL_NO_X11_HEADERS
43*4882a593Smuzhiyun #define EGL_NO_X11
44*4882a593Smuzhiyun #include <epoxy/egl.h>
45*4882a593Smuzhiyun #endif
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #ifdef GLES_USE_HIGHP
48*4882a593Smuzhiyun #define GLAMOR_DEFAULT_PRECISION \
49*4882a593Smuzhiyun "precision highp float;\n"
50*4882a593Smuzhiyun #else
51*4882a593Smuzhiyun #define GLAMOR_DEFAULT_PRECISION \
52*4882a593Smuzhiyun "#ifdef GL_ES\n" \
53*4882a593Smuzhiyun "precision mediump float;\n" \
54*4882a593Smuzhiyun "#endif\n"
55*4882a593Smuzhiyun #endif
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun #include "glyphstr.h"
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun #include "glamor_debug.h"
60*4882a593Smuzhiyun #include "glamor_context.h"
61*4882a593Smuzhiyun #include "glamor_program.h"
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun #include <list.h>
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun #ifdef GLAMOR_HAS_GBM
66*4882a593Smuzhiyun #include <gbm.h>
67*4882a593Smuzhiyun #endif
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun struct glamor_pixmap_private;
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun typedef struct glamor_composite_shader {
72*4882a593Smuzhiyun GLuint prog;
73*4882a593Smuzhiyun GLint dest_to_dest_uniform_location;
74*4882a593Smuzhiyun GLint dest_to_source_uniform_location;
75*4882a593Smuzhiyun GLint dest_to_mask_uniform_location;
76*4882a593Smuzhiyun GLint source_uniform_location;
77*4882a593Smuzhiyun GLint mask_uniform_location;
78*4882a593Smuzhiyun GLint source_wh;
79*4882a593Smuzhiyun GLint mask_wh;
80*4882a593Smuzhiyun GLint source_repeat_mode;
81*4882a593Smuzhiyun GLint mask_repeat_mode;
82*4882a593Smuzhiyun union {
83*4882a593Smuzhiyun float source_solid_color[4];
84*4882a593Smuzhiyun struct {
85*4882a593Smuzhiyun PixmapPtr source_pixmap;
86*4882a593Smuzhiyun PicturePtr source;
87*4882a593Smuzhiyun };
88*4882a593Smuzhiyun };
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun union {
91*4882a593Smuzhiyun float mask_solid_color[4];
92*4882a593Smuzhiyun struct {
93*4882a593Smuzhiyun PixmapPtr mask_pixmap;
94*4882a593Smuzhiyun PicturePtr mask;
95*4882a593Smuzhiyun };
96*4882a593Smuzhiyun };
97*4882a593Smuzhiyun } glamor_composite_shader;
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun enum ca_state {
100*4882a593Smuzhiyun CA_NONE,
101*4882a593Smuzhiyun CA_TWO_PASS,
102*4882a593Smuzhiyun CA_DUAL_BLEND,
103*4882a593Smuzhiyun };
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun enum shader_source {
106*4882a593Smuzhiyun SHADER_SOURCE_SOLID,
107*4882a593Smuzhiyun SHADER_SOURCE_TEXTURE,
108*4882a593Smuzhiyun SHADER_SOURCE_TEXTURE_ALPHA,
109*4882a593Smuzhiyun SHADER_SOURCE_COUNT,
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun enum shader_mask {
113*4882a593Smuzhiyun SHADER_MASK_NONE,
114*4882a593Smuzhiyun SHADER_MASK_SOLID,
115*4882a593Smuzhiyun SHADER_MASK_TEXTURE,
116*4882a593Smuzhiyun SHADER_MASK_TEXTURE_ALPHA,
117*4882a593Smuzhiyun SHADER_MASK_COUNT,
118*4882a593Smuzhiyun };
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun enum shader_dest_swizzle {
121*4882a593Smuzhiyun SHADER_DEST_SWIZZLE_DEFAULT,
122*4882a593Smuzhiyun SHADER_DEST_SWIZZLE_ALPHA_TO_RED,
123*4882a593Smuzhiyun SHADER_DEST_SWIZZLE_COUNT,
124*4882a593Smuzhiyun };
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun struct shader_key {
127*4882a593Smuzhiyun enum shader_source source;
128*4882a593Smuzhiyun enum shader_mask mask;
129*4882a593Smuzhiyun glamor_program_alpha in;
130*4882a593Smuzhiyun enum shader_dest_swizzle dest_swizzle;
131*4882a593Smuzhiyun };
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun struct blendinfo {
134*4882a593Smuzhiyun Bool dest_alpha;
135*4882a593Smuzhiyun Bool source_alpha;
136*4882a593Smuzhiyun GLenum source_blend;
137*4882a593Smuzhiyun GLenum dest_blend;
138*4882a593Smuzhiyun };
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun typedef struct {
141*4882a593Smuzhiyun INT16 x_src;
142*4882a593Smuzhiyun INT16 y_src;
143*4882a593Smuzhiyun INT16 x_mask;
144*4882a593Smuzhiyun INT16 y_mask;
145*4882a593Smuzhiyun INT16 x_dst;
146*4882a593Smuzhiyun INT16 y_dst;
147*4882a593Smuzhiyun INT16 width;
148*4882a593Smuzhiyun INT16 height;
149*4882a593Smuzhiyun } glamor_composite_rect_t;
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun enum glamor_vertex_type {
152*4882a593Smuzhiyun GLAMOR_VERTEX_POS,
153*4882a593Smuzhiyun GLAMOR_VERTEX_SOURCE,
154*4882a593Smuzhiyun GLAMOR_VERTEX_MASK
155*4882a593Smuzhiyun };
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun enum gradient_shader {
158*4882a593Smuzhiyun SHADER_GRADIENT_LINEAR,
159*4882a593Smuzhiyun SHADER_GRADIENT_RADIAL,
160*4882a593Smuzhiyun SHADER_GRADIENT_CONICAL,
161*4882a593Smuzhiyun SHADER_GRADIENT_COUNT,
162*4882a593Smuzhiyun };
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun struct glamor_screen_private;
165*4882a593Smuzhiyun struct glamor_pixmap_private;
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun #define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun struct glamor_format {
170*4882a593Smuzhiyun /** X Server's "depth" value */
171*4882a593Smuzhiyun int depth;
172*4882a593Smuzhiyun /** GL internalformat for creating textures of this type */
173*4882a593Smuzhiyun GLenum internalformat;
174*4882a593Smuzhiyun /** GL format transferring pixels in/out of textures of this type. */
175*4882a593Smuzhiyun GLenum format;
176*4882a593Smuzhiyun /** GL type transferring pixels in/out of textures of this type. */
177*4882a593Smuzhiyun GLenum type;
178*4882a593Smuzhiyun /* Render PICT_* matching GL's channel layout for pixels
179*4882a593Smuzhiyun * transferred using format/type.
180*4882a593Smuzhiyun */
181*4882a593Smuzhiyun CARD32 render_format;
182*4882a593Smuzhiyun };
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun struct glamor_saved_procs {
185*4882a593Smuzhiyun CloseScreenProcPtr close_screen;
186*4882a593Smuzhiyun CreateGCProcPtr create_gc;
187*4882a593Smuzhiyun CreatePixmapProcPtr create_pixmap;
188*4882a593Smuzhiyun DestroyPixmapProcPtr destroy_pixmap;
189*4882a593Smuzhiyun GetSpansProcPtr get_spans;
190*4882a593Smuzhiyun GetImageProcPtr get_image;
191*4882a593Smuzhiyun CompositeProcPtr composite;
192*4882a593Smuzhiyun CompositeRectsProcPtr composite_rects;
193*4882a593Smuzhiyun TrapezoidsProcPtr trapezoids;
194*4882a593Smuzhiyun GlyphsProcPtr glyphs;
195*4882a593Smuzhiyun ChangeWindowAttributesProcPtr change_window_attributes;
196*4882a593Smuzhiyun CopyWindowProcPtr copy_window;
197*4882a593Smuzhiyun BitmapToRegionProcPtr bitmap_to_region;
198*4882a593Smuzhiyun TrianglesProcPtr triangles;
199*4882a593Smuzhiyun AddTrapsProcPtr addtraps;
200*4882a593Smuzhiyun #if XSYNC
201*4882a593Smuzhiyun SyncScreenFuncsRec sync_screen_funcs;
202*4882a593Smuzhiyun #endif
203*4882a593Smuzhiyun ScreenBlockHandlerProcPtr block_handler;
204*4882a593Smuzhiyun };
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun typedef struct glamor_screen_private {
207*4882a593Smuzhiyun Bool is_gles;
208*4882a593Smuzhiyun int glsl_version;
209*4882a593Smuzhiyun Bool has_pack_invert;
210*4882a593Smuzhiyun Bool has_fbo_blit;
211*4882a593Smuzhiyun Bool has_map_buffer_range;
212*4882a593Smuzhiyun Bool has_buffer_storage;
213*4882a593Smuzhiyun Bool has_khr_debug;
214*4882a593Smuzhiyun Bool has_mesa_tile_raster_order;
215*4882a593Smuzhiyun Bool has_nv_texture_barrier;
216*4882a593Smuzhiyun Bool has_pack_subimage;
217*4882a593Smuzhiyun Bool has_unpack_subimage;
218*4882a593Smuzhiyun Bool has_rw_pbo;
219*4882a593Smuzhiyun Bool use_quads;
220*4882a593Smuzhiyun Bool has_dual_blend;
221*4882a593Smuzhiyun Bool has_texture_swizzle;
222*4882a593Smuzhiyun Bool is_core_profile;
223*4882a593Smuzhiyun Bool can_copyplane;
224*4882a593Smuzhiyun int max_fbo_size;
225*4882a593Smuzhiyun Bool gl_synced;
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun struct glamor_format formats[33];
228*4882a593Smuzhiyun struct glamor_format cbcr_format;
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun /* glamor point shader */
231*4882a593Smuzhiyun glamor_program point_prog;
232*4882a593Smuzhiyun
233*4882a593Smuzhiyun /* glamor spans shaders */
234*4882a593Smuzhiyun glamor_program_fill fill_spans_program;
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun /* glamor rect shaders */
237*4882a593Smuzhiyun glamor_program_fill poly_fill_rect_program;
238*4882a593Smuzhiyun
239*4882a593Smuzhiyun /* glamor glyphblt shaders */
240*4882a593Smuzhiyun glamor_program_fill poly_glyph_blt_progs;
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun /* glamor text shaders */
243*4882a593Smuzhiyun glamor_program_fill poly_text_progs;
244*4882a593Smuzhiyun glamor_program te_text_prog;
245*4882a593Smuzhiyun glamor_program image_text_prog;
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun /* glamor copy shaders */
248*4882a593Smuzhiyun glamor_program copy_area_prog;
249*4882a593Smuzhiyun glamor_program copy_plane_prog;
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun /* glamor line shader */
252*4882a593Smuzhiyun glamor_program_fill poly_line_program;
253*4882a593Smuzhiyun
254*4882a593Smuzhiyun /* glamor segment shaders */
255*4882a593Smuzhiyun glamor_program_fill poly_segment_program;
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun /* glamor dash line shader */
258*4882a593Smuzhiyun glamor_program_fill on_off_dash_line_progs;
259*4882a593Smuzhiyun glamor_program double_dash_line_prog;
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun /* glamor composite_glyphs shaders */
262*4882a593Smuzhiyun glamor_program_render glyphs_program;
263*4882a593Smuzhiyun struct glamor_glyph_atlas *glyph_atlas_a;
264*4882a593Smuzhiyun struct glamor_glyph_atlas *glyph_atlas_argb;
265*4882a593Smuzhiyun int glyph_atlas_dim;
266*4882a593Smuzhiyun int glyph_max_dim;
267*4882a593Smuzhiyun char *glyph_defines;
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun /** Vertex buffer for all GPU rendering. */
270*4882a593Smuzhiyun GLuint vao;
271*4882a593Smuzhiyun GLuint vbo;
272*4882a593Smuzhiyun /** Next offset within the VBO that glamor_get_vbo_space() will use. */
273*4882a593Smuzhiyun int vbo_offset;
274*4882a593Smuzhiyun int vbo_size;
275*4882a593Smuzhiyun Bool vbo_mapped;
276*4882a593Smuzhiyun /**
277*4882a593Smuzhiyun * Pointer to glamor_get_vbo_space()'s current VBO mapping.
278*4882a593Smuzhiyun *
279*4882a593Smuzhiyun * Note that this is not necessarily equal to the pointer returned
280*4882a593Smuzhiyun * by glamor_get_vbo_space(), so it can't be used in place of that.
281*4882a593Smuzhiyun */
282*4882a593Smuzhiyun char *vb;
283*4882a593Smuzhiyun int vb_stride;
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun /** Cached index buffer for translating GL_QUADS to triangles. */
286*4882a593Smuzhiyun GLuint ib;
287*4882a593Smuzhiyun /** Index buffer type: GL_UNSIGNED_SHORT or GL_UNSIGNED_INT */
288*4882a593Smuzhiyun GLenum ib_type;
289*4882a593Smuzhiyun /** Number of quads the index buffer has indices for. */
290*4882a593Smuzhiyun unsigned ib_size;
291*4882a593Smuzhiyun
292*4882a593Smuzhiyun Bool has_source_coords, has_mask_coords;
293*4882a593Smuzhiyun int render_nr_quads;
294*4882a593Smuzhiyun glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
295*4882a593Smuzhiyun [SHADER_MASK_COUNT]
296*4882a593Smuzhiyun [glamor_program_alpha_count]
297*4882a593Smuzhiyun [SHADER_DEST_SWIZZLE_COUNT];
298*4882a593Smuzhiyun
299*4882a593Smuzhiyun /* glamor gradient, 0 for small nstops, 1 for
300*4882a593Smuzhiyun large nstops and 2 for dynamic generate. */
301*4882a593Smuzhiyun GLint gradient_prog[SHADER_GRADIENT_COUNT][3];
302*4882a593Smuzhiyun int linear_max_nstops;
303*4882a593Smuzhiyun int radial_max_nstops;
304*4882a593Smuzhiyun
305*4882a593Smuzhiyun struct glamor_saved_procs saved_procs;
306*4882a593Smuzhiyun GetDrawableModifiersFuncPtr get_drawable_modifiers;
307*4882a593Smuzhiyun int flags;
308*4882a593Smuzhiyun ScreenPtr screen;
309*4882a593Smuzhiyun int dri3_enabled;
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun Bool suppress_gl_out_of_memory_logging;
312*4882a593Smuzhiyun Bool logged_any_fbo_allocation_failure;
313*4882a593Smuzhiyun Bool logged_any_pbo_allocation_failure;
314*4882a593Smuzhiyun
315*4882a593Smuzhiyun /* xv */
316*4882a593Smuzhiyun glamor_program xv_prog;
317*4882a593Smuzhiyun glamor_program xv_prog_ext;
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun struct glamor_context ctx;
320*4882a593Smuzhiyun } glamor_screen_private;
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun typedef enum glamor_access {
323*4882a593Smuzhiyun GLAMOR_ACCESS_RO,
324*4882a593Smuzhiyun GLAMOR_ACCESS_RW,
325*4882a593Smuzhiyun } glamor_access_t;
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun enum glamor_fbo_state {
328*4882a593Smuzhiyun /** There is no storage attached to the pixmap. */
329*4882a593Smuzhiyun GLAMOR_FBO_UNATTACHED,
330*4882a593Smuzhiyun /**
331*4882a593Smuzhiyun * The pixmap has FBO storage attached, but devPrivate.ptr doesn't
332*4882a593Smuzhiyun * point at anything.
333*4882a593Smuzhiyun */
334*4882a593Smuzhiyun GLAMOR_FBO_NORMAL,
335*4882a593Smuzhiyun };
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun typedef struct glamor_pixmap_fbo {
338*4882a593Smuzhiyun GLuint tex; /**< GL texture name */
339*4882a593Smuzhiyun GLuint fb; /**< GL FBO name */
340*4882a593Smuzhiyun int width; /**< width in pixels */
341*4882a593Smuzhiyun int height; /**< height in pixels */
342*4882a593Smuzhiyun Bool is_red;
343*4882a593Smuzhiyun } glamor_pixmap_fbo;
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun typedef struct glamor_pixmap_clipped_regions {
346*4882a593Smuzhiyun int block_idx;
347*4882a593Smuzhiyun RegionPtr region;
348*4882a593Smuzhiyun } glamor_pixmap_clipped_regions;
349*4882a593Smuzhiyun
350*4882a593Smuzhiyun typedef struct glamor_pixmap_private {
351*4882a593Smuzhiyun glamor_pixmap_type_t type;
352*4882a593Smuzhiyun enum glamor_fbo_state gl_fbo;
353*4882a593Smuzhiyun /**
354*4882a593Smuzhiyun * If devPrivate.ptr is non-NULL (meaning we're within
355*4882a593Smuzhiyun * glamor_prepare_access), determies whether we should re-upload
356*4882a593Smuzhiyun * that data on glamor_finish_access().
357*4882a593Smuzhiyun */
358*4882a593Smuzhiyun glamor_access_t map_access;
359*4882a593Smuzhiyun glamor_pixmap_fbo *fbo;
360*4882a593Smuzhiyun /** current fbo's coords in the whole pixmap. */
361*4882a593Smuzhiyun BoxRec box;
362*4882a593Smuzhiyun GLuint pbo;
363*4882a593Smuzhiyun RegionRec prepare_region;
364*4882a593Smuzhiyun Bool prepared;
365*4882a593Smuzhiyun #ifdef GLAMOR_HAS_GBM
366*4882a593Smuzhiyun struct gbm_bo *bo;
367*4882a593Smuzhiyun Bool owned_bo;
368*4882a593Smuzhiyun Bool used_modifiers;
369*4882a593Smuzhiyun Bool bo_mapped;
370*4882a593Smuzhiyun void *map_data;
371*4882a593Smuzhiyun Bool exporting;
372*4882a593Smuzhiyun #endif
373*4882a593Smuzhiyun Bool gl_synced;
374*4882a593Smuzhiyun /** block width of this large pixmap. */
375*4882a593Smuzhiyun int block_w;
376*4882a593Smuzhiyun /** block height of this large pixmap. */
377*4882a593Smuzhiyun int block_h;
378*4882a593Smuzhiyun
379*4882a593Smuzhiyun /** block_wcnt: block count in one block row. */
380*4882a593Smuzhiyun int block_wcnt;
381*4882a593Smuzhiyun /** block_hcnt: block count in one block column. */
382*4882a593Smuzhiyun int block_hcnt;
383*4882a593Smuzhiyun
384*4882a593Smuzhiyun /**
385*4882a593Smuzhiyun * The list of boxes for the bounds of the FBOs making up the
386*4882a593Smuzhiyun * pixmap.
387*4882a593Smuzhiyun *
388*4882a593Smuzhiyun * For a 2048x2048 pixmap with GL FBO size limits of 1024x1024:
389*4882a593Smuzhiyun *
390*4882a593Smuzhiyun * ******************
391*4882a593Smuzhiyun * * fbo0 * fbo1 *
392*4882a593Smuzhiyun * * * *
393*4882a593Smuzhiyun * ******************
394*4882a593Smuzhiyun * * fbo2 * fbo3 *
395*4882a593Smuzhiyun * * * *
396*4882a593Smuzhiyun * ******************
397*4882a593Smuzhiyun *
398*4882a593Smuzhiyun * box[0] = {0,0,1024,1024}
399*4882a593Smuzhiyun * box[1] = {1024,0,2048,2048}
400*4882a593Smuzhiyun * ...
401*4882a593Smuzhiyun */
402*4882a593Smuzhiyun BoxPtr box_array;
403*4882a593Smuzhiyun
404*4882a593Smuzhiyun /**
405*4882a593Smuzhiyun * Array of fbo structs containing the actual GL texture/fbo
406*4882a593Smuzhiyun * names.
407*4882a593Smuzhiyun */
408*4882a593Smuzhiyun glamor_pixmap_fbo **fbo_array;
409*4882a593Smuzhiyun
410*4882a593Smuzhiyun Bool is_cbcr;
411*4882a593Smuzhiyun } glamor_pixmap_private;
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun extern DevPrivateKeyRec glamor_pixmap_private_key;
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun static inline glamor_pixmap_private *
glamor_get_pixmap_private(PixmapPtr pixmap)416*4882a593Smuzhiyun glamor_get_pixmap_private(PixmapPtr pixmap)
417*4882a593Smuzhiyun {
418*4882a593Smuzhiyun if (pixmap == NULL)
419*4882a593Smuzhiyun return NULL;
420*4882a593Smuzhiyun
421*4882a593Smuzhiyun return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
422*4882a593Smuzhiyun }
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun /*
425*4882a593Smuzhiyun * Returns TRUE if pixmap has no image object
426*4882a593Smuzhiyun */
427*4882a593Smuzhiyun static inline Bool
glamor_pixmap_drm_only(PixmapPtr pixmap)428*4882a593Smuzhiyun glamor_pixmap_drm_only(PixmapPtr pixmap)
429*4882a593Smuzhiyun {
430*4882a593Smuzhiyun glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
431*4882a593Smuzhiyun
432*4882a593Smuzhiyun return priv->type == GLAMOR_DRM_ONLY;
433*4882a593Smuzhiyun }
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun /*
436*4882a593Smuzhiyun * Returns TRUE if pixmap is plain memory (not a GL object at all)
437*4882a593Smuzhiyun */
438*4882a593Smuzhiyun static inline Bool
glamor_pixmap_is_memory(PixmapPtr pixmap)439*4882a593Smuzhiyun glamor_pixmap_is_memory(PixmapPtr pixmap)
440*4882a593Smuzhiyun {
441*4882a593Smuzhiyun glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
442*4882a593Smuzhiyun
443*4882a593Smuzhiyun return priv->type == GLAMOR_MEMORY;
444*4882a593Smuzhiyun }
445*4882a593Smuzhiyun
446*4882a593Smuzhiyun /*
447*4882a593Smuzhiyun * Returns TRUE if pixmap requires multiple textures to hold it
448*4882a593Smuzhiyun */
449*4882a593Smuzhiyun static inline Bool
glamor_pixmap_priv_is_large(glamor_pixmap_private * priv)450*4882a593Smuzhiyun glamor_pixmap_priv_is_large(glamor_pixmap_private *priv)
451*4882a593Smuzhiyun {
452*4882a593Smuzhiyun return priv->block_wcnt > 1 || priv->block_hcnt > 1;
453*4882a593Smuzhiyun }
454*4882a593Smuzhiyun
455*4882a593Smuzhiyun static inline Bool
glamor_pixmap_priv_is_small(glamor_pixmap_private * priv)456*4882a593Smuzhiyun glamor_pixmap_priv_is_small(glamor_pixmap_private *priv)
457*4882a593Smuzhiyun {
458*4882a593Smuzhiyun return priv->block_wcnt <= 1 && priv->block_hcnt <= 1;
459*4882a593Smuzhiyun }
460*4882a593Smuzhiyun
461*4882a593Smuzhiyun static inline Bool
glamor_pixmap_is_large(PixmapPtr pixmap)462*4882a593Smuzhiyun glamor_pixmap_is_large(PixmapPtr pixmap)
463*4882a593Smuzhiyun {
464*4882a593Smuzhiyun glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun return glamor_pixmap_priv_is_large(priv);
467*4882a593Smuzhiyun }
468*4882a593Smuzhiyun /*
469*4882a593Smuzhiyun * Returns TRUE if pixmap has an FBO
470*4882a593Smuzhiyun */
471*4882a593Smuzhiyun static inline Bool
glamor_pixmap_has_fbo(PixmapPtr pixmap)472*4882a593Smuzhiyun glamor_pixmap_has_fbo(PixmapPtr pixmap)
473*4882a593Smuzhiyun {
474*4882a593Smuzhiyun glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
475*4882a593Smuzhiyun
476*4882a593Smuzhiyun return priv->gl_fbo == GLAMOR_FBO_NORMAL;
477*4882a593Smuzhiyun }
478*4882a593Smuzhiyun
479*4882a593Smuzhiyun static inline void
glamor_set_pixmap_fbo_current(glamor_pixmap_private * priv,int idx)480*4882a593Smuzhiyun glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
481*4882a593Smuzhiyun {
482*4882a593Smuzhiyun if (glamor_pixmap_priv_is_large(priv)) {
483*4882a593Smuzhiyun priv->fbo = priv->fbo_array[idx];
484*4882a593Smuzhiyun priv->box = priv->box_array[idx];
485*4882a593Smuzhiyun }
486*4882a593Smuzhiyun }
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun static inline glamor_pixmap_fbo *
glamor_pixmap_fbo_at(glamor_pixmap_private * priv,int box)489*4882a593Smuzhiyun glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int box)
490*4882a593Smuzhiyun {
491*4882a593Smuzhiyun assert(box < priv->block_wcnt * priv->block_hcnt);
492*4882a593Smuzhiyun return priv->fbo_array[box];
493*4882a593Smuzhiyun }
494*4882a593Smuzhiyun
495*4882a593Smuzhiyun static inline BoxPtr
glamor_pixmap_box_at(glamor_pixmap_private * priv,int box)496*4882a593Smuzhiyun glamor_pixmap_box_at(glamor_pixmap_private *priv, int box)
497*4882a593Smuzhiyun {
498*4882a593Smuzhiyun assert(box < priv->block_wcnt * priv->block_hcnt);
499*4882a593Smuzhiyun return &priv->box_array[box];
500*4882a593Smuzhiyun }
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun static inline int
glamor_pixmap_wcnt(glamor_pixmap_private * priv)503*4882a593Smuzhiyun glamor_pixmap_wcnt(glamor_pixmap_private *priv)
504*4882a593Smuzhiyun {
505*4882a593Smuzhiyun return priv->block_wcnt;
506*4882a593Smuzhiyun }
507*4882a593Smuzhiyun
508*4882a593Smuzhiyun static inline int
glamor_pixmap_hcnt(glamor_pixmap_private * priv)509*4882a593Smuzhiyun glamor_pixmap_hcnt(glamor_pixmap_private *priv)
510*4882a593Smuzhiyun {
511*4882a593Smuzhiyun return priv->block_hcnt;
512*4882a593Smuzhiyun }
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun #define glamor_pixmap_loop(priv, box_index) \
515*4882a593Smuzhiyun for (box_index = 0; box_index < glamor_pixmap_hcnt(priv) * \
516*4882a593Smuzhiyun glamor_pixmap_wcnt(priv); box_index++) \
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun /* GC private structure. Currently holds only any computed dash pixmap */
519*4882a593Smuzhiyun
520*4882a593Smuzhiyun typedef struct {
521*4882a593Smuzhiyun PixmapPtr dash;
522*4882a593Smuzhiyun PixmapPtr stipple;
523*4882a593Smuzhiyun DamagePtr stipple_damage;
524*4882a593Smuzhiyun } glamor_gc_private;
525*4882a593Smuzhiyun
526*4882a593Smuzhiyun extern DevPrivateKeyRec glamor_gc_private_key;
527*4882a593Smuzhiyun extern DevPrivateKeyRec glamor_screen_private_key;
528*4882a593Smuzhiyun
529*4882a593Smuzhiyun extern glamor_screen_private *
530*4882a593Smuzhiyun glamor_get_screen_private(ScreenPtr screen);
531*4882a593Smuzhiyun
532*4882a593Smuzhiyun extern void
533*4882a593Smuzhiyun glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv);
534*4882a593Smuzhiyun
535*4882a593Smuzhiyun static inline glamor_gc_private *
glamor_get_gc_private(GCPtr gc)536*4882a593Smuzhiyun glamor_get_gc_private(GCPtr gc)
537*4882a593Smuzhiyun {
538*4882a593Smuzhiyun return dixLookupPrivate(&gc->devPrivates, &glamor_gc_private_key);
539*4882a593Smuzhiyun }
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun /**
542*4882a593Smuzhiyun * Returns TRUE if the given planemask covers all the significant bits in the
543*4882a593Smuzhiyun * pixel values for pDrawable.
544*4882a593Smuzhiyun */
545*4882a593Smuzhiyun static inline Bool
glamor_pm_is_solid(int depth,unsigned long planemask)546*4882a593Smuzhiyun glamor_pm_is_solid(int depth, unsigned long planemask)
547*4882a593Smuzhiyun {
548*4882a593Smuzhiyun return (planemask & FbFullMask(depth)) ==
549*4882a593Smuzhiyun FbFullMask(depth);
550*4882a593Smuzhiyun }
551*4882a593Smuzhiyun
552*4882a593Smuzhiyun extern int glamor_debug_level;
553*4882a593Smuzhiyun
554*4882a593Smuzhiyun /* glamor.c */
555*4882a593Smuzhiyun PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
556*4882a593Smuzhiyun
557*4882a593Smuzhiyun glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
558*4882a593Smuzhiyun pixmap_priv);
559*4882a593Smuzhiyun void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
560*4882a593Smuzhiyun glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
561*4882a593Smuzhiyun glamor_priv, PixmapPtr pixmap,
562*4882a593Smuzhiyun int w, int h, GLint tex,
563*4882a593Smuzhiyun int flag);
564*4882a593Smuzhiyun glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv,
565*4882a593Smuzhiyun PixmapPtr pixmap, int w, int h, int flag);
566*4882a593Smuzhiyun void glamor_destroy_fbo(glamor_screen_private *glamor_priv,
567*4882a593Smuzhiyun glamor_pixmap_fbo *fbo);
568*4882a593Smuzhiyun void glamor_pixmap_destroy_fbo(PixmapPtr pixmap);
569*4882a593Smuzhiyun Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
570*4882a593Smuzhiyun void glamor_pixmap_clear_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo);
571*4882a593Smuzhiyun
572*4882a593Smuzhiyun const struct glamor_format *glamor_format_for_pixmap(PixmapPtr pixmap);
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun /* Return whether 'picture' is alpha-only */
glamor_picture_is_alpha(PicturePtr picture)575*4882a593Smuzhiyun static inline Bool glamor_picture_is_alpha(PicturePtr picture)
576*4882a593Smuzhiyun {
577*4882a593Smuzhiyun return picture->format == PICT_a1 || picture->format == PICT_a8;
578*4882a593Smuzhiyun }
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun /* Return whether 'picture' is storing alpha bits in the red channel */
581*4882a593Smuzhiyun static inline Bool
glamor_picture_red_is_alpha(PicturePtr picture)582*4882a593Smuzhiyun glamor_picture_red_is_alpha(PicturePtr picture)
583*4882a593Smuzhiyun {
584*4882a593Smuzhiyun /* True when the picture is alpha only and the screen is using GL_RED for alpha pictures */
585*4882a593Smuzhiyun return glamor_picture_is_alpha(picture) &&
586*4882a593Smuzhiyun glamor_get_screen_private(picture->pDrawable->pScreen)->formats[8].format == GL_RED;
587*4882a593Smuzhiyun }
588*4882a593Smuzhiyun
589*4882a593Smuzhiyun void glamor_bind_texture(glamor_screen_private *glamor_priv,
590*4882a593Smuzhiyun GLenum texture,
591*4882a593Smuzhiyun glamor_pixmap_fbo *fbo,
592*4882a593Smuzhiyun Bool destination_red);
593*4882a593Smuzhiyun
594*4882a593Smuzhiyun glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
595*4882a593Smuzhiyun PixmapPtr pixmap,
596*4882a593Smuzhiyun int flag, int block_w, int block_h,
597*4882a593Smuzhiyun glamor_pixmap_private *);
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun void glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv,
600*4882a593Smuzhiyun unsigned count);
601*4882a593Smuzhiyun
602*4882a593Smuzhiyun /* glamor_core.c */
603*4882a593Smuzhiyun Bool glamor_get_drawable_location(const DrawablePtr drawable);
604*4882a593Smuzhiyun void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
605*4882a593Smuzhiyun int *x, int *y);
606*4882a593Smuzhiyun GLint glamor_compile_glsl_prog(GLenum type, const char *source);
607*4882a593Smuzhiyun void glamor_link_glsl_prog(ScreenPtr screen, GLint prog,
608*4882a593Smuzhiyun const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
609*4882a593Smuzhiyun void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
610*4882a593Smuzhiyun unsigned long fg_pixel, GLfloat *color);
611*4882a593Smuzhiyun
612*4882a593Smuzhiyun int glamor_set_destination_pixmap(PixmapPtr pixmap);
613*4882a593Smuzhiyun int glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
614*4882a593Smuzhiyun void glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *, int, int, int, int);
615*4882a593Smuzhiyun
616*4882a593Smuzhiyun /* nc means no check. caller must ensure this pixmap has valid fbo.
617*4882a593Smuzhiyun * usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
618*4882a593Smuzhiyun * */
619*4882a593Smuzhiyun void glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv);
620*4882a593Smuzhiyun
621*4882a593Smuzhiyun Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
622*4882a593Smuzhiyun Bool glamor_set_planemask(int depth, unsigned long planemask);
623*4882a593Smuzhiyun RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
624*4882a593Smuzhiyun
625*4882a593Smuzhiyun void
626*4882a593Smuzhiyun glamor_track_stipple(GCPtr gc);
627*4882a593Smuzhiyun
628*4882a593Smuzhiyun /* glamor_render.c */
629*4882a593Smuzhiyun Bool glamor_composite_clipped_region(CARD8 op,
630*4882a593Smuzhiyun PicturePtr source,
631*4882a593Smuzhiyun PicturePtr mask,
632*4882a593Smuzhiyun PicturePtr dest,
633*4882a593Smuzhiyun PixmapPtr source_pixmap,
634*4882a593Smuzhiyun PixmapPtr mask_pixmap,
635*4882a593Smuzhiyun PixmapPtr dest_pixmap,
636*4882a593Smuzhiyun RegionPtr region,
637*4882a593Smuzhiyun int x_source,
638*4882a593Smuzhiyun int y_source,
639*4882a593Smuzhiyun int x_mask, int y_mask,
640*4882a593Smuzhiyun int x_dest, int y_dest);
641*4882a593Smuzhiyun
642*4882a593Smuzhiyun void glamor_composite(CARD8 op,
643*4882a593Smuzhiyun PicturePtr pSrc,
644*4882a593Smuzhiyun PicturePtr pMask,
645*4882a593Smuzhiyun PicturePtr pDst,
646*4882a593Smuzhiyun INT16 xSrc,
647*4882a593Smuzhiyun INT16 ySrc,
648*4882a593Smuzhiyun INT16 xMask,
649*4882a593Smuzhiyun INT16 yMask,
650*4882a593Smuzhiyun INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
651*4882a593Smuzhiyun
652*4882a593Smuzhiyun void glamor_composite_rects(CARD8 op,
653*4882a593Smuzhiyun PicturePtr pDst,
654*4882a593Smuzhiyun xRenderColor *color, int nRect, xRectangle *rects);
655*4882a593Smuzhiyun
656*4882a593Smuzhiyun /* glamor_trapezoid.c */
657*4882a593Smuzhiyun void glamor_trapezoids(CARD8 op,
658*4882a593Smuzhiyun PicturePtr src, PicturePtr dst,
659*4882a593Smuzhiyun PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
660*4882a593Smuzhiyun int ntrap, xTrapezoid *traps);
661*4882a593Smuzhiyun
662*4882a593Smuzhiyun /* glamor_gradient.c */
663*4882a593Smuzhiyun void glamor_init_gradient_shader(ScreenPtr screen);
664*4882a593Smuzhiyun PicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen,
665*4882a593Smuzhiyun PicturePtr src_picture,
666*4882a593Smuzhiyun int x_source, int y_source,
667*4882a593Smuzhiyun int width, int height,
668*4882a593Smuzhiyun PictFormatShort format);
669*4882a593Smuzhiyun PicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
670*4882a593Smuzhiyun PicturePtr src_picture,
671*4882a593Smuzhiyun int x_source, int y_source,
672*4882a593Smuzhiyun int width, int height,
673*4882a593Smuzhiyun PictFormatShort format);
674*4882a593Smuzhiyun
675*4882a593Smuzhiyun /* glamor_triangles.c */
676*4882a593Smuzhiyun void glamor_triangles(CARD8 op,
677*4882a593Smuzhiyun PicturePtr pSrc,
678*4882a593Smuzhiyun PicturePtr pDst,
679*4882a593Smuzhiyun PictFormatPtr maskFormat,
680*4882a593Smuzhiyun INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
681*4882a593Smuzhiyun
682*4882a593Smuzhiyun /* glamor_pixmap.c */
683*4882a593Smuzhiyun
684*4882a593Smuzhiyun void glamor_pixmap_init(ScreenPtr screen);
685*4882a593Smuzhiyun void glamor_pixmap_fini(ScreenPtr screen);
686*4882a593Smuzhiyun
687*4882a593Smuzhiyun /* glamor_vbo.c */
688*4882a593Smuzhiyun
689*4882a593Smuzhiyun void glamor_init_vbo(ScreenPtr screen);
690*4882a593Smuzhiyun void glamor_fini_vbo(ScreenPtr screen);
691*4882a593Smuzhiyun
692*4882a593Smuzhiyun void *
693*4882a593Smuzhiyun glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset);
694*4882a593Smuzhiyun
695*4882a593Smuzhiyun void
696*4882a593Smuzhiyun glamor_put_vbo_space(ScreenPtr screen);
697*4882a593Smuzhiyun
698*4882a593Smuzhiyun /**
699*4882a593Smuzhiyun * According to the flag,
700*4882a593Smuzhiyun * if the flag is GLAMOR_CREATE_FBO_NO_FBO then just ensure
701*4882a593Smuzhiyun * the fbo has a valid texture. Otherwise, it will ensure
702*4882a593Smuzhiyun * the fbo has valid texture and attach to a valid fb.
703*4882a593Smuzhiyun * If the fbo already has a valid glfbo then do nothing.
704*4882a593Smuzhiyun */
705*4882a593Smuzhiyun Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, int flag);
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun glamor_pixmap_clipped_regions *
708*4882a593Smuzhiyun glamor_compute_clipped_regions(PixmapPtr pixmap,
709*4882a593Smuzhiyun RegionPtr region, int *clipped_nbox,
710*4882a593Smuzhiyun int repeat_type, int reverse,
711*4882a593Smuzhiyun int upsidedown);
712*4882a593Smuzhiyun
713*4882a593Smuzhiyun glamor_pixmap_clipped_regions *
714*4882a593Smuzhiyun glamor_compute_clipped_regions_ext(PixmapPtr pixmap,
715*4882a593Smuzhiyun RegionPtr region, int *n_region,
716*4882a593Smuzhiyun int inner_block_w, int inner_block_h,
717*4882a593Smuzhiyun int reverse, int upsidedown);
718*4882a593Smuzhiyun
719*4882a593Smuzhiyun Bool glamor_composite_largepixmap_region(CARD8 op,
720*4882a593Smuzhiyun PicturePtr source,
721*4882a593Smuzhiyun PicturePtr mask,
722*4882a593Smuzhiyun PicturePtr dest,
723*4882a593Smuzhiyun PixmapPtr source_pixmap,
724*4882a593Smuzhiyun PixmapPtr mask_pixmap,
725*4882a593Smuzhiyun PixmapPtr dest_pixmap,
726*4882a593Smuzhiyun RegionPtr region, Bool force_clip,
727*4882a593Smuzhiyun INT16 x_source,
728*4882a593Smuzhiyun INT16 y_source,
729*4882a593Smuzhiyun INT16 x_mask,
730*4882a593Smuzhiyun INT16 y_mask,
731*4882a593Smuzhiyun INT16 x_dest, INT16 y_dest,
732*4882a593Smuzhiyun CARD16 width, CARD16 height);
733*4882a593Smuzhiyun
734*4882a593Smuzhiyun /**
735*4882a593Smuzhiyun * Upload a picture to gl texture. Similar to the
736*4882a593Smuzhiyun * glamor_upload_pixmap_to_texture. Used in rendering.
737*4882a593Smuzhiyun **/
738*4882a593Smuzhiyun Bool glamor_upload_picture_to_texture(PicturePtr picture);
739*4882a593Smuzhiyun
740*4882a593Smuzhiyun void glamor_add_traps(PicturePtr pPicture,
741*4882a593Smuzhiyun INT16 x_off, INT16 y_off, int ntrap, xTrap *traps);
742*4882a593Smuzhiyun
743*4882a593Smuzhiyun /* glamor_text.c */
744*4882a593Smuzhiyun int glamor_poly_text8(DrawablePtr pDrawable, GCPtr pGC,
745*4882a593Smuzhiyun int x, int y, int count, char *chars);
746*4882a593Smuzhiyun
747*4882a593Smuzhiyun int glamor_poly_text16(DrawablePtr pDrawable, GCPtr pGC,
748*4882a593Smuzhiyun int x, int y, int count, unsigned short *chars);
749*4882a593Smuzhiyun
750*4882a593Smuzhiyun void glamor_image_text8(DrawablePtr pDrawable, GCPtr pGC,
751*4882a593Smuzhiyun int x, int y, int count, char *chars);
752*4882a593Smuzhiyun
753*4882a593Smuzhiyun void glamor_image_text16(DrawablePtr pDrawable, GCPtr pGC,
754*4882a593Smuzhiyun int x, int y, int count, unsigned short *chars);
755*4882a593Smuzhiyun
756*4882a593Smuzhiyun /* glamor_spans.c */
757*4882a593Smuzhiyun void
758*4882a593Smuzhiyun glamor_fill_spans(DrawablePtr drawable,
759*4882a593Smuzhiyun GCPtr gc,
760*4882a593Smuzhiyun int n, DDXPointPtr points, int *widths, int sorted);
761*4882a593Smuzhiyun
762*4882a593Smuzhiyun void
763*4882a593Smuzhiyun glamor_get_spans(DrawablePtr drawable, int wmax,
764*4882a593Smuzhiyun DDXPointPtr points, int *widths, int count, char *dst);
765*4882a593Smuzhiyun
766*4882a593Smuzhiyun void
767*4882a593Smuzhiyun glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
768*4882a593Smuzhiyun DDXPointPtr points, int *widths, int numPoints, int sorted);
769*4882a593Smuzhiyun
770*4882a593Smuzhiyun /* glamor_rects.c */
771*4882a593Smuzhiyun void
772*4882a593Smuzhiyun glamor_poly_fill_rect(DrawablePtr drawable,
773*4882a593Smuzhiyun GCPtr gc, int nrect, xRectangle *prect);
774*4882a593Smuzhiyun
775*4882a593Smuzhiyun /* glamor_image.c */
776*4882a593Smuzhiyun void
777*4882a593Smuzhiyun glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
778*4882a593Smuzhiyun int w, int h, int leftPad, int format, char *bits);
779*4882a593Smuzhiyun
780*4882a593Smuzhiyun void
781*4882a593Smuzhiyun glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
782*4882a593Smuzhiyun unsigned int format, unsigned long planeMask, char *d);
783*4882a593Smuzhiyun
784*4882a593Smuzhiyun /* glamor_dash.c */
785*4882a593Smuzhiyun Bool
786*4882a593Smuzhiyun glamor_poly_lines_dash_gl(DrawablePtr drawable, GCPtr gc,
787*4882a593Smuzhiyun int mode, int n, DDXPointPtr points);
788*4882a593Smuzhiyun
789*4882a593Smuzhiyun Bool
790*4882a593Smuzhiyun glamor_poly_segment_dash_gl(DrawablePtr drawable, GCPtr gc,
791*4882a593Smuzhiyun int nseg, xSegment *segs);
792*4882a593Smuzhiyun
793*4882a593Smuzhiyun /* glamor_lines.c */
794*4882a593Smuzhiyun void
795*4882a593Smuzhiyun glamor_poly_lines(DrawablePtr drawable, GCPtr gc,
796*4882a593Smuzhiyun int mode, int n, DDXPointPtr points);
797*4882a593Smuzhiyun
798*4882a593Smuzhiyun /* glamor_segs.c */
799*4882a593Smuzhiyun void
800*4882a593Smuzhiyun glamor_poly_segment(DrawablePtr drawable, GCPtr gc,
801*4882a593Smuzhiyun int nseg, xSegment *segs);
802*4882a593Smuzhiyun
803*4882a593Smuzhiyun /* glamor_copy.c */
804*4882a593Smuzhiyun void
805*4882a593Smuzhiyun glamor_copy(DrawablePtr src,
806*4882a593Smuzhiyun DrawablePtr dst,
807*4882a593Smuzhiyun GCPtr gc,
808*4882a593Smuzhiyun BoxPtr box,
809*4882a593Smuzhiyun int nbox,
810*4882a593Smuzhiyun int dx,
811*4882a593Smuzhiyun int dy,
812*4882a593Smuzhiyun Bool reverse,
813*4882a593Smuzhiyun Bool upsidedown,
814*4882a593Smuzhiyun Pixel bitplane,
815*4882a593Smuzhiyun void *closure);
816*4882a593Smuzhiyun
817*4882a593Smuzhiyun RegionPtr
818*4882a593Smuzhiyun glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
819*4882a593Smuzhiyun int srcx, int srcy, int width, int height, int dstx, int dsty);
820*4882a593Smuzhiyun
821*4882a593Smuzhiyun RegionPtr
822*4882a593Smuzhiyun glamor_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
823*4882a593Smuzhiyun int srcx, int srcy, int width, int height, int dstx, int dsty,
824*4882a593Smuzhiyun unsigned long bitplane);
825*4882a593Smuzhiyun
826*4882a593Smuzhiyun /* glamor_glyphblt.c */
827*4882a593Smuzhiyun void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
828*4882a593Smuzhiyun int x, int y, unsigned int nglyph,
829*4882a593Smuzhiyun CharInfoPtr *ppci, void *pglyphBase);
830*4882a593Smuzhiyun
831*4882a593Smuzhiyun void glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
832*4882a593Smuzhiyun int x, int y, unsigned int nglyph,
833*4882a593Smuzhiyun CharInfoPtr *ppci, void *pglyphBase);
834*4882a593Smuzhiyun
835*4882a593Smuzhiyun void glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
836*4882a593Smuzhiyun DrawablePtr pDrawable, int w, int h, int x, int y);
837*4882a593Smuzhiyun
838*4882a593Smuzhiyun void glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
839*4882a593Smuzhiyun DDXPointPtr ppt);
840*4882a593Smuzhiyun
841*4882a593Smuzhiyun void glamor_composite_rectangles(CARD8 op,
842*4882a593Smuzhiyun PicturePtr dst,
843*4882a593Smuzhiyun xRenderColor *color,
844*4882a593Smuzhiyun int num_rects, xRectangle *rects);
845*4882a593Smuzhiyun
846*4882a593Smuzhiyun /* glamor_composite_glyphs.c */
847*4882a593Smuzhiyun Bool
848*4882a593Smuzhiyun glamor_composite_glyphs_init(ScreenPtr pScreen);
849*4882a593Smuzhiyun
850*4882a593Smuzhiyun void
851*4882a593Smuzhiyun glamor_composite_glyphs_fini(ScreenPtr pScreen);
852*4882a593Smuzhiyun
853*4882a593Smuzhiyun void
854*4882a593Smuzhiyun glamor_composite_glyphs(CARD8 op,
855*4882a593Smuzhiyun PicturePtr src,
856*4882a593Smuzhiyun PicturePtr dst,
857*4882a593Smuzhiyun PictFormatPtr mask_format,
858*4882a593Smuzhiyun INT16 x_src,
859*4882a593Smuzhiyun INT16 y_src, int nlist,
860*4882a593Smuzhiyun GlyphListPtr list, GlyphPtr *glyphs);
861*4882a593Smuzhiyun
862*4882a593Smuzhiyun /* glamor_sync.c */
863*4882a593Smuzhiyun Bool
864*4882a593Smuzhiyun glamor_sync_init(ScreenPtr screen);
865*4882a593Smuzhiyun
866*4882a593Smuzhiyun void
867*4882a593Smuzhiyun glamor_sync_close(ScreenPtr screen);
868*4882a593Smuzhiyun
869*4882a593Smuzhiyun /* glamor_util.c */
870*4882a593Smuzhiyun void
871*4882a593Smuzhiyun glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
872*4882a593Smuzhiyun unsigned long fg_pixel);
873*4882a593Smuzhiyun
874*4882a593Smuzhiyun void
875*4882a593Smuzhiyun glamor_solid_boxes(PixmapPtr pixmap,
876*4882a593Smuzhiyun BoxPtr box, int nbox, unsigned long fg_pixel);
877*4882a593Smuzhiyun
878*4882a593Smuzhiyun Bool
879*4882a593Smuzhiyun glamor_prefer_gl(const char *func);
880*4882a593Smuzhiyun
881*4882a593Smuzhiyun #define GLAMOR_PREFER_GL() glamor_prefer_gl(__func__)
882*4882a593Smuzhiyun
883*4882a593Smuzhiyun /* glamor_xv */
884*4882a593Smuzhiyun typedef struct {
885*4882a593Smuzhiyun uint32_t transform_index;
886*4882a593Smuzhiyun uint32_t gamma; /* gamma value x 1000 */
887*4882a593Smuzhiyun int brightness;
888*4882a593Smuzhiyun int saturation;
889*4882a593Smuzhiyun int hue;
890*4882a593Smuzhiyun int contrast;
891*4882a593Smuzhiyun uint32_t dma_client;
892*4882a593Smuzhiyun uint32_t dma_hor_stride;
893*4882a593Smuzhiyun uint32_t dma_ver_stride;
894*4882a593Smuzhiyun uint32_t dma_drm_fourcc;
895*4882a593Smuzhiyun uint32_t dma_drm_afbc;
896*4882a593Smuzhiyun int dma_socket_fd;
897*4882a593Smuzhiyun
898*4882a593Smuzhiyun DrawablePtr pDraw;
899*4882a593Smuzhiyun PixmapPtr pPixmap;
900*4882a593Smuzhiyun uint32_t src_pitch;
901*4882a593Smuzhiyun uint8_t *src_addr;
902*4882a593Smuzhiyun int src_w, src_h, dst_w, dst_h;
903*4882a593Smuzhiyun int src_x, src_y, drw_x, drw_y;
904*4882a593Smuzhiyun int w, h;
905*4882a593Smuzhiyun RegionRec clip;
906*4882a593Smuzhiyun PixmapPtr src_pix[3]; /* y, u, v for planar */
907*4882a593Smuzhiyun int src_pix_w, src_pix_h;
908*4882a593Smuzhiyun } glamor_port_private;
909*4882a593Smuzhiyun
910*4882a593Smuzhiyun extern XvAttributeRec glamor_xv_attributes[];
911*4882a593Smuzhiyun extern int glamor_xv_num_attributes;
912*4882a593Smuzhiyun extern XvImageRec glamor_xv_images[];
913*4882a593Smuzhiyun extern int glamor_xv_num_images;
914*4882a593Smuzhiyun
915*4882a593Smuzhiyun void glamor_xv_init_port(glamor_port_private *port_priv);
916*4882a593Smuzhiyun void glamor_xv_stop_video(glamor_port_private *port_priv);
917*4882a593Smuzhiyun int glamor_xv_set_port_attribute(glamor_port_private *port_priv,
918*4882a593Smuzhiyun Atom attribute, INT32 value);
919*4882a593Smuzhiyun int glamor_xv_get_port_attribute(glamor_port_private *port_priv,
920*4882a593Smuzhiyun Atom attribute, INT32 *value);
921*4882a593Smuzhiyun int glamor_xv_query_image_attributes(int id,
922*4882a593Smuzhiyun unsigned short *w, unsigned short *h,
923*4882a593Smuzhiyun int *pitches, int *offsets);
924*4882a593Smuzhiyun int glamor_xv_put_image(glamor_port_private *port_priv,
925*4882a593Smuzhiyun DrawablePtr pDrawable,
926*4882a593Smuzhiyun short src_x, short src_y,
927*4882a593Smuzhiyun short drw_x, short drw_y,
928*4882a593Smuzhiyun short src_w, short src_h,
929*4882a593Smuzhiyun short drw_w, short drw_h,
930*4882a593Smuzhiyun int id,
931*4882a593Smuzhiyun unsigned char *buf,
932*4882a593Smuzhiyun short width,
933*4882a593Smuzhiyun short height,
934*4882a593Smuzhiyun Bool sync,
935*4882a593Smuzhiyun RegionPtr clipBoxes);
936*4882a593Smuzhiyun void glamor_xv_core_init(ScreenPtr screen);
937*4882a593Smuzhiyun void glamor_xv_render(glamor_port_private *port_priv, int id);
938*4882a593Smuzhiyun
939*4882a593Smuzhiyun #include "glamor_utils.h"
940*4882a593Smuzhiyun
941*4882a593Smuzhiyun #if 0
942*4882a593Smuzhiyun #define MAX_FBO_SIZE 32 /* For test purpose only. */
943*4882a593Smuzhiyun #endif
944*4882a593Smuzhiyun
945*4882a593Smuzhiyun #include "glamor_font.h"
946*4882a593Smuzhiyun
947*4882a593Smuzhiyun #define GLAMOR_MIN_ALU_INSTRUCTIONS 128 /* Minimum required number of native ALU instructions */
948*4882a593Smuzhiyun
949*4882a593Smuzhiyun #endif /* GLAMOR_PRIV_H */
950