1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/libpixman/src/pixman-noop.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,176 @@ 1.4 +/* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */ 1.5 +/* 1.6 + * Copyright © 2011 Red Hat, Inc. 1.7 + * 1.8 + * Permission is hereby granted, free of charge, to any person obtaining a 1.9 + * copy of this software and associated documentation files (the "Software"), 1.10 + * to deal in the Software without restriction, including without limitation 1.11 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1.12 + * and/or sell copies of the Software, and to permit persons to whom the 1.13 + * Software is furnished to do so, subject to the following conditions: 1.14 + * 1.15 + * The above copyright notice and this permission notice (including the next 1.16 + * paragraph) shall be included in all copies or substantial portions of the 1.17 + * Software. 1.18 + * 1.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1.22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 1.25 + * DEALINGS IN THE SOFTWARE. 1.26 + */ 1.27 +#ifdef HAVE_CONFIG_H 1.28 +#include <config.h> 1.29 +#endif 1.30 +#include <string.h> 1.31 +#include <stdlib.h> 1.32 +#include "pixman-private.h" 1.33 +#include "pixman-combine32.h" 1.34 +#include "pixman-inlines.h" 1.35 + 1.36 +static void 1.37 +noop_composite (pixman_implementation_t *imp, 1.38 + pixman_composite_info_t *info) 1.39 +{ 1.40 + return; 1.41 +} 1.42 + 1.43 +static void 1.44 +dest_write_back_direct (pixman_iter_t *iter) 1.45 +{ 1.46 + iter->buffer += iter->image->bits.rowstride; 1.47 +} 1.48 + 1.49 +static uint32_t * 1.50 +noop_get_scanline (pixman_iter_t *iter, const uint32_t *mask) 1.51 +{ 1.52 + uint32_t *result = iter->buffer; 1.53 + 1.54 + iter->buffer += iter->image->bits.rowstride; 1.55 + 1.56 + return result; 1.57 +} 1.58 + 1.59 +static uint32_t * 1.60 +get_scanline_null (pixman_iter_t *iter, const uint32_t *mask) 1.61 +{ 1.62 + return NULL; 1.63 +} 1.64 + 1.65 +static pixman_bool_t 1.66 +noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) 1.67 +{ 1.68 + pixman_image_t *image = iter->image; 1.69 + 1.70 +#define FLAGS \ 1.71 + (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM) 1.72 + 1.73 + if (!image) 1.74 + { 1.75 + iter->get_scanline = get_scanline_null; 1.76 + } 1.77 + else if ((iter->iter_flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) == 1.78 + (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) 1.79 + { 1.80 + iter->get_scanline = _pixman_iter_get_scanline_noop; 1.81 + } 1.82 + else if (image->common.extended_format_code == PIXMAN_solid && 1.83 + (iter->image->type == SOLID || 1.84 + (iter->image_flags & FAST_PATH_NO_ALPHA_MAP))) 1.85 + { 1.86 + if (iter->iter_flags & ITER_NARROW) 1.87 + { 1.88 + uint32_t *buffer = iter->buffer; 1.89 + uint32_t *end = buffer + iter->width; 1.90 + uint32_t color; 1.91 + 1.92 + if (image->type == SOLID) 1.93 + color = image->solid.color_32; 1.94 + else 1.95 + color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); 1.96 + 1.97 + while (buffer < end) 1.98 + *(buffer++) = color; 1.99 + } 1.100 + else 1.101 + { 1.102 + argb_t *buffer = (argb_t *)iter->buffer; 1.103 + argb_t *end = buffer + iter->width; 1.104 + argb_t color; 1.105 + 1.106 + if (image->type == SOLID) 1.107 + color = image->solid.color_float; 1.108 + else 1.109 + color = image->bits.fetch_pixel_float (&image->bits, 0, 0); 1.110 + 1.111 + while (buffer < end) 1.112 + *(buffer++) = color; 1.113 + } 1.114 + 1.115 + iter->get_scanline = _pixman_iter_get_scanline_noop; 1.116 + } 1.117 + else if (image->common.extended_format_code == PIXMAN_a8r8g8b8 && 1.118 + (iter->iter_flags & ITER_NARROW) && 1.119 + (iter->image_flags & FLAGS) == FLAGS && 1.120 + iter->x >= 0 && iter->y >= 0 && 1.121 + iter->x + iter->width <= image->bits.width && 1.122 + iter->y + iter->height <= image->bits.height) 1.123 + { 1.124 + iter->buffer = 1.125 + image->bits.bits + iter->y * image->bits.rowstride + iter->x; 1.126 + 1.127 + iter->get_scanline = noop_get_scanline; 1.128 + } 1.129 + else 1.130 + { 1.131 + return FALSE; 1.132 + } 1.133 + 1.134 + return TRUE; 1.135 +} 1.136 + 1.137 +static pixman_bool_t 1.138 +noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) 1.139 +{ 1.140 + pixman_image_t *image = iter->image; 1.141 + uint32_t image_flags = iter->image_flags; 1.142 + uint32_t iter_flags = iter->iter_flags; 1.143 + 1.144 + if ((image_flags & FAST_PATH_STD_DEST_FLAGS) == FAST_PATH_STD_DEST_FLAGS && 1.145 + (iter_flags & ITER_NARROW) == ITER_NARROW && 1.146 + ((image->common.extended_format_code == PIXMAN_a8r8g8b8) || 1.147 + (image->common.extended_format_code == PIXMAN_x8r8g8b8 && 1.148 + (iter_flags & (ITER_LOCALIZED_ALPHA))))) 1.149 + { 1.150 + iter->buffer = image->bits.bits + iter->y * image->bits.rowstride + iter->x; 1.151 + 1.152 + iter->get_scanline = _pixman_iter_get_scanline_noop; 1.153 + iter->write_back = dest_write_back_direct; 1.154 + 1.155 + return TRUE; 1.156 + } 1.157 + else 1.158 + { 1.159 + return FALSE; 1.160 + } 1.161 +} 1.162 + 1.163 +static const pixman_fast_path_t noop_fast_paths[] = 1.164 +{ 1.165 + { PIXMAN_OP_DST, PIXMAN_any, 0, PIXMAN_any, 0, PIXMAN_any, 0, noop_composite }, 1.166 + { PIXMAN_OP_NONE }, 1.167 +}; 1.168 + 1.169 +pixman_implementation_t * 1.170 +_pixman_implementation_create_noop (pixman_implementation_t *fallback) 1.171 +{ 1.172 + pixman_implementation_t *imp = 1.173 + _pixman_implementation_create (fallback, noop_fast_paths); 1.174 + 1.175 + imp->src_iter_init = noop_src_iter_init; 1.176 + imp->dest_iter_init = noop_dest_iter_init; 1.177 + 1.178 + return imp; 1.179 +}