2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Zhigang Gong <zhigang.gong@linux.intel.com>
29 #error This file can only be included by glamor_priv.h
32 #ifndef __GLAMOR_UTILS_H__
33 #define __GLAMOR_UTILS_H__
35 #include "glamor_prepare.h"
38 #define v_from_x_coord_x(_xscale_, _x_) ( 2 * (_x_) * (_xscale_) - 1.0)
39 #define v_from_x_coord_y(_yscale_, _y_) (2 * (_y_) * (_yscale_) - 1.0)
40 #define t_from_x_coord_x(_xscale_, _x_) ((_x_) * (_xscale_))
41 #define t_from_x_coord_y(_yscale_, _y_) ((_y_) * (_yscale_))
43 #define pixmap_priv_get_dest_scale(pixmap, _pixmap_priv_, _pxscale_, _pyscale_) \
46 PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, _pixmap_priv_, _w_, _h_); \
47 *(_pxscale_) = 1.0 / _w_; \
48 *(_pyscale_) = 1.0 / _h_; \
51 #define pixmap_priv_get_scale(_pixmap_priv_, _pxscale_, _pyscale_) \
53 *(_pxscale_) = 1.0 / (_pixmap_priv_)->fbo->width; \
54 *(_pyscale_) = 1.0 / (_pixmap_priv_)->fbo->height; \
57 #define PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, w, h) \
59 if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
60 w = priv->box.x2 - priv->box.x1; \
61 h = priv->box.y2 - priv->box.y1; \
63 w = (pixmap)->drawable.width; \
64 h = (pixmap)->drawable.height; \
68 #define glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, priv) \
70 int actual_w, actual_h; \
71 PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, actual_w, actual_h); \
72 wh[0] = (float)priv->fbo->width / actual_w; \
73 wh[1] = (float)priv->fbo->height / actual_h; \
74 wh[2] = 1.0 / priv->fbo->width; \
75 wh[3] = 1.0 / priv->fbo->height; \
78 #define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_) \
80 if (_X_UNLIKELY(_priv_ && glamor_pixmap_priv_is_large(_priv_))) { \
81 *(_xoff_) = - (_priv_)->box.x1; \
82 *(_yoff_) = - (_priv_)->box.y1; \
89 #define xFixedToFloat(_val_) ((float)xFixedToInt(_val_) \
90 + ((float)xFixedFrac(_val_) / 65536.0))
92 #define glamor_picture_get_matrixf(_picture_, _matrix_) \
95 if ((_picture_)->transform) \
97 for(_i_ = 0; _i_ < 3; _i_++) \
99 (_matrix_)[_i_ * 3 + 0] = \
100 xFixedToFloat((_picture_)->transform->matrix[_i_][0]); \
101 (_matrix_)[_i_ * 3 + 1] = \
102 xFixedToFloat((_picture_)->transform->matrix[_i_][1]); \
103 (_matrix_)[_i_ * 3 + 2] = \
104 xFixedToFloat((_picture_)->transform->matrix[_i_][2]); \
109 #define fmod(x, w) (x - w * floor((float)x/w))
111 #define fmodulus(x, w, c) do {c = fmod(x, w); \
112 c = c >= 0 ? c : c + w;} \
114 /* @x: is current coord
115 * @x2: is the right/bottom edge
116 * @w: is current width or height
117 * @odd: is output value, 0 means we are in an even region, 1 means we are in a
119 * @c: is output value, equal to x mod w. */
120 #define fodd_repeat_mod(x, x2, w, odd, c) \
123 fmodulus((x), w, c); \
124 shift = fabs((x) - (c)); \
125 shift = floor(fabs(round(shift)) / w); \
126 odd = (int)shift & 1; \
127 if (odd && (((x2 % w) == 0) && \
128 round(fabs(x)) == x2)) \
132 /* @txy: output value, is the corrected coords.
133 * @xy: input coords to be fixed up.
134 * @cd: xy mod wh, is a input value.
135 * @wh: current width or height.
136 * @bxy1,bxy2: current box edge's x1/x2 or y1/y2
143 * tx = (c - x1) mod w
150 * tx = - (c - (x1 mod w))
158 * tx = ((x2 mod x) - c) + (x2 - x1)
160 #define __glamor_repeat_reflect_fixup(txy, xy, \
161 cd, wh, bxy1, bxy2) \
164 if ( xy >= bxy1 && xy < bxy2) { \
166 fmodulus(cd, wh, txy); \
167 } else if (xy < bxy1) { \
169 fmodulus(bxy1, wh, bxy1_mod); \
170 txy = -(cd - bxy1_mod); \
172 else if (xy >= bxy2) { \
174 fmodulus(bxy2, wh, bxy2_mod); \
177 txy = (bxy2_mod - cd) + bxy2 - bxy1; \
178 } else {assert(0); txy = 0;} \
181 #define _glamor_repeat_reflect_fixup(txy, xy, cd, odd, \
185 __glamor_repeat_reflect_fixup(txy, xy, \
186 cd, wh, bxy1, bxy2); \
191 #define _glamor_get_reflect_transform_coords(pixmap, priv, repeat_type, \
197 fodd_repeat_mod(_x1_,priv->box.x2, \
198 (pixmap)->drawable.width, \
200 fodd_repeat_mod(_y1_, priv->box.y2, \
201 (pixmap)->drawable.height, \
203 DEBUGF("c %f d %f oddx %d oddy %d \n", \
204 c, d, odd_x, odd_y); \
205 DEBUGF("x2 %d x1 %d fbo->width %d \n", priv->box.x2, \
206 priv->box.x1, priv->fbo->width); \
207 DEBUGF("y2 %d y1 %d fbo->height %d \n", priv->box.y2, \
208 priv->box.y1, priv->fbo->height); \
209 _glamor_repeat_reflect_fixup(tx1, _x1_, c, odd_x, \
210 (pixmap)->drawable.width, \
211 priv->box.x1, priv->box.x2); \
212 _glamor_repeat_reflect_fixup(ty1, _y1_, d, odd_y, \
213 (pixmap)->drawable.height, \
214 priv->box.y1, priv->box.y2); \
217 #define _glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, \
220 _y2_, c, d, odd_x, odd_y) \
222 if (repeat_type == RepeatReflect) { \
223 DEBUGF("x1 y1 %d %d\n", \
225 DEBUGF("width %d box.x1 %d \n", \
226 (pixmap)->drawable.width, \
229 c = (pixmap)->drawable.width \
231 tx1 = c - priv->box.x1; \
232 tx2 = tx1 - ((_x2_) - (_x1_)); \
234 tx1 = c - priv->box.x1; \
235 tx2 = tx1 + ((_x2_) - (_x1_)); \
238 d = (pixmap)->drawable.height\
240 ty1 = d - priv->box.y1; \
241 ty2 = ty1 - ((_y2_) - (_y1_)); \
243 ty1 = d - priv->box.y1; \
244 ty2 = ty1 + ((_y2_) - (_y1_)); \
246 } else { /* RepeatNormal*/ \
247 tx1 = (c - priv->box.x1); \
248 ty1 = (d - priv->box.y1); \
249 tx2 = tx1 + ((_x2_) - (_x1_)); \
250 ty2 = ty1 + ((_y2_) - (_y1_)); \
254 /* _x1_ ... _y2_ may has fractional. */
255 #define glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, tx1, \
258 DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \
259 (pixmap)->drawable.width, \
260 priv->box.x1, priv->box.x2, priv->box.y1, \
262 DEBUGF("x1 %f y1 %f \n", _x1_, _y1_); \
263 if (repeat_type != RepeatReflect) { \
264 tx1 = _x1_ - priv->box.x1; \
265 ty1 = _y1_ - priv->box.y1; \
267 _glamor_get_reflect_transform_coords(pixmap, priv, repeat_type, \
270 DEBUGF("tx1 %f ty1 %f \n", tx1, ty1); \
273 /* _x1_ ... _y2_ must be integer. */
274 #define glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, \
275 ty1, tx2, ty2, _x1_, _y1_, _x2_, \
279 int odd_x = 0, odd_y = 0; \
280 DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \
281 (pixmap)->drawable.width, \
282 priv->box.x1, priv->box.x2, \
283 priv->box.y1, priv->box.y2); \
284 modulus((_x1_), (pixmap)->drawable.width, c); \
285 modulus((_y1_), (pixmap)->drawable.height, d); \
286 DEBUGF("c %d d %d \n", c, d); \
287 if (repeat_type == RepeatReflect) { \
288 odd_x = abs((_x1_ - c) \
289 / ((pixmap)->drawable.width)) & 1; \
290 odd_y = abs((_y1_ - d) \
291 / ((pixmap)->drawable.height)) & 1; \
293 _glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, ty1, tx2, ty2, \
294 _x1_, _y1_, _x2_, _y2_, c, d, \
298 #define glamor_transform_point(matrix, tx, ty, x, y) \
302 for (_i_ = 0; _i_ < 3; _i_++) { \
303 _result_[_i_] = (matrix)[_i_ * 3] * (x) + (matrix)[_i_ * 3 + 1] * (y) \
304 + (matrix)[_i_ * 3 + 2]; \
306 tx = _result_[0] / _result_[2]; \
307 ty = _result_[1] / _result_[2]; \
310 #define _glamor_set_normalize_tpoint(xscale, yscale, _tx_, _ty_, \
313 (texcoord)[0] = t_from_x_coord_x(xscale, _tx_); \
314 (texcoord)[1] = t_from_x_coord_y(yscale, _ty_); \
315 DEBUGF("normalized point tx %f ty %f \n", (texcoord)[0], \
319 #define glamor_set_transformed_point(priv, matrix, xscale, \
324 int fbo_x_off, fbo_y_off; \
325 pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
326 glamor_transform_point(matrix, tx, ty, x, y); \
327 DEBUGF("tx %f ty %f fbooff %d %d \n", \
328 tx, ty, fbo_x_off, fbo_y_off); \
332 (texcoord)[0] = t_from_x_coord_x(xscale, tx); \
333 (texcoord)[1] = t_from_x_coord_y(yscale, ty); \
334 DEBUGF("normalized tx %f ty %f \n", (texcoord)[0], (texcoord)[1]); \
337 #define glamor_set_transformed_normalize_tcoords_ext( priv, \
341 tx1, ty1, tx2, ty2, \
345 glamor_set_transformed_point(priv, matrix, xscale, yscale, \
346 texcoords, tx1, ty1); \
347 glamor_set_transformed_point(priv, matrix, xscale, yscale, \
348 texcoords + 1 * stride, tx2, ty1); \
349 glamor_set_transformed_point(priv, matrix, xscale, yscale, \
350 texcoords + 2 * stride, tx2, ty2); \
351 glamor_set_transformed_point(priv, matrix, xscale, yscale, \
352 texcoords + 3 * stride, tx1, ty2); \
355 #define glamor_set_repeat_transformed_normalize_tcoords_ext(pixmap, priv, \
365 if (_X_LIKELY(glamor_pixmap_priv_is_small(priv))) { \
366 glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale, \
367 yscale, _x1_, _y1_, \
369 texcoords, stride); \
371 float tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4; \
372 float ttx1, tty1, ttx2, tty2, ttx3, tty3, ttx4, tty4; \
373 DEBUGF("original coords %d %d %d %d\n", _x1_, _y1_, _x2_, _y2_); \
374 glamor_transform_point(matrix, tx1, ty1, _x1_, _y1_); \
375 glamor_transform_point(matrix, tx2, ty2, _x2_, _y1_); \
376 glamor_transform_point(matrix, tx3, ty3, _x2_, _y2_); \
377 glamor_transform_point(matrix, tx4, ty4, _x1_, _y2_); \
378 DEBUGF("transformed %f %f %f %f %f %f %f %f\n", \
379 tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4); \
380 glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, \
383 glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, \
386 glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, \
389 glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, \
392 DEBUGF("repeat transformed %f %f %f %f %f %f %f %f\n", ttx1, tty1, \
393 ttx2, tty2, ttx3, tty3, ttx4, tty4); \
394 _glamor_set_normalize_tpoint(xscale, yscale, ttx1, tty1, \
396 _glamor_set_normalize_tpoint(xscale, yscale, ttx2, tty2, \
397 texcoords + 1 * stride); \
398 _glamor_set_normalize_tpoint(xscale, yscale, ttx3, tty3, \
399 texcoords + 2 * stride); \
400 _glamor_set_normalize_tpoint(xscale, yscale, ttx4, tty4, \
401 texcoords + 3 * stride); \
405 #define glamor_set_repeat_transformed_normalize_tcoords( pixmap, \
415 glamor_set_repeat_transformed_normalize_tcoords_ext( pixmap, \
427 #define _glamor_set_normalize_tcoords(xscale, yscale, tx1, \
431 /* vertices may be write-only, so we use following \
432 * temporary variable. */ \
433 float _t0_, _t1_, _t2_, _t5_; \
434 (vertices)[0] = _t0_ = t_from_x_coord_x(xscale, tx1); \
435 (vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2); \
436 (vertices)[2 * stride] = _t2_; \
437 (vertices)[3 * stride] = _t0_; \
438 (vertices)[1] = _t1_ = t_from_x_coord_y(yscale, ty1); \
439 (vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y(yscale, ty2); \
440 (vertices)[1 * stride + 1] = _t1_; \
441 (vertices)[3 * stride + 1] = _t5_; \
444 #define glamor_set_normalize_tcoords_ext(priv, xscale, yscale, \
448 if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
449 float tx1, tx2, ty1, ty2; \
450 int fbo_x_off, fbo_y_off; \
451 pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
452 tx1 = x1 + fbo_x_off; \
453 tx2 = x2 + fbo_x_off; \
454 ty1 = y1 + fbo_y_off; \
455 ty2 = y2 + fbo_y_off; \
456 _glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
457 tx2, ty2, vertices, \
460 _glamor_set_normalize_tcoords(xscale, yscale, x1, y1, \
461 x2, y2, vertices, stride); \
464 #define glamor_set_repeat_normalize_tcoords_ext(pixmap, priv, repeat_type, \
466 _x1_, _y1_, _x2_, _y2_, \
469 if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
470 float tx1, tx2, ty1, ty2; \
471 if (repeat_type == RepeatPad) { \
472 tx1 = _x1_ - priv->box.x1; \
473 ty1 = _y1_ - priv->box.y1; \
474 tx2 = tx1 + ((_x2_) - (_x1_)); \
475 ty2 = ty1 + ((_y2_) - (_y1_)); \
477 glamor_get_repeat_coords(pixmap, priv, repeat_type, \
478 tx1, ty1, tx2, ty2, \
479 _x1_, _y1_, _x2_, _y2_); \
481 _glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
482 tx2, ty2, vertices, \
485 _glamor_set_normalize_tcoords(xscale, yscale, _x1_, _y1_, \
486 _x2_, _y2_, vertices, \
490 #define glamor_set_normalize_tcoords_tri_stripe(xscale, yscale, \
494 (vertices)[0] = t_from_x_coord_x(xscale, x1); \
495 (vertices)[2] = t_from_x_coord_x(xscale, x2); \
496 (vertices)[6] = (vertices)[2]; \
497 (vertices)[4] = (vertices)[0]; \
498 (vertices)[1] = t_from_x_coord_y(yscale, y1); \
499 (vertices)[7] = t_from_x_coord_y(yscale, y2); \
500 (vertices)[3] = (vertices)[1]; \
501 (vertices)[5] = (vertices)[7]; \
504 #define glamor_set_tcoords_tri_strip(x1, y1, x2, y2, vertices) \
506 (vertices)[0] = (x1); \
507 (vertices)[2] = (x2); \
508 (vertices)[6] = (vertices)[2]; \
509 (vertices)[4] = (vertices)[0]; \
510 (vertices)[1] = (y1); \
511 (vertices)[7] = (y2); \
512 (vertices)[3] = (vertices)[1]; \
513 (vertices)[5] = (vertices)[7]; \
516 #define glamor_set_normalize_vcoords_ext(priv, xscale, yscale, \
520 int fbo_x_off, fbo_y_off; \
521 /* vertices may be write-only, so we use following \
522 * temporary variable. */ \
523 float _t0_, _t1_, _t2_, _t5_; \
524 pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
525 (vertices)[0] = _t0_ = v_from_x_coord_x(xscale, x1 + fbo_x_off); \
526 (vertices)[1 * stride] = _t2_ = v_from_x_coord_x(xscale, \
528 (vertices)[2 * stride] = _t2_; \
529 (vertices)[3 * stride] = _t0_; \
530 (vertices)[1] = _t1_ = v_from_x_coord_y(yscale, y1 + fbo_y_off); \
531 (vertices)[2 * stride + 1] = _t5_ = \
532 v_from_x_coord_y(yscale, y2 + fbo_y_off); \
533 (vertices)[1 * stride + 1] = _t1_; \
534 (vertices)[3 * stride + 1] = _t5_; \
537 #define glamor_set_normalize_vcoords_tri_strip(xscale, yscale, \
541 (vertices)[0] = v_from_x_coord_x(xscale, x1); \
542 (vertices)[2] = v_from_x_coord_x(xscale, x2); \
543 (vertices)[6] = (vertices)[2]; \
544 (vertices)[4] = (vertices)[0]; \
545 (vertices)[1] = v_from_x_coord_y(yscale, y1); \
546 (vertices)[7] = v_from_x_coord_y(yscale, y2); \
547 (vertices)[3] = (vertices)[1]; \
548 (vertices)[5] = (vertices)[7]; \
551 #define glamor_set_normalize_pt(xscale, yscale, x, y, \
554 (pt)[0] = t_from_x_coord_x(xscale, x); \
555 (pt)[1] = t_from_x_coord_y(yscale, y); \
558 #define glamor_set_circle_centre(width, height, x, y, \
565 #define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
566 #define MIN(a,b) ((a) < (b) ? (a) : (b))
567 #define MAX(a,b) ((a) > (b) ? (a) : (b))
569 #define glamor_check_fbo_size(_glamor_,_w_, _h_) ((_w_) > 0 && (_h_) > 0 \
570 && (_w_) <= _glamor_->max_fbo_size \
571 && (_h_) <= _glamor_->max_fbo_size)
573 #define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv->gl_fbo == GLAMOR_FBO_NORMAL)
575 #define REVERT_NONE 0
576 #define REVERT_NORMAL 1
577 #define REVERT_UPLOADING_A1 3
579 #define SWAP_UPLOADING 2
580 #define SWAP_NONE_UPLOADING 3
582 /* borrowed from uxa */
584 glamor_get_rgba_from_pixel(CARD32 pixel
,
587 float *blue
, float *alpha
, CARD32 format
)
589 int rbits
, bbits
, gbits
, abits
;
590 int rshift
, bshift
, gshift
, ashift
;
592 rbits
= PICT_FORMAT_R(format
);
593 gbits
= PICT_FORMAT_G(format
);
594 bbits
= PICT_FORMAT_B(format
);
595 abits
= PICT_FORMAT_A(format
);
597 if (PICT_FORMAT_TYPE(format
) == PICT_TYPE_A
) {
598 rshift
= gshift
= bshift
= ashift
= 0;
600 else if (PICT_FORMAT_TYPE(format
) == PICT_TYPE_ARGB
) {
603 rshift
= gshift
+ gbits
;
604 ashift
= rshift
+ rbits
;
606 else if (PICT_FORMAT_TYPE(format
) == PICT_TYPE_ABGR
) {
609 bshift
= gshift
+ gbits
;
610 ashift
= bshift
+ bbits
;
612 else if (PICT_FORMAT_TYPE(format
) == PICT_TYPE_BGRA
) {
616 rshift
= PICT_FORMAT_BPP(format
) - (rbits
+ gbits
+ bbits
);
617 gshift
= rshift
+ rbits
;
618 bshift
= gshift
+ gbits
;
623 #define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
624 *_fc_ = (((_p_) >> (_s_)) & (( 1 << (_bits_)) - 1)) \
625 / (float)((1<<(_bits_)) - 1)
628 COLOR_INT_TO_FLOAT(red
, pixel
, rshift
, rbits
);
633 COLOR_INT_TO_FLOAT(green
, pixel
, gshift
, gbits
);
638 COLOR_INT_TO_FLOAT(blue
, pixel
, bshift
, bbits
);
643 COLOR_INT_TO_FLOAT(alpha
, pixel
, ashift
, abits
);
651 glamor_get_rgba_from_color(const xRenderColor
*color
, float rgba
[4])
653 rgba
[0] = color
->red
/ (float)UINT16_MAX
;
654 rgba
[1] = color
->green
/ (float)UINT16_MAX
;
655 rgba
[2] = color
->blue
/ (float)UINT16_MAX
;
656 rgba
[3] = color
->alpha
/ (float)UINT16_MAX
;
660 glamor_is_large_pixmap(PixmapPtr pixmap
)
662 glamor_pixmap_private
*priv
;
664 priv
= glamor_get_pixmap_private(pixmap
);
665 return (glamor_pixmap_priv_is_large(priv
));
669 glamor_make_current(glamor_screen_private
*glamor_priv
)
671 if (lastGLContext
!= glamor_priv
->ctx
.ctx
) {
672 lastGLContext
= glamor_priv
->ctx
.ctx
;
673 glamor_priv
->ctx
.make_current(&glamor_priv
->ctx
);
675 glamor_priv
->dirty
= TRUE
;
679 glamor_flush(glamor_screen_private
*glamor_priv
)
681 if (glamor_priv
->dirty
) {
682 glamor_make_current(glamor_priv
);
684 glamor_priv
->dirty
= FALSE
;
689 glamor_no_rendering_bounds(void)
702 glamor_start_rendering_bounds(void)
715 glamor_bounds_union_rect(BoxPtr bounds
, xRectangle
*rect
)
717 bounds
->x1
= min(bounds
->x1
, rect
->x
);
718 bounds
->y1
= min(bounds
->y1
, rect
->y
);
719 bounds
->x2
= min(SHRT_MAX
, max(bounds
->x2
, rect
->x
+ rect
->width
));
720 bounds
->y2
= min(SHRT_MAX
, max(bounds
->y2
, rect
->y
+ rect
->height
));
724 glamor_bounds_union_box(BoxPtr bounds
, BoxPtr box
)
726 bounds
->x1
= min(bounds
->x1
, box
->x1
);
727 bounds
->y1
= min(bounds
->y1
, box
->y1
);
728 bounds
->x2
= max(bounds
->x2
, box
->x2
);
729 bounds
->y2
= max(bounds
->y2
, box
->y2
);
733 * Helper function for implementing draws with GL_QUADS on GLES2,
734 * where we don't have them.
737 glamor_glDrawArrays_GL_QUADS(glamor_screen_private
*glamor_priv
, unsigned count
)
739 if (glamor_priv
->use_quads
) {
740 glDrawArrays(GL_QUADS
, 0, count
* 4);
742 glamor_gldrawarrays_quads_using_indices(glamor_priv
, count
);
747 glamor_glsl_has_ints(glamor_screen_private
*glamor_priv
) {
748 return glamor_priv
->glsl_version
>= 130 || glamor_priv
->use_gpu_shader4
;