summaryrefslogtreecommitdiff
path: root/fb/fbpict.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-03-21 12:55:09 -0700
committerKeith Packard <keithp@keithp.com>2012-03-21 13:54:42 -0700
commit9838b7032ea9792bec21af424c53c07078636d21 (patch)
treeb72d0827dac50f0f3b8eab29b3b7639546d735d7 /fb/fbpict.c
parent75199129c603fc8567185ac31866c9518193cb78 (diff)
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'fb/fbpict.c')
-rw-r--r--fb/fbpict.c380
1 files changed, 187 insertions, 193 deletions
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 57c93fd06..097a1a6bd 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -36,171 +36,165 @@
#include "fbpict.h"
void
-fbComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
+fbComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
{
pixman_image_t *src, *mask, *dest;
int src_xoff, src_yoff;
int msk_xoff, msk_yoff;
int dst_xoff, dst_yoff;
-
- miCompositeSourceValidate (pSrc);
+
+ miCompositeSourceValidate(pSrc);
if (pMask)
- miCompositeSourceValidate (pMask);
-
- src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
- mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
- dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
-
- if (src && dest && !(pMask && !mask))
- {
- pixman_image_composite (op, src, mask, dest,
- xSrc + src_xoff, ySrc + src_yoff,
- xMask + msk_xoff, yMask + msk_yoff,
- xDst + dst_xoff, yDst + dst_yoff,
- width, height);
+ miCompositeSourceValidate(pMask);
+
+ src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
+ mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
+ dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+
+ if (src && dest && !(pMask && !mask)) {
+ pixman_image_composite(op, src, mask, dest,
+ xSrc + src_xoff, ySrc + src_yoff,
+ xMask + msk_xoff, yMask + msk_yoff,
+ xDst + dst_xoff, yDst + dst_yoff, width, height);
}
- free_pixman_pict (pSrc, src);
- free_pixman_pict (pMask, mask);
- free_pixman_pict (pDst, dest);
+ free_pixman_pict(pSrc, src);
+ free_pixman_pict(pMask, mask);
+ free_pixman_pict(pDst, dest);
}
static pixman_image_t *
-create_solid_fill_image (PicturePtr pict)
+create_solid_fill_image(PicturePtr pict)
{
PictSolidFill *solid = &pict->pSourcePict->solidFill;
pixman_color_t color;
CARD32 a, r, g, b;
-
+
a = (solid->color & 0xff000000) >> 24;
r = (solid->color & 0x00ff0000) >> 16;
- g = (solid->color & 0x0000ff00) >> 8;
- b = (solid->color & 0x000000ff) >> 0;
-
+ g = (solid->color & 0x0000ff00) >> 8;
+ b = (solid->color & 0x000000ff) >> 0;
+
color.alpha = (a << 8) | a;
- color.red = (r << 8) | r;
+ color.red = (r << 8) | r;
color.green = (g << 8) | g;
- color.blue = (b << 8) | b;
-
- return pixman_image_create_solid_fill (&color);
+ color.blue = (b << 8) | b;
+
+ return pixman_image_create_solid_fill(&color);
}
static pixman_image_t *
-create_linear_gradient_image (PictGradient *gradient)
+create_linear_gradient_image(PictGradient * gradient)
{
- PictLinearGradient *linear = (PictLinearGradient *)gradient;
+ PictLinearGradient *linear = (PictLinearGradient *) gradient;
pixman_point_fixed_t p1;
pixman_point_fixed_t p2;
-
+
p1.x = linear->p1.x;
p1.y = linear->p1.y;
p2.x = linear->p2.x;
p2.y = linear->p2.y;
-
- return pixman_image_create_linear_gradient (
- &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+
+ return pixman_image_create_linear_gradient(&p1, &p2,
+ (pixman_gradient_stop_t *)
+ gradient->stops,
+ gradient->nstops);
}
static pixman_image_t *
-create_radial_gradient_image (PictGradient *gradient)
+create_radial_gradient_image(PictGradient * gradient)
{
- PictRadialGradient *radial = (PictRadialGradient *)gradient;
+ PictRadialGradient *radial = (PictRadialGradient *) gradient;
pixman_point_fixed_t c1;
pixman_point_fixed_t c2;
-
+
c1.x = radial->c1.x;
c1.y = radial->c1.y;
c2.x = radial->c2.x;
c2.y = radial->c2.y;
-
- return pixman_image_create_radial_gradient (
- &c1, &c2, radial->c1.radius,
- radial->c2.radius,
- (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+
+ return pixman_image_create_radial_gradient(&c1, &c2, radial->c1.radius,
+ radial->c2.radius,
+ (pixman_gradient_stop_t *)
+ gradient->stops,
+ gradient->nstops);
}
static pixman_image_t *
-create_conical_gradient_image (PictGradient *gradient)
+create_conical_gradient_image(PictGradient * gradient)
{
- PictConicalGradient *conical = (PictConicalGradient *)gradient;
+ PictConicalGradient *conical = (PictConicalGradient *) gradient;
pixman_point_fixed_t center;
-
+
center.x = conical->center.x;
center.y = conical->center.y;
-
- return pixman_image_create_conical_gradient (
- &center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
- gradient->nstops);
+
+ return pixman_image_create_conical_gradient(&center, conical->angle,
+ (pixman_gradient_stop_t *)
+ gradient->stops,
+ gradient->nstops);
}
static pixman_image_t *
-create_bits_picture (PicturePtr pict,
- Bool has_clip,
- int *xoff,
- int *yoff)
+create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
{
PixmapPtr pixmap;
FbBits *bits;
FbStride stride;
int bpp;
pixman_image_t *image;
-
- fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
+
+ fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
fbGetPixmapBitsData(pixmap, bits, stride, bpp);
- image = pixman_image_create_bits (
- (pixman_format_code_t)pict->format,
- pixmap->drawable.width, pixmap->drawable.height,
- (uint32_t *)bits, stride * sizeof (FbStride));
+ image = pixman_image_create_bits((pixman_format_code_t) pict->format,
+ pixmap->drawable.width,
+ pixmap->drawable.height, (uint32_t *) bits,
+ stride * sizeof(FbStride));
if (!image)
- return NULL;
-
+ return NULL;
+
#ifdef FB_ACCESS_WRAPPER
#if FB_SHIFT==5
-
- pixman_image_set_accessors (image,
- (pixman_read_memory_func_t)wfbReadMemory,
- (pixman_write_memory_func_t)wfbWriteMemory);
-
+
+ pixman_image_set_accessors(image,
+ (pixman_read_memory_func_t) wfbReadMemory,
+ (pixman_write_memory_func_t) wfbWriteMemory);
+
#else
-
+
#error The pixman library only works when FbBits is 32 bits wide
-
+
#endif
#endif
-
+
/* pCompositeClip is undefined for source pictures, so
* only set the clip region for pictures with drawables
*/
- if (has_clip)
- {
- if (pict->clientClipType != CT_NONE)
- pixman_image_set_has_client_clip (image, TRUE);
+ if (has_clip) {
+ if (pict->clientClipType != CT_NONE)
+ pixman_image_set_has_client_clip(image, TRUE);
- if (*xoff || *yoff)
- pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
+ if (*xoff || *yoff)
+ pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
- pixman_image_set_clip_region (image, pict->pCompositeClip);
+ pixman_image_set_clip_region(image, pict->pCompositeClip);
- if (*xoff || *yoff)
- pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
+ if (*xoff || *yoff)
+ pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
}
-
+
/* Indexed table */
if (pict->pFormat->index.devPrivate)
- pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
+ pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
/* Add in drawable origin to position within the image */
*xoff += pict->pDrawable->x;
@@ -209,158 +203,158 @@ create_bits_picture (PicturePtr pict,
return image;
}
-static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map);
+static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
+ int *xoff, int *yoff,
+ Bool is_alpha_map);
static void
-set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
+ int *xoff, int *yoff, Bool is_alpha_map)
{
pixman_repeat_t repeat;
pixman_filter_t filter;
-
- if (pict->transform)
- {
- /* For source images, adjust the transform to account
- * for the drawable offset within the pixman image,
- * then set the offset to 0 as it will be used
- * to compute positions within the transformed image.
- */
- if (!has_clip) {
- struct pixman_transform adjusted;
-
- adjusted = *pict->transform;
- pixman_transform_translate(&adjusted,
- NULL,
- pixman_int_to_fixed(*xoff),
- pixman_int_to_fixed(*yoff));
- pixman_image_set_transform (image, &adjusted);
- *xoff = 0;
- *yoff = 0;
- } else
- pixman_image_set_transform (image, pict->transform);
+
+ if (pict->transform) {
+ /* For source images, adjust the transform to account
+ * for the drawable offset within the pixman image,
+ * then set the offset to 0 as it will be used
+ * to compute positions within the transformed image.
+ */
+ if (!has_clip) {
+ struct pixman_transform adjusted;
+
+ adjusted = *pict->transform;
+ pixman_transform_translate(&adjusted,
+ NULL,
+ pixman_int_to_fixed(*xoff),
+ pixman_int_to_fixed(*yoff));
+ pixman_image_set_transform(image, &adjusted);
+ *xoff = 0;
+ *yoff = 0;
+ }
+ else
+ pixman_image_set_transform(image, pict->transform);
}
-
- switch (pict->repeatType)
- {
+
+ switch (pict->repeatType) {
default:
case RepeatNone:
- repeat = PIXMAN_REPEAT_NONE;
- break;
-
+ repeat = PIXMAN_REPEAT_NONE;
+ break;
+
case RepeatPad:
- repeat = PIXMAN_REPEAT_PAD;
- break;
-
+ repeat = PIXMAN_REPEAT_PAD;
+ break;
+
case RepeatNormal:
- repeat = PIXMAN_REPEAT_NORMAL;
- break;
-
+ repeat = PIXMAN_REPEAT_NORMAL;
+ break;
+
case RepeatReflect:
- repeat = PIXMAN_REPEAT_REFLECT;
- break;
+ repeat = PIXMAN_REPEAT_REFLECT;
+ break;
}
-
- pixman_image_set_repeat (image, repeat);
-
+
+ pixman_image_set_repeat(image, repeat);
+
/* Fetch alpha map unless 'pict' is being used
* as the alpha map for this operation
*/
- if (pict->alphaMap && !is_alpha_map)
- {
- int alpha_xoff, alpha_yoff;
- pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff, TRUE);
-
- pixman_image_set_alpha_map (
- image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
-
- free_pixman_pict (pict->alphaMap, alpha_map);
+ if (pict->alphaMap && !is_alpha_map) {
+ int alpha_xoff, alpha_yoff;
+ pixman_image_t *alpha_map =
+ image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
+ &alpha_yoff, TRUE);
+
+ pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
+ pict->alphaOrigin.y);
+
+ free_pixman_pict(pict->alphaMap, alpha_map);
}
-
- pixman_image_set_component_alpha (image, pict->componentAlpha);
- switch (pict->filter)
- {
+ pixman_image_set_component_alpha(image, pict->componentAlpha);
+
+ switch (pict->filter) {
default:
case PictFilterNearest:
case PictFilterFast:
- filter = PIXMAN_FILTER_NEAREST;
- break;
-
+ filter = PIXMAN_FILTER_NEAREST;
+ break;
+
case PictFilterBilinear:
case PictFilterGood:
- filter = PIXMAN_FILTER_BILINEAR;
- break;
-
+ filter = PIXMAN_FILTER_BILINEAR;
+ break;
+
case PictFilterConvolution:
- filter = PIXMAN_FILTER_CONVOLUTION;
- break;
+ filter = PIXMAN_FILTER_CONVOLUTION;
+ break;
}
-
- pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
- pixman_image_set_source_clipping (image, TRUE);
+
+ pixman_image_set_filter(image, filter,
+ (pixman_fixed_t *) pict->filter_params,
+ pict->filter_nparams);
+ pixman_image_set_source_clipping(image, TRUE);
}
static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
+ Bool is_alpha_map)
{
pixman_image_t *image = NULL;
if (!pict)
- return NULL;
+ return NULL;
- if (pict->pDrawable)
- {
- image = create_bits_picture (pict, has_clip, xoff, yoff);
+ if (pict->pDrawable) {
+ image = create_bits_picture(pict, has_clip, xoff, yoff);
}
- else if (pict->pSourcePict)
- {
- SourcePict *sp = pict->pSourcePict;
-
- if (sp->type == SourcePictTypeSolidFill)
- {
- image = create_solid_fill_image (pict);
- }
- else
- {
- PictGradient *gradient = &pict->pSourcePict->gradient;
-
- if (sp->type == SourcePictTypeLinear)
- image = create_linear_gradient_image (gradient);
- else if (sp->type == SourcePictTypeRadial)
- image = create_radial_gradient_image (gradient);
- else if (sp->type == SourcePictTypeConical)
- image = create_conical_gradient_image (gradient);
- }
- *xoff = *yoff = 0;
+ else if (pict->pSourcePict) {
+ SourcePict *sp = pict->pSourcePict;
+
+ if (sp->type == SourcePictTypeSolidFill) {
+ image = create_solid_fill_image(pict);
+ }
+ else {
+ PictGradient *gradient = &pict->pSourcePict->gradient;
+
+ if (sp->type == SourcePictTypeLinear)
+ image = create_linear_gradient_image(gradient);
+ else if (sp->type == SourcePictTypeRadial)
+ image = create_radial_gradient_image(gradient);
+ else if (sp->type == SourcePictTypeConical)
+ image = create_conical_gradient_image(gradient);
+ }
+ *xoff = *yoff = 0;
}
-
+
if (image)
- set_image_properties (image, pict, has_clip, xoff, yoff, is_alpha_map);
-
+ set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
+
return image;
}
pixman_image_t *
-image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
{
- return image_from_pict_internal (pict, has_clip, xoff, yoff, FALSE);
+ return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
}
void
-free_pixman_pict (PicturePtr pict, pixman_image_t *image)
+free_pixman_pict(PicturePtr pict, pixman_image_t * image)
{
- if (image && pixman_image_unref (image) && pict->pDrawable)
- fbFinishAccess (pict->pDrawable);
+ if (image && pixman_image_unref(image) && pict->pDrawable)
+ fbFinishAccess(pict->pDrawable);
}
Bool
-fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
{
- PictureScreenPtr ps;
+ PictureScreenPtr ps;
- if (!miPictureInit (pScreen, formats, nformats))
- return FALSE;
+ if (!miPictureInit(pScreen, formats, nformats))
+ return FALSE;
ps = GetPictureScreen(pScreen);
ps->Composite = fbComposite;
ps->Glyphs = miGlyphs;