From 4c74f519ca3788fe357caf54e22e6cab609b681e Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Thu, 30 Apr 2009 02:08:44 -0400 Subject: [PATCH] Factor out duplicated fetcher finding code --- pixman/pixman-compose.c | 85 ++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c index 68b5683..627f5c3 100644 --- a/pixman/pixman-compose.c +++ b/pixman/pixman-compose.c @@ -170,6 +170,39 @@ static inline scanStoreProc get_store_external_alpha(const int wide) return (scanStoreProc)ACCESS(fbStoreExternalAlpha); } +static scanFetchProc +get_fetcher (pixman_image_t *image, int wide) +{ + if (IS_SOURCE_IMAGE (image)) + { + return get_fetch_source_pict(wide); + } + else + { + bits_image_t *bits = (bits_image_t *)image; + + if (bits->common.alpha_map) + { + return get_fetch_external_alpha(wide); + } + else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) && + bits->width == 1 && + bits->height == 1) + { + return get_fetch_solid(wide); + } + else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION + && bits->common.repeat != PIXMAN_REPEAT_PAD && bits->common.repeat != PIXMAN_REPEAT_REFLECT) + { + return get_fetch(wide); + } + else + { + return get_fetch_transformed(wide); + } + } +} + #ifndef PIXMAN_FB_ACCESSORS static #endif @@ -200,34 +233,8 @@ PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data, if (data->op == PIXMAN_OP_CLEAR) fetchSrc = NULL; - else if (IS_SOURCE_IMAGE (data->src)) - { - fetchSrc = get_fetch_source_pict(wide); - } else - { - bits_image_t *bits = (bits_image_t *)data->src; - - if (bits->common.alpha_map) - { - fetchSrc = get_fetch_external_alpha(wide); - } - else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) && - bits->width == 1 && - bits->height == 1) - { - fetchSrc = get_fetch_solid(wide); - } - else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION - && bits->common.repeat != PIXMAN_REPEAT_PAD && bits->common.repeat != PIXMAN_REPEAT_REFLECT) - { - fetchSrc = get_fetch(wide); - } - else - { - fetchSrc = get_fetch_transformed(wide); - } - } + fetchSrc = get_fetcher (data->src, wide); if (!data->mask || data->op == PIXMAN_OP_CLEAR) { @@ -235,29 +242,7 @@ PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data, } else { - if (IS_SOURCE_IMAGE (data->mask)) - { - fetchMask = (scanFetchProc)pixmanFetchSourcePict; - } - else - { - bits_image_t *bits = (bits_image_t *)data->mask; - - if (bits->common.alpha_map) - { - fetchMask = get_fetch_external_alpha(wide); - } - else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) && - bits->width == 1 && bits->height == 1) - { - fetchMask = get_fetch_solid(wide); - } - else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION - && bits->common.repeat != PIXMAN_REPEAT_PAD && bits->common.repeat != PIXMAN_REPEAT_REFLECT) - fetchMask = get_fetch(wide); - else - fetchMask = get_fetch_transformed(wide); - } + fetchMask = get_fetcher (data->mask, wide); } if (data->dest->common.alpha_map) -- 2.7.4