glamor: Create inline tests for small/large pixmaps
This will let us eliminate the pixmap types shortly Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
020fcc5828
commit
cc731ce0ca
|
@ -246,7 +246,7 @@ glamor_composite_rectangles(CARD8 op,
|
|||
goto done;
|
||||
}
|
||||
else {
|
||||
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
if (_X_LIKELY(glamor_pixmap_priv_is_small(priv))) {
|
||||
int error;
|
||||
|
||||
source = CreateSolidPicture(0, color, &error);
|
||||
|
|
|
@ -367,7 +367,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
|
|||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_off_x, &src_off_y);
|
||||
|
||||
set_scissor = src_priv->type == GLAMOR_TEXTURE_LARGE;
|
||||
set_scissor = glamor_pixmap_priv_is_large(src_priv);
|
||||
if (set_scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv,
|
|||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_large(priv)) {
|
||||
int i;
|
||||
glamor_pixmap_private *large = priv;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
static inline glamor_pixmap_private *
|
||||
__glamor_large(glamor_pixmap_private *pixmap_priv) {
|
||||
assert(pixmap_priv->type == GLAMOR_TEXTURE_LARGE);
|
||||
assert(glamor_pixmap_priv_is_large(pixmap_priv));
|
||||
return pixmap_priv;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ glamor_compute_clipped_regions_ext(PixmapPtr pixmap,
|
|||
|
||||
DEBUGF("ext called \n");
|
||||
|
||||
if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_small(pixmap_priv)) {
|
||||
clipped_regions = calloc(1, sizeof(*clipped_regions));
|
||||
if (clipped_regions == NULL) {
|
||||
*n_region = 0;
|
||||
|
@ -355,7 +355,7 @@ _glamor_compute_clipped_regions(PixmapPtr pixmap,
|
|||
glamor_pixmap_private *priv;
|
||||
|
||||
DEBUGRegionPrint(region);
|
||||
if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_small(pixmap_priv)) {
|
||||
clipped_regions = calloc(1, sizeof(*clipped_regions));
|
||||
clipped_regions[0].region = RegionCreate(NULL, 1);
|
||||
clipped_regions[0].block_idx = 0;
|
||||
|
@ -798,7 +798,7 @@ glamor_merge_clipped_regions(PixmapPtr pixmap,
|
|||
}
|
||||
|
||||
temp_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
assert(temp_priv->type != GLAMOR_TEXTURE_LARGE);
|
||||
assert(glamor_pixmap_priv_is_small(temp_priv));
|
||||
|
||||
priv->box = temp_box;
|
||||
if (temp_extent->x1 >= 0 && temp_extent->x2 <= pixmap_width
|
||||
|
@ -1065,7 +1065,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
else
|
||||
mask_repeat_type = RepeatNone;
|
||||
|
||||
if (dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_large(dest_pixmap_priv)) {
|
||||
dest_block_width = __glamor_large(dest_pixmap_priv)->block_w;
|
||||
dest_block_height = __glamor_large(dest_pixmap_priv)->block_h;
|
||||
} else {
|
||||
|
@ -1096,7 +1096,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
*/
|
||||
if (source_pixmap_priv
|
||||
&& source->transform
|
||||
&& source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
&& glamor_pixmap_priv_is_large(source_pixmap_priv)) {
|
||||
int source_transformed_block_width, source_transformed_block_height;
|
||||
|
||||
if (!glamor_get_transform_block_size(source->transform,
|
||||
|
@ -1118,7 +1118,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
}
|
||||
|
||||
if (mask_pixmap_priv
|
||||
&& mask->transform && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
&& mask->transform && glamor_pixmap_priv_is_large(mask_pixmap_priv)) {
|
||||
int mask_transformed_block_width, mask_transformed_block_height;
|
||||
|
||||
if (!glamor_get_transform_block_size(mask->transform,
|
||||
|
@ -1156,7 +1156,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
if (source_pixmap_priv
|
||||
&& (source_pixmap_priv == dest_pixmap_priv ||
|
||||
source_pixmap_priv == mask_pixmap_priv)
|
||||
&& source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
&& glamor_pixmap_priv_is_large(source_pixmap_priv)) {
|
||||
/* XXX self-copy... */
|
||||
need_free_source_pixmap_priv = source_pixmap_priv;
|
||||
source_pixmap_priv = malloc(sizeof(*source_pixmap_priv));
|
||||
|
@ -1172,7 +1172,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
glamor_set_pixmap_fbo_current(dest_pixmap_priv,
|
||||
clipped_dest_regions[i].block_idx);
|
||||
if (source_pixmap_priv &&
|
||||
source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
glamor_pixmap_priv_is_large(source_pixmap_priv)) {
|
||||
if (!source->transform && source_repeat_type != RepeatPad) {
|
||||
RegionTranslate(clipped_dest_regions[i].region,
|
||||
x_source - x_dest, y_source - y_dest);
|
||||
|
@ -1213,7 +1213,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
clipped_source_regions[j].block_idx);
|
||||
|
||||
if (mask_pixmap_priv &&
|
||||
mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
glamor_pixmap_priv_is_large(mask_pixmap_priv)) {
|
||||
if (is_normal_mask_fbo && is_normal_source_fbo) {
|
||||
/* both mask and source are normal fbo box without transform or repeatpad.
|
||||
* The region is clipped against source and then we clip it against mask here.*/
|
||||
|
@ -1371,7 +1371,7 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
}
|
||||
else {
|
||||
if (mask_pixmap_priv &&
|
||||
mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
glamor_pixmap_priv_is_large(mask_pixmap_priv)) {
|
||||
if (!mask->transform && mask_repeat_type != RepeatPad) {
|
||||
RegionTranslate(clipped_dest_regions[i].region,
|
||||
x_mask - x_dest, y_mask - y_dest);
|
||||
|
|
|
@ -799,7 +799,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
|||
if (no_alpha == 0
|
||||
&& revert == REVERT_NONE && swap_rb == SWAP_NONE_UPLOADING
|
||||
#ifdef WALKAROUND_LARGE_TEXTURE_MAP
|
||||
&& pixmap_priv->type != GLAMOR_TEXTURE_LARGE
|
||||
&& glamor_pixmap_priv_is_small(pixmap_priv)
|
||||
#endif
|
||||
) {
|
||||
int fbo_x_off, fbo_y_off;
|
||||
|
@ -956,7 +956,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
|
|||
force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP
|
||||
&& !glamor_check_fbo_size(glamor_priv, w, h);
|
||||
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE || force_clip) {
|
||||
if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {
|
||||
RegionRec region;
|
||||
BoxRec box;
|
||||
int n_region;
|
||||
|
|
|
@ -471,15 +471,86 @@ typedef struct glamor_pixmap_private {
|
|||
glamor_pixmap_fbo **fbo_array;
|
||||
} glamor_pixmap_private;
|
||||
|
||||
extern DevPrivateKeyRec glamor_pixmap_private_key;
|
||||
|
||||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
|
||||
if (pixmap == NULL)
|
||||
return NULL;
|
||||
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
|
||||
if (!priv) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
&glamor_pixmap_private_key);
|
||||
}
|
||||
return priv;
|
||||
}
|
||||
|
||||
void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv);
|
||||
|
||||
/*
|
||||
* @base.fbo: current fbo.
|
||||
*
|
||||
**/
|
||||
* Returns TRUE if pixmap has no image object
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_drm_only(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && priv->type == GLAMOR_DRM_ONLY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap is plain memory (not a GL object at all)
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_is_memory(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return !priv || priv->type == GLAMOR_MEMORY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap requires multiple textures to hold it
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_priv_is_large(glamor_pixmap_private *priv)
|
||||
{
|
||||
return priv && priv->type == GLAMOR_TEXTURE_LARGE;
|
||||
}
|
||||
|
||||
static inline Bool
|
||||
glamor_pixmap_priv_is_small(glamor_pixmap_private *priv)
|
||||
{
|
||||
return priv && priv->type != GLAMOR_TEXTURE_LARGE;
|
||||
}
|
||||
|
||||
static inline Bool
|
||||
glamor_pixmap_is_large(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && glamor_pixmap_priv_is_large(priv);
|
||||
}
|
||||
/*
|
||||
* Returns TRUE if pixmap has an FBO
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_has_fbo(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && priv->gl_fbo == GLAMOR_FBO_NORMAL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
|
||||
{
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_large(priv)) {
|
||||
priv->fbo = priv->fbo_array[idx];
|
||||
priv->box = priv->box_array[idx];
|
||||
}
|
||||
|
@ -488,7 +559,7 @@ glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
|
|||
static inline glamor_pixmap_fbo *
|
||||
glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
|
||||
{
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_large(priv)) {
|
||||
assert(x < priv->block_wcnt);
|
||||
assert(y < priv->block_hcnt);
|
||||
return priv->fbo_array[y * priv->block_wcnt + x];
|
||||
|
@ -501,7 +572,7 @@ glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
|
|||
static inline BoxPtr
|
||||
glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y)
|
||||
{
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
if (glamor_pixmap_priv_is_large(priv)) {
|
||||
assert(x < priv->block_wcnt);
|
||||
assert(y < priv->block_hcnt);
|
||||
return &priv->box_array[y * priv->block_wcnt + x];
|
||||
|
@ -514,7 +585,7 @@ glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y)
|
|||
static inline int
|
||||
glamor_pixmap_wcnt(glamor_pixmap_private *priv)
|
||||
{
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE)
|
||||
if (glamor_pixmap_priv_is_large(priv))
|
||||
return priv->block_wcnt;
|
||||
return 1;
|
||||
}
|
||||
|
@ -522,7 +593,7 @@ glamor_pixmap_wcnt(glamor_pixmap_private *priv)
|
|||
static inline int
|
||||
glamor_pixmap_hcnt(glamor_pixmap_private *priv)
|
||||
{
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE)
|
||||
if (glamor_pixmap_priv_is_large(priv))
|
||||
return priv->block_hcnt;
|
||||
return 1;
|
||||
}
|
||||
|
@ -557,7 +628,6 @@ typedef struct {
|
|||
|
||||
extern DevPrivateKeyRec glamor_gc_private_key;
|
||||
extern DevPrivateKeyRec glamor_screen_private_key;
|
||||
extern DevPrivateKeyRec glamor_pixmap_private_key;
|
||||
|
||||
static inline glamor_screen_private *
|
||||
glamor_get_screen_private(ScreenPtr screen)
|
||||
|
@ -572,69 +642,6 @@ glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv)
|
|||
dixSetPrivate(&screen->devPrivates, &glamor_screen_private_key, priv);
|
||||
}
|
||||
|
||||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
|
||||
if (pixmap == NULL)
|
||||
return NULL;
|
||||
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
|
||||
if (!priv) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
&glamor_pixmap_private_key);
|
||||
}
|
||||
return priv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap has no image object
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_drm_only(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && priv->type == GLAMOR_DRM_ONLY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap is plain memory (not a GL object at all)
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_is_memory(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return !priv || priv->type == GLAMOR_TEXTURE_LARGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap requires multiple textures to hold it
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_is_large(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && priv->type == GLAMOR_TEXTURE_LARGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if pixmap has an FBO
|
||||
*/
|
||||
static inline Bool
|
||||
glamor_pixmap_has_fbo(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return priv && priv->gl_fbo == GLAMOR_FBO_NORMAL;
|
||||
}
|
||||
|
||||
void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv);
|
||||
|
||||
static inline glamor_gc_private *
|
||||
glamor_get_gc_private(GCPtr gc)
|
||||
{
|
||||
|
|
|
@ -542,7 +542,7 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
|
|||
if (repeat_type != RepeatNone)
|
||||
repeat_type += RepeatFix;
|
||||
else if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
|
||||
|| pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
|| glamor_pixmap_priv_is_large(pixmap_priv)) {
|
||||
if (picture->transform)
|
||||
repeat_type += RepeatFix;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ glamor_set_texture(PixmapPtr pixmap,
|
|||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(texture_priv))
|
||||
return FALSE;
|
||||
|
||||
if (texture_priv->type == GLAMOR_TEXTURE_LARGE)
|
||||
if (glamor_pixmap_priv_is_large(texture_priv))
|
||||
return FALSE;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
#define PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, w, h) \
|
||||
do { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
|
||||
w = priv->box.x2 - priv->box.x1; \
|
||||
h = priv->box.y2 - priv->box.y1; \
|
||||
} else { \
|
||||
|
@ -78,7 +78,7 @@
|
|||
|
||||
#define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_) \
|
||||
do { \
|
||||
if (_X_UNLIKELY(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(_priv_ && glamor_pixmap_priv_is_large(_priv_))) { \
|
||||
*(_xoff_) = - (_priv_)->box.x1; \
|
||||
*(_yoff_) = - (_priv_)->box.y1; \
|
||||
} else { \
|
||||
|
@ -410,7 +410,7 @@
|
|||
texcoords, \
|
||||
stride) \
|
||||
do { \
|
||||
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_LIKELY(glamor_pixmap_priv_is_small(priv))) { \
|
||||
glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale, \
|
||||
yscale, _x1_, _y1_, \
|
||||
_x2_, _y2_, \
|
||||
|
@ -493,7 +493,7 @@
|
|||
x1, y1, x2, y2, \
|
||||
vertices, stride) \
|
||||
do { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
|
||||
float tx1, tx2, ty1, ty2; \
|
||||
int fbo_x_off, fbo_y_off; \
|
||||
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
|
||||
|
@ -523,7 +523,7 @@
|
|||
_x1_, _y1_, _x2_, _y2_, \
|
||||
vertices, stride) \
|
||||
do { \
|
||||
if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \
|
||||
if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) { \
|
||||
float tx1, tx2, ty1, ty2; \
|
||||
if (repeat_type == RepeatPad) { \
|
||||
tx1 = _x1_ - priv->box.x1; \
|
||||
|
@ -943,7 +943,7 @@ glamor_is_large_pixmap(PixmapPtr pixmap)
|
|||
glamor_pixmap_private *priv;
|
||||
|
||||
priv = glamor_get_pixmap_private(pixmap);
|
||||
return (priv->type == GLAMOR_TEXTURE_LARGE);
|
||||
return (glamor_pixmap_priv_is_large(priv));
|
||||
}
|
||||
|
||||
inline static Bool
|
||||
|
|
Loading…
Reference in New Issue