michael@0: /* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */ michael@0: /* michael@0: * Copyright © 2011 Red Hat, Inc. michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice (including the next michael@0: * paragraph) shall be included in all copies or substantial portions of the michael@0: * Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: */ michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: #include michael@0: #include michael@0: #include "pixman-private.h" michael@0: #include "pixman-combine32.h" michael@0: #include "pixman-inlines.h" michael@0: michael@0: static void michael@0: noop_composite (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: return; michael@0: } michael@0: michael@0: static void michael@0: dest_write_back_direct (pixman_iter_t *iter) michael@0: { michael@0: iter->buffer += iter->image->bits.rowstride; michael@0: } michael@0: michael@0: static uint32_t * michael@0: noop_get_scanline (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: uint32_t *result = iter->buffer; michael@0: michael@0: iter->buffer += iter->image->bits.rowstride; michael@0: michael@0: return result; michael@0: } michael@0: michael@0: static uint32_t * michael@0: get_scanline_null (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: return NULL; michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) michael@0: { michael@0: pixman_image_t *image = iter->image; michael@0: michael@0: #define FLAGS \ michael@0: (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM) michael@0: michael@0: if (!image) michael@0: { michael@0: iter->get_scanline = get_scanline_null; michael@0: } michael@0: else if ((iter->iter_flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) == michael@0: (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) michael@0: { michael@0: iter->get_scanline = _pixman_iter_get_scanline_noop; michael@0: } michael@0: else if (image->common.extended_format_code == PIXMAN_solid && michael@0: (iter->image->type == SOLID || michael@0: (iter->image_flags & FAST_PATH_NO_ALPHA_MAP))) michael@0: { michael@0: if (iter->iter_flags & ITER_NARROW) michael@0: { michael@0: uint32_t *buffer = iter->buffer; michael@0: uint32_t *end = buffer + iter->width; michael@0: uint32_t color; michael@0: michael@0: if (image->type == SOLID) michael@0: color = image->solid.color_32; michael@0: else michael@0: color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); michael@0: michael@0: while (buffer < end) michael@0: *(buffer++) = color; michael@0: } michael@0: else michael@0: { michael@0: argb_t *buffer = (argb_t *)iter->buffer; michael@0: argb_t *end = buffer + iter->width; michael@0: argb_t color; michael@0: michael@0: if (image->type == SOLID) michael@0: color = image->solid.color_float; michael@0: else michael@0: color = image->bits.fetch_pixel_float (&image->bits, 0, 0); michael@0: michael@0: while (buffer < end) michael@0: *(buffer++) = color; michael@0: } michael@0: michael@0: iter->get_scanline = _pixman_iter_get_scanline_noop; michael@0: } michael@0: else if (image->common.extended_format_code == PIXMAN_a8r8g8b8 && michael@0: (iter->iter_flags & ITER_NARROW) && michael@0: (iter->image_flags & FLAGS) == FLAGS && michael@0: iter->x >= 0 && iter->y >= 0 && michael@0: iter->x + iter->width <= image->bits.width && michael@0: iter->y + iter->height <= image->bits.height) michael@0: { michael@0: iter->buffer = michael@0: image->bits.bits + iter->y * image->bits.rowstride + iter->x; michael@0: michael@0: iter->get_scanline = noop_get_scanline; michael@0: } michael@0: else michael@0: { michael@0: return FALSE; michael@0: } michael@0: michael@0: return TRUE; michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: noop_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) michael@0: { michael@0: pixman_image_t *image = iter->image; michael@0: uint32_t image_flags = iter->image_flags; michael@0: uint32_t iter_flags = iter->iter_flags; michael@0: michael@0: if ((image_flags & FAST_PATH_STD_DEST_FLAGS) == FAST_PATH_STD_DEST_FLAGS && michael@0: (iter_flags & ITER_NARROW) == ITER_NARROW && michael@0: ((image->common.extended_format_code == PIXMAN_a8r8g8b8) || michael@0: (image->common.extended_format_code == PIXMAN_x8r8g8b8 && michael@0: (iter_flags & (ITER_LOCALIZED_ALPHA))))) michael@0: { michael@0: iter->buffer = image->bits.bits + iter->y * image->bits.rowstride + iter->x; michael@0: michael@0: iter->get_scanline = _pixman_iter_get_scanline_noop; michael@0: iter->write_back = dest_write_back_direct; michael@0: michael@0: return TRUE; michael@0: } michael@0: else michael@0: { michael@0: return FALSE; michael@0: } michael@0: } michael@0: michael@0: static const pixman_fast_path_t noop_fast_paths[] = michael@0: { michael@0: { PIXMAN_OP_DST, PIXMAN_any, 0, PIXMAN_any, 0, PIXMAN_any, 0, noop_composite }, michael@0: { PIXMAN_OP_NONE }, michael@0: }; michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_noop (pixman_implementation_t *fallback) michael@0: { michael@0: pixman_implementation_t *imp = michael@0: _pixman_implementation_create (fallback, noop_fast_paths); michael@0: michael@0: imp->src_iter_init = noop_src_iter_init; michael@0: imp->dest_iter_init = noop_dest_iter_init; michael@0: michael@0: return imp; michael@0: }