static int hpgl_picture_frame_coords(hpgl_state_t *pgls, gs_int_rect *gl2_win) { gs_rect dev_win; /* device window */ hpgl_real_t x1 = pgls->g.picture_frame.anchor_point.x; hpgl_real_t y1 = pgls->g.picture_frame.anchor_point.y; hpgl_real_t x2 = x1 + pgls->g.picture_frame_width; hpgl_real_t y2 = y1 + pgls->g.picture_frame_height; pcl_set_ctm(pgls, false); hpgl_call(gs_transform(pgls->pgs, x1, y1, &dev_win.p)); hpgl_call(gs_transform(pgls->pgs, x2, y2, &dev_win.q)); hpgl_call(hpgl_set_plu_ctm(pgls)); /* * gs_bbox_transform_inverse puts the resulting points in the * correct order, with p < q. */ { gs_matrix mat; gs_rect pcl_win; /* pcl window */ gs_currentmatrix(pgls->pgs, &mat); hpgl_call(gs_bbox_transform_inverse(&dev_win, &mat, &pcl_win)); /* Round all coordinates to the nearest integer. */ #define set_round(e) gl2_win->e = (int)floor(pcl_win.e + 0.5) set_round(p.x); set_round(p.y); set_round(q.x); set_round(q.y); #undef set_round } /* restore the ctm */ hpgl_call(hpgl_set_ctm(pgls)); return 0; }
void ROUND_W_S() { if (check_cop1_unusable()) return; set_round(); *((long*)reg_cop1_simple[cffd]) = *reg_cop1_simple[cffs]; PC++; }
void ROUND_L_D(void) { if (check_cop1_unusable()) return; set_round(); *((long long*)(reg_cop1_double[cffd])) = *reg_cop1_double[cffs]; PC++; }
void ROUND_W_D(void) { if (check_cop1_unusable()) return; set_round(); *((int*)reg_cop1_simple[cffd]) = *reg_cop1_double[cffs]; PC++; }
/***************************************************************************** * dce_transform_bit_depth_reduction_program * * @brief * Programs the DCP bit depth reduction registers (Clamp, Round/Truncate, * Dither) for dce * * @param depth : bit depth to set the clamp to (should match denorm) * ******************************************************************************/ static void program_bit_depth_reduction( struct dce_transform *xfm_dce, enum dc_color_depth depth, const struct bit_depth_reduction_params *bit_depth_params) { enum dcp_out_trunc_round_depth trunc_round_depth; enum dcp_out_trunc_round_mode trunc_mode; bool spatial_dither_enable; ASSERT(depth < COLOR_DEPTH_121212); /* Invalid clamp bit depth */ spatial_dither_enable = bit_depth_params->flags.SPATIAL_DITHER_ENABLED; /* Default to 12 bit truncation without rounding */ trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_12BIT; trunc_mode = DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE; if (bit_depth_params->flags.TRUNCATE_ENABLED) { /* Don't enable dithering if truncation is enabled */ spatial_dither_enable = false; trunc_mode = bit_depth_params->flags.TRUNCATE_MODE ? DCP_OUT_TRUNC_ROUND_MODE_ROUND : DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE; if (bit_depth_params->flags.TRUNCATE_DEPTH == 0 || bit_depth_params->flags.TRUNCATE_DEPTH == 1) trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_8BIT; else if (bit_depth_params->flags.TRUNCATE_DEPTH == 2) trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_10BIT; else { /* * Invalid truncate/round depth. Setting here to 12bit * to prevent use-before-initialize errors. */ trunc_round_depth = DCP_OUT_TRUNC_ROUND_DEPTH_12BIT; BREAK_TO_DEBUGGER(); } } set_clamp(xfm_dce, depth); set_round(xfm_dce, trunc_mode, trunc_round_depth); set_dither(xfm_dce, spatial_dither_enable, DCP_SPATIAL_DITHER_MODE_A_AA_A, DCP_SPATIAL_DITHER_DEPTH_30BPP, bit_depth_params->flags.FRAME_RANDOM, bit_depth_params->flags.RGB_RANDOM, bit_depth_params->flags.HIGHPASS_RANDOM); }
/** ******************************************************************************* * dce110_transform_bit_depth_reduction_program * * @brief * Programs the DCP bit depth reduction registers (Clamp, Round/Truncate, * Dither) for dce110 * * @param depth : bit depth to set the clamp to (should match denorm) * * @return * true if succeeds. ******************************************************************************* */ static bool program_bit_depth_reduction( struct dce110_transform *xfm110, enum dc_color_depth depth, const struct bit_depth_reduction_params *bit_depth_params) { enum dcp_bit_depth_reduction_mode depth_reduction_mode; enum dcp_spatial_dither_mode spatial_dither_mode; bool frame_random_enable; bool rgb_random_enable; bool highpass_random_enable; if (depth > COLOR_DEPTH_121212) { ASSERT_CRITICAL(false); /* Invalid clamp bit depth */ return false; } if (bit_depth_params->flags.SPATIAL_DITHER_ENABLED) { depth_reduction_mode = DCP_BIT_DEPTH_REDUCTION_MODE_DITHER; frame_random_enable = true; rgb_random_enable = true; highpass_random_enable = true; } else { depth_reduction_mode = DCP_BIT_DEPTH_REDUCTION_MODE_DISABLED; frame_random_enable = false; rgb_random_enable = false; highpass_random_enable = false; } spatial_dither_mode = DCP_SPATIAL_DITHER_MODE_A_AA_A; if (!set_clamp(xfm110, depth)) { /* Failure in set_clamp() */ ASSERT_CRITICAL(false); return false; } switch (depth_reduction_mode) { case DCP_BIT_DEPTH_REDUCTION_MODE_DITHER: /* Spatial Dither: Set round/truncate to bypass (12bit), * enable Dither (30bpp) */ set_round(xfm110, DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE, DCP_OUT_TRUNC_ROUND_DEPTH_12BIT); set_dither(xfm110, true, spatial_dither_mode, DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable, rgb_random_enable, highpass_random_enable); break; case DCP_BIT_DEPTH_REDUCTION_MODE_ROUND: /* Round: Enable round (10bit), disable Dither */ set_round(xfm110, DCP_OUT_TRUNC_ROUND_MODE_ROUND, DCP_OUT_TRUNC_ROUND_DEPTH_10BIT); set_dither(xfm110, false, spatial_dither_mode, DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable, rgb_random_enable, highpass_random_enable); break; case DCP_BIT_DEPTH_REDUCTION_MODE_TRUNCATE: /* Truncate */ /* Truncate: Enable truncate (10bit), disable Dither */ set_round(xfm110, DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE, DCP_OUT_TRUNC_ROUND_DEPTH_10BIT); set_dither(xfm110, false, spatial_dither_mode, DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable, rgb_random_enable, highpass_random_enable); break; case DCP_BIT_DEPTH_REDUCTION_MODE_DISABLED: /* Disabled */ /* Truncate: Set round/truncate to bypass (12bit), * disable Dither */ set_round(xfm110, DCP_OUT_TRUNC_ROUND_MODE_TRUNCATE, DCP_OUT_TRUNC_ROUND_DEPTH_12BIT); set_dither(xfm110, false, spatial_dither_mode, DCP_SPATIAL_DITHER_DEPTH_30BPP, frame_random_enable, rgb_random_enable, highpass_random_enable); break; default: /* Invalid DCP Depth reduction mode */ ASSERT_CRITICAL(false); break; } return true; }
int main (int argc, const char* argv[]) { char *line, *cmd, *args; ChessGame* game; ChessGameIterator iter; int quit = 0; chess_generate_init(); game = chess_game_new(); chess_game_iterator_init(&iter, game); print_board(&iter); line = 0; for (;;) { if (line) free(line); if (quit) break; line = read_line("> "); if (!parse_line(line, &cmd, &args)) continue; if (!strcmp(cmd, "quit") || !strcmp(cmd, "q")) { quit = 1; } else if (!strcmp(cmd, "new")) { chess_game_iterator_cleanup(&iter); chess_game_reset(game); chess_game_iterator_init(&iter, game); print_board(&iter); } else if (!strcmp(cmd, "fen")) { load_fen(game, args); } else if (!strcmp(cmd, "pgn")) { save_pgn(game); } else if (!strcmp(cmd, "ls")) { list_moves(&iter); } else if (!strcmp(cmd, "moves")) { game_moves(game); } else if (!strcmp(cmd, "bd")) { print_board(&iter); } else if (!strcmp(cmd, "undo")) { undo_move(&iter); } else if (!strcmp(cmd, "event")) { set_event(game, args); } else if (!strcmp(cmd, "site")) { set_site(game, args); } else if (!strcmp(cmd, "date")) { set_date(game, args); } else if (!strcmp(cmd, "round")) { set_round(game, args); } else if (!strcmp(cmd, "white")) { set_white(game, args); } else if (!strcmp(cmd, "black")) { set_black(game, args); } else if (!strcmp(cmd, "result")) { set_result(game, args); } else { handle_move(&iter, cmd); } } chess_game_iterator_cleanup(&iter); chess_game_destroy(game); return 0; }