int main () { int o, s, m, d; enable_fp_exceptions(); for (o = 0; o < ARRAY_LENGTH (pdf_ops); ++o) { pixman_op_t op = pdf_ops[o]; for (s = 0; s < ARRAY_LENGTH (pixels); ++s) { pixman_image_t *src; src = pixman_image_create_bits ( PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[s]), 4); for (m = -1; m < ARRAY_LENGTH (pixels); ++m) { pixman_image_t *msk = NULL; if (m >= 0) { msk = pixman_image_create_bits ( PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[m]), 4); } for (d = 0; d < ARRAY_LENGTH (pixels); ++d) { pixman_image_t *dst; uint32_t dp = pixels[d]; dst = pixman_image_create_bits ( PIXMAN_a8r8g8b8, 1, 1, &dp, 4); pixman_image_composite (op, src, msk, dst, 0, 0, 0, 0, 0, 0, 1, 1); pixman_image_unref (dst); } if (msk) pixman_image_unref (msk); } pixman_image_unref (src); } } return 0; }
/* Initial entry point to RIP. This initialises all of the modules present, and then calls the interpreter initialisation. */ HqBool RIPCALL SwStart(SWSTART *params) { Bool result ; #ifdef FPEXCEPTION /* Ensure fp exceptions enabled when the RIP is run in a different thread to * the one used to initialise it */ enable_fp_exceptions(); #endif /* FPEXCEPTION */ /* One way or another SwInit is *ALWAYS* called before SwStart(). */ if ( core_init_state == CORE_NOT_INITIALISED ) { /* If SwInit fails, it calls rip_finish() */ if ( !SwInit(params) ) return FALSE ; } if ( core_init_state != CORE_DONE_SWINIT ) { HQFAIL("SwStart called with core in inconsistent state") ; return FALSE ; } /* Set this parameter again, in case it was only supplied to SwStart(). */ set_swstart_must_return(params) ; core_init_state = CORE_DOING_SWSTART ; /* Restart init recursion and accumulated error numbers */ core_init_error = CORE_BASE_MODULE_SWEXIT ; result = core_swstart_run(init_functions, NUM_ARRAY_ITEMS(init_functions), params) ; HQASSERT(core_init_error < CORE_BASE_SWEXIT, "Exit code range for modules needs to be made bigger") ; if ( !result ) { HQASSERT(core_init_state == CORE_NOT_INITIALISED, "SwStart failure didn't clean up properly") ; return FALSE ; } core_init_state = CORE_STARTING_INTERPRETER ; /* We don't care about the return status of the interpreter. It takes care of error handling itself. It also deals with the calls to dispatch_SwExit() under any error condition which may arise. */ start_interpreter() ; /* If we get this far there are two scenarios: a. start_interpreter has returned raising an error condition itself (i.e. It has called dispatch_SwExit()). b. Is returning cleanly under no error condition. Since we don't know which, we will invoke a non-error call to dispatch_SwExit(). This is OK because dispatch_SwExit() protects itself when called multiple times ensuring the client only gets to see the first dispatch. */ rip_finish() ; /* Make sure client always gets a call to SwExit() under all conditions. */ if (exiting_rip_cleanly) { (void)dispatch_SwExit(0, NULL) ; return TRUE ; } /* The only way start_interpreter will return is if exiting_rip_cleanly is TRUE which is caught above. */ HQFAIL("Should NEVER reach here.") ; /* If there is a bug in the code and the above assert fires (because of a bug in the RIP), the function will return anyway. This is the best we can do at this stage and release builds should continue to work. */ return dispatch_SwExit(1, "exiting_rip_cleanly protocol error.") ; }
Bool RIPCALL SwInit( SWSTART *params ) { Bool result ; #ifdef FPEXCEPTION /* STEP -1. Enable fp exceptions for all the RIP does in the startup thread */ enable_fp_exceptions(); /* Use following block of code to test fp exceptions are firing when turning * exceptions on on a new platform/compiler. */ #undef MIKES_FP_TEST #if defined(MIKES_FP_TEST) { /* Simple test that exceptions are working in non-release builds and are * masked in release builds. */ double x = 1.0; double y = 0.0; double z = x/y; } #endif /* MIKES_FP_TEST */ #endif /* FPEXCEPTION */ /* STEP 0. We need to know whether to return or exit the process on failure. */ swstart_must_return = FALSE ; set_swstart_must_return(params) ; /* STEP 1. Init C globals and anything else related to the C runtime environment. */ if (core_init_state != CORE_NOT_INITIALISED) { HQFAIL("SwInit() called more than once"); /** \todo ajcd 2009-02-09: Should this really shut down the previously-initialised RIP instance? Why not just exit instead? */ return dispatch_SwExit( swexit_error_meminit_01, "SwInit() called more than once.") ; } core_init_state = CORE_RUNTIME_INIT ; /* Run all of the C runtime initialiser functions. Always the VERY first thing SwInit does. Emulates executable load time static initialization. */ core_C_globals_run(init_functions, NUM_ARRAY_ITEMS(init_functions)) ; /* At this point, all of the C statics and globals should have been set to their initial values. */ core_init_state = CORE_DOING_SWINIT ; /* STEP 2. Run all of the preboot initialiser functions. These functions may fail, causing an immediate cleanup and exit. */ /* Restart init recursion and accumulated error numbers */ core_init_error = CORE_BASE_MODULE_SWEXIT ; setup_module_fail(); result = core_swinit_run(init_functions, NUM_ARRAY_ITEMS(init_functions), params) ; HQASSERT(core_init_error < CORE_BASE_SWEXIT, "Exit code range for modules needs to be made bigger") ; /* Clear core context from the startup thread */ clear_core_context(); if ( result ) core_init_state = CORE_DONE_SWINIT ; /* STEPS 3 & 4 are run during SwStart. */ return result ; }
int main (int argc, char **argv) { #define WIDTH 400 #define HEIGHT 200 uint32_t *dest = malloc (WIDTH * HEIGHT * 4); pixman_image_t *src_img; pixman_image_t *dest_img; int i, j, k, p; typedef struct { pixman_point_fixed_t p0; pixman_point_fixed_t p1; } point_pair_t; pixman_gradient_stop_t onestop[1] = { { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } }, }; pixman_gradient_stop_t subsetstops[2] = { { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } }, { pixman_int_to_fixed (1), { 0xffff, 0xeeee, 0xeeee, 0xeeee } }, }; pixman_gradient_stop_t stops01[2] = { { pixman_int_to_fixed (0), { 0xffff, 0xeeee, 0xeeee, 0xeeee } }, { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0x1111 } } }; point_pair_t point_pairs [] = { { { pixman_double_to_fixed (0), 0 }, { pixman_double_to_fixed (WIDTH / 8.), pixman_int_to_fixed (0) } }, { { pixman_double_to_fixed (WIDTH / 2.0), pixman_double_to_fixed (HEIGHT / 2.0) }, { pixman_double_to_fixed (WIDTH / 2.0), pixman_double_to_fixed (HEIGHT / 2.0) } } }; pixman_transform_t transformations[] = { { { { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), }, { pixman_double_to_fixed (0), pixman_double_to_fixed (3), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) } } }, { { { pixman_double_to_fixed (1), pixman_double_to_fixed (0), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (0), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) } } }, { { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (2), pixman_double_to_fixed (1.000), pixman_double_to_fixed (1.0) } } }, { { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (0), pixman_double_to_fixed (0), pixman_double_to_fixed (0) } } }, { { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (2), pixman_double_to_fixed (-1), pixman_double_to_fixed (0) } } }, { { { pixman_double_to_fixed (2), pixman_double_to_fixed (1), pixman_double_to_fixed (3), }, { pixman_double_to_fixed (1), pixman_double_to_fixed (1), pixman_double_to_fixed (0), }, { pixman_double_to_fixed (2), pixman_double_to_fixed (-1), pixman_double_to_fixed (0) } } }, }; pixman_fixed_t r_inner; pixman_fixed_t r_outer; enable_fp_exceptions(); for (i = 0; i < WIDTH * HEIGHT; ++i) dest[i] = 0x4f00004f; /* pale blue */ dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4); r_inner = 0; r_outer = pixman_double_to_fixed (50.0); for (i = 0; i < 3; ++i) { pixman_gradient_stop_t *stops; int num_stops; if (i == 0) { stops = onestop; num_stops = sizeof(onestop) / sizeof(onestop[0]); } else if (i == 1) { stops = subsetstops; num_stops = sizeof(subsetstops) / sizeof(subsetstops[0]); } else { stops = stops01; num_stops = sizeof(stops01) / sizeof(stops01[0]); } for (j = 0; j < 3; ++j) { for (p = 0; p < ARRAY_LENGTH (point_pairs); ++p) { point_pair_t *pair = &(point_pairs[p]); if (j == 0) src_img = pixman_image_create_conical_gradient (&(pair->p0), r_inner, stops, num_stops); else if (j == 1) src_img = pixman_image_create_radial_gradient (&(pair->p0), &(pair->p1), r_inner, r_outer, stops, num_stops); else src_img = pixman_image_create_linear_gradient (&(pair->p0), &(pair->p1), stops, num_stops); for (k = 0; k < ARRAY_LENGTH (transformations); ++k) { pixman_image_set_transform (src_img, &transformations[k]); pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NONE); pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img, 0, 0, 0, 0, 0, 0, 10 * WIDTH, HEIGHT); } pixman_image_unref (src_img); } } } pixman_image_unref (dest_img); free (dest); return 0; }
int main (int argc, char **argv) { pixman_transform_t transform; pixman_image_t *src_img, *dest_img; int i, j; enable_fp_exceptions (); dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, NULL, 0); pixman_transform_init_identity (&transform); /* * The create_radial() function returns gradients centered in the * origin and whose interesting part fits a 1x1 square. We want to * paint these gradients on a SIZExSIZE square and to make things * easier we want the origin in the top-left corner of the square * we want to see. */ pixman_transform_translate (NULL, &transform, pixman_double_to_fixed (0.5), pixman_double_to_fixed (0.5)); pixman_transform_scale (NULL, &transform, pixman_double_to_fixed (SIZE), pixman_double_to_fixed (SIZE)); /* * Gradients are evaluated at the center of each pixel, so we need * to translate by half a pixel to trigger some interesting * cornercases. In particular, the original implementation of PDF * radial gradients tried to divide by 0 when using this transform * on the "tangent circles" cases. */ pixman_transform_translate (NULL, &transform, pixman_double_to_fixed (0.5), pixman_double_to_fixed (0.5)); for (i = 0; i < NUM_GRADIENTS; i++) { src_img = create_radial (i); pixman_image_set_transform (src_img, &transform); for (j = 0; j < NUM_REPEAT; j++) { pixman_image_set_repeat (src_img, repeat[j]); pixman_image_composite32 (PIXMAN_OP_OVER, src_img, NULL, dest_img, 0, 0, 0, 0, i * SIZE, j * SIZE, SIZE, SIZE); } pixman_image_unref (src_img); } show_image (dest_img); pixman_image_unref (dest_img); return 0; }