summaryrefslogtreecommitdiff
path: root/xserver/glamor/glamor_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/glamor/glamor_utils.h')
-rw-r--r--xserver/glamor/glamor_utils.h64
1 files changed, 56 insertions, 8 deletions
diff --git a/xserver/glamor/glamor_utils.h b/xserver/glamor/glamor_utils.h
index a35917c37..0d5674d63 100644
--- a/xserver/glamor/glamor_utils.h
+++ b/xserver/glamor/glamor_utils.h
@@ -562,10 +562,6 @@
(c)[1] = (float)y; \
} while(0)
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
-
#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -605,10 +601,8 @@ format_for_depth(int depth)
default:
case 24:
return PICT_x8r8g8b8;
-#if XORG_VERSION_CURRENT >= 10699900
case 30:
return PICT_x2r10g10b10;
-#endif
case 32:
return PICT_a8r8g8b8;
}
@@ -623,6 +617,9 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) {
return glamor_priv->one_channel_format;
+ } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
+ (pixmap)->drawable.depth == 30) {
+ return GL_RGB10_A2;
} else {
return GL_RGBA;
}
@@ -670,7 +667,6 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
gshift = rbits;
bshift = gshift + gbits;
ashift = bshift + bbits;
-#if XORG_VERSION_CURRENT >= 10699900
}
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
ashift = 0;
@@ -679,7 +675,6 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits + bbits);
gshift = rshift + rbits;
bshift = gshift + gbits;
-#endif
}
else {
return FALSE;
@@ -711,6 +706,15 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
return TRUE;
}
+static inline void
+glamor_get_rgba_from_color(const xRenderColor *color, float rgba[4])
+{
+ rgba[0] = color->red / (float)UINT16_MAX;
+ rgba[1] = color->green / (float)UINT16_MAX;
+ rgba[2] = color->blue / (float)UINT16_MAX;
+ rgba[3] = color->alpha / (float)UINT16_MAX;
+}
+
inline static Bool
glamor_is_large_pixmap(PixmapPtr pixmap)
{
@@ -729,6 +733,50 @@ glamor_make_current(glamor_screen_private *glamor_priv)
}
}
+static inline BoxRec
+glamor_no_rendering_bounds(void)
+{
+ BoxRec bounds = {
+ .x1 = 0,
+ .y1 = 0,
+ .x2 = MAXSHORT,
+ .y2 = MAXSHORT,
+ };
+
+ return bounds;
+}
+
+static inline BoxRec
+glamor_start_rendering_bounds(void)
+{
+ BoxRec bounds = {
+ .x1 = MAXSHORT,
+ .y1 = MAXSHORT,
+ .x2 = 0,
+ .y2 = 0,
+ };
+
+ return bounds;
+}
+
+static inline void
+glamor_bounds_union_rect(BoxPtr bounds, xRectangle *rect)
+{
+ bounds->x1 = min(bounds->x1, rect->x);
+ bounds->y1 = min(bounds->y1, rect->y);
+ bounds->x2 = min(SHRT_MAX, max(bounds->x2, rect->x + rect->width));
+ bounds->y2 = min(SHRT_MAX, max(bounds->y2, rect->y + rect->height));
+}
+
+static inline void
+glamor_bounds_union_box(BoxPtr bounds, BoxPtr box)
+{
+ bounds->x1 = min(bounds->x1, box->x1);
+ bounds->y1 = min(bounds->y1, box->y1);
+ bounds->x2 = max(bounds->x2, box->x2);
+ bounds->y2 = max(bounds->y2, box->y2);
+}
+
/**
* Helper function for implementing draws with GL_QUADS on GLES2,
* where we don't have them.