summaryrefslogtreecommitdiff
path: root/common/picture_solid.c
blob: e06e0d886313aad97c4d3d58851b50a951cbc46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "picturestr.h"
#include "pixmapstr.h"
#include "pictureutil.h"
#include "pixmaputil.h"

/*
 * Returns TRUE and the pixel value in COLOUR if the picture
 * represents a solid surface of constant colour.
 */
Bool picture_is_solid(PicturePtr pict, CARD32 *colour)
{
	if (pict->pDrawable) {
		DrawablePtr pDraw = pict->pDrawable;

		if (pDraw->width == 1 && pDraw->height == 1 && pict->repeat) {
			if (colour)
				*colour = get_first_pixel(pDraw);
			return TRUE;
		}
	} else {
		SourcePict *sp = pict->pSourcePict;

		if (sp->type == SourcePictTypeSolidFill) {
			if (colour)
				*colour = sp->solidFill.color;
			return TRUE;
		}
	}

	return FALSE;
}