sna: Mark up const boxes to keep the compiler happy
Pass around const to suppress a few compiler warnings. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
e5c68b4358
commit
91bc9e42e4
|
|
@ -125,10 +125,10 @@ region_boxptr(const RegionRec *r)
|
|||
return (BoxPtr)(r->data + 1);
|
||||
}
|
||||
|
||||
static inline BoxPtr
|
||||
static inline const BoxRec *
|
||||
region_rects(const RegionRec *r)
|
||||
{
|
||||
return r->data ? region_boxptr(r) : (BoxPtr)&r->extents;
|
||||
return r->data ? (const BoxRec *)(r->data + 1) : &r->extents;
|
||||
}
|
||||
|
||||
#ifndef INCLUDE_LEGACY_REGION_DEFINES
|
||||
|
|
|
|||
|
|
@ -5382,7 +5382,7 @@ gen3_render_video(struct sna *sna,
|
|||
PixmapPtr pixmap)
|
||||
{
|
||||
struct sna_pixmap *priv = sna_pixmap(pixmap);
|
||||
BoxPtr pbox = region_rects(dstRegion);
|
||||
const BoxRec *pbox = region_rects(dstRegion);
|
||||
int nbox = region_num_rects(dstRegion);
|
||||
int dst_width = dstRegion->extents.x2 - dstRegion->extents.x1;
|
||||
int dst_height = dstRegion->extents.y2 - dstRegion->extents.y1;
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,7 @@ gen4_render_video(struct sna *sna,
|
|||
float src_offset_x, src_offset_y;
|
||||
float src_scale_x, src_scale_y;
|
||||
int nbox, pix_xoff, pix_yoff;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
|
||||
DBG(("%s: %dx%d -> %dx%d\n", __FUNCTION__,
|
||||
src_width, src_height, dst_width, dst_height));
|
||||
|
|
|
|||
|
|
@ -1356,7 +1356,7 @@ gen5_render_video(struct sna *sna,
|
|||
float src_offset_x, src_offset_y;
|
||||
float src_scale_x, src_scale_y;
|
||||
int nbox, pix_xoff, pix_yoff;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
|
||||
DBG(("%s: %dx%d -> %dx%d\n", __FUNCTION__,
|
||||
src_width, src_height, dst_width, dst_height));
|
||||
|
|
|
|||
|
|
@ -1594,7 +1594,7 @@ gen6_render_video(struct sna *sna,
|
|||
float src_scale_x, src_scale_y;
|
||||
int nbox, pix_xoff, pix_yoff;
|
||||
unsigned filter;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
|
||||
DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n",
|
||||
__FUNCTION__,
|
||||
|
|
|
|||
|
|
@ -1836,7 +1836,7 @@ gen7_render_video(struct sna *sna,
|
|||
float src_scale_x, src_scale_y;
|
||||
int nbox, pix_xoff, pix_yoff;
|
||||
unsigned filter;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
|
||||
DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n",
|
||||
__FUNCTION__,
|
||||
|
|
|
|||
|
|
@ -3726,7 +3726,7 @@ gen8_render_video(struct sna *sna,
|
|||
float src_scale_x, src_scale_y;
|
||||
int nbox, pix_xoff, pix_yoff;
|
||||
unsigned filter;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
|
||||
DBG(("%s: src=(%d, %d), dst=(%d, %d), %dx[(%d, %d), (%d, %d)...]\n",
|
||||
__FUNCTION__,
|
||||
|
|
|
|||
|
|
@ -2306,7 +2306,7 @@ skip_inplace_map:
|
|||
}
|
||||
|
||||
if (priv->gpu_damage) {
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
int n;
|
||||
|
||||
DBG(("%s: flushing GPU damage\n", __FUNCTION__));
|
||||
|
|
@ -2800,7 +2800,7 @@ move_to_cpu:
|
|||
|
||||
if (priv->clear) {
|
||||
int n = region_num_rects(region);
|
||||
BoxPtr box = region_rects(region);
|
||||
const BoxRec *box = region_rects(region);
|
||||
|
||||
assert(DAMAGE_IS_ALL(priv->gpu_damage));
|
||||
assert(priv->cpu_damage == NULL);
|
||||
|
|
@ -2889,7 +2889,7 @@ move_to_cpu:
|
|||
*/
|
||||
if (flags & MOVE_WRITE) {
|
||||
int n = region_num_rects(region), i;
|
||||
BoxPtr boxes = region_rects(region);
|
||||
const BoxRec *boxes = region_rects(region);
|
||||
BoxPtr blocks;
|
||||
|
||||
blocks = NULL;
|
||||
|
|
@ -2920,7 +2920,7 @@ move_to_cpu:
|
|||
}
|
||||
|
||||
if (region_subsumes_damage(r, priv->gpu_damage)) {
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
int n;
|
||||
|
||||
DBG(("%s: region wholly contains damage\n",
|
||||
|
|
@ -3287,7 +3287,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
|
|||
bool ok = false;
|
||||
int n;
|
||||
|
||||
n = sna_damage_get_boxes(priv->cpu_damage, (BoxPtr *)&box);
|
||||
n = sna_damage_get_boxes(priv->cpu_damage, &box);
|
||||
assert(n);
|
||||
if (use_cpu_bo_for_upload(sna, priv, 0)) {
|
||||
DBG(("%s: using CPU bo for upload to GPU\n", __FUNCTION__));
|
||||
|
|
@ -3928,7 +3928,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
|
|||
{
|
||||
struct sna *sna = to_sna_from_pixmap(pixmap);
|
||||
struct sna_pixmap *priv;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
int n;
|
||||
|
||||
DBG(("%s(pixmap=%ld, usage=%d), flags=%x\n",
|
||||
|
|
@ -4447,7 +4447,7 @@ try_upload__tiled_x(PixmapPtr pixmap, RegionRec *region,
|
|||
{
|
||||
struct sna *sna = to_sna_from_pixmap(pixmap);
|
||||
struct sna_pixmap *priv = sna_pixmap(pixmap);
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
uint8_t *dst;
|
||||
int n;
|
||||
|
||||
|
|
@ -4551,7 +4551,7 @@ try_upload__inplace(PixmapPtr pixmap, RegionRec *region,
|
|||
struct sna_pixmap *priv = sna_pixmap(pixmap);
|
||||
bool ignore_cpu = false;
|
||||
bool replaces;
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
uint8_t *dst;
|
||||
int n;
|
||||
|
||||
|
|
@ -4858,7 +4858,7 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
|
|||
{
|
||||
PixmapPtr pixmap = get_drawable_pixmap(drawable);
|
||||
unsigned int hint;
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
int16_t dx, dy;
|
||||
int n;
|
||||
|
||||
|
|
@ -4954,7 +4954,7 @@ sna_put_xybitmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
|
|||
struct sna *sna = to_sna_from_pixmap(pixmap);
|
||||
struct sna_damage **damage;
|
||||
struct kgem_bo *bo;
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
int16_t dx, dy;
|
||||
int n;
|
||||
uint8_t rop = copy_ROP[gc->alu];
|
||||
|
|
@ -5486,14 +5486,17 @@ move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv,
|
|||
}
|
||||
}
|
||||
|
||||
static BoxPtr
|
||||
reorder_boxes(BoxPtr box, int n, int dx, int dy)
|
||||
static const BoxRec *
|
||||
reorder_boxes(const BoxRec *box, int n, int dx, int dy)
|
||||
{
|
||||
BoxPtr new, base, next, tmp;
|
||||
const BoxRec *next, *base;
|
||||
BoxRec *new;
|
||||
|
||||
DBG(("%s x %d dx=%d, dy=%d\n", __FUNCTION__, n, dx, dy));
|
||||
|
||||
if (dy <= 0 && dx <= 0) {
|
||||
BoxRec *tmp;
|
||||
|
||||
new = malloc(sizeof(BoxRec) * n);
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
|
@ -5510,6 +5513,8 @@ reorder_boxes(BoxPtr box, int n, int dx, int dy)
|
|||
|
||||
base = next = box + n - 1;
|
||||
while (base >= box) {
|
||||
const BoxRec *tmp;
|
||||
|
||||
while (next >= box && base->y1 == next->y1)
|
||||
next--;
|
||||
tmp = next + 1;
|
||||
|
|
@ -5525,6 +5530,8 @@ reorder_boxes(BoxPtr box, int n, int dx, int dy)
|
|||
|
||||
base = next = box;
|
||||
while (base < box + n) {
|
||||
const BoxRec *tmp;
|
||||
|
||||
while (next < box + n && next->y1 == base->y1)
|
||||
next++;
|
||||
tmp = next;
|
||||
|
|
@ -5546,7 +5553,7 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
|||
PixmapPtr pixmap = get_drawable_pixmap(src);
|
||||
struct sna *sna = to_sna_from_pixmap(pixmap);
|
||||
struct sna_pixmap *priv = sna_pixmap(pixmap);
|
||||
BoxPtr box = region_rects(region);
|
||||
const BoxRec *box = region_rects(region);
|
||||
int n = region_num_rects(region);
|
||||
int alu = gc ? gc->alu : GXcopy;
|
||||
int16_t tx, ty, sx, sy;
|
||||
|
|
@ -5659,7 +5666,7 @@ out:
|
|||
|
||||
free_boxes:
|
||||
if (box != region_rects(region))
|
||||
free(box);
|
||||
free((void *)box);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
|
@ -6060,7 +6067,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
|||
struct kgem_bo *bo;
|
||||
int16_t src_dx, src_dy;
|
||||
int16_t dst_dx, dst_dy;
|
||||
BoxPtr box = region_rects(region);
|
||||
const BoxRec *box = region_rects(region);
|
||||
int n = region_num_rects(region);
|
||||
int alu = gc->alu;
|
||||
int stride, bpp;
|
||||
|
|
@ -7924,7 +7931,7 @@ sna_copy_bitmap_blt(DrawablePtr _bitmap, DrawablePtr drawable, GCPtr gc,
|
|||
PixmapPtr bitmap = (PixmapPtr)_bitmap;
|
||||
uint32_t br00, br13;
|
||||
int16_t dx, dy;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
int n;
|
||||
|
||||
DBG(("%s: plane=%x (%d,%d),(%d,%d)xld\n",
|
||||
|
|
@ -8147,7 +8154,7 @@ sna_copy_plane_blt(DrawablePtr source, DrawablePtr drawable, GCPtr gc,
|
|||
int16_t dx, dy;
|
||||
int bit = ffs(bitplane) - 1;
|
||||
uint32_t br00, br13;
|
||||
BoxPtr box = region_rects(region);
|
||||
const BoxRec *box = region_rects(region);
|
||||
int n = region_num_rects(region);
|
||||
|
||||
DBG(("%s: plane=%x [%d] x%d\n", __FUNCTION__,
|
||||
|
|
@ -12645,7 +12652,7 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
|
|||
} else {
|
||||
while (n--) {
|
||||
RegionRec region;
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
int nbox;
|
||||
|
||||
region.extents.x1 = rect->x + drawable->x;
|
||||
|
|
@ -16066,7 +16073,7 @@ sna_push_pixels_solid_blt(GCPtr gc,
|
|||
struct sna *sna = to_sna_from_pixmap(pixmap);
|
||||
struct sna_damage **damage;
|
||||
struct kgem_bo *bo;
|
||||
BoxRec *box;
|
||||
const BoxRec *box;
|
||||
int16_t dx, dy;
|
||||
int n;
|
||||
uint8_t rop = copy_ROP[gc->alu];
|
||||
|
|
@ -17021,7 +17028,7 @@ static void sna_accel_post_damage(struct sna *sna)
|
|||
xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
|
||||
RegionRec region, *damage;
|
||||
PixmapPtr src, dst;
|
||||
BoxPtr box;
|
||||
const BoxRec *box;
|
||||
int n;
|
||||
|
||||
assert(dirty->src == sna->front);
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ sna_composite_fb(CARD8 op,
|
|||
region->extents.x2 + sx <= src->pDrawable->width &&
|
||||
region->extents.y2 + sy <= src->pDrawable->height) {
|
||||
if (sigtrap_get() == 0) {
|
||||
BoxPtr box = region_rects(region);
|
||||
const BoxRec *box = region_rects(region);
|
||||
int nbox = region_num_rects(region);
|
||||
|
||||
sx += src->pDrawable->x;
|
||||
|
|
@ -1103,7 +1103,7 @@ fallback:
|
|||
if (sigtrap_get() == 0) {
|
||||
if (op <= PictOpSrc) {
|
||||
int nbox = region_num_rects(®ion);
|
||||
BoxPtr box = region_rects(®ion);
|
||||
const BoxRec *box = region_rects(®ion);
|
||||
uint32_t pixel;
|
||||
|
||||
if (op == PictOpClear)
|
||||
|
|
|
|||
|
|
@ -1533,7 +1533,7 @@ bool _sna_damage_intersect(struct sna_damage *damage,
|
|||
}
|
||||
#endif
|
||||
|
||||
static int __sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes)
|
||||
static int __sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes)
|
||||
{
|
||||
assert(damage && damage->mode != DAMAGE_ALL);
|
||||
|
||||
|
|
@ -1565,7 +1565,7 @@ struct sna_damage *_sna_damage_reduce(struct sna_damage *damage)
|
|||
}
|
||||
|
||||
#if HAS_DEBUG_FULL
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes)
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes)
|
||||
{
|
||||
char damage_buf[1000];
|
||||
int count;
|
||||
|
|
@ -1579,7 +1579,7 @@ int _sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes)
|
|||
return count;
|
||||
}
|
||||
#else
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes)
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes)
|
||||
{
|
||||
return __sna_damage_get_boxes(damage, boxes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,9 +244,9 @@ sna_damage_contains_box__no_reduce(const struct sna_damage *damage,
|
|||
return _sna_damage_contains_box__no_reduce(damage, box);
|
||||
}
|
||||
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes);
|
||||
int _sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes);
|
||||
static inline int
|
||||
sna_damage_get_boxes(struct sna_damage *damage, BoxPtr *boxes)
|
||||
sna_damage_get_boxes(struct sna_damage *damage, const BoxRec **boxes)
|
||||
{
|
||||
assert(damage);
|
||||
|
||||
|
|
|
|||
|
|
@ -5914,7 +5914,7 @@ sna_crtc_redisplay__composite(xf86CrtcPtr crtc, RegionPtr region, struct kgem_bo
|
|||
PictFormatPtr format;
|
||||
PicturePtr src, dst;
|
||||
PixmapPtr pixmap;
|
||||
BoxPtr b;
|
||||
const BoxRec *b;
|
||||
int n, depth, error;
|
||||
|
||||
DBG(("%s: compositing transformed damage boxes\n", __FUNCTION__));
|
||||
|
|
|
|||
|
|
@ -857,7 +857,7 @@ __sna_dri2_copy_region(struct sna *sna, DrawablePtr draw, RegionPtr region,
|
|||
struct kgem_bo *bo = NULL;
|
||||
struct kgem_bo *src_bo;
|
||||
struct kgem_bo *dst_bo;
|
||||
BoxRec *boxes;
|
||||
const BoxRec *boxes;
|
||||
int16_t dx, dy, sx, sy;
|
||||
int w, h, n;
|
||||
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ glyphs_to_dst(struct sna *sna,
|
|||
struct sna_composite_op tmp;
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
PicturePtr glyph_atlas;
|
||||
BoxPtr rects;
|
||||
const BoxRec *rects;
|
||||
int nrect;
|
||||
int16_t x, y;
|
||||
|
||||
|
|
@ -737,7 +737,7 @@ glyphs0_to_dst(struct sna *sna,
|
|||
struct sna_composite_op tmp;
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
PicturePtr glyph_atlas = NO_ATLAS;
|
||||
BoxPtr rects;
|
||||
const BoxRec *rects;
|
||||
int nrect;
|
||||
int x, y;
|
||||
|
||||
|
|
@ -944,7 +944,7 @@ glyphs_slow(struct sna *sna,
|
|||
while (n--) {
|
||||
GlyphPtr glyph = *glyphs++;
|
||||
struct sna_glyph *p;
|
||||
BoxPtr rects;
|
||||
const BoxRec *rects;
|
||||
BoxRec box;
|
||||
int nrect;
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ composite_aligned_boxes(struct sna *sna,
|
|||
clip.extents.y2 - clip.extents.y1,
|
||||
COMPOSITE_PARTIAL, memset(&tmp, 0, sizeof(tmp)))) {
|
||||
unsigned int flags;
|
||||
pixman_box16_t *b;
|
||||
const pixman_box16_t *b;
|
||||
int i, count;
|
||||
|
||||
DBG(("%s: composite render op not supported\n",
|
||||
|
|
@ -771,7 +771,7 @@ composite_unaligned_boxes_inplace__solid(struct sna *sna,
|
|||
__FUNCTION__, n));
|
||||
do {
|
||||
RegionRec clip;
|
||||
BoxPtr extents;
|
||||
const BoxRec *extents;
|
||||
int count;
|
||||
|
||||
clip.extents.x1 = pixman_fixed_to_int(t->left.p1.x);
|
||||
|
|
@ -855,7 +855,7 @@ pixman:
|
|||
do {
|
||||
struct pixman_inplace pi;
|
||||
RegionRec clip;
|
||||
BoxPtr extents;
|
||||
const BoxRec *extents;
|
||||
int count;
|
||||
|
||||
clip.extents.x1 = pixman_fixed_to_int(t->left.p1.x);
|
||||
|
|
@ -1071,7 +1071,7 @@ composite_unaligned_boxes_inplace(struct sna *sna,
|
|||
src_y -= pixman_fixed_to_int(t[0].left.p1.y);
|
||||
do {
|
||||
RegionRec clip;
|
||||
BoxPtr extents;
|
||||
const BoxRec *extents;
|
||||
int count;
|
||||
int num_threads;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue