From 34c1e86406451a3604de4982339058088434ab40 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 17 Jan 2012 08:43:22 +0100 Subject: git update mesa pixman xserver 17 jan 2012 --- mesalib/docs/contents.html | 1 + mesalib/docs/intro.html | 31 +- mesalib/src/gallium/auxiliary/util/u_blitter.c | 4 +- mesalib/src/gallium/auxiliary/util/u_debug_stack.c | 222 +++++++------- mesalib/src/gallium/auxiliary/util/u_dump_state.c | 6 +- mesalib/src/mesa/main/format_pack.c | 2 +- mesalib/src/mesa/main/version.c | 6 +- mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 18 +- pixman/pixman/pixman-bits-image.c | 53 +++- pixman/pixman/pixman-general.c | 16 +- pixman/pixman/pixman-implementation.c | 119 ++------ pixman/pixman/pixman-private.h | 33 +- pixman/test/alphamap.c | 144 +++++++-- pixman/test/composite.c | 332 ++++++--------------- pixman/test/utils.c | 175 +++++++++++ pixman/test/utils.h | 35 +++ xorg-server/configure.ac | 2 +- xorg-server/glx/glxscreens.c | 9 - xorg-server/hw/xfree86/dixmods/Makefile.am | 1 - xorg-server/hw/xfree86/sdksyms.sh | 1 + xorg-server/test/Makefile.am | 57 +++- xorg-server/test/ddxstubs.c | 91 ++++++ 22 files changed, 797 insertions(+), 561 deletions(-) create mode 100644 xorg-server/test/ddxstubs.c diff --git a/mesalib/docs/contents.html b/mesalib/docs/contents.html index e3cea2a7c..33c2191ee 100644 --- a/mesalib/docs/contents.html +++ b/mesalib/docs/contents.html @@ -63,6 +63,7 @@ a:visited {
  • Mesa Extensions
  • Function Name Mangling
  • Gallium llvmpipe driver +
  • VMware SVGA3D guest driver
  • Gallium post-processing
  • Viewperf Issues diff --git a/mesalib/docs/intro.html b/mesalib/docs/intro.html index 0806caf38..303f5eb0f 100644 --- a/mesalib/docs/intro.html +++ b/mesalib/docs/intro.html @@ -132,12 +132,26 @@ June 2007: Mesa 7.0 is released, implementing the OpenGL 2.1 specification and OpenGL Shading Language.

    +

    +2008: Keith Whitwell and other Tungsten Graphics employees develop +Gallium +- a new GPU abstraction layer. The latest Mesa drivers are based on +Gallium and other APIs such as OpenVG are implemented on top of Gallium. +

    + +

    +February 2012: Mesa 8.0 is released, implementing the OpenGL 3.0 specification +and version 1.30 of the OpenGL Shading Language. +

    -Ongoing: Mesa is used as the core of many hardware OpenGL drivers for -the XFree86 and X.org X servers within the -DRI project. -I continue to enhance Mesa with new extensions and features. +Ongoing: Mesa is the OpenGL implementation for several types of hardware +made by Intel, AMD and NVIDIA, plus the VMware virtual GPU. +There's also several software-based renderers: swrast (the legacy +Mesa rasterizer), softpipe (a gallium reference driver) and llvmpipe +(LLVM/JIT-based high-speed rasterizer). +Work continues on the drivers and core Mesa to implement newer versions +of the OpenGL specification.

    @@ -151,6 +165,15 @@ of the OpenGL specification is implemented.

    +

    Version 8.x features

    +

    +Version 8.x of Mesa implements the OpenGL 3.0 API. +The developers at Intel deserve a lot of credit for implementing most +of the OpenGL 3.0 features in core Mesa, the GLSL compiler as well as +the i965 driver. +

    + +

    Version 7.x features

    Version 7.x of Mesa implements the OpenGL 2.1 API. The main feature diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 59940d9cb..6a32de619 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -263,8 +263,8 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) memset(&so, 0, sizeof(so)); so.num_outputs = 1; - so.output[0].register_mask = TGSI_WRITEMASK_XYZW; - so.stride = 4; + so.output[0].num_components = 4; + so.stride[0] = 4; ctx->vs_pos_only = util_make_vertex_passthrough_shader_with_so(pipe, 1, semantic_names, diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_stack.c b/mesalib/src/gallium/auxiliary/util/u_debug_stack.c index 046bb43b1..558b911f2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug_stack.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug_stack.c @@ -1,110 +1,112 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * @file - * Stack backtracing. - * - * @author Jose Fonseca - */ - -#include "u_debug.h" -#include "u_debug_symbol.h" -#include "u_debug_stack.h" - - -void -debug_backtrace_capture(struct debug_stack_frame *backtrace, - unsigned start_frame, - unsigned nr_frames) -{ - const void **frame_pointer = NULL; - unsigned i = 0; - - if(!nr_frames) - return; - -#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86) - __asm__ __volatile__("mov (%%ebp),%0": "=r" (frame_pointer)); - frame_pointer = (const void **)frame_pointer[0]; -#elif defined(PIPE_CC_GCC) - frame_pointer = ((const void **)__builtin_frame_address(1)); -#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86) - __asm { - mov frame_pointer, ebp - } - frame_pointer = (const void **)frame_pointer[0]; -#else - frame_pointer = NULL; -#endif - - -#ifdef PIPE_ARCH_X86 - while(nr_frames) { - const void **next_frame_pointer; - - if(!frame_pointer) - break; - - if(start_frame) - --start_frame; - else { - backtrace[i++].function = frame_pointer[1]; - --nr_frames; - } - - next_frame_pointer = (const void **)frame_pointer[0]; - - /* Limit the stack walk to avoid referencing undefined memory */ - if((uintptr_t)next_frame_pointer <= (uintptr_t)frame_pointer || - (uintptr_t)next_frame_pointer > (uintptr_t)frame_pointer + 64*1024) - break; - - frame_pointer = next_frame_pointer; - } -#endif - - while(nr_frames) { - backtrace[i++].function = NULL; - --nr_frames; - } -} - - -void -debug_backtrace_dump(const struct debug_stack_frame *backtrace, - unsigned nr_frames) -{ - unsigned i; - - for(i = 0; i < nr_frames; ++i) { - if(!backtrace[i].function) - break; - debug_symbol_print(backtrace[i].function); - } -} - +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * @file + * Stack backtracing. + * + * @author Jose Fonseca + */ + +#include "u_debug.h" +#include "u_debug_symbol.h" +#include "u_debug_stack.h" + + +void +debug_backtrace_capture(struct debug_stack_frame *backtrace, + unsigned start_frame, + unsigned nr_frames) +{ + const void **frame_pointer = NULL; + unsigned i = 0; + + if(!nr_frames) + return; + +#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86) + __asm__ __volatile__("mov (%%ebp),%0": "=r" (frame_pointer)); + frame_pointer = (const void **)frame_pointer[0]; +#elif defined(PIPE_CC_GCC) + frame_pointer = ((const void **)__builtin_frame_address(1)); +#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86) + __asm { + mov frame_pointer, ebp + } + frame_pointer = (const void **)frame_pointer[0]; +#else + frame_pointer = NULL; +#endif + + +#ifdef PIPE_ARCH_X86 + while(nr_frames) { + const void **next_frame_pointer; + + if(!frame_pointer) + break; + + if(start_frame) + --start_frame; + else { + backtrace[i++].function = frame_pointer[1]; + --nr_frames; + } + + next_frame_pointer = (const void **)frame_pointer[0]; + + /* Limit the stack walk to avoid referencing undefined memory */ + if((uintptr_t)next_frame_pointer <= (uintptr_t)frame_pointer || + (uintptr_t)next_frame_pointer > (uintptr_t)frame_pointer + 64*1024) + break; + + frame_pointer = next_frame_pointer; + } +#else + (void) frame_pointer; +#endif + + while(nr_frames) { + backtrace[i++].function = NULL; + --nr_frames; + } +} + + +void +debug_backtrace_dump(const struct debug_stack_frame *backtrace, + unsigned nr_frames) +{ + unsigned i; + + for(i = 0; i < nr_frames; ++i) { + if(!backtrace[i].function) + break; + debug_symbol_print(backtrace[i].function); + } +} + diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c index c728bc402..c346a0ba5 100644 --- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c +++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c @@ -444,13 +444,15 @@ util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state) util_dump_member_begin(stream, "stream_output"); util_dump_struct_begin(stream, "pipe_stream_output_info"); util_dump_member(stream, uint, &state->stream_output, num_outputs); - util_dump_member(stream, uint, &state->stream_output, stride); + util_dump_array(stream, uint, state->stream_output.stride, + Elements(state->stream_output.stride)); util_dump_array_begin(stream); for(i = 0; i < state->stream_output.num_outputs; ++i) { util_dump_elem_begin(stream); util_dump_struct_begin(stream, ""); /* anonymous */ util_dump_member(stream, uint, &state->stream_output.output[i], register_index); - util_dump_member(stream, uint, &state->stream_output.output[i], register_mask); + util_dump_member(stream, uint, &state->stream_output.output[i], start_component); + util_dump_member(stream, uint, &state->stream_output.output[i], num_components); util_dump_member(stream, uint, &state->stream_output.output[i], output_buffer); util_dump_struct_end(stream); util_dump_elem_end(stream); diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c index 0982c9af4..85b2c691c 100644 --- a/mesalib/src/mesa/main/format_pack.c +++ b/mesalib/src/mesa/main/format_pack.c @@ -636,7 +636,7 @@ pack_float_ARGB1555_REV(const GLfloat src[4], void *dst) static void pack_ubyte_AL44(const GLubyte src[4], void *dst) { - GLushort *d = ((GLushort *) dst); + GLubyte *d = ((GLubyte *) dst); *d = PACK_COLOR_44(src[ACOMP], src[RCOMP]); } diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 49cdc3088..38ae1ce85 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -130,16 +130,14 @@ compute_version(struct gl_context *ctx) ctx->Extensions.ARB_half_float_pixel && ctx->Extensions.ARB_half_float_vertex && ctx->Extensions.ARB_map_buffer_range && + ctx->Extensions.ARB_shader_texture_lod && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_compression_rgtc && ctx->Extensions.APPLE_vertex_array_object && ctx->Extensions.EXT_draw_buffers2 && - ctx->Extensions.EXT_framebuffer_blit && - ctx->Extensions.EXT_framebuffer_multisample && - ctx->Extensions.EXT_framebuffer_object && + ctx->Extensions.ARB_framebuffer_object && ctx->Extensions.EXT_framebuffer_sRGB && - ctx->Extensions.EXT_packed_depth_stencil && ctx->Extensions.EXT_packed_float && ctx->Extensions.EXT_texture_array && ctx->Extensions.EXT_texture_integer && diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 26047cfe0..dc841ff97 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5097,25 +5097,21 @@ st_translate_stream_output_info(glsl_to_tgsi_visitor *glsl_to_tgsi, const GLuint outputMapping[], struct pipe_stream_output_info *so) { - static unsigned comps_to_mask[] = { - 0, - TGSI_WRITEMASK_X, - TGSI_WRITEMASK_XY, - TGSI_WRITEMASK_XYZ, - TGSI_WRITEMASK_XYZW - }; unsigned i; struct gl_transform_feedback_info *info = &glsl_to_tgsi->shader_program->LinkedTransformFeedback; for (i = 0; i < info->NumOutputs; i++) { - assert(info->Outputs[i].NumComponents < Elements(comps_to_mask)); so->output[i].register_index = outputMapping[info->Outputs[i].OutputRegister]; - so->output[i].register_mask = - comps_to_mask[info->Outputs[i].NumComponents] - << info->Outputs[i].ComponentOffset; + so->output[i].start_component = info->Outputs[i].ComponentOffset; + so->output[i].num_components = info->Outputs[i].NumComponents; so->output[i].output_buffer = info->Outputs[i].OutputBuffer; + so->output[i].dst_offset = info->Outputs[i].DstOffset; + } + + for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) { + so->stride[i] = info->BufferStride[i]; } so->num_outputs = info->NumOutputs; } diff --git a/pixman/pixman/pixman-bits-image.c b/pixman/pixman/pixman-bits-image.c index 99c0dfe6d..2f56de31c 100644 --- a/pixman/pixman/pixman-bits-image.c +++ b/pixman/pixman/pixman-bits-image.c @@ -1294,12 +1294,27 @@ dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask) image->bits.fetch_scanline_32 (image, x, y, width, buffer, mask); if (image->common.alpha_map) { - x -= image->common.alpha_origin_x; - y -= image->common.alpha_origin_y; + uint32_t *alpha; + + if ((alpha = malloc (width * sizeof (uint32_t)))) + { + int i; + + x -= image->common.alpha_origin_x; + y -= image->common.alpha_origin_y; + + image->common.alpha_map->fetch_scanline_32 ( + (pixman_image_t *)image->common.alpha_map, + x, y, width, alpha, mask); - image->common.alpha_map->fetch_scanline_32 ( - (pixman_image_t *)image->common.alpha_map, - x, y, width, buffer, mask); + for (i = 0; i < width; ++i) + { + buffer[i] &= ~0xff000000; + buffer[i] |= (alpha[i] & 0xff000000); + } + + free (alpha); + } } return iter->buffer; @@ -1312,17 +1327,33 @@ dest_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask) int x = iter->x; int y = iter->y; int width = iter->width; - uint32_t * buffer = iter->buffer; + uint64_t * buffer = (uint64_t *)iter->buffer; image->fetch_scanline_64 ( - (pixman_image_t *)image, x, y, width, buffer, mask); + (pixman_image_t *)image, x, y, width, (uint32_t *)buffer, mask); if (image->common.alpha_map) { - x -= image->common.alpha_origin_x; - y -= image->common.alpha_origin_y; + uint64_t *alpha; + + if ((alpha = malloc (width * sizeof (uint64_t)))) + { + int i; + + x -= image->common.alpha_origin_x; + y -= image->common.alpha_origin_y; - image->common.alpha_map->fetch_scanline_64 ( - (pixman_image_t *)image->common.alpha_map, x, y, width, buffer, mask); + image->common.alpha_map->fetch_scanline_64 ( + (pixman_image_t *)image->common.alpha_map, + x, y, width, (uint32_t *)alpha, mask); + + for (i = 0; i < width; ++i) + { + buffer[i] &= ~0xffff000000000000ULL; + buffer[i] |= (alpha[i] & 0xffff000000000000ULL); + } + + free (alpha); + } } return iter->buffer; diff --git a/pixman/pixman/pixman-general.c b/pixman/pixman/pixman-general.c index 2ccdfcd0f..27fa3abe5 100644 --- a/pixman/pixman/pixman-general.c +++ b/pixman/pixman/pixman-general.c @@ -171,20 +171,8 @@ general_composite_rect (pixman_implementation_t *imp, imp->toplevel, &dest_iter, dest_image, dest_x, dest_y, width, height, dest_buffer, narrow | op_flags[op].dst); - if (narrow) - { - if (component_alpha) - compose = _pixman_implementation_combine_32_ca; - else - compose = _pixman_implementation_combine_32; - } - else - { - if (component_alpha) - compose = (pixman_combine_32_func_t)_pixman_implementation_combine_64_ca; - else - compose = (pixman_combine_32_func_t)_pixman_implementation_combine_64; - } + compose = _pixman_implementation_lookup_combiner ( + imp->toplevel, op, component_alpha, narrow); if (!compose) return; diff --git a/pixman/pixman/pixman-implementation.c b/pixman/pixman/pixman-implementation.c index 2b7b19d0a..b0a295939 100644 --- a/pixman/pixman/pixman-implementation.c +++ b/pixman/pixman/pixman-implementation.c @@ -27,54 +27,6 @@ #include #include "pixman-private.h" -static void -delegate_combine_32 (pixman_implementation_t * imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width) -{ - _pixman_implementation_combine_32 (imp->delegate, - op, dest, src, mask, width); -} - -static void -delegate_combine_64 (pixman_implementation_t * imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width) -{ - _pixman_implementation_combine_64 (imp->delegate, - op, dest, src, mask, width); -} - -static void -delegate_combine_32_ca (pixman_implementation_t * imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width) -{ - _pixman_implementation_combine_32_ca (imp->delegate, - op, dest, src, mask, width); -} - -static void -delegate_combine_64_ca (pixman_implementation_t * imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width) -{ - _pixman_implementation_combine_64_ca (imp->delegate, - op, dest, src, mask, width); -} - static pixman_bool_t delegate_blt (pixman_implementation_t * imp, uint32_t * src_bits, @@ -150,61 +102,44 @@ _pixman_implementation_create (pixman_implementation_t *delegate, imp->src_iter_init = delegate_src_iter_init; imp->dest_iter_init = delegate_dest_iter_init; + imp->fast_paths = fast_paths; + for (i = 0; i < PIXMAN_N_OPERATORS; ++i) { - imp->combine_32[i] = delegate_combine_32; - imp->combine_64[i] = delegate_combine_64; - imp->combine_32_ca[i] = delegate_combine_32_ca; - imp->combine_64_ca[i] = delegate_combine_64_ca; + imp->combine_32[i] = NULL; + imp->combine_64[i] = NULL; + imp->combine_32_ca[i] = NULL; + imp->combine_64_ca[i] = NULL; } - imp->fast_paths = fast_paths; - return imp; } -void -_pixman_implementation_combine_32 (pixman_implementation_t * imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width) +pixman_combine_32_func_t +_pixman_implementation_lookup_combiner (pixman_implementation_t *imp, + pixman_op_t op, + pixman_bool_t component_alpha, + pixman_bool_t narrow) { - (*imp->combine_32[op]) (imp, op, dest, src, mask, width); -} + pixman_combine_32_func_t f; -void -_pixman_implementation_combine_64 (pixman_implementation_t * imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width) -{ - (*imp->combine_64[op]) (imp, op, dest, src, mask, width); -} + do + { + pixman_combine_32_func_t (*combiners[]) = + { + (pixman_combine_32_func_t *)imp->combine_64, + (pixman_combine_32_func_t *)imp->combine_64_ca, + imp->combine_32, + imp->combine_32_ca, + }; -void -_pixman_implementation_combine_32_ca (pixman_implementation_t * imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width) -{ - (*imp->combine_32_ca[op]) (imp, op, dest, src, mask, width); -} + f = combiners[component_alpha | (narrow << 1)][op]; -void -_pixman_implementation_combine_64_ca (pixman_implementation_t * imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width) -{ - (*imp->combine_64_ca[op]) (imp, op, dest, src, mask, width); + imp = imp->delegate; + } + while (!f); + + return f; } pixman_bool_t diff --git a/pixman/pixman/pixman-private.h b/pixman/pixman/pixman-private.h index 1443bfb3d..856038547 100644 --- a/pixman/pixman/pixman-private.h +++ b/pixman/pixman/pixman-private.h @@ -475,34 +475,11 @@ pixman_implementation_t * _pixman_implementation_create (pixman_implementation_t *delegate, const pixman_fast_path_t *fast_paths); -void -_pixman_implementation_combine_32 (pixman_implementation_t *imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width); -void -_pixman_implementation_combine_64 (pixman_implementation_t *imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width); -void -_pixman_implementation_combine_32_ca (pixman_implementation_t *imp, - pixman_op_t op, - uint32_t * dest, - const uint32_t * src, - const uint32_t * mask, - int width); -void -_pixman_implementation_combine_64_ca (pixman_implementation_t *imp, - pixman_op_t op, - uint64_t * dest, - const uint64_t * src, - const uint64_t * mask, - int width); +pixman_combine_32_func_t +_pixman_implementation_lookup_combiner (pixman_implementation_t *imp, + pixman_op_t op, + pixman_bool_t component_alpha, + pixman_bool_t wide); pixman_bool_t _pixman_implementation_blt (pixman_implementation_t *imp, diff --git a/pixman/test/alphamap.c b/pixman/test/alphamap.c index 24a350ed7..0c5757ea3 100644 --- a/pixman/test/alphamap.c +++ b/pixman/test/alphamap.c @@ -2,8 +2,8 @@ #include #include "utils.h" -#define WIDTH 100 -#define HEIGHT 100 +#define WIDTH 48 +#define HEIGHT 48 static const pixman_format_code_t formats[] = { @@ -70,24 +70,6 @@ make_image (pixman_format_code_t format) return image; } -static pixman_image_t * -create_image (pixman_format_code_t format, pixman_format_code_t alpha_format, - int alpha_origin_x, int alpha_origin_y) -{ - pixman_image_t *image = make_image (format); - - if (alpha_format != PIXMAN_null) - { - pixman_image_t *alpha = make_image (alpha_format); - - pixman_image_set_alpha_map (image, alpha, - alpha_origin_x, alpha_origin_y); - pixman_image_unref (alpha); - } - - return image; -} - static uint8_t get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y) { @@ -139,6 +121,45 @@ get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y) return r; } +static uint16_t +get_red (pixman_image_t *image, int x, int y, int orig_x, int orig_y) +{ + uint8_t *bits; + uint16_t r; + + bits = (uint8_t *)image->bits.bits; + + if (image->bits.format == PIXMAN_a8) + { + r = 0x00; + } + else if (image->bits.format == PIXMAN_a2r10g10b10) + { + r = ((uint32_t *)bits)[y * WIDTH + x] >> 14; + r &= 0xffc0; + r |= (r >> 10); + } + else if (image->bits.format == PIXMAN_a8r8g8b8) + { + r = ((uint32_t *)bits)[y * WIDTH + x] >> 16; + r &= 0xff; + r |= r << 8; + } + else if (image->bits.format == PIXMAN_a4r4g4b4) + { + r = ((uint16_t *)bits)[y * WIDTH + x] >> 8; + r &= 0xf; + r |= r << 4; + r |= r << 8; + } + else + { + assert (0); + } + + return r; +} + static int run_test (int s, int d, int sa, int da, int soff, int doff) { @@ -146,10 +167,10 @@ run_test (int s, int d, int sa, int da, int soff, int doff) pixman_format_code_t df = formats[d]; pixman_format_code_t saf = alpha_formats[sa]; pixman_format_code_t daf = alpha_formats[da]; - pixman_image_t *src, *dst, *orig_dst; + pixman_image_t *src, *dst, *orig_dst, *alpha, *orig_alpha; pixman_transform_t t1; int j, k; - int n_alpha_bits; + int n_alpha_bits, n_red_bits; soff = origins[soff]; doff = origins[doff]; @@ -158,10 +179,37 @@ run_test (int s, int d, int sa, int da, int soff, int doff) if (daf != PIXMAN_null) n_alpha_bits = PIXMAN_FORMAT_A (daf); + n_red_bits = PIXMAN_FORMAT_R (df); + + /* Source */ + src = make_image (sf); + if (saf != PIXMAN_null) + { + alpha = make_image (saf); + pixman_image_set_alpha_map (src, alpha, soff, soff); + pixman_image_unref (alpha); + } + + /* Destination */ + orig_dst = make_image (df); + dst = make_image (df); + pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst, + 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + + if (daf != PIXMAN_null) + { + orig_alpha = make_image (daf); + alpha = make_image (daf); + + pixman_image_composite (PIXMAN_OP_SRC, orig_alpha, NULL, alpha, + 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); - src = create_image (sf, saf, soff, soff); - orig_dst = create_image (df, daf, doff, doff); - dst = create_image (df, daf, doff, doff); + pixman_image_set_alpha_map (orig_dst, orig_alpha, doff, doff); + pixman_image_set_alpha_map (dst, alpha, doff, doff); + + pixman_image_unref (orig_alpha); + pixman_image_unref (alpha); + } /* Transformations, repeats and filters on destinations should be ignored, * so just set some random ones. @@ -175,9 +223,6 @@ run_test (int s, int d, int sa, int da, int soff, int doff) pixman_image_set_filter (dst, PIXMAN_FILTER_BILINEAR, NULL, 0); pixman_image_set_repeat (dst, PIXMAN_REPEAT_REFLECT); - pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst, - 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); - pixman_image_composite (PIXMAN_OP_ADD, src, NULL, dst, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); @@ -185,21 +230,22 @@ run_test (int s, int d, int sa, int da, int soff, int doff) { for (k = MAX (doff, 0); k < MIN (WIDTH, WIDTH + doff); ++k) { - uint8_t sa, da, oda, ref; + uint8_t sa, da, oda, refa; + uint16_t sr, dr, odr, refr; sa = get_alpha (src, k, j, soff, soff); da = get_alpha (dst, k, j, doff, doff); oda = get_alpha (orig_dst, k, j, doff, doff); if (sa + oda > 255) - ref = 255; + refa = 255; else - ref = sa + oda; + refa = sa + oda; - if (da >> (8 - n_alpha_bits) != ref >> (8 - n_alpha_bits)) + if (da >> (8 - n_alpha_bits) != refa >> (8 - n_alpha_bits)) { printf ("\nWrong alpha value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n", - k, j, ref, da, sa, oda); + k, j, refa, da, sa, oda); printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n", format_name (sf), @@ -210,6 +256,38 @@ run_test (int s, int d, int sa, int da, int soff, int doff) doff, doff); return 1; } + + /* There are cases where we go through the 8 bit compositing + * path even with 10bpc formats. This results in incorrect + * results here, so only do the red check for narrow formats + */ + if (n_red_bits <= 8) + { + sr = get_red (src, k, j, soff, soff); + dr = get_red (dst, k, j, doff, doff); + odr = get_red (orig_dst, k, j, doff, doff); + + if (sr + odr > 0xffff) + refr = 0xffff; + else + refr = sr + odr; + + if (abs ((dr >> (16 - n_red_bits)) - (refr >> (16 - n_red_bits))) > 1) + { + printf ("%d red bits\n", n_red_bits); + printf ("\nWrong red value at (%d, %d). Should be 0x%x; got 0x%x. Source was 0x%x, original dest was 0x%x\n", + k, j, refr, dr, sr, odr); + + printf ("src: %s, alpha: %s, origin %d %d\ndst: %s, alpha: %s, origin: %d %d\n\n", + format_name (sf), + format_name (saf), + soff, soff, + format_name (df), + format_name (daf), + doff, doff); + return 1; + } + } } } diff --git a/pixman/test/composite.c b/pixman/test/composite.c index fe59eae3c..48bde9c7d 100644 --- a/pixman/test/composite.c +++ b/pixman/test/composite.c @@ -28,16 +28,10 @@ #include #include "utils.h" -typedef struct color_t color_t; typedef struct format_t format_t; typedef struct image_t image_t; typedef struct operator_t operator_t; -struct color_t -{ - double r, g, b, a; -}; - struct format_t { pixman_format_code_t format; @@ -480,147 +474,19 @@ do_composite (pixman_op_t op, result->a = calc_op (op, srcval.a, dst->a, srcalpha.a, dst->a); } -static void -color_correct (pixman_format_code_t format, - color_t *color) +static uint32_t +get_value (pixman_image_t *image) { -#define MASK(x) ((1 << (x)) - 1) -#define round_pix(pix, m) \ - ((int)((pix) * (MASK(m)) + .5) / (double) (MASK(m))) - - if (PIXMAN_FORMAT_R (format) == 0) - { - color->r = 0.0; - color->g = 0.0; - color->b = 0.0; - } - else - { - color->r = round_pix (color->r, PIXMAN_FORMAT_R (format)); - color->g = round_pix (color->g, PIXMAN_FORMAT_G (format)); - color->b = round_pix (color->b, PIXMAN_FORMAT_B (format)); - } - - if (PIXMAN_FORMAT_A (format) == 0) - color->a = 1.0; - else - color->a = round_pix (color->a, PIXMAN_FORMAT_A (format)); + uint32_t value = *(uint32_t *)pixman_image_get_data (image); -#undef round_pix -#undef MASK -} - -static void -get_pixel (pixman_image_t *image, - pixman_format_code_t format, - color_t *color) -{ -#define MASK(N) ((1UL << (N))-1) - - unsigned long rs, gs, bs, as; - int a, r, g, b; - unsigned long val; - - val = *(unsigned long *) pixman_image_get_data (image); #ifdef WORDS_BIGENDIAN - val >>= 8 * sizeof(val) - PIXMAN_FORMAT_BPP (format); -#endif - - /* Number of bits in each channel */ - a = PIXMAN_FORMAT_A (format); - r = PIXMAN_FORMAT_R (format); - g = PIXMAN_FORMAT_G (format); - b = PIXMAN_FORMAT_B (format); - - switch (PIXMAN_FORMAT_TYPE (format)) { - case PIXMAN_TYPE_ARGB: - bs = 0; - gs = b + bs; - rs = g + gs; - as = r + rs; - break; - - case PIXMAN_TYPE_ABGR: - rs = 0; - gs = r + rs; - bs = g + gs; - as = b + bs; - break; - - case PIXMAN_TYPE_BGRA: - as = 0; - rs = PIXMAN_FORMAT_BPP (format) - (b + g + r); - gs = r + rs; - bs = g + gs; - break; - - case PIXMAN_TYPE_RGBA: - as = 0; - bs = PIXMAN_FORMAT_BPP (format) - (b + g + r); - gs = b + bs; - rs = g + gs; - break; - - case PIXMAN_TYPE_A: - as = 0; - rs = 0; - gs = 0; - bs = 0; - break; - - case PIXMAN_TYPE_OTHER: - case PIXMAN_TYPE_COLOR: - case PIXMAN_TYPE_GRAY: - case PIXMAN_TYPE_YUY2: - case PIXMAN_TYPE_YV12: - default: - abort (); - as = 0; - rs = 0; - gs = 0; - bs = 0; - break; - } - - if (MASK (a) != 0) - color->a = ((val >> as) & MASK (a)) / (double) MASK (a); - else - color->a = 1.0; - - if (MASK (r) != 0) - { - color->r = ((val >> rs) & MASK (r)) / (double) MASK (r); - color->g = ((val >> gs) & MASK (g)) / (double) MASK (g); - color->b = ((val >> bs) & MASK (b)) / (double) MASK (b); + pixman_format_code_t format = pixman_image_get_format (image); + value >>= 8 * sizeof(value) - PIXMAN_FORMAT_BPP (format); } - else - { - color->r = 0.0; - color->g = 0.0; - color->b = 0.0; - } - -#undef MASK -} - -static double -eval_diff (color_t *expected, color_t *test, pixman_format_code_t format) -{ - double rscale, gscale, bscale, ascale; - double rdiff, gdiff, bdiff, adiff; - - rscale = 1.0 * ((1 << PIXMAN_FORMAT_R (format)) - 1); - gscale = 1.0 * ((1 << PIXMAN_FORMAT_G (format)) - 1); - bscale = 1.0 * ((1 << PIXMAN_FORMAT_B (format)) - 1); - ascale = 1.0 * ((1 << PIXMAN_FORMAT_A (format)) - 1); - - rdiff = fabs (test->r - expected->r) * rscale; - bdiff = fabs (test->g - expected->g) * gscale; - gdiff = fabs (test->b - expected->b) * bscale; - adiff = fabs (test->a - expected->a) * ascale; +#endif - return MAX (MAX (MAX (rdiff, gdiff), bdiff), adiff); + return value; } static char * @@ -628,10 +494,10 @@ describe_image (image_t *info, char *buf) { if (info->size) { - sprintf (buf, "%s %dx%d%s", + sprintf (buf, "%s, %dx%d%s", info->format->name, info->size, info->size, - info->repeat ? "R" :""); + info->repeat ? " R" :""); } else { @@ -641,52 +507,40 @@ describe_image (image_t *info, char *buf) return buf; } -/* Test a composite of a given operation, source, mask, and destination - * picture. - * Fills the window, and samples from the 0,0 pixel corner. - */ +static char * +describe_color (const color_t *color, char *buf) +{ + sprintf (buf, "%.3f %.3f %.3f %.3f", + color->r, color->g, color->b, color->a); + + return buf; +} + static pixman_bool_t composite_test (image_t *dst, const operator_t *op, image_t *src, image_t *mask, - pixman_bool_t component_alpha) + pixman_bool_t component_alpha, + int testno) { pixman_color_t fill; pixman_rectangle16_t rect; - color_t expected, result, tdst, tsrc, tmsk; - double diff; - pixman_bool_t success = TRUE; + color_t expected, tdst, tsrc, tmsk; + pixel_checker_t checker; + /* Initialize dst */ compute_pixman_color (dst->color, &fill); rect.x = rect.y = 0; rect.width = rect.height = dst->size; - pixman_image_fill_rectangles (PIXMAN_OP_SRC, dst->image, - &fill, 1, &rect); + pixman_image_fill_rectangles (PIXMAN_OP_SRC, dst->image, &fill, 1, &rect); - if (mask != NULL) + if (mask) { pixman_image_set_component_alpha (mask->image, component_alpha); - pixman_image_composite (op->op, src->image, mask->image, dst->image, - 0, 0, - 0, 0, - 0, 0, - dst->size, dst->size); - tmsk = *mask->color; - if (mask->size) - { - color_correct (mask->format->format, &tmsk); - - if (component_alpha && - PIXMAN_FORMAT_R (mask->format->format) == 0) - { - /* Ax component-alpha masks expand alpha into - * all color channels. - */ - tmsk.r = tmsk.g = tmsk.b = tmsk.a; - } - } + pixman_image_composite (op->op, src->image, mask->image, dst->image, + 0, 0, 0, 0, 0, 0, dst->size, dst->size); } else { @@ -696,71 +550,81 @@ composite_test (image_t *dst, 0, 0, dst->size, dst->size); } - get_pixel (dst->image, dst->format->format, &result); tdst = *dst->color; - color_correct (dst->format->format, &tdst); + round_color (dst->format->format, &tdst); + tsrc = *src->color; if (src->size) - color_correct (src->format->format, &tsrc); - do_composite (op->op, &tsrc, mask ? &tmsk : NULL, &tdst, - &expected, component_alpha); - color_correct (dst->format->format, &expected); - - diff = eval_diff (&expected, &result, dst->format->format); - - /* FIXME: We should find out what deviation is acceptable. 3.0 - * is clearly absurd for 2 bit formats for example. On the other - * hand currently 1.0 does not work. - */ - if (diff > 3.0) + round_color (src->format->format, &tsrc); + + if (mask) { - char buf[40]; + tmsk = *mask->color; + if (mask->size) + round_color (mask->format->format, &tmsk); + if (component_alpha && PIXMAN_FORMAT_R (mask->format->format) == 0) + { + /* Ax component-alpha masks expand alpha into + * all color channels. + */ + tmsk.r = tmsk.g = tmsk.b = tmsk.a; + } + } - sprintf (buf, "%s %scomposite", - op->name, - component_alpha ? "CA " : ""); + do_composite (op->op, + &tsrc, + mask? &tmsk : NULL, + &tdst, + &expected, + component_alpha); - printf ("%s test error of %.4f --\n" - " R G B A\n" - "got: %.2f %.2f %.2f %.2f [%08lx]\n" - "expected: %.2f %.2f %.2f %.2f\n", - buf, diff, - result.r, result.g, result.b, result.a, - *(unsigned long *) pixman_image_get_data (dst->image), - expected.r, expected.g, expected.b, expected.a); + pixel_checker_init (&checker, dst->format->format); + if (!pixel_checker_check (&checker, get_value (dst->image), &expected)) + { + char buf[40], buf2[40]; + int a, r, g, b; + uint32_t pixel; + + printf ("---- Test %d failed ----\n", testno); + printf ("Operator: %s %s\n", + op->name, component_alpha ? "CA" : ""); + + printf ("Source: %s\n", describe_image (src, buf)); if (mask != NULL) + printf ("Mask: %s\n", describe_image (mask, buf)); + + printf ("Destination: %s\n\n", describe_image (dst, buf)); + printf (" R G B A Rounded\n"); + printf ("Source color: %s %s\n", + describe_color (src->color, buf), + describe_color (&tsrc, buf2)); + if (mask) { - printf ("src color: %.2f %.2f %.2f %.2f\n" - "msk color: %.2f %.2f %.2f %.2f\n" - "dst color: %.2f %.2f %.2f %.2f\n", - src->color->r, src->color->g, - src->color->b, src->color->a, - mask->color->r, mask->color->g, - mask->color->b, mask->color->a, - dst->color->r, dst->color->g, - dst->color->b, dst->color->a); - printf ("src: %s, ", describe_image (src, buf)); - printf ("mask: %s, ", describe_image (mask, buf)); - printf ("dst: %s\n\n", describe_image (dst, buf)); - } - else - { - printf ("src color: %.2f %.2f %.2f %.2f\n" - "dst color: %.2f %.2f %.2f %.2f\n", - src->color->r, src->color->g, - src->color->b, src->color->a, - dst->color->r, dst->color->g, - dst->color->b, dst->color->a); - printf ("src: %s, ", describe_image (src, buf)); - printf ("dst: %s\n\n", describe_image (dst, buf)); + printf ("Mask color: %s %s\n", + describe_color (mask->color, buf), + describe_color (&tmsk, buf2)); } + printf ("Dest. color: %s %s\n", + describe_color (dst->color, buf), + describe_color (&tdst, buf2)); - success = FALSE; - } + pixel = get_value (dst->image); + + printf ("Expected: %s\n", describe_color (&expected, buf)); - return success; + pixel_checker_split_pixel (&checker, pixel, &a, &r, &g, &b); + + printf ("Got: %5d %5d %5d %5d [pixel: 0x%08x]\n", r, g, b, a, pixel); + pixel_checker_get_min (&checker, &expected, &a, &r, &g, &b); + printf ("Min accepted: %5d %5d %5d %5d\n", r, g, b, a); + pixel_checker_get_max (&checker, &expected, &a, &r, &g, &b); + printf ("Max accepted: %5d %5d %5d %5d\n", r, g, b, a); + + return FALSE; + } + return TRUE; } static void @@ -791,7 +655,7 @@ image_init (image_t *info, pixman_image_fill_rectangles (PIXMAN_OP_SRC, info->image, &fill, 1, &rect); - if (size & REPEAT) + if (sizes[size] & REPEAT) { pixman_image_set_repeat (info->image, PIXMAN_REPEAT_NORMAL); info->repeat = PIXMAN_REPEAT_NORMAL; @@ -836,7 +700,7 @@ run_test (uint32_t seed) int ok; lcg_srand (seed); - + image_init (&dst, random_color(), random_format(), 1); image_init (&src, random_color(), random_format(), random_size()); image_init (&mask, random_color(), random_format(), random_size()); @@ -848,14 +712,14 @@ run_test (uint32_t seed) switch (ca) { case 0: - ok = composite_test (&dst, op, &src, NULL, FALSE); + ok = composite_test (&dst, op, &src, NULL, FALSE, seed); break; case 1: - ok = composite_test (&dst, op, &src, &mask, FALSE); + ok = composite_test (&dst, op, &src, &mask, FALSE, seed); break; case 2: ok = composite_test (&dst, op, &src, &mask, - mask.size? TRUE : FALSE); + mask.size? TRUE : FALSE, seed); break; default: ok = FALSE; @@ -879,7 +743,7 @@ main (int argc, char **argv) if (argc > 1) { char *end; - + i = strtol (argv[1], &end, 0); if (end != argv[1]) @@ -900,7 +764,7 @@ main (int argc, char **argv) seed = get_random_seed(); else seed = 1; - + #ifdef USE_OPENMP # pragma omp parallel for default(none) shared(result, argv, seed) #endif @@ -909,10 +773,10 @@ main (int argc, char **argv) if (!result && !run_test (i + seed)) { printf ("Test 0x%08X failed.\n", seed + i); - + result = seed + i; } } - + return result; } diff --git a/pixman/test/utils.c b/pixman/test/utils.c index 204066f9b..379bd71a8 100644 --- a/pixman/test/utils.c +++ b/pixman/test/utils.c @@ -703,3 +703,178 @@ initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb) assert (palette->ent[CONVERT_15 (palette->rgba[i], is_rgb)] == i); } } + +static double +round_channel (double p, int m) +{ + int t; + double r; + + t = p * ((1 << m)); + t -= t >> m; + + r = t / (double)((1 << m) - 1); + + return r; +} + +void +round_color (pixman_format_code_t format, color_t *color) +{ + if (PIXMAN_FORMAT_R (format) == 0) + { + color->r = 0.0; + color->g = 0.0; + color->b = 0.0; + } + else + { + color->r = round_channel (color->r, PIXMAN_FORMAT_R (format)); + color->g = round_channel (color->g, PIXMAN_FORMAT_G (format)); + color->b = round_channel (color->b, PIXMAN_FORMAT_B (format)); + } + + if (PIXMAN_FORMAT_A (format) == 0) + color->a = 1; + else + color->a = round_channel (color->a, PIXMAN_FORMAT_A (format)); +} + +/* Check whether @pixel is a valid quantization of the a, r, g, b + * parameters. Some slack is permitted. + */ +void +pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format) +{ + assert (PIXMAN_FORMAT_VIS (format)); + + checker->format = format; + + switch (PIXMAN_FORMAT_TYPE (format)) + { + case PIXMAN_TYPE_A: + checker->bs = 0; + checker->gs = 0; + checker->rs = 0; + checker->as = 0; + break; + + case PIXMAN_TYPE_ARGB: + checker->bs = 0; + checker->gs = checker->bs + PIXMAN_FORMAT_B (format); + checker->rs = checker->gs + PIXMAN_FORMAT_G (format); + checker->as = checker->rs + PIXMAN_FORMAT_R (format); + break; + + case PIXMAN_TYPE_ABGR: + checker->rs = 0; + checker->gs = checker->rs + PIXMAN_FORMAT_R (format); + checker->bs = checker->gs + PIXMAN_FORMAT_G (format); + checker->as = checker->bs + PIXMAN_FORMAT_B (format); + break; + + case PIXMAN_TYPE_BGRA: + /* With BGRA formats we start counting at the high end of the pixel */ + checker->bs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_B (format); + checker->gs = checker->bs - PIXMAN_FORMAT_B (format); + checker->rs = checker->gs - PIXMAN_FORMAT_G (format); + checker->as = checker->rs - PIXMAN_FORMAT_R (format); + break; + + case PIXMAN_TYPE_RGBA: + /* With BGRA formats we start counting at the high end of the pixel */ + checker->rs = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_R (format); + checker->gs = checker->rs - PIXMAN_FORMAT_R (format); + checker->bs = checker->gs - PIXMAN_FORMAT_G (format); + checker->as = checker->bs - PIXMAN_FORMAT_B (format); + break; + + default: + assert (0); + break; + } + + checker->am = ((1 << PIXMAN_FORMAT_A (format)) - 1) << checker->as; + checker->rm = ((1 << PIXMAN_FORMAT_R (format)) - 1) << checker->rs; + checker->gm = ((1 << PIXMAN_FORMAT_G (format)) - 1) << checker->gs; + checker->bm = ((1 << PIXMAN_FORMAT_B (format)) - 1) << checker->bs; + + checker->aw = PIXMAN_FORMAT_A (format); + checker->rw = PIXMAN_FORMAT_R (format); + checker->gw = PIXMAN_FORMAT_G (format); + checker->bw = PIXMAN_FORMAT_B (format); +} + +void +pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel, + int *a, int *r, int *g, int *b) +{ + *a = (pixel & checker->am) >> checker->as; + *r = (pixel & checker->rm) >> checker->rs; + *g = (pixel & checker->gm) >> checker->gs; + *b = (pixel & checker->bm) >> checker->bs; +} + +static int32_t +convert (double v, uint32_t width, uint32_t mask, uint32_t shift, double def) +{ + int32_t r; + + if (!mask) + v = def; + + r = (v * ((mask >> shift) + 1)); + r -= r >> width; + + return r; +} + +static void +get_limits (const pixel_checker_t *checker, double limit, + color_t *color, + int *ao, int *ro, int *go, int *bo) +{ + *ao = convert (color->a + limit, checker->aw, checker->am, checker->as, 1.0); + *ro = convert (color->r + limit, checker->rw, checker->rm, checker->rs, 0.0); + *go = convert (color->g + limit, checker->gw, checker->gm, checker->gs, 0.0); + *bo = convert (color->b + limit, checker->bw, checker->bm, checker->bs, 0.0); +} + +/* The acceptable deviation in units of [0.0, 1.0] + */ +#define DEVIATION (0.004) + +void +pixel_checker_get_max (const pixel_checker_t *checker, color_t *color, + int *am, int *rm, int *gm, int *bm) +{ + get_limits (checker, DEVIATION, color, am, rm, gm, bm); +} + +void +pixel_checker_get_min (const pixel_checker_t *checker, color_t *color, + int *am, int *rm, int *gm, int *bm) +{ + get_limits (checker, - DEVIATION, color, am, rm, gm, bm); +} + +pixman_bool_t +pixel_checker_check (const pixel_checker_t *checker, uint32_t pixel, + color_t *color) +{ + int32_t a_lo, a_hi, r_lo, r_hi, g_lo, g_hi, b_lo, b_hi; + int32_t ai, ri, gi, bi; + pixman_bool_t result; + + pixel_checker_get_min (checker, color, &a_lo, &r_lo, &g_lo, &b_lo); + pixel_checker_get_max (checker, color, &a_hi, &r_hi, &g_hi, &b_hi); + pixel_checker_split_pixel (checker, pixel, &ai, &ri, &gi, &bi); + + result = + a_lo <= ai && ai <= a_hi && + r_lo <= ri && ri <= r_hi && + g_lo <= gi && gi <= g_hi && + b_lo <= bi && bi <= b_hi; + + return result; +} diff --git a/pixman/test/utils.h b/pixman/test/utils.h index 3bff78e76..3c0647bc6 100644 --- a/pixman/test/utils.h +++ b/pixman/test/utils.h @@ -151,3 +151,38 @@ aligned_malloc (size_t align, size_t size); void initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb); + +typedef struct +{ + double r, g, b, a; +} color_t; + +void +round_color (pixman_format_code_t format, color_t *color); + +typedef struct +{ + pixman_format_code_t format; + uint32_t am, rm, gm, bm; + uint32_t as, rs, gs, bs; + uint32_t aw, rw, gw, bw; +} pixel_checker_t; + +void +pixel_checker_init (pixel_checker_t *checker, pixman_format_code_t format); + +void +pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel, + int *a, int *r, int *g, int *b); + +void +pixel_checker_get_max (const pixel_checker_t *checker, color_t *color, + int *a, int *r, int *g, int *b); + +void +pixel_checker_get_min (const pixel_checker_t *checker, color_t *color, + int *a, int *r, int *g, int *b); + +pixman_bool_t +pixel_checker_check (const pixel_checker_t *checker, + uint32_t pixel, color_t *color); diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index a203ab285..b0bb9bba7 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -1532,7 +1532,7 @@ if test "x$XORG" = xyes; then XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os' XORG_INCS="$XORG_DDXINCS $XORG_OSINCS" XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H" - XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB" + XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB" dnl ================================================================== dnl symbol visibility diff --git a/xorg-server/glx/glxscreens.c b/xorg-server/glx/glxscreens.c index 928cf0c92..ebb9747b4 100644 --- a/xorg-server/glx/glxscreens.c +++ b/xorg-server/glx/glxscreens.c @@ -419,15 +419,6 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen) void __glXScreenDestroy(__GLXscreen *screen) { - __GLXconfig *head, *next; - - head = screen->fbconfigs; - while (head) { - next = head->next; - free(head); - head = next; - } - free(screen->GLXvendor); free(screen->GLXextensions); free(screen->GLextensions); diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.am b/xorg-server/hw/xfree86/dixmods/Makefile.am index b6eb54f16..a5be3ae00 100644 --- a/xorg-server/hw/xfree86/dixmods/Makefile.am +++ b/xorg-server/hw/xfree86/dixmods/Makefile.am @@ -65,4 +65,3 @@ libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS) libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c -libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh index 4a4e1f64d..9034f3829 100644 --- a/xorg-server/hw/xfree86/sdksyms.sh +++ b/xorg-server/hw/xfree86/sdksyms.sh @@ -324,6 +324,7 @@ topdir=$1 shift LC_ALL=C export LC_ALL +${CPP:-cpp} "$@" -DXorgLoader sdksyms.c > /dev/null || exit $? ${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir ' BEGIN { sdk = 0; diff --git a/xorg-server/test/Makefile.am b/xorg-server/test/Makefile.am index ba8932c5d..b875b75f7 100644 --- a/xorg-server/test/Makefile.am +++ b/xorg-server/test/Makefile.am @@ -50,11 +50,60 @@ libxservertest_la_LIBADD += \ $(top_builddir)/hw/xfree86/ramdac/libramdac.la \ $(top_builddir)/hw/xfree86/ddc/libddc.la \ $(top_builddir)/hw/xfree86/i2c/libi2c.la \ - $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la + $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \ + @XORG_LIBS@ +else +nodist_libxservertest_la_SOURCES = \ + ddxstubs.c \ + $(top_srcdir)/mi/miinitext.c \ + $(top_srcdir)/Xext/dpmsstubs.c \ + $(top_srcdir)/Xi/stubs.c + +libxservertest_la_LIBADD += \ + $(top_builddir)/damageext/libdamageext.la \ + $(top_builddir)/fb/libfb.la \ + $(top_builddir)/fb/libwfb.la \ + $(top_builddir)/miext/damage/libdamage.la \ + $(top_builddir)/miext/sync/libsync.la \ + $(top_builddir)/randr/librandr.la \ + $(top_builddir)/render/librender.la \ + $(top_builddir)/Xext/libXext.la \ + $(top_builddir)/Xi/libXi.la \ + $(top_builddir)/xfixes/libxfixes.la \ + $(top_builddir)/xkb/libxkb.la \ + $(top_builddir)/xkb/libxkbstubs.la + +if COMPOSITE +libxservertest_la_LIBADD += \ + $(top_builddir)/composite/libcomposite.la endif + +if DBE libxservertest_la_LIBADD += \ - $(top_builddir)/mi/libmi.la \ - $(top_builddir)/os/libos.la \ - @XORG_LIBS@ + $(top_builddir)/dbe/libdbe.la +endif + +if GLX +libxservertest_la_LIBADD += \ + $(top_builddir)/glx/libglx.la +endif + +if RECORD +libxservertest_la_LIBADD += \ + $(top_builddir)/record/librecord.la +endif + +if XQUARTZ +libxservertest_la_LIBADD += \ + $(top_builddir)/miext/rootless/librootless.la +TEST_LDADD += -lXplugin +endif + +if XWIN_MULTIWINDOWEXTWM +libxservertest_la_LIBADD += \ + $(top_builddir)/miext/rootless/librootless.la +endif +endif + libxservertest_la_DEPENDENCIES = $(libxservertest_la_LIBADD) endif diff --git a/xorg-server/test/ddxstubs.c b/xorg-server/test/ddxstubs.c new file mode 100644 index 000000000..baf2a7a50 --- /dev/null +++ b/xorg-server/test/ddxstubs.c @@ -0,0 +1,91 @@ +/** + * Copyright © 2012 Apple Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* This file contains stubs for some symbols which are usually provided by a + * DDX. These stubs should allow the unit tests to build on platforms with + * stricter linkers (eg: darwin) when the Xorg DDX is not built. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "input.h" +#include "mi.h" + +void DDXRingBell(int volume, int pitch, int duration) { +} + +void ProcessInputEvents(void) { + mieqProcessInputEvents(); +} + +void OsVendorInit(void) { +} + +void OsVendorFatalError(void) { +} + +void AbortDDX(enum ExitCode error) { + OsAbort(); +} + +void ddxUseMsg(void) { +} + +int ddxProcessArgument(int argc, char *argv[], int i) { + return 0; +} + +void ddxGiveUp( enum ExitCode error ) { +} + +Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) { + return TRUE; +} + +#ifdef XQUARTZ +#include + +BOOL serverRunning = TRUE; +pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; + +int darwinMainScreenX = 0; +int darwinMainScreenY = 0; + +BOOL no_configure_window = FALSE; + +void darwinEvents_lock(void) { +} + +void darwinEvents_unlock(void) { +} +#endif + +#ifdef DDXBEFORERESET +void +ddxBeforeReset(void) { +} +#endif + -- cgit v1.2.3